Use %u to print uid/gid, not %lu and adjust casts to match.

This commit is contained in:
Todd C. Miller
2010-11-30 15:21:36 -05:00
parent 3f605ebfaa
commit 4527bdd9b4
6 changed files with 36 additions and 34 deletions

View File

@@ -77,8 +77,8 @@ kerb4_verify(struct passwd *pw, char *pass, sudo_auth *auth)
* Set the ticket file to be in sudo sudo timedir so we don't
* wipe out other (real) kerberos tickets.
*/
(void) snprintf(tkfile, sizeof(tkfile), "%s/tkt%lu",
_PATH_SUDO_TIMEDIR, (unsigned long) pw->pw_uid);
(void) snprintf(tkfile, sizeof(tkfile), "%s/tkt%u",
_PATH_SUDO_TIMEDIR, (unsigned int) pw->pw_uid);
(void) krb_set_tkt_string(tkfile);
/* Convert the password to a ticket given. */

View File

@@ -447,9 +447,9 @@ timestamp_status(char *timestampdir, char *timestampfile, char *user, int flags)
log_error(NO_EXIT, "%s exists but is not a directory (0%o)",
dirparent, (unsigned int) sb.st_mode);
else if (sb.st_uid != timestamp_uid)
log_error(NO_EXIT, "%s owned by uid %lu, should be uid %lu",
dirparent, (unsigned long) sb.st_uid,
(unsigned long) timestamp_uid);
log_error(NO_EXIT, "%s owned by uid %u, should be uid %u",
dirparent, (unsigned int) sb.st_uid,
(unsigned int) timestamp_uid);
else if ((sb.st_mode & 0000022))
log_error(NO_EXIT,
"%s writable by non-owner (0%o), should be mode 0700",
@@ -491,9 +491,9 @@ timestamp_status(char *timestampdir, char *timestampfile, char *user, int flags)
log_error(NO_EXIT, "%s exists but is not a directory (0%o)",
timestampdir, (unsigned int) sb.st_mode);
} else if (sb.st_uid != timestamp_uid)
log_error(NO_EXIT, "%s owned by uid %lu, should be uid %lu",
timestampdir, (unsigned long) sb.st_uid,
(unsigned long) timestamp_uid);
log_error(NO_EXIT, "%s owned by uid %u, should be uid %u",
timestampdir, (unsigned int) sb.st_uid,
(unsigned int) timestamp_uid);
else if ((sb.st_mode & 0000022))
log_error(NO_EXIT,
"%s writable by non-owner (0%o), should be mode 0700",
@@ -536,9 +536,9 @@ timestamp_status(char *timestampdir, char *timestampfile, char *user, int flags)
/* If bad uid or file mode, complain and kill the bogus file. */
if (sb.st_uid != timestamp_uid) {
log_error(NO_EXIT,
"%s owned by uid %lu, should be uid %lu",
timestampfile, (unsigned long) sb.st_uid,
(unsigned long) timestamp_uid);
"%s owned by uid %u, should be uid %u",
timestampfile, (unsigned int) sb.st_uid,
(unsigned int) timestamp_uid);
(void) unlink(timestampfile);
} else if ((sb.st_mode & 0000022)) {
log_error(NO_EXIT,
@@ -708,8 +708,8 @@ get_authpw(void)
log_error(0, "unknown user: %s", def_runas_default);
} else if (def_targetpw) {
if (runas_pw->pw_name == NULL)
log_error(NO_MAIL|MSG_ONLY, "unknown uid: %lu",
(unsigned long) runas_pw->pw_uid);
log_error(NO_MAIL|MSG_ONLY, "unknown uid: %u",
(unsigned int) runas_pw->pw_uid);
pw_addref(runas_pw);
pw = runas_pw;
} else {

View File

@@ -641,9 +641,9 @@ rebuild_env(int noexec)
/* Add the SUDO_USER, SUDO_UID, SUDO_GID environment variables. */
sudo_setenv("SUDO_USER", user_name, TRUE);
snprintf(idbuf, sizeof(idbuf), "%lu", (unsigned long) user_uid);
snprintf(idbuf, sizeof(idbuf), "%u", (unsigned int) user_uid);
sudo_setenv("SUDO_UID", idbuf, TRUE);
snprintf(idbuf, sizeof(idbuf), "%lu", (unsigned long) user_gid);
snprintf(idbuf, sizeof(idbuf), "%u", (unsigned int) user_gid);
sudo_setenv("SUDO_GID", idbuf, TRUE);
/* Free old environment. */

View File

@@ -241,15 +241,16 @@ sudo_getpwuid(uid_t uid)
if ((key.d.pw = getpwuid(uid)) != NULL) {
item = make_pwitem(key.d.pw, NULL);
if (rbinsert(pwcache_byuid, item) != NULL)
errorx(1, "unable to cache uid %lu (%s), already exists",
uid, item->d.pw->pw_name);
errorx(1, "unable to cache uid %u (%s), already exists",
(unsigned int) uid, item->d.pw->pw_name);
} else {
item = emalloc(sizeof(*item));
item->refcnt = 1;
item->k.uid = uid;
item->d.pw = NULL;
if (rbinsert(pwcache_byuid, item) != NULL)
errorx(1, "unable to cache uid %lu, already exists", uid);
errorx(1, "unable to cache uid %u, already exists",
(unsigned int) uid);
}
#ifdef HAVE_SETAUTHDB
aix_restoreauthdb();
@@ -507,15 +508,16 @@ sudo_getgrgid(gid_t gid)
if ((key.d.gr = getgrgid(gid)) != NULL) {
item = make_gritem(key.d.gr, NULL);
if (rbinsert(grcache_bygid, item) != NULL)
errorx(1, "unable to cache gid %lu (%s), already exists",
gid, key.d.gr->gr_name);
errorx(1, "unable to cache gid %u (%s), already exists",
(unsigned int) gid, key.d.gr->gr_name);
} else {
item = emalloc(sizeof(*item));
item->refcnt = 1;
item->k.gid = gid;
item->d.gr = NULL;
if (rbinsert(grcache_bygid, item) != NULL)
errorx(1, "unable to cache gid %lu, already exists, gid");
errorx(1, "unable to cache gid %u, already exists",
(unsigned int) gid);
}
done:
item->refcnt++;

View File

@@ -599,8 +599,8 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
cp = gid_list + sizeof("runas_groups=") - 1;
for (i = 0; i < runas_ngroups; i++) {
/* XXX - check rval */
len = snprintf(cp, glsize - (cp - gid_list), "%s%lu",
i ? "," : "", (unsigned long)runas_groups[i]);
len = snprintf(cp, glsize - (cp - gid_list), "%s%u",
i ? "," : "", (unsigned int) runas_groups[i]);
cp += len;
}
command_info[info_len++] = gid_list;
@@ -877,11 +877,11 @@ open_sudoers(const char *sudoers, int doedit, int *keepopen)
(unsigned int) (statbuf.st_mode & 07777),
(unsigned int) SUDOERS_MODE);
else if (statbuf.st_uid != SUDOERS_UID)
log_error(NO_EXIT, "%s is owned by uid %lu, should be %lu", sudoers,
(unsigned long) statbuf.st_uid, (unsigned long) SUDOERS_UID);
log_error(NO_EXIT, "%s is owned by uid %u, should be %u", sudoers,
(unsigned int) statbuf.st_uid, (unsigned int) SUDOERS_UID);
else if (statbuf.st_gid != SUDOERS_GID)
log_error(NO_EXIT, "%s is owned by gid %lu, should be %lu", sudoers,
(unsigned long) statbuf.st_gid, (unsigned long) SUDOERS_GID);
log_error(NO_EXIT, "%s is owned by gid %u, should be %u", sudoers,
(unsigned int) statbuf.st_gid, (unsigned int) SUDOERS_GID);
else if ((fp = fopen(sudoers, "r")) == NULL)
log_error(USE_ERRNO|NO_EXIT, "can't open %s", sudoers);
else {

View File

@@ -324,8 +324,8 @@ get_user_groups(struct user_details *ud)
cp = gid_list + sizeof("groups=") - 1;
for (i = 0; i < ud->ngroups; i++) {
/* XXX - check rval */
len = snprintf(cp, glsize - (cp - gid_list), "%s%lu",
i ? "," : "", (unsigned long)ud->groups[i]);
len = snprintf(cp, glsize - (cp - gid_list), "%s%u",
i ? "," : "", (unsigned int)ud->groups[i]);
cp += len;
}
#endif
@@ -355,7 +355,7 @@ get_user_info(struct user_details *ud)
pw = getpwuid(ud->uid);
if (pw == NULL)
errorx(1, "unknown uid %lu: who are you?", (unsigned long)ud->uid);
errorx(1, "unknown uid %u: who are you?", (unsigned int)ud->uid);
user_info[i] = fmt_string("user", pw->pw_name);
if (user_info[i] == NULL)
@@ -368,10 +368,10 @@ get_user_info(struct user_details *ud)
}
ud->shell = estrdup(ud->shell);
easprintf(&user_info[++i], "uid=%lu", (unsigned long)ud->uid);
easprintf(&user_info[++i], "euid=%lu", (unsigned long)ud->euid);
easprintf(&user_info[++i], "gid=%lu", (unsigned long)ud->gid);
easprintf(&user_info[++i], "egid=%lu", (unsigned long)ud->egid);
easprintf(&user_info[++i], "uid=%u", (unsigned int)ud->uid);
easprintf(&user_info[++i], "euid=%u", (unsigned int)ud->euid);
easprintf(&user_info[++i], "gid=%u", (unsigned int)ud->gid);
easprintf(&user_info[++i], "egid=%u", (unsigned int)ud->egid);
if ((cp = get_user_groups(ud)) != NULL)
user_info[++i] = cp;