diff options
author | Niels Provos <provos@cvs.openbsd.org> | 1997-04-10 20:04:55 +0000 |
---|---|---|
committer | Niels Provos <provos@cvs.openbsd.org> | 1997-04-10 20:04:55 +0000 |
commit | 5468443bf964034e51ecfffb078104e28829ad0c (patch) | |
tree | 7f6db2fdbef937390669eca03f5ec38310265c02 | |
parent | 9f202a44445e15a2bba9c01df67b16fa9fb10083 (diff) |
enable .group entries in /etc/passwd.conf
-rw-r--r-- | usr.bin/passwd/pwd_gensalt.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/usr.bin/passwd/pwd_gensalt.c b/usr.bin/passwd/pwd_gensalt.c index bd3f1985e16..526e914c4c6 100644 --- a/usr.bin/passwd/pwd_gensalt.c +++ b/usr.bin/passwd/pwd_gensalt.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pwd_gensalt.c,v 1.7 1997/04/10 20:04:54 provos Exp $ */ /* * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> * All rights reserved. @@ -29,10 +30,12 @@ */ #include <sys/syslimits.h> +#include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <err.h> +#include <grp.h> #include <pwd.h> #include <util.h> #include <time.h> @@ -49,18 +52,36 @@ pwd_gensalt(salt, max, pwd, type) char *bcrypt_gensalt __P((u_int8_t)); char option[LINE_MAX]; char *next, *now; + char *cipher; *salt = '\0'; switch (type) { case 'y': - pw_getconf(option, LINE_MAX, pwd->pw_name, "ypcipher"); + cipher = "ypcipher"; break; case 'l': default: - pw_getconf(option, LINE_MAX, pwd->pw_name, "localcipher"); + cipher = "localcipher"; break; } + pw_getconf(option, LINE_MAX, pwd->pw_name, cipher); + + /* Try to find an entry for the group */ + if (*option == 0) { + struct group *grp; + char grpkey[LINE_MAX]; + + grp = getgrgid(pwd->pw_gid); + if (grp != NULL) { + snprintf(grpkey, LINE_MAX-1, ".%s", grp->gr_name); + grpkey[LINE_MAX-1] = 0; + pw_getconf(option, LINE_MAX, grpkey, cipher); + } + if (*option == 0) + pw_getconf(option, LINE_MAX, "default", cipher); + } + next = option; now = strsep(&next, ","); if (!strcmp(now, "old")) { |