]> git.ipfire.org Git - telemetry.git/commitdiff
telemetryd: Add switch to run as a non-privileged user
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 24 Feb 2026 11:32:53 +0000 (11:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 24 Feb 2026 11:32:53 +0000 (11:32 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/main.c

index cdd3a83282f316a8f2ad4893650dcc00b8a14cce..16129e1edcb9abd80b68d31d627a15091cdf0d80 100644 (file)
@@ -36,17 +36,21 @@ static const char* doc = "The IPFire Telemetry Daemon";
 enum {
        OPT_DEBUG  = 1,
        OPT_SOURCE = 2,
+       OPT_USER   = 3,
 };
 
 static struct argp_option options[] = {
        { "debug", OPT_DEBUG, NULL, 0, "Run in debug mode", 0 },
        { "source", OPT_SOURCE, "SOURCE", 0, "Only enable this source (for testing)", 0 },
+       { "user",   OPT_USER,   "USER",   0, "Run as user", 0 },
        { NULL },
 };
 
 // Collect all sources that should be enabled
 static char** sources = NULL;
 
+static const char* user = "nobody";
+
 static error_t parse(int key, char* arg, struct argp_state* state) {
        td_ctx* ctx = state->input;
 
@@ -62,6 +66,10 @@ static error_t parse(int key, char* arg, struct argp_state* state) {
                case OPT_SOURCE:
                        return td_strings_append(&sources, arg);
 
+               case OPT_USER:
+                       user = arg;
+                       break;
+
                default:
                        return ARGP_ERR_UNKNOWN;
        }