Unlink socket before use (agent).

pull/2/head
Christopher Wellons 2017-03-08 11:34:10 -05:00
parent ff6ac9c7ca
commit 6e8453894b
1 changed files with 5 additions and 0 deletions

View File

@ -165,6 +165,11 @@ agent_run(const u8 *key, const u8 *iv)
close(1);
umask(~(S_IRUSR | S_IWUSR));
if (unlink(addr.sun_path))
if (errno != ENOENT)
fatal("failed to remove existing socket -- %s", strerror(errno));
if (bind(pfd.fd, (struct sockaddr *)&addr, sizeof(addr))) {
if (errno != EADDRINUSE)
warning("could not bind agent socket %s -- %s",