[libvirt] [PATCH] daemon: Change CWD to / before daemonizing

We were doing so for child processes but not for libvirtd itself. --- daemon/libvirtd.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 791b3dc..58fc492 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -3158,6 +3158,13 @@ int main(int argc, char **argv) { if (godaemon) { char ebuf[1024]; + + if (chdir("/") < 0) { + VIR_ERROR(_("cannot change to root directory: %s"), + virStrerror(errno, ebuf, sizeof(ebuf))); + goto error; + } + if ((statuswrite = daemonForkIntoBackground()) < 0) { VIR_ERROR(_("Failed to fork as daemon: %s"), virStrerror(errno, ebuf, sizeof ebuf)); -- 1.7.3.3

On 12/13/2010 03:40 AM, Jiri Denemark wrote:
We were doing so for child processes but not for libvirtd itself. --- daemon/libvirtd.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 791b3dc..58fc492 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -3158,6 +3158,13 @@ int main(int argc, char **argv) {
if (godaemon) { char ebuf[1024]; + + if (chdir("/") < 0) { + VIR_ERROR(_("cannot change to root directory: %s"), + virStrerror(errno, ebuf, sizeof(ebuf))); + goto error; + } +
ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

We were doing so for child processes but not for libvirtd itself. --- daemon/libvirtd.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 791b3dc..58fc492 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -3158,6 +3158,13 @@ int main(int argc, char **argv) {
if (godaemon) { char ebuf[1024]; + + if (chdir("/") < 0) { + VIR_ERROR(_("cannot change to root directory: %s"), + virStrerror(errno, ebuf, sizeof(ebuf))); + goto error; + } +
ACK.
Thanks, pushed. Jirka
participants (2)
-
Eric Blake
-
Jiri Denemark