How to acknowledge a Password for a Daemon point of view ?
Kim Christian Madsen
kimcm at diku.dk
Sat Aug 25 12:54:41 AEST 1990
pnoe at dg13.cec.be (Pierre Noel) writes:
>I would then know how it is possible, for the daemon process, to check the
>validity of the tuple UserName-Password as a real logname to the system.
>In fact, what I'm looking for is kind of a function which takes the
>Name and the Password as parameter and reply Yes or No depending on
>the validity.
1) Read the encrypted password from the password file and store it in
a variable, store the user typed password in another variable and
use the function below:
int authenticate(crypt_pw,typed_pw)
char *crypt_pw, *typed_pw;
{
char salt[2];
extern char *crypt();
(void) strncpy(salt,crypt_pw,2);
return(strcmp(crypt_pw,crypt(typed_pw,salt)) == 0);
}
>By the way, I don't have crypt function (as we are in Europe, not in USA).
I'm pretty sure you have mixed two different issues up, the crypt
missing outside USA is the UNIX command (crypt(1)), the C library
routine crypt(3) is another matter, it has to be there for jos like
these, otherwise you could grap the code from reverse-engineering of
the su(1) program, since it has to be there as well.
Best Regards
Kim Chr. Madsen
More information about the Comp.unix.wizards
mailing list