提交 8dc0bf26 编写于 作者: M Michal Privoznik 提交者: Paolo Bonzini

qemu-pr-helper: Daemonize before dropping privileges

After we've dropped privileges it might be not possible to write
pidfile. For instance, if this binary is run as root (because
user wants it to write pidfile to some privileged location)
writing pidfile fails because privileges are dropped before we
even get to that.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 9f91022f
......@@ -1081,13 +1081,6 @@ int main(int argc, char **argv)
accept_client,
NULL, NULL);
#ifdef CONFIG_LIBCAP
if (drop_privileges() < 0) {
error_report("Failed to drop privileges: %s", strerror(errno));
exit(EXIT_FAILURE);
}
#endif
if (daemonize) {
if (daemon(0, 0) < 0) {
error_report("Failed to daemonize: %s", strerror(errno));
......@@ -1096,6 +1089,13 @@ int main(int argc, char **argv)
write_pidfile();
}
#ifdef CONFIG_LIBCAP
if (drop_privileges() < 0) {
error_report("Failed to drop privileges: %s", strerror(errno));
exit(EXIT_FAILURE);
}
#endif
state = RUNNING;
do {
main_loop_wait(false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册