2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-01 14:55:18 +00:00

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>
This commit is contained in:
Andy Zhou
2015-10-09 19:07:40 -07:00
parent 6069edb0ea
commit 3de44dd188
3 changed files with 28 additions and 2 deletions

View File

@@ -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);