Use %u to print uid/gid, not %lu and adjust casts to match.
This commit is contained in:
@@ -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
|
* Set the ticket file to be in sudo sudo timedir so we don't
|
||||||
* wipe out other (real) kerberos tickets.
|
* wipe out other (real) kerberos tickets.
|
||||||
*/
|
*/
|
||||||
(void) snprintf(tkfile, sizeof(tkfile), "%s/tkt%lu",
|
(void) snprintf(tkfile, sizeof(tkfile), "%s/tkt%u",
|
||||||
_PATH_SUDO_TIMEDIR, (unsigned long) pw->pw_uid);
|
_PATH_SUDO_TIMEDIR, (unsigned int) pw->pw_uid);
|
||||||
(void) krb_set_tkt_string(tkfile);
|
(void) krb_set_tkt_string(tkfile);
|
||||||
|
|
||||||
/* Convert the password to a ticket given. */
|
/* Convert the password to a ticket given. */
|
||||||
|
@@ -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)",
|
log_error(NO_EXIT, "%s exists but is not a directory (0%o)",
|
||||||
dirparent, (unsigned int) sb.st_mode);
|
dirparent, (unsigned int) sb.st_mode);
|
||||||
else if (sb.st_uid != timestamp_uid)
|
else if (sb.st_uid != timestamp_uid)
|
||||||
log_error(NO_EXIT, "%s owned by uid %lu, should be uid %lu",
|
log_error(NO_EXIT, "%s owned by uid %u, should be uid %u",
|
||||||
dirparent, (unsigned long) sb.st_uid,
|
dirparent, (unsigned int) sb.st_uid,
|
||||||
(unsigned long) timestamp_uid);
|
(unsigned int) timestamp_uid);
|
||||||
else if ((sb.st_mode & 0000022))
|
else if ((sb.st_mode & 0000022))
|
||||||
log_error(NO_EXIT,
|
log_error(NO_EXIT,
|
||||||
"%s writable by non-owner (0%o), should be mode 0700",
|
"%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)",
|
log_error(NO_EXIT, "%s exists but is not a directory (0%o)",
|
||||||
timestampdir, (unsigned int) sb.st_mode);
|
timestampdir, (unsigned int) sb.st_mode);
|
||||||
} else if (sb.st_uid != timestamp_uid)
|
} else if (sb.st_uid != timestamp_uid)
|
||||||
log_error(NO_EXIT, "%s owned by uid %lu, should be uid %lu",
|
log_error(NO_EXIT, "%s owned by uid %u, should be uid %u",
|
||||||
timestampdir, (unsigned long) sb.st_uid,
|
timestampdir, (unsigned int) sb.st_uid,
|
||||||
(unsigned long) timestamp_uid);
|
(unsigned int) timestamp_uid);
|
||||||
else if ((sb.st_mode & 0000022))
|
else if ((sb.st_mode & 0000022))
|
||||||
log_error(NO_EXIT,
|
log_error(NO_EXIT,
|
||||||
"%s writable by non-owner (0%o), should be mode 0700",
|
"%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 bad uid or file mode, complain and kill the bogus file. */
|
||||||
if (sb.st_uid != timestamp_uid) {
|
if (sb.st_uid != timestamp_uid) {
|
||||||
log_error(NO_EXIT,
|
log_error(NO_EXIT,
|
||||||
"%s owned by uid %lu, should be uid %lu",
|
"%s owned by uid %u, should be uid %u",
|
||||||
timestampfile, (unsigned long) sb.st_uid,
|
timestampfile, (unsigned int) sb.st_uid,
|
||||||
(unsigned long) timestamp_uid);
|
(unsigned int) timestamp_uid);
|
||||||
(void) unlink(timestampfile);
|
(void) unlink(timestampfile);
|
||||||
} else if ((sb.st_mode & 0000022)) {
|
} else if ((sb.st_mode & 0000022)) {
|
||||||
log_error(NO_EXIT,
|
log_error(NO_EXIT,
|
||||||
@@ -708,8 +708,8 @@ get_authpw(void)
|
|||||||
log_error(0, "unknown user: %s", def_runas_default);
|
log_error(0, "unknown user: %s", def_runas_default);
|
||||||
} else if (def_targetpw) {
|
} else if (def_targetpw) {
|
||||||
if (runas_pw->pw_name == NULL)
|
if (runas_pw->pw_name == NULL)
|
||||||
log_error(NO_MAIL|MSG_ONLY, "unknown uid: %lu",
|
log_error(NO_MAIL|MSG_ONLY, "unknown uid: %u",
|
||||||
(unsigned long) runas_pw->pw_uid);
|
(unsigned int) runas_pw->pw_uid);
|
||||||
pw_addref(runas_pw);
|
pw_addref(runas_pw);
|
||||||
pw = runas_pw;
|
pw = runas_pw;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -641,9 +641,9 @@ rebuild_env(int noexec)
|
|||||||
|
|
||||||
/* Add the SUDO_USER, SUDO_UID, SUDO_GID environment variables. */
|
/* Add the SUDO_USER, SUDO_UID, SUDO_GID environment variables. */
|
||||||
sudo_setenv("SUDO_USER", user_name, TRUE);
|
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);
|
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);
|
sudo_setenv("SUDO_GID", idbuf, TRUE);
|
||||||
|
|
||||||
/* Free old environment. */
|
/* Free old environment. */
|
||||||
|
@@ -241,15 +241,16 @@ sudo_getpwuid(uid_t uid)
|
|||||||
if ((key.d.pw = getpwuid(uid)) != NULL) {
|
if ((key.d.pw = getpwuid(uid)) != NULL) {
|
||||||
item = make_pwitem(key.d.pw, NULL);
|
item = make_pwitem(key.d.pw, NULL);
|
||||||
if (rbinsert(pwcache_byuid, item) != NULL)
|
if (rbinsert(pwcache_byuid, item) != NULL)
|
||||||
errorx(1, "unable to cache uid %lu (%s), already exists",
|
errorx(1, "unable to cache uid %u (%s), already exists",
|
||||||
uid, item->d.pw->pw_name);
|
(unsigned int) uid, item->d.pw->pw_name);
|
||||||
} else {
|
} else {
|
||||||
item = emalloc(sizeof(*item));
|
item = emalloc(sizeof(*item));
|
||||||
item->refcnt = 1;
|
item->refcnt = 1;
|
||||||
item->k.uid = uid;
|
item->k.uid = uid;
|
||||||
item->d.pw = NULL;
|
item->d.pw = NULL;
|
||||||
if (rbinsert(pwcache_byuid, item) != 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
|
#ifdef HAVE_SETAUTHDB
|
||||||
aix_restoreauthdb();
|
aix_restoreauthdb();
|
||||||
@@ -507,15 +508,16 @@ sudo_getgrgid(gid_t gid)
|
|||||||
if ((key.d.gr = getgrgid(gid)) != NULL) {
|
if ((key.d.gr = getgrgid(gid)) != NULL) {
|
||||||
item = make_gritem(key.d.gr, NULL);
|
item = make_gritem(key.d.gr, NULL);
|
||||||
if (rbinsert(grcache_bygid, item) != NULL)
|
if (rbinsert(grcache_bygid, item) != NULL)
|
||||||
errorx(1, "unable to cache gid %lu (%s), already exists",
|
errorx(1, "unable to cache gid %u (%s), already exists",
|
||||||
gid, key.d.gr->gr_name);
|
(unsigned int) gid, key.d.gr->gr_name);
|
||||||
} else {
|
} else {
|
||||||
item = emalloc(sizeof(*item));
|
item = emalloc(sizeof(*item));
|
||||||
item->refcnt = 1;
|
item->refcnt = 1;
|
||||||
item->k.gid = gid;
|
item->k.gid = gid;
|
||||||
item->d.gr = NULL;
|
item->d.gr = NULL;
|
||||||
if (rbinsert(grcache_bygid, item) != 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:
|
done:
|
||||||
item->refcnt++;
|
item->refcnt++;
|
||||||
|
@@ -599,8 +599,8 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
|
|||||||
cp = gid_list + sizeof("runas_groups=") - 1;
|
cp = gid_list + sizeof("runas_groups=") - 1;
|
||||||
for (i = 0; i < runas_ngroups; i++) {
|
for (i = 0; i < runas_ngroups; i++) {
|
||||||
/* XXX - check rval */
|
/* XXX - check rval */
|
||||||
len = snprintf(cp, glsize - (cp - gid_list), "%s%lu",
|
len = snprintf(cp, glsize - (cp - gid_list), "%s%u",
|
||||||
i ? "," : "", (unsigned long)runas_groups[i]);
|
i ? "," : "", (unsigned int) runas_groups[i]);
|
||||||
cp += len;
|
cp += len;
|
||||||
}
|
}
|
||||||
command_info[info_len++] = gid_list;
|
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) (statbuf.st_mode & 07777),
|
||||||
(unsigned int) SUDOERS_MODE);
|
(unsigned int) SUDOERS_MODE);
|
||||||
else if (statbuf.st_uid != SUDOERS_UID)
|
else if (statbuf.st_uid != SUDOERS_UID)
|
||||||
log_error(NO_EXIT, "%s is owned by uid %lu, should be %lu", sudoers,
|
log_error(NO_EXIT, "%s is owned by uid %u, should be %u", sudoers,
|
||||||
(unsigned long) statbuf.st_uid, (unsigned long) SUDOERS_UID);
|
(unsigned int) statbuf.st_uid, (unsigned int) SUDOERS_UID);
|
||||||
else if (statbuf.st_gid != SUDOERS_GID)
|
else if (statbuf.st_gid != SUDOERS_GID)
|
||||||
log_error(NO_EXIT, "%s is owned by gid %lu, should be %lu", sudoers,
|
log_error(NO_EXIT, "%s is owned by gid %u, should be %u", sudoers,
|
||||||
(unsigned long) statbuf.st_gid, (unsigned long) SUDOERS_GID);
|
(unsigned int) statbuf.st_gid, (unsigned int) SUDOERS_GID);
|
||||||
else if ((fp = fopen(sudoers, "r")) == NULL)
|
else if ((fp = fopen(sudoers, "r")) == NULL)
|
||||||
log_error(USE_ERRNO|NO_EXIT, "can't open %s", sudoers);
|
log_error(USE_ERRNO|NO_EXIT, "can't open %s", sudoers);
|
||||||
else {
|
else {
|
||||||
|
14
src/sudo.c
14
src/sudo.c
@@ -324,8 +324,8 @@ get_user_groups(struct user_details *ud)
|
|||||||
cp = gid_list + sizeof("groups=") - 1;
|
cp = gid_list + sizeof("groups=") - 1;
|
||||||
for (i = 0; i < ud->ngroups; i++) {
|
for (i = 0; i < ud->ngroups; i++) {
|
||||||
/* XXX - check rval */
|
/* XXX - check rval */
|
||||||
len = snprintf(cp, glsize - (cp - gid_list), "%s%lu",
|
len = snprintf(cp, glsize - (cp - gid_list), "%s%u",
|
||||||
i ? "," : "", (unsigned long)ud->groups[i]);
|
i ? "," : "", (unsigned int)ud->groups[i]);
|
||||||
cp += len;
|
cp += len;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -355,7 +355,7 @@ get_user_info(struct user_details *ud)
|
|||||||
|
|
||||||
pw = getpwuid(ud->uid);
|
pw = getpwuid(ud->uid);
|
||||||
if (pw == NULL)
|
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);
|
user_info[i] = fmt_string("user", pw->pw_name);
|
||||||
if (user_info[i] == NULL)
|
if (user_info[i] == NULL)
|
||||||
@@ -368,10 +368,10 @@ get_user_info(struct user_details *ud)
|
|||||||
}
|
}
|
||||||
ud->shell = estrdup(ud->shell);
|
ud->shell = estrdup(ud->shell);
|
||||||
|
|
||||||
easprintf(&user_info[++i], "uid=%lu", (unsigned long)ud->uid);
|
easprintf(&user_info[++i], "uid=%u", (unsigned int)ud->uid);
|
||||||
easprintf(&user_info[++i], "euid=%lu", (unsigned long)ud->euid);
|
easprintf(&user_info[++i], "euid=%u", (unsigned int)ud->euid);
|
||||||
easprintf(&user_info[++i], "gid=%lu", (unsigned long)ud->gid);
|
easprintf(&user_info[++i], "gid=%u", (unsigned int)ud->gid);
|
||||||
easprintf(&user_info[++i], "egid=%lu", (unsigned long)ud->egid);
|
easprintf(&user_info[++i], "egid=%u", (unsigned int)ud->egid);
|
||||||
|
|
||||||
if ((cp = get_user_groups(ud)) != NULL)
|
if ((cp = get_user_groups(ud)) != NULL)
|
||||||
user_info[++i] = cp;
|
user_info[++i] = cp;
|
||||||
|
Reference in New Issue
Block a user