/*
- * $Id: afppasswd.c,v 1.8 2001-09-06 20:00:59 rufustfirefly Exp $
- *
* Copyright 1999 (c) Adrian Sun (asun@u.washington.edu)
* All Rights Reserved. See COPYRIGHT.
*
#include "config.h"
#endif /* HAVE_CONFIG_H */
-/* STDC check */
-#if STDC_HEADERS
-#include <string.h>
-#else /* STDC_HEADERS */
-#ifndef HAVE_STRCHR
-#define strchr index
-#define strrchr index
-#endif /* HAVE_STRCHR */
-char *strchr (), *strrchr ();
-#ifndef HAVE_MEMCPY
-#define memcpy(d,s,n) bcopy ((s), (d), (n))
-#define memmove(d,s,n) bcopy ((s), (d), (n))
-#endif /* ! HAVE_MEMCPY */
-#endif /* STDC_HEADERS */
-
#include <stdio.h>
#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
+#include <string.h>
+#include <errno.h>
#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
-#ifdef HAVE_FCNTL_H
#include <fcntl.h>
-#endif /* HAVE_FCNTL_H */
#include <pwd.h>
+#include <arpa/inet.h>
-#include <netatalk/endian.h>
-
-#ifdef UAM_RNDNUM
#include <des.h>
#ifdef USE_CRACKLIB
#define unhex(x) (isdigit(x) ? (x) - '0' : toupper(x) + 10 - 'A')
static void convert_passwd(char *buf, char *newpwd, const int keyfd)
{
- u_int8_t key[HEXPASSWDLEN];
+ uint8_t key[HEXPASSWDLEN];
Key_schedule schedule;
- int i, j;
+ unsigned int i, j;
if (!newpwd) {
/* convert to binary */
/* decrypt the password */
ecb_encrypt((C_Block *) buf, (C_Block *) buf, schedule, DES_DECRYPT);
}
- memset(schedule, 0, sizeof(schedule));
+ memset(&schedule, 0, sizeof(schedule));
}
if (newpwd) {
while (fgets(buf, sizeof(buf), fp)) {
if ((p = strchr(buf, ':'))) {
/* check for a match */
- if (strncmp(buf, name, p - buf) == 0) {
+ if (strlen(name) == (p - buf) &&
+ strncmp(buf, name, p - buf) == 0) {
p++;
if (!(flags & OPT_ISROOT) && (*p == PASSWD_ILLEGAL)) {
fprintf(stderr, "Your password is disabled. Please see your administrator.\n");
strcat(buf, FORMAT);
len = strlen(buf);
if (write(fd, buf, len) != len) {
- fprintf(stderr, "afppasswd: problem writing to %s: %m\n", path);
+ fprintf(stderr, "afppasswd: problem writing to %s: %s\n", path,
+ strerror(errno));
err = -1;
break;
}
flags = ((uid = getuid()) == 0) ? OPT_ISROOT : 0;
if (((flags & OPT_ISROOT) == 0) && (argc > 1)) {
+ fprintf(stderr, "afppasswd (Netatalk %s)\n", VERSION);
fprintf(stderr, "Usage: afppasswd [-acfn] [-u minuid] [-p path] [username]\n");
fprintf(stderr, " -a add a new user\n");
fprintf(stderr, " -c create and initialize password file or specific user\n");
return -1;
}
}
-#else /* UAM_RNDNUM */
-
-main(int argc, char **argv)
-{
- fprintf(stderr, "afppasswd is only useful if you're using centralized passwords\n");
- fprintf(stderr, "for the Random Number authentication methods.\n");
- return -1;
-}
-
-#endif /* UAM_RNDNUM */