X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=bin%2Fafppasswd%2Fafppasswd.c;h=3125f53ffb7ddd88c04305bc37fd80a3abc3e006;hb=ae97675aefb21e9e3039b759c688f5f1328cfa7e;hp=980ca4a26087d0d562cc1b83f41604de65c59293;hpb=fd371714895adf541884a0f3f83b746a1253fec9;p=netatalk.git diff --git a/bin/afppasswd/afppasswd.c b/bin/afppasswd/afppasswd.c index 980ca4a2..3125f53f 100644 --- a/bin/afppasswd/afppasswd.c +++ b/bin/afppasswd/afppasswd.c @@ -1,5 +1,5 @@ /* - * $Id: afppasswd.c,v 1.7 2001-07-31 19:49:02 srittau Exp $ + * $Id: afppasswd.c,v 1.19 2005-04-28 20:49:19 bfernhomberg Exp $ * * Copyright 1999 (c) Adrian Sun (asun@u.washington.edu) * All Rights Reserved. See COPYRIGHT. @@ -26,22 +26,18 @@ #include #include -#ifdef HAVE_UNISTD_H +#include +#include #include -#endif /* HAVE_UNISTD_H */ #include -#include #include #include #include -#ifdef HAVE_FCNTL_H #include -#endif /* HAVE_FCNTL_H */ #include #include -#ifdef UAM_RNDNUM #include #ifdef USE_CRACKLIB @@ -73,7 +69,7 @@ static void convert_passwd(char *buf, char *newpwd, const int keyfd) { u_int8_t key[HEXPASSWDLEN]; Key_schedule schedule; - int i, j; + unsigned int i, j; if (!newpwd) { /* convert to binary */ @@ -100,7 +96,7 @@ static void convert_passwd(char *buf, char *newpwd, const int keyfd) /* 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) { @@ -139,7 +135,8 @@ static int update_passwd(const char *path, const char *name, int flags) 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"); @@ -242,7 +239,8 @@ static int create_file(const char *path, uid_t minuid) 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; } @@ -356,13 +354,3 @@ int main(int argc, char **argv) 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 */