meson: Make default seatd socket path configurable
FreeBSD and Linux have different preferred socket locations. Expose an option to set the location, and implement simple auto-logic for linux/freebsd.
This commit is contained in:
parent
a763e16f26
commit
884c1416b3
4 changed files with 17 additions and 6 deletions
|
@ -67,9 +67,9 @@ static int seatd_connect(void) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
char *path = getenv("SEATD_SOCK");
|
const char *path = getenv("SEATD_SOCK");
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
path = "/run/seatd.sock";
|
path = SEATD_DEFAULTPATH;
|
||||||
}
|
}
|
||||||
addr.unix.sun_family = AF_UNIX;
|
addr.unix.sun_family = AF_UNIX;
|
||||||
strncpy(addr.unix.sun_path, path, sizeof addr.unix.sun_path);
|
strncpy(addr.unix.sun_path, path, sizeof addr.unix.sun_path);
|
||||||
|
|
11
meson.build
11
meson.build
|
@ -14,6 +14,16 @@ project(
|
||||||
# Bump whenever ABI-breaking changes occur.
|
# Bump whenever ABI-breaking changes occur.
|
||||||
libseat_soversion = 1
|
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(
|
add_project_arguments(
|
||||||
[
|
[
|
||||||
'-Wundef',
|
'-Wundef',
|
||||||
|
@ -32,6 +42,7 @@ add_project_arguments(
|
||||||
'-D_XOPEN_SOURCE=700',
|
'-D_XOPEN_SOURCE=700',
|
||||||
'-D__BSD_VISIBLE',
|
'-D__BSD_VISIBLE',
|
||||||
'-DSEATD_VERSION="@0@"'.format(meson.project_version()),
|
'-DSEATD_VERSION="@0@"'.format(meson.project_version()),
|
||||||
|
'-DSEATD_DEFAULTPATH="@0@"'.format(defaultpath)
|
||||||
],
|
],
|
||||||
language: 'c',
|
language: 'c',
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,4 +4,4 @@ option('builtin', type: 'feature', value: 'disabled', description: 'builtin seat
|
||||||
option('server', type: 'feature', value: 'enabled', description: 'seatd server')
|
option('server', type: 'feature', value: 'enabled', description: 'seatd server')
|
||||||
option('examples', type: 'feature', value: 'enabled', description: 'libseat example programs')
|
option('examples', type: 'feature', value: 'enabled', description: 'libseat example programs')
|
||||||
option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
|
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)')
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#define LISTEN_BACKLOG 16
|
#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 {
|
union {
|
||||||
struct sockaddr_un unix;
|
struct sockaddr_un unix;
|
||||||
struct sockaddr generic;
|
struct sockaddr generic;
|
||||||
|
@ -78,7 +78,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
int uid = 0, gid = 0;
|
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) {
|
while ((c = getopt(argc, argv, "vhs:g:u:")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 's':
|
case 's':
|
||||||
|
@ -119,7 +119,7 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (socket_path == NULL) {
|
if (socket_path == NULL) {
|
||||||
socket_path = "/run/seatd.sock";
|
socket_path = SEATD_DEFAULTPATH;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(socket_path, &st) == 0) {
|
if (stat(socket_path, &st) == 0) {
|
||||||
log_info("removing leftover seatd socket");
|
log_info("removing leftover seatd socket");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue