diff options
author | Kenny Levinsen <kl@kl.wtf> | 2022-02-26 19:05:49 +0100 |
---|---|---|
committer | Kenny Levinsen <kl@kl.wtf> | 2022-02-26 19:17:26 +0100 |
commit | 9bbdf0f0b8d383edd1d621507c04db0a5382a5af (patch) | |
tree | 319802f0b4a9bc6a406b9e04ed6954a7eef5dcc0 /seatd-launch | |
parent | 3eb0db57bb1c23b5157279223f248d58d9662aae (diff) | |
download | seatd-9bbdf0f0b8d383edd1d621507c04db0a5382a5af.tar.xz |
seatd: Command-line argument for loglevel
SEATD_LOGLEVEL was used to set the loglevel despite already having
getopt in place. Remove the environment variable and make a command-line
argument for it instead.
Diffstat (limited to 'seatd-launch')
-rw-r--r-- | seatd-launch/seatd-launch.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/seatd-launch/seatd-launch.c b/seatd-launch/seatd-launch.c index d03a50f..f8ab8d4 100644 --- a/seatd-launch/seatd-launch.c +++ b/seatd-launch/seatd-launch.c @@ -13,13 +13,19 @@ int main(int argc, char *argv[]) { const char *usage = "Usage: seatd-launch [options] [--] command\n" "\n" - " -h Show this help message\n" - " -v Show the version number\n" + " -l <loglevel> Log-level to pass to seatd\n" + " -h Show this help message\n" + " -v Show the version number\n" "\n"; int c; - while ((c = getopt(argc, argv, "vh")) != -1) { + char loglevel[16] = "info"; + while ((c = getopt(argc, argv, "vhl:")) != -1) { switch (c) { + case 'l': + strncpy(loglevel, optarg, sizeof loglevel); + loglevel[sizeof loglevel - 1] = '\0'; + break; case 'v': printf("seatd-launch version %s\n", SEATD_VERSION); return 0; @@ -60,15 +66,8 @@ int main(int argc, char *argv[]) { char pipebuf[16] = {0}; snprintf(pipebuf, sizeof pipebuf, "%d", readiness_pipe[1]); - char *env[2] = {NULL, NULL}; - char loglevelbuf[32] = {0}; - char *cur_loglevel = getenv("SEATD_LOGLEVEL"); - if (cur_loglevel != NULL) { - snprintf(loglevelbuf, sizeof loglevelbuf, "SEATD_LOGLEVEL=%s", cur_loglevel); - env[0] = loglevelbuf; - } - - char *command[] = {"seatd", "-n", pipebuf, "-s", sockpath, NULL}; + char *env[1] = {NULL}; + char *command[] = {"seatd", "-n", pipebuf, "-s", sockpath, "-l", loglevel, NULL}; execve(SEATD_INSTALLPATH, command, env); perror("Could not start seatd"); _exit(1); |