diff options
-rw-r--r-- | usr.sbin/pw/psdate.c | 20 | ||||
-rw-r--r-- | usr.sbin/pw/pw.c | 3 | ||||
-rw-r--r-- | usr.sbin/pw/pw_group.c | 4 | ||||
-rw-r--r-- | usr.sbin/pw/pw_log.c | 3 | ||||
-rw-r--r-- | usr.sbin/pw/pw_user.c | 20 |
5 files changed, 27 insertions, 23 deletions
diff --git a/usr.sbin/pw/psdate.c b/usr.sbin/pw/psdate.c index f8b1fce..f97253b 100644 --- a/usr.sbin/pw/psdate.c +++ b/usr.sbin/pw/psdate.c @@ -43,9 +43,9 @@ a2i(char const ** str) int i = 0; char const *s = *str; - if (isdigit(*s)) { + if (isdigit((unsigned char)*s)) { i = atoi(s); - while (isdigit(*s)) + while (isdigit((unsigned char)*s)) ++s; *str = s; } @@ -55,10 +55,10 @@ a2i(char const ** str) static int numerics(char const * str) { - int rc = isdigit(*str); + int rc = isdigit((unsigned char)*str); if (rc) - while (isdigit(*str) || *str == 'x') + while (isdigit((unsigned char)*str) || *str == 'x') ++str; return rc && !*str; } @@ -72,15 +72,15 @@ aindex(char const * arr[], char const ** str, int len) mystr[len] = '\0'; l = strlen(strncpy(mystr, *str, len)); for (i = 0; i < l; i++) - mystr[i] = (char) tolower(mystr[i]); + mystr[i] = (char) tolower((unsigned char)mystr[i]); for (i = 0; arr[i] && strcmp(mystr, arr[i]) != 0; i++); if (arr[i] == NULL) i = -1; else { /* Skip past it */ - while (**str && isalpha(**str)) + while (**str && isalpha((unsigned char)**str)) ++(*str); /* And any following whitespace */ - while (**str && (**str == ',' || isspace(**str))) + while (**str && (**str == ',' || isspace((unsigned char)**str))) ++(*str); } /* Return index */ return i; @@ -143,7 +143,7 @@ parse_datesub(char const * str, int *day, int *mon, int *year) while (*str && strchr(nchrs + 10, *str) != NULL) ++str; - if (isdigit(*str)) { + if (isdigit((unsigned char)*str)) { *year = atoi(str); if (*year > 1900) *year -= 1900; @@ -176,7 +176,7 @@ parse_date(time_t dt, char const * str) if (dt == 0) dt = time(NULL); - while (*str && isspace(*str)) + while (*str && isspace((unsigned char)*str)) ++str; if (numerics(str)) { @@ -247,7 +247,7 @@ parse_date(time_t dt, char const * str) else { int j = 1; - while (q[j] && isupper(q[j])) + while (q[j] && isupper((unsigned char)q[j])) ++j; if (q[j] == '\0') *q = '\0'; diff --git a/usr.sbin/pw/pw.c b/usr.sbin/pw/pw.c index 6c070ac..5c77783 100644 --- a/usr.sbin/pw/pw.c +++ b/usr.sbin/pw/pw.c @@ -31,6 +31,7 @@ static const char rcsid[] = #include <err.h> #include <fcntl.h> +#include <locale.h> #include <paths.h> #include <sys/wait.h> #include "pw.h" @@ -131,6 +132,8 @@ main(int argc, char *argv[]) umask(0); /* We wish to handle this manually */ LIST_INIT(&arglist); + (void)setlocale(LC_TIME, ""); + /* * Break off the first couple of words to determine what exactly * we're being asked to do diff --git a/usr.sbin/pw/pw_group.c b/usr.sbin/pw/pw_group.c index 6042a68..c9af998 100644 --- a/usr.sbin/pw/pw_group.c +++ b/usr.sbin/pw/pw_group.c @@ -88,7 +88,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args) if (a_name == NULL) errx(EX_DATAERR, "group name or id required"); - if (mode != M_ADD && grp == NULL && isdigit(*a_name->val)) { + if (mode != M_ADD && grp == NULL && isdigit((unsigned char)*a_name->val)) { (a_gid = a_name)->ch = 'g'; a_name = NULL; } @@ -220,7 +220,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args) for (p = strtok(arg->val, ", \t"); p != NULL; p = strtok(NULL, ", \t")) { int j; if ((pwd = GETPWNAM(p)) == NULL) { - if (!isdigit(*p) || (pwd = getpwuid((uid_t) atoi(p))) == NULL) + if (!isdigit((unsigned char)*p) || (pwd = getpwuid((uid_t) atoi(p))) == NULL) errx(EX_NOUSER, "user `%s' does not exist", p); } /* diff --git a/usr.sbin/pw/pw_log.c b/usr.sbin/pw/pw_log.c index 6f72c0d..fc85828 100644 --- a/usr.sbin/pw/pw_log.c +++ b/usr.sbin/pw/pw_log.c @@ -55,7 +55,8 @@ pw_log(struct userconf * cnf, int mode, int which, char const * fmt,...) if ((name = getenv("LOGNAME")) == NULL && (name = getenv("USER")) == NULL) name = "unknown"; - strftime(nfmt, sizeof nfmt, "%d-%b-%Y %R ", t); + /* ISO 8601 International Standard Date format */ + strftime(nfmt, sizeof nfmt, "%Y-%m-%d %T ", t); l = strlen(nfmt); sprintf(nfmt + strlen(nfmt), "[%s:%s%s] %s\n", name, Which[which], Modes[mode], fmt); va_start(argp, fmt); diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c index b70a410..4429050 100644 --- a/usr.sbin/pw/pw_user.c +++ b/usr.sbin/pw/pw_user.c @@ -221,7 +221,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) if ((arg = getarg(args, 'g')) != NULL) { p = arg->val; if ((grp = GETGRNAM(p)) == NULL) { - if (!isdigit(*p) || (grp = GETGRGID((gid_t) atoi(p))) == NULL) + if (!isdigit((unsigned char)*p) || (grp = GETGRGID((gid_t) atoi(p))) == NULL) errx(EX_NOUSER, "group `%s' does not exist", p); } cnf->default_group = newstr(grp->gr_name); @@ -234,7 +234,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) for (p = strtok(arg->val, ", \t"); p != NULL; p = strtok(NULL, ", \t")) { if ((grp = GETGRNAM(p)) == NULL) { - if (!isdigit(*p) || (grp = GETGRGID((gid_t) atoi(p))) == NULL) + if (!isdigit((unsigned char)*p) || (grp = GETGRGID((gid_t) atoi(p))) == NULL) errx(EX_NOUSER, "group `%s' does not exist", p); } if (extendarray(&cnf->groups, &cnf->numgroups, i + 2) != -1) @@ -455,7 +455,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) edited = 1; } - if ((arg = getarg(args, 'u')) != NULL && isdigit(*arg->val)) { + if ((arg = getarg(args, 'u')) != NULL && isdigit((unsigned char)*arg->val)) { pwd->pw_uid = (uid_t) atol(arg->val); edited = 1; if (pwd->pw_uid != 0 && strcmp(pwd->pw_name, "root") == 0) @@ -827,7 +827,7 @@ pw_gidpolicy(struct userconf * cnf, struct cargs * args, char *nam, gid_t prefer if (a_gid != NULL) { if ((grp = GETGRNAM(a_gid->val)) == NULL) { gid = (gid_t) atol(a_gid->val); - if ((gid == 0 && !isdigit(*a_gid->val)) || (grp = GETGRGID(gid)) == NULL) + if ((gid == 0 && !isdigit((unsigned char)*a_gid->val)) || (grp = GETGRGID(gid)) == NULL) errx(EX_NOUSER, "group `%s' is not defined", a_gid->val); } gid = grp->gr_gid; @@ -1078,7 +1078,7 @@ pw_password(struct userconf * cnf, struct cargs * args, char const * user) * We give this information back to the user */ if (getarg(args, 'h') == NULL && getarg(args, 'N') == NULL) { - if (isatty(1)) + if (isatty(STDOUT_FILENO)) printf("Password for '%s' is: ", user); printf("%s\n", pwbuf); fflush(stdout); @@ -1143,12 +1143,12 @@ print_user(struct passwd * pwd, int pretty, int v7) memmove(p + l, p + 1, m); memmove(p, pwd->pw_name, l); - *p = (char) toupper(*p); + *p = (char) toupper((unsigned char)*p); } if (pwd->pw_expire > (time_t)0 && (tptr = localtime(&pwd->pw_expire)) != NULL) - strftime(acexpire, sizeof acexpire, "%e-%b-%Y %T", tptr); - if (pwd->pw_change > (time_t)9 && (tptr = localtime(&pwd->pw_change)) != NULL) - strftime(pwexpire, sizeof pwexpire, "%e-%b-%Y %T", tptr); + strftime(acexpire, sizeof acexpire, "%Ef %Y %X", tptr); + if (pwd->pw_change > (time_t)0 && (tptr = localtime(&pwd->pw_change)) != NULL) + strftime(pwexpire, sizeof pwexpire, "%Ef %Y %X", tptr); printf("Login Name: %-15s #%-12ld Group: %-15s #%ld\n" " Full Name: %s\n" " Home: %-26.26s Class: %s\n" @@ -1176,7 +1176,7 @@ print_user(struct passwd * pwd, int pretty, int v7) } } ENDGRENT(); - printf("%s\n", j ? "\n" : ""); + printf("%s", j ? "\n" : ""); } return EXIT_SUCCESS; } |