[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
crypt system call
This is a multi-part message in MIME format.
- --------------BCD02F1086C6AD55DF0BD31F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi All,
I am porting some c++ program from Solaris to Linux. One module uses the
system call 'crypt'.
When I try to compile the source, the linker(ld) is unable to link the
'crypt' code from the
system library/libc(I am not sure). I checked the man pages for crypt.
It's there. So I guess my system(RH 5.2, Kernel 2.0.36) supports 'crypt'
call. There is no /etc/shadow file. /etc/passwd file is there, and all
users and their encrypted passwords are listed there.
So I guess Shadow-Password suite is not installed on my system.
I am attaching a simple C test code and the linker output. Why 'crypt'
call is giving this problem? If crypt call can't be used, are there any
alternative method for password authentication programatically?
BTW if I want to know, what is the source code name for say "cp", are
there any way to find this info?
TIA,
Kousik
- --------------BCD02F1086C6AD55DF0BD31F
Content-Type: image/x-xbitmap; name="cryptest.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="cryptest.c"
#define __XOPEN_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <pwd.h>
#include <sys/types.h>
#include <string.h>
main()
{
char user[24], passwrd[24];
struct passwd *pw;
char *result;
printf("Enter Username :");
scanf("%s",user);
printf("Enter Password :");
scanf("%s",passwrd);
if((pw=getpwnam(user)) == NULL)
{
result = crypt(passwrd,pw->pw_passwd);
if(!strcmp(result,pw->pw_passwd))
printf("Ok !\n");
else
printf("Invalid Password \n");
}
}
- --------------BCD02F1086C6AD55DF0BD31F
Content-Type: text/plain; charset=us-ascii; name="log"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="log"
cryptest.c: In function `main':
cryptest.c:18: warning: assignment makes pointer from integer without a cast
/tmp/cca005701.o: In function `main':
/tmp/cca005701.o(.text+0x65): undefined reference to `crypt'
- --------------BCD02F1086C6AD55DF0BD31F--
- --------------------------------------------------------------------
For more information on Linux in India visit http://www.linux-india.org/
Linux India is NOT a forum for Microsoft/India/Pakistan/US/UK bashing.
Flame baits will not be tolerated. If you can appreciate satire read
http://www.templetons.com/brad/emily.html
------------------------------