logrotate/explicitly-cast-uid_t-and-gid_t-to-unsigned-int.patch
2019-09-30 11:02:46 -04:00

85 lines
3.0 KiB
Diff

From 6563e6551657b63898c7387fd56bb2f3ee115fa1 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 1 Aug 2018 11:42:08 +0200
Subject: [PATCH 16/39] logrotate: explicitly cast uid_t and gid_t to unsigned int
reason: explicitly cast uid_t and gid_t to unsigned int
https://github.com/logrotate/logrotate/commit/6563e6551657b63898c7387fd56bb2f3ee115fa1
... before passing them to the %u conversion in printf() invocation.
The uid_t and gid_t types do not need to be the same as unsigned int
on all supported platforms.
Closes #200
---
config.c | 2 +-
logrotate.c | 13 +++++++------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/config.c b/config.c
index 53b7416..960ee9b 100644
--- a/config.c
+++ b/config.c
@@ -361,7 +361,7 @@ static int do_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid) {
/* newly created directory, set the owner and permissions */
if (chown(path, uid, gid) != 0) {
message(MESS_ERROR, "error setting owner of %s to uid %u and gid %u: %s\n",
- path, uid, gid, strerror(errno));
+ path, (unsigned) uid, (unsigned) gid, strerror(errno));
return -1;
}
diff --git a/logrotate.c b/logrotate.c
index 4fd546f..46f10a2 100644
--- a/logrotate.c
+++ b/logrotate.c
@@ -157,10 +157,10 @@ int switch_user(uid_t user, gid_t group) {
if (save_euid == user && save_egid == group)
return 0;
message(MESS_DEBUG, "switching euid to %u and egid to %u\n",
- user, group);
+ (unsigned) user, (unsigned) group);
if (setegid(group) || seteuid(user)) {
message(MESS_ERROR, "error switching euid to %u and egid to %u: %s\n",
- user, group, strerror(errno));
+ (unsigned) user, (unsigned) group, strerror(errno));
return 1;
}
return 0;
@@ -180,10 +180,10 @@ static int switch_user_permanently(const struct logInfo *log) {
return 1;
}
message(MESS_DEBUG, "switching uid to %u and gid to %u\n",
- user, group);
+ (unsigned) user, (unsigned) group);
if (setgid(group) || setuid(user)) {
message(MESS_ERROR, "error switching euid to %u and egid to %u: %s\n",
- user, group, strerror(errno));
+ (unsigned) user, (unsigned) group, strerror(errno));
return 1;
}
return 0;
@@ -541,7 +541,7 @@ static int createOutputFile(char *fileName, int flags, struct stat *sb,
if ((sb_create.st_uid != sb->st_uid || sb_create.st_gid != sb->st_gid) &&
fchown(fd, sb->st_uid, sb->st_gid)) {
message(MESS_ERROR, "error setting owner of %s to uid %u and gid %u: %s\n",
- fileName, sb->st_uid, sb->st_gid, strerror(errno));
+ fileName, (unsigned) sb->st_uid, (unsigned) sb->st_gid, strerror(errno));
close(fd);
return -1;
}
@@ -1993,7 +1993,8 @@ static int rotateLogSet(struct logInfo *log, int force)
message(MESS_DEBUG, "%jd bytes ", (intmax_t)log->threshold);
break;
default:
- message(MESS_DEBUG, "rotateLogSet() does not have case for: %u ", log->criterium);
+ message(MESS_DEBUG, "rotateLogSet() does not have case for: %u ",
+ (unsigned) log->criterium);
}
}
--
1.8.3.1