diff options
author | Andy Zhou <azhou@nicira.com> | 2015-10-09 19:07:40 -0700 |
---|---|---|
committer | Andy Zhou <azhou@nicira.com> | 2015-11-11 18:05:54 -0800 |
commit | 3de44dd188690763cfa8f08cf36c64ade0174501 (patch) | |
tree | 3cb1216bc9d5a7fe802f30cf132f8efb57c13179 /lib/daemon-unix.c | |
parent | 6069edb0ea9c861d32016473a86d330f5ce60123 (diff) | |
download | openvswitch-3de44dd188690763cfa8f08cf36c64ade0174501.tar.gz |
vlog: change log file owner when switching user
vlog log file can be created when parsing --log-file option, before
switching user, in case the --user option is also specified. While this
does not directly cause errors for the running daemons, it can
leave the log files on the disk as created under the "root" user.
This patch fix the log file ownership to the user specified with --user.
Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ansis Atteka <aatteka@nicira.com>
Diffstat (limited to 'lib/daemon-unix.c')
-rw-r--r-- | lib/daemon-unix.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/daemon-unix.c b/lib/daemon-unix.c index 012574555..e69517ab4 100644 --- a/lib/daemon-unix.c +++ b/lib/daemon-unix.c @@ -739,7 +739,7 @@ daemon_switch_group(gid_t real, gid_t effective, { if ((setresgid(real, effective, saved) == -1) || !gid_verify(real, effective, saved)) { - VLOG_FATAL("%s: fail to switch group to gid as %d, aborting", + VLOG_FATAL("%s: failed to switch group to gid as %d, aborting", pidfile, gid); } } @@ -847,6 +847,10 @@ daemon_become_new_user_linux(bool access_datapath OVS_UNUSED) static void daemon_become_new_user__(bool access_datapath) { + /* If vlog file has been created, change its owner to the non-root user + * as specifed by the --user option. */ + vlog_change_owner(uid, gid); + if (LINUX) { if (LIBCAPNG) { daemon_become_new_user_linux(access_datapath); |