2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-03 15:55:40 +00:00

Cast uid/gid to unsigned int before printing.

This commit is contained in:
Todd C. Miller
2018-08-22 12:58:24 -06:00
parent 10198ef6f3
commit fe58062547
4 changed files with 12 additions and 10 deletions

View File

@@ -613,7 +613,7 @@ sudoers_policy_exec_setup(char *argv[], char *envp[], mode_t cmnd_umask,
/* On BSD systems the effective gid is the first group in the list. */
egid = runas_gr ? (unsigned int)runas_gr->gr_gid :
(unsigned int)runas_pw->pw_gid;
len = snprintf(cp, glsize - (cp - gid_list), "%u", egid);
len = snprintf(cp, glsize - (cp - gid_list), "%u", (unsigned int)egid);
if (len < 0 || (size_t)len >= glsize - (cp - gid_list)) {
sudo_warnx(U_("internal error, %s overflow"), __func__);
free(gid_list);

View File

@@ -85,7 +85,7 @@ ts_match_record(struct timestamp_entry *key, struct timestamp_entry *entry,
if (!ISSET(key->flags, TS_ANYUID) && entry->auth_uid != key->auth_uid) {
sudo_debug_printf(SUDO_DEBUG_DEBUG,
"%s:%u record uid mismatch (want %u, got %u)", __func__, recno,
key->auth_uid, entry->auth_uid);
(unsigned int)key->auth_uid, (unsigned int)entry->auth_uid);
debug_return_bool(false);
}
if (entry->type != key->type) {

View File

@@ -721,7 +721,8 @@ install_sudoers(struct sudoersfile *sp, bool oldperms)
} else {
if (chown(sp->tpath, sudoers_uid, sudoers_gid) != 0) {
sudo_warn(U_("unable to set (uid, gid) of %s to (%u, %u)"),
sp->tpath, sudoers_uid, sudoers_gid);
sp->tpath, (unsigned int)sudoers_uid,
(unsigned int)sudoers_gid);
goto done;
}
if (chmod(sp->tpath, sudoers_mode) != 0) {
@@ -878,7 +879,7 @@ check_owner(const char *path, bool quiet)
if (!quiet) {
fprintf(stderr,
_("%s: wrong owner (uid, gid) should be (%u, %u)\n"),
path, sudoers_uid, sudoers_gid);
path, (unsigned int)sudoers_uid, (unsigned int)sudoers_gid);
}
}
if ((sb.st_mode & ALLPERMS) != sudoers_mode) {

View File

@@ -62,7 +62,8 @@ switch_user(uid_t euid, gid_t egid, int ngroups, GETGROUPS_T *groups)
debug_decl(switch_user, SUDO_DEBUG_EDIT)
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"set uid:gid to %u:%u(%u)", euid, egid, ngroups ? groups[0] : egid);
"set uid:gid to %u:%u(%u)", (unsigned int)euid, (unsigned int)egid,
ngroups ? (unsigned int)groups[0] : (unsigned int)egid);
/* When restoring root, change euid first; otherwise change it last. */
if (euid == ROOT_UID) {
@@ -77,7 +78,7 @@ switch_user(uid_t euid, gid_t egid, int ngroups, GETGROUPS_T *groups)
}
if (euid != ROOT_UID) {
if (seteuid(euid) != 0)
sudo_fatal("seteuid(%d)", (int)euid);
sudo_fatal("seteuid(%u)", (unsigned int)euid);
}
errno = serrno;
@@ -606,9 +607,9 @@ sudo_edit_create_tfiles(struct command_details *command_details,
tf[j].osize = sb.st_size;
mtim_get(&sb, tf[j].omtim);
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"seteuid(%u)", user_details.uid);
"seteuid(%u)", (unsigned int)user_details.uid);
if (seteuid(user_details.uid) != 0)
sudo_fatal("seteuid(%d)", (int)user_details.uid);
sudo_fatal("seteuid(%u)", (unsigned int)user_details.uid);
tfd = sudo_edit_mktemp(tf[j].ofile, &tf[j].tfile);
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"seteuid(%u)", ROOT_UID);
@@ -680,9 +681,9 @@ sudo_edit_copy_tfiles(struct command_details *command_details,
for (i = 0; i < nfiles; i++) {
rc = -1;
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"seteuid(%u)", user_details.uid);
"seteuid(%u)", (unsigned int)user_details.uid);
if (seteuid(user_details.uid) != 0)
sudo_fatal("seteuid(%d)", (int)user_details.uid);
sudo_fatal("seteuid(%u)", (unsigned int)user_details.uid);
tfd = sudo_edit_open(tf[i].tfile, O_RDONLY,
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, NULL);
if (tfd != -1)