[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] poked: change the default socket path
From: |
Mohammad-Reza Nabipoor |
Subject: |
[COMMITTED] poked: change the default socket path |
Date: |
Wed, 1 Feb 2023 01:24:46 +0100 |
This commit changes the default socket path from `/tmp/poked.ipc'
to `/tmp/poked-$UID.ipc'.
2023-02-01 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* poked/poked.c: Include `<unistd.h>' for `getuid'.
(poked_options): Remove const-qualifier from `socket_path'.
(poked_options_init): Change the default socket path to have
UID in the path.
---
ChangeLog | 8 ++++++++
poked/poked.c | 12 +++++++++---
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c16acc79..b8dddfed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-02-01 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
+
+ * poked/poked.c: Include `<unistd.h>' for `getuid'.
+ (poked_options): Remove const-qualifier from `socket_path'.
+ (poked_options_init): Change the default socket path to have
+ UID in the path.
+ (main): Adapt.
+
2023-01-31 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* poked/usock.c: Include `<sys/stat.h>' for `umask'.
diff --git a/poked/poked.c b/poked/poked.c
index 7f94aeaa..e739dc39 100644
--- a/poked/poked.c
+++ b/poked/poked.c
@@ -26,6 +26,7 @@
#include <err.h>
#include <getopt.h>
#include <pthread.h>
+#include <unistd.h>
#include "pk-utils.h"
#include "usock.h"
@@ -479,7 +480,7 @@ poked_version (void);
static struct poked_options
{
int debug_p;
- const char *socket_path;
+ char *socket_path;
} poked_options;
static void
@@ -523,7 +524,7 @@ poked_options_init (int argc, char *argv[])
break;
case OPT_SOCK_PATH:
case 'S':
- poked_options.socket_path = optarg;
+ poked_options.socket_path = strdup (optarg);
break;
default:
poked_help ();
@@ -531,7 +532,11 @@ poked_options_init (int argc, char *argv[])
}
}
if (poked_options.socket_path == NULL)
- poked_options.socket_path = "/tmp/poked.ipc";
+ {
+ if (asprintf (&poked_options.socket_path, "/tmp/poked-%ld.ipc",
+ (long)getuid ()) == -1)
+ err (1, "asprintf() failed for default socket path");
+ }
}
static void
@@ -658,6 +663,7 @@ poked_restart:
}
done:
+ free (poked_options.socket_path);
poked_free ();
usock_done (srv);
pthread_join (th, &ret);
--
2.39.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [COMMITTED] poked: change the default socket path,
Mohammad-Reza Nabipoor <=