mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
util: introduce reset_uid_gid() for resetting all uids and gids to 0
This commit is contained in:
parent
417a7fdc41
commit
b4da6d6bec
@ -4686,16 +4686,7 @@ int namespace_enter(int pidns_fd, int mntns_fd, int netns_fd, int root_fd) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
if (setresgid(0, 0, 0) < 0)
|
||||
return -errno;
|
||||
|
||||
if (setgroups(0, NULL) < 0)
|
||||
return -errno;
|
||||
|
||||
if (setresuid(0, 0, 0) < 0)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
return reset_uid_gid();
|
||||
}
|
||||
|
||||
int getpeercred(int fd, struct ucred *ucred) {
|
||||
@ -6247,3 +6238,17 @@ int mount_move_root(const char *path) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int reset_uid_gid(void) {
|
||||
|
||||
if (setgroups(0, NULL) < 0)
|
||||
return -errno;
|
||||
|
||||
if (setresgid(0, 0, 0) < 0)
|
||||
return -errno;
|
||||
|
||||
if (setresuid(0, 0, 0) < 0)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -908,3 +908,5 @@ char *shell_maybe_quote(const char *s);
|
||||
int parse_mode(const char *s, mode_t *ret);
|
||||
|
||||
int mount_move_root(const char *path);
|
||||
|
||||
int reset_uid_gid(void);
|
||||
|
Loading…
Reference in New Issue
Block a user