Add explicit cast from mode_t -> u_int in printf to silence warnings on Solaris

This commit is contained in:
Todd C. Miller
2005-04-24 23:24:58 +00:00
parent 7ce5994d6c
commit c7ea24f2cc
2 changed files with 8 additions and 7 deletions

12
check.c
View File

@@ -367,7 +367,7 @@ timestamp_status(timestampdir, timestampfile, user, make_dirs)
if (lstat(dirparent, &sb) == 0) { if (lstat(dirparent, &sb) == 0) {
if (!S_ISDIR(sb.st_mode)) if (!S_ISDIR(sb.st_mode))
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, 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 %lu, should be uid %lu",
dirparent, (unsigned long) sb.st_uid, dirparent, (unsigned long) sb.st_uid,
@@ -375,7 +375,7 @@ timestamp_status(timestampdir, timestampfile, user, make_dirs)
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",
dirparent, sb.st_mode); dirparent, (unsigned int) sb.st_mode);
else { else {
if ((sb.st_mode & 0000777) != 0700) if ((sb.st_mode & 0000777) != 0700)
(void) chmod(dirparent, 0700); (void) chmod(dirparent, 0700);
@@ -414,7 +414,7 @@ timestamp_status(timestampdir, timestampfile, user, make_dirs)
status = TS_MISSING; status = TS_MISSING;
} else } else
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, 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 %lu, should be uid %lu",
timestampdir, (unsigned long) sb.st_uid, timestampdir, (unsigned long) sb.st_uid,
@@ -422,7 +422,7 @@ timestamp_status(timestampdir, timestampfile, user, make_dirs)
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",
timestampdir, sb.st_mode); timestampdir, (unsigned int) sb.st_mode);
else { else {
if ((sb.st_mode & 0000777) != 0700) if ((sb.st_mode & 0000777) != 0700)
(void) chmod(timestampdir, 0700); (void) chmod(timestampdir, 0700);
@@ -454,7 +454,7 @@ timestamp_status(timestampdir, timestampfile, user, make_dirs)
if (!S_ISREG(sb.st_mode)) { if (!S_ISREG(sb.st_mode)) {
status = TS_ERROR; status = TS_ERROR;
log_error(NO_EXIT, "%s exists but is not a regular file (0%o)", log_error(NO_EXIT, "%s exists but is not a regular file (0%o)",
timestampfile, sb.st_mode); timestampfile, (unsigned int) sb.st_mode);
} else { } else {
/* 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) {
@@ -466,7 +466,7 @@ timestamp_status(timestampdir, timestampfile, user, make_dirs)
} 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 0600", "%s writable by non-owner (0%o), should be mode 0600",
timestampfile, sb.st_mode); timestampfile, (unsigned int) sb.st_mode);
(void) unlink(timestampfile); (void) unlink(timestampfile);
} else { } else {
/* If not mode 0600, fix it. */ /* If not mode 0600, fix it. */

3
sudo.c
View File

@@ -964,7 +964,8 @@ open_sudoers(sudoers, keepopen)
log_error(0, "%s is zero length", sudoers); log_error(0, "%s is zero length", sudoers);
else if ((statbuf.st_mode & 07777) != SUDOERS_MODE) else if ((statbuf.st_mode & 07777) != SUDOERS_MODE)
log_error(0, "%s is mode 0%o, should be 0%o", sudoers, log_error(0, "%s is mode 0%o, should be 0%o", sudoers,
(statbuf.st_mode & 07777), SUDOERS_MODE); (unsigned int) (statbuf.st_mode & 07777),
(unsigned int) SUDOERS_MODE);
else if (statbuf.st_uid != SUDOERS_UID) else if (statbuf.st_uid != SUDOERS_UID)
log_error(0, "%s is owned by uid %lu, should be %lu", sudoers, log_error(0, "%s is owned by uid %lu, should be %lu", sudoers,
(unsigned long) statbuf.st_uid, (unsigned long) SUDOERS_UID); (unsigned long) statbuf.st_uid, (unsigned long) SUDOERS_UID);