Unix Programming - crypt() function is not working.????

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2006 > crypt() function is not working.????





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author crypt() function is not working.????
sethukr@gmail.com

2006-10-28, 1:40 pm

hi,

I'm doing user authendication in my FTP server..

I used crypt() function to encrypt the user password. So that i
can compare with the encripted password in the database.

but, while executing the program, it shows an error as,

UNDEFINED REFERENCE TO CRYPT() FUNCTION.

But i included "unistd.h"..

what can i do???

please help me..

-Sethu

Robert Harris

2006-10-28, 1:40 pm

sethukr@gmail.com wrote:
> hi,
>
> I'm doing user authendication in my FTP server..
>
> I used crypt() function to encrypt the user password. So that i
> can compare with the encripted password in the database.
>
> but, while executing the program, it shows an error as,
>
> UNDEFINED REFERENCE TO CRYPT() FUNCTION.
>
> But i included "unistd.h"..
>
> what can i do???
>
> please help me..
>
> -Sethu
>

"unistd.h" just declares crypt(), meaning that it tells the compiler
what the parameter types and return type are. You need to link to the
library providing crypt. That probably means in the line where you
compile your program, you need to include:

-lcrypt

which tells it to search libcrypt.a or libcrypt.so for the crypt function.

Robert
Jens Thoms Toerring

2006-10-28, 1:40 pm

sethukr@gmail.com wrote:
> I'm doing user authendication in my FTP server..


> I used crypt() function to encrypt the user password. So that i
> can compare with the encripted password in the database.


> but, while executing the program, it shows an error as,


> UNDEFINED REFERENCE TO CRYPT() FUNCTION.


Are you also linking against libcrypt.so, i.e. have '-lcrypt' in
the command you compile (link, to be precise) your program with?

> But i included "unistd.h"..


I just found that on my system using (as required according to the
man page for crypt)

#define _XOPEN_SOURCE
#include <unistd.h>

or just (as according to SUSv3)

#include <unistd.h>

does _not_ make the compiler find the declaration of crypt(3), I
instead had to include <crypt.h>. Does anybody know what could be
the reasons for this?
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Pascal Bourguignon

2006-10-28, 1:40 pm

jt@toerring.de (Jens Thoms Toerring) writes:

> sethukr@gmail.com wrote:
>
>
>
>
> Are you also linking against libcrypt.so, i.e. have '-lcrypt' in
> the command you compile (link, to be precise) your program with?
>
>
> I just found that on my system using (as required according to the
> man page for crypt)
>
> #define _XOPEN_SOURCE
> #include <unistd.h>
>
> or just (as according to SUSv3)
>
> #include <unistd.h>
>
> does _not_ make the compiler find the declaration of crypt(3), I
> instead had to include <crypt.h>. Does anybody know what could be
> the reasons for this?


It might be because crypt is becoming slowly obsolete. Nowadays, we
should probably use PAM or some other more sophisticated API.

--
__Pascal Bourguignon__ http://www.informatimago.com/

"By filing this bug report you have challenged the honor of my
family. Prepare to die!"
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com