aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2022-02-21 11:27:56 +0100
committerKenny Levinsen <kl@kl.wtf>2022-02-21 12:02:31 +0100
commit157ce685658c19b51caa091601240940267c0940 (patch)
tree7e1e69b21412a3923206c3b32282c3e262e80c82
parentf128359332ac33d5ef0c2e91830059fb1c1ef923 (diff)
seatd: Remove SOCK_PATH and improve cleanup
SOCK_PATH is made redundant by the -s command-line argument added in a98e0c4ce90347d37370f2debcbed8ae9678a990. Support was originally left behind for short-term compatibility, but it should be fine to remove. Previous socket cleanup is changed to run unconditionally. The cleanup now fails if the existing file is not a socket.
-rw-r--r--seatd/seatd.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/seatd/seatd.c b/seatd/seatd.c
index 053d44b..8480350 100644
--- a/seatd/seatd.c
+++ b/seatd/seatd.c
@@ -84,7 +84,7 @@ int main(int argc, char *argv[]) {
int c;
int uid = -1, gid = -1;
int readiness = -1;
- const char *socket_path = getenv("SEATD_SOCK");
+ const char *socket_path = SEATD_DEFAULTPATH;
while ((c = getopt(argc, argv, "vhn:s:g:u:")) != -1) {
switch (c) {
case 'n':
@@ -131,11 +131,14 @@ int main(int argc, char *argv[]) {
}
}
- if (socket_path == NULL) {
- socket_path = SEATD_DEFAULTPATH;
- struct stat st;
- if (stat(socket_path, &st) == 0) {
- log_info("Removing leftover seatd socket");
+ struct stat st;
+ if (stat(socket_path, &st) == 0) {
+ if (!S_ISSOCK(st.st_mode)) {
+ log_errorf("Non-socket file found at socket path %s, refusing to start",
+ socket_path);
+ return 1;
+ } else {
+ log_infof("Removing leftover socket at %s", socket_path);
unlink(socket_path);
}
}