57#define OPT_ISROOT (1 << 0)
58#define OPT_CREATE (1 << 1)
59#define OPT_FORCE (1 << 2)
60#define OPT_ADDUSER (1 << 3)
61#define OPT_NOCRACK (1 << 4)
62#define OPT_RANDNUM (1 << 5)
63#define OPT_MIGRATE (1 << 6)
64#define OPT_DISABLE (1 << 7)
66#define PASSWD_ILLEGAL '*'
69#define FORMAT ":****************:****************:********\n"
72#define SRP_PASSWDLEN 255
75#define HEXPASSWDLEN 16
78#define AFPPASSWD_OPTSTRING "cd:fmnra:p:u:w:"
80static int unhex(
unsigned char x)
82 return isdigit(x) ? x -
'0' : toupper(x) + 10 -
'A';
85static char buf[MAXPATHLEN + 1];
86static const unsigned char hextable[] =
"0123456789ABCDEF";
95 gcry_control(GCRYCTL_SET_PREFERRED_RNG_TYPE, GCRY_RNG_TYPE_SYSTEM);
98 fprintf(stderr,
"afppasswd: libgcrypt %s or later is required.\n",
111 if (*value ==
'\0' || *value ==
'-' ||
112 isspace((
unsigned char) * value)) {
117 parsed = strtoumax(value, &end, 10);
119 if (errno == ERANGE || end == value || *end !=
'\0' ||
120 (uintmax_t)(uid_t)parsed != parsed) {
124 *uid = (uid_t)parsed;
132 if (
fstat(fd, &st) < 0) {
133 fprintf(stderr,
"afppasswd: can't inspect %s: %s\n",
path,
138 if (!S_ISREG(st.st_mode)) {
139 fprintf(stderr,
"afppasswd: %s is not a regular file.\n",
path);
143 if (st.st_uid != geteuid()) {
144 fprintf(stderr,
"afppasswd: %s is not owned by the administrator.\n",
149 if (st.st_mode & (S_IRWXG | S_IRWXO)) {
151 "afppasswd: %s must not be accessible by group or other.\n",
156 if (st.st_nlink != 1) {
157 fprintf(stderr,
"afppasswd: %s must have exactly one hard link.\n",
168 fd = open(
path, access_mode | O_CLOEXEC | O_NOFOLLOW);
171 fprintf(stderr,
"afppasswd: can't open %s: %s\n",
path,
189 if (fseek(fp, 0, SEEK_END) < 0 || (*pos = ftell(fp)) < 0) {
190 fprintf(stderr,
"afppasswd: can't seek %s: %s\n",
path,
199 if (fseek(fp, -1, SEEK_END) < 0 || (last = fgetc(fp)) == EOF) {
200 fprintf(stderr,
"afppasswd: can't inspect the end of %s: %s\n",
path,
207 "afppasswd: can't append to %s: final record is incomplete.\n",
217 int fd = open(
path, O_CREAT | O_RDWR | O_CLOEXEC | O_NOFOLLOW, 0600);
220 fprintf(stderr,
"afppasswd: can't create %s: %s\n",
path,
230 if (
fchmod(fd, 0600) < 0 || ftruncate(fd, 0) < 0) {
231 fprintf(stderr,
"afppasswd: can't safely replace %s: %s\n",
path,
245 if (path_len > keypath_size -
sizeof(
".key")) {
247 "afppasswd: Randnum password file path is too long to locate companion key file.\n");
252 strlcat(keypath,
".key", keypath_size);
262 if (lseek(keyfd, 0, SEEK_SET) < 0) {
263 fprintf(stderr,
"afppasswd: could not seek Randnum key file%s%s: %s\n",
264 keypath ?
" " :
"", keypath ? keypath :
"", strerror(errno));
269 keylen = read(keyfd, encoded,
sizeof(encoded));
272 fprintf(stderr,
"afppasswd: could not read Randnum key file%s%s: %s\n",
273 keypath ?
" " :
"", keypath ? keypath :
"", strerror(errno));
281 "afppasswd: invalid Randnum key file%s%s: expected 16 hexadecimal characters with an optional trailing newline.\n",
282 keypath ?
" " :
"", keypath ? keypath :
"");
288 if (!isxdigit(encoded[i])) {
290 "afppasswd: invalid Randnum key file%s%s: expected hexadecimal characters only.\n",
291 keypath ?
" " :
"", keypath ? keypath :
"");
298 key[j] = (uint8_t)((
unhex(encoded[i]) << 4) |
unhex(encoded[i + 1]));
307 char keypath[MAXPATHLEN + 1];
318 fprintf(stderr,
"afppasswd: required Randnum key file is unavailable.\n");
338 gcry_randomize(
key,
sizeof(
key), GCRY_STRONG_RANDOM);
340 for (
int i = 0, j = 0; i <
DES_KEY_SZ; i++, j += 2) {
354 if (
write(fd, encoded,
sizeof(encoded)) != (ssize_t)
sizeof(encoded)) {
355 fprintf(stderr,
"afppasswd: problem writing Randnum key file %s: %s\n",
356 keypath, strerror(errno));
371 char keypath[MAXPATHLEN + 1];
379 keyfd = open(keypath, O_RDONLY | O_CLOEXEC | O_NOFOLLOW);
382 if (errno != ENOENT) {
383 fprintf(stderr,
"afppasswd: can't open Randnum key file %s: %s\n",
384 keypath, strerror(errno));
407 "afppasswd: use -f with -r -c to replace invalid Randnum key file %s.\n",
422 gcry_error_t ctxerror;
427 passwd_buf[j] = (char)(uint8_t)((
unhex(passwd_buf[i]) << 4) |
428 unhex(passwd_buf[i + 1]));
440 ctxerror = gcry_cipher_open(&
ctx, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_ECB, 0);
443 fprintf(stderr,
"afppasswd: gcry_cipher_open failed: %s\n",
444 gcry_strerror(ctxerror));
453 fprintf(stderr,
"afppasswd: gcry_cipher_setkey failed: %s\n",
454 gcry_strerror(ctxerror));
455 gcry_cipher_close(
ctx);
467 fprintf(stderr,
"afppasswd: Randnum password conversion failed: %s\n",
468 gcry_strerror(ctxerror));
469 gcry_cipher_close(
ctx);
473 gcry_cipher_close(
ctx);
477 for (i = j = 0; i <
DES_KEY_SZ; i++, j += 2) {
478 passwd_buf[j] =
hextable[(newpwd[i] & 0xF0) >> 4];
479 passwd_buf[j + 1] =
hextable[newpwd[i] & 0x0F];
493 const unsigned char *salt,
494 unsigned char *v_out)
516 if (gcry_md_open(&hd, GCRY_MD_SHA1, 0) != 0) {
520 gcry_md_write(hd, username, username_len);
521 gcry_md_write(hd,
":", 1);
522 gcry_md_write(hd, password, password_len);
523 memcpy(inner_hash, gcry_md_read(hd, GCRY_MD_SHA1),
SRP_SHA1_LEN);
527 if (gcry_md_open(&hd, GCRY_MD_SHA1, 0) != 0) {
533 memcpy(x_hash, gcry_md_read(hd, GCRY_MD_SHA1),
SRP_SHA1_LEN);
537 gcry_mpi_scan(&N, GCRYMPI_FMT_USG, srp_N_bytes,
SRP_NBYTES,
NULL);
538 g = gcry_mpi_set_ui(
NULL, srp_g_byte);
540 gcry_mpi_powm(v, g, x, N);
543 gcry_mpi_print(GCRYMPI_FMT_USG, v_out,
SRP_NBYTES, &nwritten, v);
546 memmove(v_out +
SRP_NBYTES - nwritten, v_out, nwritten);
564 const unsigned char *verifier)
567 out_hex[i * 2] =
hextable[(salt[i] >> 4) & 0x0F];
568 out_hex[i * 2 + 1] =
hextable[salt[i] & 0x0F];
575 hextable[(verifier[i] >> 4) & 0x0F];
584 int fd = open(
path, O_RDONLY | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
587 if (lstat(
path, &st) == 0 && S_ISREG(st.st_mode)) {
589 "afppasswd: %s is a legacy flat SRP verifier file; stop afpd and run 'afppasswd -m'.\n",
593 "afppasswd: can't open SRP verifier directory %s: %s\n",
594 path, strerror(errno));
600 if (
fstat(fd, &st) < 0 || !
S_ISDIR(st.st_mode) || st.st_uid != 0 ||
601 (st.st_mode & (S_IWGRP | S_IWOTH))) {
603 "afppasswd: SRP verifier directory %s must be root-owned and not writable by group or other.\n",
614 int len = snprintf(name, size,
"%ju", (uintmax_t)uid);
615 return len < 0 || (size_t)len >= size ? -1 : 0;
623 if (
fstat(fd, &st) < 0 || !S_ISREG(st.st_mode) ||
624 (st.st_uid != uid && !(administrative && st.st_uid == 0)) ||
625 (!administrative && !srp_verifier_mode_is_safe(st.st_mode)) ||
628 "afppasswd: verifier in %s must be a single-link regular file owned by uid %ju%s.\n",
629 path, (uintmax_t)uid,
630 administrative ?
" or root" :
" and accessible only by its owner");
640 char uid_name[3 *
sizeof(uid_t) + 1];
648 fd = openat(dirfd, uid_name, O_RDWR | O_CLOEXEC | O_NOFOLLOW |
649 (create ? O_CREAT | O_EXCL : 0), 0600);
651 if (fd < 0 && create && errno == EEXIST) {
652 fd = openat(dirfd, uid_name, O_RDWR | O_CLOEXEC | O_NOFOLLOW);
653 }
else if (fd >= 0) {
658 if (!create && errno == EACCES) {
661 "Your password is disabled. Please see your administrator.\n");
663 fprintf(stderr,
"afppasswd: can't open verifier %s/%s: %s\n",
664 path, uid_name, strerror(errno));
680 if (create &&
fchmod(fd, 0600) < 0) {
681 fprintf(stderr,
"afppasswd: can't prepare verifier %s/%s: %s\n",
682 path, uid_name, strerror(errno));
691 int flags,
const char *pass)
698 const char *p =
NULL;
711 fprintf(stderr,
"afppasswd: only root can add a user.\n");
715 if (!srp_valid_username(name)) {
716 fprintf(stderr,
"afppasswd: invalid username.\n");
723 fprintf(stderr,
"afppasswd: max SRP password length is %d.\n",
SRP_PASSWDLEN);
727 name_len =
strnlen(name,
sizeof(line));
742 if ((fp = fdopen(fd,
"r+")) ==
NULL) {
743 fprintf(stderr,
"afppasswd: can't open stream for %s: %s\n",
path,
751 if (fgets(line,
sizeof(line), fp) !=
NULL && fgetc(fp) != EOF) {
753 "afppasswd: verifier file must contain exactly one record.\n");
759 fprintf(stderr,
"afppasswd: can't read verifier in %s: %s\n",
path,
765 p = strchr(line,
':');
768 if (p && name_len == (
size_t)(p - line) && strncmp(line, name, name_len) == 0) {
771 if (!srp_valid_fields(p)) {
772 fprintf(stderr,
"afppasswd: corrupt verifier file.\n");
778 fprintf(stderr,
"Your password is disabled. Please see your administrator.\n");
783 fprintf(stderr,
"afppasswd: can't find verifier for %s in %s\n", name,
792 passwd = getpass(
"Enter OLD AFP password: ");
794 if (passwd ==
NULL || passwd[0] ==
'\0') {
795 fprintf(stderr,
"afppasswd: password input canceled.\n");
801 fprintf(stderr,
"afppasswd: no existing password set.\n");
807 if (!isxdigit(p[i * 2]) || !isxdigit(p[i * 2 + 1])) {
808 fprintf(stderr,
"afppasswd: corrupt verifier file.\n");
813 old_salt[i] = (
unsigned char)((
unhex(p[i * 2]) << 4) |
unhex(p[i * 2 + 1]));
820 if (!isxdigit(vp[i * 2]) || !isxdigit(vp[i * 2 + 1])) {
821 fprintf(stderr,
"afppasswd: corrupt verifier file.\n");
826 old_v[i] = (
unsigned char)((
unhex(vp[i * 2]) << 4) |
unhex(vp[i * 2 + 1]));
831 fprintf(stderr,
"afppasswd: internal error computing verifier.\n");
837 fprintf(stderr,
"afppasswd: invalid password.\n");
848 passwd = getpass(
"Enter NEW AFP password: ");
850 if (passwd ==
NULL || passwd[0] ==
'\0') {
851 fprintf(stderr,
"afppasswd: password input canceled.\n");
859 fprintf(stderr,
"afppasswd: max SRP password length is %d.\n",
SRP_PASSWDLEN);
864 memcpy(password, passwd, passwd_len + 1);
866 strlcpy(password, pass,
sizeof(password));
875 fprintf(stderr,
"Error: %s\n", pwcheck);
884 passwd = getpass(
"Enter NEW AFP password again: ");
886 if (passwd ==
NULL || passwd[0] ==
'\0' ||
887 strcmp(passwd, password) != 0) {
888 fprintf(stderr,
"afppasswd: passwords don't match!\n");
895 gcry_randomize(new_salt,
SRP_SALT_LEN, GCRY_STRONG_RANDOM);
898 fprintf(stderr,
"afppasswd: failed to compute verifier.\n");
907 struct flock lock = {0};
908 int expected_len = (int)(name_len + 1 +
sizeof(hex_buf) + 1);
910 lock.l_type = F_WRLCK;
913 lock.l_whence = SEEK_SET;
915 if (
fcntl(fd, F_SETLK, &lock) < 0 || fseek(fp, 0, SEEK_SET) != 0) {
916 fprintf(stderr,
"afppasswd: can't lock or seek %s: %s\n",
path,
923 written = fprintf(fp,
"%s:%.*s\n", name, (
int)
sizeof(hex_buf), hex_buf);
925 if (written != expected_len || fflush(fp) != 0 ||
926 ftruncate(fd, expected_len) < 0 ||
fsync(fd) < 0) {
927 fprintf(stderr,
"afppasswd: problem writing to %s: %s\n",
path,
934 (
fchown(fd, uid, (gid_t) -1) < 0 ||
fsync(fd) < 0)) {
935 fprintf(stderr,
"afppasswd: can't enable verifier in %s: %s\n",
936 path, strerror(errno));
940 lock.l_type = F_UNLCK;
942 if (
fcntl(fd, F_SETLK, &lock) < 0) {
943 fprintf(stderr,
"afppasswd: can't unlock %s: %s\n",
path,
950 printf(
"afppasswd: updated SRP verifier.\n");
955 if (passwd !=
NULL) {
976 struct flock lock = {0};
977 int dirfd = -1, fd = -1;
982 if (!srp_valid_username(name)) {
983 fprintf(stderr,
"afppasswd: invalid username.\n");
988 length = snprintf(line,
sizeof(line),
"%s:", name);
990 if (length < 0 || (
size_t)length != name_len + 1 ||
993 fprintf(stderr,
"afppasswd: username is too long.\n");
999 line[length++] =
':';
1002 line[length++] =
'\n';
1013 lock.l_type = F_WRLCK;
1016 lock.l_whence = SEEK_SET;
1019 if (
fcntl(fd, F_SETLK, &lock) < 0) {
1020 fprintf(stderr,
"afppasswd: can't lock verifier in %s: %s\n",
path,
1026 if (
fchown(fd, 0, (gid_t) -1) < 0 ||
fchmod(fd, 0600) < 0 ||
1027 ftruncate(fd, 0) < 0 || lseek(fd, 0, SEEK_SET) < 0 ||
1028 write(fd, line, length) != length ||
fsync(fd) < 0 ||
1030 fprintf(stderr,
"afppasswd: can't disable verifier in %s: %s\n",
path,
1037 lock.l_type = F_UNLCK;
1039 if (
fcntl(fd, F_SETLK, &lock) < 0) {
1040 fprintf(stderr,
"afppasswd: can't unlock verifier in %s: %s\n",
path,
1061 if (mkdir(
path, 0755) < 0) {
1062 fprintf(stderr,
"afppasswd: can't create SRP verifier directory %s: %s\n",
1063 path, strerror(errno));
1071 if (
fchmod(dirfd, 0755) < 0) {
1073 "afppasswd: can't set permissions on SRP verifier directory %s: %s\n",
1074 path, strerror(errno));
1082 if (pwd->pw_uid < minuid) {
1088 size_t namelen =
strnlen(pwd->pw_name,
sizeof(
buf));
1090 if (!srp_valid_username(pwd->pw_name) || namelen ==
sizeof(
buf) ||
1095 int n = snprintf(
buf,
sizeof(
buf),
"%s:", pwd->pw_name);
1118 if (
fchown(fd, 0, (gid_t) -1) < 0 || ftruncate(fd, 0) < 0 ||
1119 lseek(fd, 0, SEEK_SET) < 0 ||
write(fd,
buf, n) != n ||
1121 fprintf(stderr,
"afppasswd: problem writing to %s: %s\n",
1122 path, strerror(errno));
1142 for (
size_t i = 0; i < len; i++) {
1150 for (
size_t i = 0; i < len; i++) {
1151 if (!isxdigit((
unsigned char)field[i])) {
1162 return strlen(fields) == fields_len && fields[
HEXPASSWDLEN] ==
':' &&
1164 fields[fields_len - 1] ==
'\n' &&
1174 char password[
PASSWDLEN + 1] = {0}, *p =
NULL, *passwd =
"";
1177 int fd, keyfd = -1, err = 0, new_entry = 0;
1182 fprintf(stderr,
"afppasswd: only root can manage RandNum passwords.\n");
1186 if (!srp_valid_username(name)) {
1187 fprintf(stderr,
"afppasswd: invalid username.\n");
1202 if ((fp = fdopen(fd,
"r+")) ==
NULL) {
1203 fprintf(stderr,
"afppasswd: can't open stream for %s: %s\n",
path,
1213 memset(
buf, 0,
sizeof(
buf));
1215 while (fgets(
buf,
sizeof(
buf), fp)) {
1216 p = strchr(
buf,
':');
1219 if (p && name_len == (
size_t)(p -
buf) && strncmp(
buf, name, name_len) == 0) {
1223 fprintf(stderr,
"afppasswd: corrupt Randnum password file.\n");
1229 fprintf(stderr,
"Your password is disabled. Please see your administrator.\n");
1238 memset(
buf, 0,
sizeof(
buf));
1245 p = strchr(
buf,
':') + 1;
1254 fprintf(stderr,
"afppasswd: can't find %s in %s\n", name,
path);
1263 passwd = getpass(
"Enter OLD AFP password: ");
1265 if (passwd ==
NULL || passwd[0] ==
'\0') {
1266 fprintf(stderr,
"afppasswd: password input canceled.\n");
1277 fprintf(stderr,
"afppasswd: invalid password.\n");
1285 passwd = getpass(
"Enter NEW AFP password: ");
1287 if (passwd ==
NULL || passwd[0] ==
'\0') {
1288 fprintf(stderr,
"afppasswd: password input canceled.\n");
1296 fprintf(stderr,
"afppasswd: max RandNum password length is %d.\n",
PASSWDLEN);
1303 for (
int s = (
int) passwd_len; s <=
PASSWDLEN; s++) {
1308 memcpy(password, passwd,
sizeof(password));
1310 memcpy(password, pass,
sizeof(password));
1313 for (
int i = (
int) pass_len; i <=
PASSWDLEN; i++) {
1326 fprintf(stderr,
"Error: %s\n", pwcheck);
1335 passwd = getpass(
"Enter NEW AFP password again: ");
1338 if ((passwd !=
NULL && passwd[0] !=
'\0' &&
1339 strcmp(passwd, password) == 0) || pass_len > 0) {
1340 struct flock lock = {0};
1348 lock.l_type = F_WRLCK;
1351 lock.l_whence = SEEK_SET;
1353 if (
fcntl(fd, F_SETLKW, &lock) < 0 || fseek(fp, pos, SEEK_SET) < 0) {
1354 fprintf(stderr,
"afppasswd: can't lock or seek %s: %s\n",
path,
1363 if (fwrite(
buf, 1, write_len, fp) != write_len || fflush(fp) != 0) {
1364 fprintf(stderr,
"afppasswd: problem writing to %s: %s\n",
path,
1369 lock.l_type = F_UNLCK;
1371 if (
fcntl(fd, F_SETLK, &lock) < 0) {
1372 fprintf(stderr,
"afppasswd: can't unlock %s: %s\n",
path,
1378 printf(
"afppasswd: updated Randnum password.\n");
1381 fprintf(stderr,
"afppasswd: passwords don't match!\n");
1387 if (passwd !=
NULL) {
1407 int fd, len, err = 0;
1416 if (pwd->pw_uid < minuid) {
1421 size_t name_len =
strnlen(pwd->pw_name,
sizeof(
buf));
1423 if (!srp_valid_username(pwd->pw_name) || name_len ==
sizeof(
buf) ||
1433 fprintf(stderr,
"afppasswd: problem writing to %s: %s\n",
path,
1448 fprintf(stderr,
"afppasswd (Netatalk %s)\n", VERSION);
1451 "Usage (root): afppasswd [-cfmrn] [-a username | -d username] [-p directory] [-u minuid] [-w string]\n");
1454 "Usage (root): afppasswd [-cfmr] [-a username | -d username] [-p directory] [-u minuid] [-w string]\n");
1457 "Usage (user): afppasswd\n");
1458 fprintf(stderr,
" -a user add or reset password for the named user\n");
1460 " -d user disable the named user's SRP verifier\n");
1462 " -c create and initialize the credential store\n");
1464 " -f replace an existing Randnum credential file with -r -c\n");
1465 fprintf(stderr,
" -m migrate a legacy flat SRP verifier file\n");
1466 fprintf(stderr,
" -r use legacy RandNum mode (default is SRP)\n");
1468 fprintf(stderr,
" -n disable password strength check\n");
1470 fprintf(stderr,
" -u uid minimum uid to use, defaults to 100\n");
1472 " -p path path to SRP verifier directory (or Randnum password file with -r)\n");
1473 fprintf(stderr,
" -w string use string as password\n");
1482 int adduser_seen = 0, disable_seen = 0, path_seen = 0;
1483 int password_seen = 0, uid_seen = 0;
1484 const char *pass =
"";
1485 const char *add_username =
NULL;
1486 const char *disable_username =
NULL;
1488 extern char *optarg;
1494 if (uid != 0 && geteuid() != uid &&
1495 (setuid(uid) < 0 || geteuid() != uid)) {
1496 fprintf(stderr,
"afppasswd: can't drop obsolete elevated privileges: %s\n",
1515 add_username = optarg;
1521 disable_username = optarg;
1539 fprintf(stderr,
"afppasswd: invalid minimum uid: %s\n", optarg);
1572 if (err || optind != argc) {
1583 (flags &
OPT_RANDNUM) || adduser_seen || disable_seen ||
1584 uid_seen || password_seen)) {
1586 "ERROR: non-root users may update only their own SRP verifier.\n\n");
1593 uid_seen || password_seen)) {
1595 "afppasswd: -m accepts only -p; stop afpd before migration.\n");
1601 fprintf(stderr,
"afppasswd: -a and -d cannot be combined.\n");
1608 fprintf(stderr,
"afppasswd: -c cannot be combined with -a, -d, or -w.\n");
1614 fprintf(stderr,
"afppasswd: -u is valid only with -c.\n");
1621 fprintf(stderr,
"afppasswd: -f is valid only with -r -c.\n");
1629 fprintf(stderr,
"afppasswd: -d accepts only -p.\n");
1640 "ERROR: root must specify a user with -a or -d username.\n");
1647 _PATH_AFPSRPVERIFIERPATH;
1652 fprintf(stderr,
"afppasswd: max RandNum password length is %d.\n",
PASSWDLEN);
1662 fprintf(stderr,
"afppasswd: only root can initialize credentials.\n");
1666 i = lstat(
path, &st);
1669 if (!(flags &
OPT_RANDNUM) && S_ISREG(st.st_mode)) {
1671 "afppasswd: %s is a legacy flat SRP verifier file; stop afpd and run 'afppasswd -m -p %s'.\n",
1675 "afppasswd: credential path already exists.\n");
1691 struct passwd *pwd =
NULL;
1708 fprintf(stderr,
"afppasswd: can't get password entry.\n");
struct context * ctx
Definition afp_avahi.c:31
static void print_usage(void)
Definition afppasswd.c:1446
static int open_srp_verifier(int dirfd, const char *path, uid_t uid, int create)
Definition afppasswd.c:637
#define OPT_ADDUSER
Definition afppasswd.c:60
#define OPT_FORCE
Definition afppasswd.c:59
#define SRP_PASSWDLEN
Definition afppasswd.c:72
#define FORMAT_LEN
Definition afppasswd.c:70
static int srp_compute_verifier(const char *username, const char *password, const unsigned char *salt, unsigned char *v_out)
Definition afppasswd.c:492
static void srp_encode_hex(char *out_hex, const unsigned char *salt, const unsigned char *verifier)
Definition afppasswd.c:563
#define OPT_MIGRATE
Definition afppasswd.c:63
static int randnum_open_keyfile(const char *path, int *keyfd_out)
Definition afppasswd.c:305
static int open_credential_file(const char *path, int access_mode)
Definition afppasswd.c:165
#define PASSWDLEN
Definition afppasswd.c:76
#define AFPPASSWD_OPTSTRING
Definition afppasswd.c:78
static int valid_hex_or_disabled(const char *field, size_t len)
Definition afppasswd.c:1138
static int open_credential_for_replacement(const char *path)
Definition afppasswd.c:215
#define PASSWD_ILLEGAL
Definition afppasswd.c:66
static int randnum_write_keyfile(const char *keypath)
Definition afppasswd.c:333
static int convert_passwd(char *passwd_buf, char *newpwd, const int keyfd)
Definition afppasswd.c:417
static int randnum_ensure_keyfile(const char *path, int flags)
Definition afppasswd.c:369
static int create_file(const char *path, uid_t minuid)
Definition afppasswd.c:1404
#define HEXPASSWDLEN
Definition afppasswd.c:75
static int validate_opened_file(int fd, const char *path)
Definition afppasswd.c:128
static char buf[MAXPATHLEN+1]
Definition afppasswd.c:85
static int randnum_read_keyfd(int keyfd, uint8_t key[DES_KEY_SZ], const char *keypath)
Definition afppasswd.c:256
static int find_append_position(FILE *fp, const char *path, off_t *pos)
Definition afppasswd.c:184
static int open_srp_verifier_directory(const char *path)
Definition afppasswd.c:581
static int disable_srp_verifier(const char *path, const char *name, uid_t uid)
Definition afppasswd.c:973
static int update_passwd(const char *path, const char *name, int flags, const char *pass)
Definition afppasswd.c:1171
static const unsigned char hextable[]
Definition afppasswd.c:86
static int create_srp_directory(const char *path, uid_t minuid)
Definition afppasswd.c:1056
#define DES_KEY_SZ
Definition afppasswd.c:50
static int valid_randnum_record(const char *fields)
Definition afppasswd.c:1159
static int randnum_make_keypath(const char *path, char *keypath, size_t keypath_size)
Definition afppasswd.c:240
#define OPT_RANDNUM
Definition afppasswd.c:62
#define FORMAT
Definition afppasswd.c:69
#define OPT_CREATE
Definition afppasswd.c:58
#define OPT_DISABLE
Definition afppasswd.c:64
#define OPT_ISROOT
Definition afppasswd.c:57
static int update_srp_passwd(const char *path, const char *name, uid_t uid, int flags, const char *pass)
Definition afppasswd.c:690
static int validate_srp_verifier_file(int fd, uid_t uid, const char *path, int administrative)
Definition afppasswd.c:618
#define UID_START
Definition afppasswd.c:74
static int initialize_libgcrypt(void)
Definition afppasswd.c:93
static int srp_uid_filename(uid_t uid, char *name, size_t size)
Definition afppasswd.c:612
static int parse_minimum_uid(const char *value, uid_t *uid)
Definition afppasswd.c:106
#define OPT_NOCRACK
Definition afppasswd.c:61
int afppasswd_migrate_srp(const char *path, uid_t administrator_uid)
Definition afppasswd_migrate.c:628
void explicit_bzero(void *s, size_t n)
Definition explicit_bzero.c:32
size_t strlcat(char *, const char *, size_t)
Definition strlcpy.c:59
size_t strlcpy(char *, const char *, size_t)
Definition strlcpy.c:36
size_t strnlen(const char *s, size_t n)
Definition misc.c:19
#define _PATH_CRACKLIB
Definition config.h:483
int atalk_ct_memcmp(const void *, const void *, size_t)
Constant-time memory equality check.
Definition constant_time.c:27
#define key
Definition hash.c:51
#define unlock(fd, offset, whence, len)
unlock a file
Definition include/atalk/util.h:158
#define S_ISDIR(s)
Definition megatron.h:96
#define SRP_HEX_V_LEN
Definition srp.h:19
#define SRP_USERNAME_MAX_LEN
Definition srp.h:14
#define SRP_NBYTES
Definition srp.h:11
#define SRP_HEX_SALT_LEN
Definition srp.h:18
#define SRP_FIELDS_LEN
Definition srp.h:21
#define SRP_SALT_LEN
Definition srp.h:10
#define SRP_SHA1_LEN
Definition srp.h:12
#define SRP_DISABLED_CHAR
Definition srp.h:15
#define SRP_FORMAT_LEN
Definition srp.h:23
Definition include/atalk/directory.h:140
#define fchown
Definition test_afppasswd.c:45
#define setpwent
Definition test_afppasswd.c:49
#define fchmod
Definition test_afppasswd.c:46
#define getpwent
Definition test_afppasswd.c:50
#define fstat
Definition test_afppasswd.c:44
#define fsync
Definition test_afppasswd.c:48
#define endpwent
Definition test_afppasswd.c:51
#define fcntl
Definition test_afppasswd.c:47
#define main
Definition test_afppasswd.c:721
#define write
Definition test_migrate.c:41
#define getpwnam
Definition test_migrate.c:40
#define UAM_NEED_LIBGCRYPT_VERSION
Definition uam.h:24
#define unhex(x)
Definition uams_srp.c:220
#define NULL
Definition utf8util.c:47