diff options
-rw-r--r-- | libseat/backend/seatd.c | 4 | ||||
-rw-r--r-- | meson.build | 11 | ||||
-rw-r--r-- | meson_options.txt | 2 | ||||
-rw-r--r-- | seatd/seatd.c | 6 |
4 files changed, 17 insertions, 6 deletions
diff --git a/libseat/backend/seatd.c b/libseat/backend/seatd.c index b0e023f..1259308 100644 --- a/libseat/backend/seatd.c +++ b/libseat/backend/seatd.c @@ -67,9 +67,9 @@ static int seatd_connect(void) { close(fd); return -1; } - char *path = getenv("SEATD_SOCK"); + const char *path = getenv("SEATD_SOCK"); if (path == NULL) { - path = "/run/seatd.sock"; + path = SEATD_DEFAULTPATH; } addr.unix.sun_family = AF_UNIX; strncpy(addr.unix.sun_path, path, sizeof addr.unix.sun_path); diff --git a/meson.build b/meson.build index fa000c1..1ab3d87 100644 --- a/meson.build +++ b/meson.build @@ -14,6 +14,16 @@ project( # Bump whenever ABI-breaking changes occur. libseat_soversion = 1 +defaultpath = get_option('defaultpath') +if defaultpath == '' + system = target_machine.system() + if system == 'linux' + defaultpath = '/run/seatd.sock' + else + defaultpath = '/var/run/seatd.sock' + endif +endif + add_project_arguments( [ '-Wundef', @@ -32,6 +42,7 @@ add_project_arguments( '-D_XOPEN_SOURCE=700', '-D__BSD_VISIBLE', '-DSEATD_VERSION="@0@"'.format(meson.project_version()), + '-DSEATD_DEFAULTPATH="@0@"'.format(defaultpath) ], language: 'c', ) diff --git a/meson_options.txt b/meson_options.txt index 6e498c4..e32221a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -4,4 +4,4 @@ option('builtin', type: 'feature', value: 'disabled', description: 'builtin seat option('server', type: 'feature', value: 'enabled', description: 'seatd server') option('examples', type: 'feature', value: 'enabled', description: 'libseat example programs') option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages') - +option('defaultpath', type: 'string', value: '', description: 'Default location for seatd socket (empty for default)') diff --git a/seatd/seatd.c b/seatd/seatd.c index bcd73b2..b601bce 100644 --- a/seatd/seatd.c +++ b/seatd/seatd.c @@ -17,7 +17,7 @@ #define LISTEN_BACKLOG 16 -static int open_socket(char *path, int uid, int gid) { +static int open_socket(const char *path, int uid, int gid) { union { struct sockaddr_un unix; struct sockaddr generic; @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) { int c; int uid = 0, gid = 0; - char *socket_path = getenv("SEATD_SOCK"); + const char *socket_path = getenv("SEATD_SOCK"); while ((c = getopt(argc, argv, "vhs:g:u:")) != -1) { switch (c) { case 's': @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) { } if (socket_path == NULL) { - socket_path = "/run/seatd.sock"; + socket_path = SEATD_DEFAULTPATH; struct stat st; if (stat(socket_path, &st) == 0) { log_info("removing leftover seatd socket"); |