summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbjj <bjj>2001-03-12 00:16:29 (GMT)
committerbjj <bjj>2001-03-12 00:16:29 (GMT)
commit6d7dac3c98256c71d94af1260495cd1e424968cd (patch)
tree2158d37b77a0e7b1781fc6796be8a190d500b871
parent15bcadfb974f1f02f33910913df897ba57055f23 (diff)
downloadmoo-cvs-6d7dac3c98256c71d94af1260495cd1e424968cd.zip
moo-cvs-6d7dac3c98256c71d94af1260495cd1e424968cd.tar.gz
moo-cvs-6d7dac3c98256c71d94af1260495cd1e424968cd.tar.bz2
moo-cvs-6d7dac3c98256c71d94af1260495cd1e424968cd.tar.xz
bf_crypt now passes the entire second argument as the salt to
the C crypt() routine. This works fine for traditional DES crypts and supports modern modular crypts like FreeBSD's. This just makes it possible to pass the entire salt: the core still has to do it.
-rw-r--r--list.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/list.c b/list.c
index ccb53fc..094c28b 100644
--- a/list.c
+++ b/list.c
@@ -560,20 +560,24 @@ bf_crypt(Var arglist, Byte next, void *vdata, Objid progr)
#if HAVE_CRYPT
char salt[3];
+ const char *saltp;
static char saltstuff[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
extern const char *crypt(const char *, const char *);
if (arglist.v.list[0].v.num == 1 || strlen(arglist.v.list[2].v.str) < 2) {
+ /* provide a random 2-letter salt, works with old and new crypts */
salt[0] = saltstuff[RANDOM() % (int) strlen(saltstuff)];
salt[1] = saltstuff[RANDOM() % (int) strlen(saltstuff)];
+ salt[2] = '\0';
+ saltp = salt;
} else {
- salt[0] = arglist.v.list[2].v.str[0];
- salt[1] = arglist.v.list[2].v.str[1];
+ /* return the entire crypted password in the salt, this works
+ * for all crypt versions */
+ saltp = arglist.v.list[2].v.str;
}
- salt[2] = '\0';
r.type = TYPE_STR;
- r.v.str = str_dup(crypt(arglist.v.list[1].v.str, salt));
+ r.v.str = str_dup(crypt(arglist.v.list[1].v.str, saltp));
#else /* !HAVE_CRYPT */
r.type = TYPE_STR;
r.v.str = str_ref(arglist.v.list[1].v.str);
@@ -1139,6 +1143,12 @@ char rcsid_list[] = "$Id$";
/*
* $Log$
+ * Revision 1.6 2001/03/12 00:16:29 bjj
+ * bf_crypt now passes the entire second argument as the salt to
+ * the C crypt() routine. This works fine for traditional DES crypts
+ * and supports modern modular crypts like FreeBSD's. This just makes
+ * it possible to pass the entire salt: the core still has to do it.
+ *
* Revision 1.5 1998/12/14 13:17:57 nop
* Merge UNSAFE_OPTS (ref fixups); fix Log tag placement to fit CVS whims
*