[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 15/20] qemu-pr-helper: Daemonize before dropping priv
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 15/20] qemu-pr-helper: Daemonize before dropping privileges |
Date: |
Fri, 6 Apr 2018 19:11:16 +0200 |
From: Michal Privoznik <address@hidden>
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: Michal Privoznik <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
scsi/qemu-pr-helper.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
index 21e1b8e..eeff80a 100644
--- a/scsi/qemu-pr-helper.c
+++ b/scsi/qemu-pr-helper.c
@@ -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);
--
1.8.3.1
- [Qemu-devel] [PULL 02/20] target/i386: Fix andn instruction, (continued)
- [Qemu-devel] [PULL 02/20] target/i386: Fix andn instruction, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 06/20] i386/hyperv: add hv-frequencies cpu property, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 07/20] i386/hyperv: error out if features requested but unsupported, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 08/20] configure: Add missing configure options to help text, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 09/20] scsi-disk: Don't enlarge min_io_size to max_io_size, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 11/20] hw/scsi: support SCSI-2 passthrough without PI, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 12/20] hw/dma/i82374: Avoid double creation of the 82374 controller, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 10/20] scsi-disk: allow customizing the SCSI version, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 13/20] kvmclock: fix clock_is_reliable on migration from QEMU < 2.9, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 14/20] virtio-serial: fix heapover-flow, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 15/20] qemu-pr-helper: Daemonize before dropping privileges,
Paolo Bonzini <=
- [Qemu-devel] [PULL 16/20] qemu-pr-helper: Write pidfile more often, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 17/20] device-crash-test: Remove fixed isa-fdc entry, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 18/20] dump: Fix build with newer gcc, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 20/20] Add missing bit for SSE instr in VEX decoding, Paolo Bonzini, 2018/04/06
- [Qemu-devel] [PULL 19/20] maint: Add .mailmap entries for patches claiming list authorship, Paolo Bonzini, 2018/04/06
- Re: [Qemu-devel] [PULL 00/20] Miscellaneous patches for QEMU 2.12-rc, Peter Maydell, 2018/04/09