Closed MarsLenug closed 2 years ago
similar like alpine
container bash:
[docker@localhost ~]$ docker exec -it nginx sh
/ $ id
uid=1001 gid=1001
/ $ whoami
whoami: unknown uid 1001
/ $ logrotate -d -s /etc/nginx/cron/logrotate.state /etc/nginx/cron/logrotate
WARNING: logrotate in debug mode does nothing except printing debug messages! Consider using verbose mode (-v) instead if this is not what you want.
error: Cannot find logrotate UID (1001) in passwd file: No such file or directory
Reading state from file: /etc/nginx/cron/logrotate.state
Allocating hash table for state file, size 64 entries
Handling 0 logs
/ $ logrotate -f -s /etc/nginx/cron/logrotate.state /etc/nginx/cron/logrotate
error: Cannot find logrotate UID (1001) in passwd file: No such file or directory
The code that errors out when getpwuid(getuid())
fails has been there since 2011 (since commit fa839dc240a623479373332c7a0a171da34e8399). I believe that commit 808401ebd6371c295a815bfb556d9881963acfa9 made the call redundant unless logrotate runs with UID 0, which is apparently not your case.
@cgzones Any objection to removing the code in question?
--- a/config.c
+++ b/config.c
@@ -1046,23 +1046,16 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
if (!S_ISREG(sb_config.st_mode)) {
message(MESS_DEBUG,
"Ignoring %s because it's not a regular file.\n",
configFile);
close(fd);
return 0;
}
- if (!getpwuid(getuid())) {
- message(MESS_ERROR, "Cannot find logrotate UID (%d) in passwd file: %s\n",
- getuid(), strerror(errno));
- close(fd);
- return 1;
- }
-
if (getuid() == ROOT_UID) {
if ((sb_config.st_mode & 07533) != 0400) {
message(MESS_WARN,
"Potentially dangerous mode on %s: 0%o\n",
configFile, (unsigned) (sb_config.st_mode & 07777));
}
if (sb_config.st_mode & 0022) {
I do not see any reason to not remove that code.
Perfect. I have submitted #464 to fix this.
Hi everyone,
should not allow the user to uid/gid numerically with container, When i executed the command
error:
images dockerfile:
docker-compose:
host bash
container bash
container /etc/passwd
Can someone help me out ?