summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2010-11-01 12:25:16 +0100
committerHans de Goede <hdegoede@redhat.com>2010-11-01 12:25:16 +0100
commitba324d0f1fdee3e5f24618b4d590011007d417a2 (patch)
treea46124f41138a22710a3a2a352f30c8fb0082f36
parentf05f0a5602cb386b905d3ffcddcb12bdf9a823e4 (diff)
vdagentd: unlink socket on exit rather then startup
This makes sure that the daemon cannot be started twice.
-rw-r--r--udscs.c8
-rw-r--r--vdagentd.c2
2 files changed, 2 insertions, 8 deletions
diff --git a/udscs.c b/udscs.c
index 6f93648..b6caa4c 100644
--- a/udscs.c
+++ b/udscs.c
@@ -108,14 +108,6 @@ struct udscs_server *udscs_create_server(const char *socketname,
return NULL;
}
- c = unlink(socketname);
- if (c != 0 && errno != ENOENT) {
- fprintf(server->errfile, "unlink %s: %s\n", socketname,
- strerror(errno));
- free(server);
- return NULL;
- }
-
address.sun_family = AF_UNIX;
snprintf(address.sun_path, sizeof(address.sun_path), "%s", socketname);
c = bind(server->fd, (struct sockaddr *)&address, sizeof(address));
diff --git a/vdagentd.c b/vdagentd.c
index b3c1ef3..47ec963 100644
--- a/vdagentd.c
+++ b/vdagentd.c
@@ -688,6 +688,8 @@ int main(int argc, char *argv[])
vdagent_virtio_port_destroy(&virtio_port);
console_kit_destroy(console_kit);
udscs_destroy_server(server);
+ if (unlink(VDAGENTD_SOCKET) != 0)
+ fprintf(logfile, "unlink %s: %s\n", VDAGENTD_SOCKET, strerror(errno));
fprintf(logfile, "vdagentd quiting, returning status %d\n", retval);
if (logfile != stderr)
fclose(logfile);