From owner-svn-src-all@freebsd.org Sat Aug 1 09:55:50 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB6EC9AFF3A; Sat, 1 Aug 2015 09:55:49 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C2185CE7; Sat, 1 Aug 2015 09:55:49 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t719tnlR068486; Sat, 1 Aug 2015 09:55:49 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t719tms9068482; Sat, 1 Aug 2015 09:55:48 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201508010955.t719tms9068482@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 1 Aug 2015 09:55:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286150 - head/usr.sbin/pw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Aug 2015 09:55:50 -0000 Author: bapt Date: Sat Aug 1 09:55:47 2015 New Revision: 286150 URL: https://svnweb.freebsd.org/changeset/base/286150 Log: Cast uid/git to uintmax_t when using printf-like functions so the size of uid/gid size remains a implementation detail Modified: head/usr.sbin/pw/pw_conf.c head/usr.sbin/pw/pw_group.c head/usr.sbin/pw/pw_user.c Modified: head/usr.sbin/pw/pw_conf.c ============================================================================== --- head/usr.sbin/pw/pw_conf.c Sat Aug 1 08:39:55 2015 (r286149) +++ head/usr.sbin/pw/pw_conf.c Sat Aug 1 09:55:47 2015 (r286150) @@ -31,6 +31,7 @@ static const char rcsid[] = #include #include +#include #include #include #include @@ -446,19 +447,19 @@ write_userconfig(char const * file) config.default_class : ""); break; case _UC_MINUID: - sbuf_printf(buf, "%u", config.min_uid); + sbuf_printf(buf, "%ju", (uintmax_t)config.min_uid); quote = 0; break; case _UC_MAXUID: - sbuf_printf(buf, "%u", config.max_uid); + sbuf_printf(buf, "%ju", (uintmax_t)config.max_uid); quote = 0; break; case _UC_MINGID: - sbuf_printf(buf, "%u", config.min_gid); + sbuf_printf(buf, "%ju", (uintmax_t)config.min_gid); quote = 0; break; case _UC_MAXGID: - sbuf_printf(buf, "%u", config.max_gid); + sbuf_printf(buf, "%ju", (uintmax_t)config.max_gid); quote = 0; break; case _UC_EXPIRE: Modified: head/usr.sbin/pw/pw_group.c ============================================================================== --- head/usr.sbin/pw/pw_group.c Sat Aug 1 08:39:55 2015 (r286149) +++ head/usr.sbin/pw/pw_group.c Sat Aug 1 09:55:47 2015 (r286150) @@ -31,6 +31,7 @@ static const char rcsid[] = #include #include +#include #include #include #include @@ -97,7 +98,7 @@ pw_groupnext(struct userconf *cnf, bool if (quiet) return (next); - printf("%u\n", next); + printf("%ju\n", (uintmax_t)next); return (EXIT_SUCCESS); } @@ -283,7 +284,7 @@ pw_group(int mode, char *name, long id, if ((grp = GETGRNAM(name)) == NULL) errx(EX_SOFTWARE, "group disappeared during update"); - pw_log(cnf, mode, W_GROUP, "%s(%u)", grp->gr_name, grp->gr_gid); + pw_log(cnf, mode, W_GROUP, "%s(%ju)", grp->gr_name, (uintmax_t)grp->gr_gid); return EXIT_SUCCESS; } @@ -345,7 +346,7 @@ gr_gidpolicy(struct userconf * cnf, long gid = (gid_t) id; if ((grp = GETGRGID(gid)) != NULL && conf.checkduplicate) - errx(EX_DATAERR, "gid `%u' has already been allocated", grp->gr_gid); + errx(EX_DATAERR, "gid `%ju' has already been allocated", (uintmax_t)grp->gr_gid); } else { struct bitmap bm; Modified: head/usr.sbin/pw/pw_user.c ============================================================================== --- head/usr.sbin/pw/pw_user.c Sat Aug 1 08:39:55 2015 (r286149) +++ head/usr.sbin/pw/pw_user.c Sat Aug 1 09:55:47 2015 (r286150) @@ -33,6 +33,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -81,8 +82,8 @@ create_and_populate_homedir(struct passw copymkdir(conf.rootfd, pwd->pw_dir, skelfd, cnf->homemode, pwd->pw_uid, pwd->pw_gid, 0); - pw_log(cnf, M_ADD, W_USER, "%s(%u) home %s made", pwd->pw_name, - pwd->pw_uid, pwd->pw_dir); + pw_log(cnf, M_ADD, W_USER, "%s(%ju) home %s made", pwd->pw_name, + (uintmax_t)pwd->pw_uid, pwd->pw_dir); } static int @@ -155,7 +156,7 @@ pw_usernext(struct userconf *cnf, bool q if (quiet) return (next); - printf("%u:", next); + printf("%ju:", (uintmax_t)next); pw_groupnext(cnf, quiet); return (EXIT_SUCCESS); @@ -749,9 +750,9 @@ pw_user(int mode, char *name, long id, s errx(EX_NOUSER, "user '%s' disappeared during update", name); grp = GETGRGID(pwd->pw_gid); - pw_log(cnf, mode, W_USER, "%s(%u):%s(%u):%s:%s:%s", - pwd->pw_name, pwd->pw_uid, - grp ? grp->gr_name : "unknown", (grp ? grp->gr_gid : (uid_t)-1), + pw_log(cnf, mode, W_USER, "%s(%ju):%s(%ju):%s:%s:%s", + pwd->pw_name, (uintmax_t)pwd->pw_uid, + grp ? grp->gr_name : "unknown", (uintmax_t)(grp ? grp->gr_gid : (uid_t)-1), pwd->pw_gecos, pwd->pw_dir, pwd->pw_shell); /* @@ -794,8 +795,8 @@ pw_user(int mode, char *name, long id, s fputs(line, pfp); } pclose(pfp); - pw_log(cnf, mode, W_USER, "%s(%u) new user mail sent", - pwd->pw_name, pwd->pw_uid); + pw_log(cnf, mode, W_USER, "%s(%ju) new user mail sent", + pwd->pw_name, (uintmax_t)pwd->pw_uid); } fclose(fp); } @@ -817,7 +818,8 @@ pw_uidpolicy(struct userconf * cnf, long uid = (uid_t) id; if ((pwd = GETPWUID(uid)) != NULL && conf.checkduplicate) - errx(EX_DATAERR, "uid `%u' has already been allocated", pwd->pw_uid); + errx(EX_DATAERR, "uid `%ju' has already been allocated", + (uintmax_t)pwd->pw_uid); } else { struct bitmap bm; @@ -1177,8 +1179,8 @@ pw_userdel(char *name, long id) } ENDGRENT(); - pw_log(conf.userconf, M_DELETE, W_USER, "%s(%u) account removed", name, - uid); + pw_log(conf.userconf, M_DELETE, W_USER, "%s(%ju) account removed", name, + (uintmax_t)uid); /* Remove mail file */ if (PWALTDIR() != PWF_ALT) @@ -1193,8 +1195,8 @@ pw_userdel(char *name, long id) getpwuid(uid) == NULL && fstatat(conf.rootfd, home + 1, &st, 0) != -1) { rm_r(conf.rootfd, home, uid); - pw_log(conf.userconf, M_DELETE, W_USER, "%s(%u) home '%s' %s" - "removed", name, uid, home, + pw_log(conf.userconf, M_DELETE, W_USER, "%s(%ju) home '%s' %s" + "removed", name, (uintmax_t)uid, home, fstatat(conf.rootfd, home + 1, &st, 0) == -1 ? "" : "not " "completely "); } @@ -1248,14 +1250,14 @@ print_user(struct passwd * pwd) strftime(acexpire, sizeof acexpire, "%c", tptr); if (pwd->pw_change > (time_t)0 && (tptr = localtime(&pwd->pw_change)) != NULL) strftime(pwexpire, sizeof pwexpire, "%c", tptr); - printf("Login Name: %-15s #%-12u Group: %-15s #%u\n" + printf("Login Name: %-15s #%-12ju Group: %-15s #%ju\n" " Full Name: %s\n" " Home: %-26.26s Class: %s\n" " Shell: %-26.26s Office: %s\n" "Work Phone: %-26.26s Home Phone: %s\n" "Acc Expire: %-26.26s Pwd Expire: %s\n", - pwd->pw_name, pwd->pw_uid, - grp ? grp->gr_name : "(invalid)", pwd->pw_gid, + pwd->pw_name, (uintmax_t)pwd->pw_uid, + grp ? grp->gr_name : "(invalid)", (uintmax_t)pwd->pw_gid, uname, pwd->pw_dir, pwd->pw_class, pwd->pw_shell, office, wphone, hphone, acexpire, pwexpire);