pw_user.c (228673) | pw_user.c (231994) |
---|---|
1/*- 2 * Copyright (C) 1996 3 * David L. Nugent. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 */ 27 28#ifndef lint 29static const char rcsid[] = | 1/*- 2 * Copyright (C) 1996 3 * David L. Nugent. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 */ 27 28#ifndef lint 29static const char rcsid[] = |
30 "$FreeBSD: head/usr.sbin/pw/pw_user.c 228673 2011-12-17 23:46:47Z dim $"; | 30 "$FreeBSD: head/usr.sbin/pw/pw_user.c 231994 2012-02-22 06:27:20Z kevlo $"; |
31#endif /* not lint */ 32 33#include <ctype.h> 34#include <err.h> 35#include <fcntl.h> 36#include <sys/param.h> 37#include <dirent.h> 38#include <paths.h> --- 984 unchanged lines hidden (view full) --- 1023 1024static char const chars[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./"; 1025 1026char * 1027pw_pwcrypt(char *password) 1028{ 1029 int i; 1030 char salt[SALTSIZE + 1]; | 31#endif /* not lint */ 32 33#include <ctype.h> 34#include <err.h> 35#include <fcntl.h> 36#include <sys/param.h> 37#include <dirent.h> 38#include <paths.h> --- 984 unchanged lines hidden (view full) --- 1023 1024static char const chars[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./"; 1025 1026char * 1027pw_pwcrypt(char *password) 1028{ 1029 int i; 1030 char salt[SALTSIZE + 1]; |
1031 char *cryptpw; |
|
1031 1032 static char buf[256]; 1033 1034 /* 1035 * Calculate a salt value 1036 */ 1037 for (i = 0; i < SALTSIZE; i++) 1038 salt[i] = chars[arc4random_uniform(sizeof(chars) - 1)]; 1039 salt[SALTSIZE] = '\0'; 1040 | 1032 1033 static char buf[256]; 1034 1035 /* 1036 * Calculate a salt value 1037 */ 1038 for (i = 0; i < SALTSIZE; i++) 1039 salt[i] = chars[arc4random_uniform(sizeof(chars) - 1)]; 1040 salt[SALTSIZE] = '\0'; 1041 |
1041 return strcpy(buf, crypt(password, salt)); | 1042 cryptpw = crypt(password, salt); 1043 if (cryptpw == NULL) 1044 errx(EX_CONFIG, "crypt(3) failure"); 1045 return strcpy(buf, cryptpw); |
1042} 1043 1044 1045static char * 1046pw_password(struct userconf * cnf, struct cargs * args, char const * user) 1047{ 1048 int i, l; 1049 char pwbuf[32]; --- 223 unchanged lines hidden --- | 1046} 1047 1048 1049static char * 1050pw_password(struct userconf * cnf, struct cargs * args, char const * user) 1051{ 1052 int i, l; 1053 char pwbuf[32]; --- 223 unchanged lines hidden --- |