cryptmodule.c

SuperUser (root@elvis.med.virginia.edu)
Thu, 5 May 1994 17:15:28 -0400

I had this hacked into pwdmodule, but Guido suggested it should go into
it's own module. I didn't expect 1.0.2 to come so soon, so I missed the
release! Here is unix crypt() - which you need with pwdmodule
and posix.setuid() if you want to check a password for authorization.

u = pwd.getpwdnam( user )
if crypt( password, u[1] ) <> u[1] :
Raise "NoNoNOnoNOyoudon'tError", 'Who are you? *REALLY*'

You can either append this to pwdmodule.c ( stripping off the redundant
#include's ) or add a line to Setup and compile separately.
( If you append it to pwdmodule.c, it will still be a separate module -
module grp shares the same file also. )

- Steve Majewski

/* cryptmodule.c
*/

#include "allobjects.h"
#include "modsupport.h"

#include <sys/types.h>

/* Module crypt */

static object *crypt_crypt(self, args)
object *self, *args;
{
char *word, *salt;
extern char * crypt();

struct passwd *p;
if (!getargs(args, "(ss)", &word, &salt)) {
return NULL;
}
return newstringobject( crypt( word, salt ) );

}

static struct methodlist crypt_methods[] = {
{"crypt", crypt_crypt},
{NULL, NULL} /* sentinel */
};

void
initcrypt()
{
initmodule("crypt", crypt_methods);
}