From patchwork Thu Oct 1 22:15:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayoub Zaki X-Patchwork-Id: 2314947 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20251104 header.b=R4IRnUY1; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13c; helo=mail-lf1-x13c.google.com; envelope-from=swupdate+bncbdbktzhrzujrbn6q7xkqmgqeqjkvi4q@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x13c.google.com (mail-lf1-x13c.google.com [IPv6:2a00:1450:4864:20::13c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hx1nW4GR8z1yFp for ; Fri, 02 Oct 2026 18:15:58 +1000 (AEST) Received: by mail-lf1-x13c.google.com with SMTP id 2adb3069b0e04-5baf6f208f6sf818566e87.3 for ; Fri, 02 Oct 2026 01:15:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1790928954; cv=pass; d=google.com; s=arc-20260327; b=LjzfNJiapLLi/twQD+WebESLrh32oJpwgp2gzswtceWqyrAz5yQo1v/JKdwiYxiYeF F+tbGzdgCsbuU1K1WQmN5pKqzjU3FTgeaEFFJcvWx7+LyP7kW5dfadl7NNteqzrlDuOx B1yck3po9a3UijtYwRIGU0UlYM9/vQcgX5ArHorg2Bj4xCloRscyjmyilvSmw73Ysf+c ue29thC43xl9lKqqnFEQqJedD32gfqo8y3N4xN5GmOPrYRpvB4jFou7C0F/nuMkDxegx aRFUIteUpuX9b65kGTPr/BBqvqrNEvgzNtam4+tC++fLFxZqMSeqkScGm8F8x6aHFGME PVNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=OcuEhoS/bCShYPT1GWnKw28iyn3CKMAYpssrerI47po=; fh=QNdZWf8yhdyw2XtYQaRXdh/1j1iXvsPV2yRDkYuWSS4=; b=XoVMd40RivMXdiCYlhxK8nCMXnA227/XM6OtEIEh8fVayh+j0SfpsZwvypP2RHyNhk qAzrvY8nqIH0XUQLfkJ4/WuXm6rw/dJaHQdPWQO2uSOO4jgXc7fhH+bg97jvC3OcgHkb kVLl50Yfk9UgXaCzMVLQ9/mGVQdoUW9yolCDnY+rfDlVF5wR7cwHJhqKm+HPWrL5mCb/ Tcm2Rl3xRIqlgjvT8GmFNNgTPl/YIKaDEEppTKzVIDqZit5GGDa/M5adHVN2tOJSoaTb x/BSYJWLyoF09MQNy3EUPHKC7mNENks3nAhgifi2F/NiCfir76nYGVbWlHTVCn7IrLsI 6YAQ==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@embetrix.com header.s=rsa1 header.b=NpT1HGgb; dkim=neutral (no key) header.i=@embetrix.com header.s=ed1 header.b=DADbSYEq; spf=none (google.com: ayoub.zaki@embetrix.com does not designate permitted sender hosts) smtp.mailfrom=ayoub.zaki@embetrix.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20251104; t=1790928954; x=1791533754; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:content-type :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OcuEhoS/bCShYPT1GWnKw28iyn3CKMAYpssrerI47po=; b=R4IRnUY1X5nqEBVgjeTP3UNwyB7AyZLhzpgA6trg/2VDPyL3w6Sn/H5ge6Ep3QXI2t sh3lb1lSQk/hhDIOwW33bCs19vmODZjs6gSfDPNM6OG3dHSwDDExAQpGuQ/i47YfRYt1 yQpE7DpVlgY4bWhoroR5wAisQeyXJ6JqvixucfMq2nVSD2zjO9tD0pX2bB1pdej8odjR tGnzmzO2Y0v309WTZsPotZWrtdT7Oz0xNmmgwfNkvWL8BRK3Dlu3mVv6v+1XJ1ZXKg6a lZsNpwJoKmNJKcqvsEO3rjdjpVx6RGAwq5qQ1eUmVose4t5retiKLGha/Ftfo9EmnE8H tXtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790928954; x=1791533754; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :content-type:x-original-authentication-results:x-original-sender :mime-version:message-id:date:subject:cc:to:from:x-beenthere :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to:content-type; bh=OcuEhoS/bCShYPT1GWnKw28iyn3CKMAYpssrerI47po=; b=T/48p8dhlPKql/TjEU80MHJrGYlC3d2e3t+/su8LCy4WpT/ApHGn2GL1DjsWSYWSYI reABgIz1oLCJfzW7YsojgMQ/VNZZcCIQg6uI/9546wVMyspGx+3X3NSVDvZukjiatA/j cZoNSvQbXtYc3TbaaQ/smXNlFgWZzQCwXJsLWYzMguDPrCTIUECrDrju1FhLUB0kpOP0 ivmeDGntpe2fNEqGOa46f/tw71sJr4CkexLdXFIlrWJ5TQrmYqVYvdnoIsqAhwXDvo7Y z5oBWCMb6ZwmYa+ztXTVp8RI0jRNQbIoZigPhQ7U+JL+BMPKw1qexpWPcCP6ZAFMCkTe lWEQ== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AKwUvBwVsmV4Letm3wzi3dFngY7Rou9oeXS3OvJIdocANk5udPRC6zjys8YNRvQTiyoXEN+E1tqVZ3BvPA==@patchwork.ozlabs.org X-Gm-Message-State: AFq9FYLs2VG2oZPUfV+rDxZqJwbfaVU8FPiCa+z9UsFos7tAy6my4MUW jkthRDbLYo3W6eqfwdnAzPWchhITsSfXpEqFMRzTBoRXS6AvXrfym1TU X-Received: by 2002:a05:6512:688d:10b0:5b8:f97f:7a22 with SMTP id 2adb3069b0e04-5bb9bc52cdamr505770e87.54.1790928954494; Fri, 02 Oct 2026 01:15:54 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com; h="ATskLdebInT0EtZFnpASXwiel9ph6scW/anXwdhPzJ+EgsqIkQ==" Received: by 2002:ac2:5293:0:b0:5b8:9ee1:5275 with SMTP id 2adb3069b0e04-5bba4a8d36als92971e87.0.-pod-prod-04-eu; Fri, 02 Oct 2026 01:15:50 -0700 (PDT) X-Received: by 2002:ac2:4301:0:b0:5b8:eb98:9bf8 with SMTP id 2adb3069b0e04-5bb9bc56d69mr492433e87.56.1790928949534; Fri, 02 Oct 2026 01:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1790928949; cv=none; d=google.com; s=arc-20260327; b=fTaYNWYiYl0GPQSjZ4oOqvDkjNkxWZnp4WtkllWJBZrNAtjdaL/r0J24WCXxDtRyD4 5OTdFuWnLmf0YIN/fcl0djkMunlaPtAhhVorNoLHkre/elCYME4Uw3BiM92RkWpbEE3U itUuaRoCs8rk5sizTB2gUO/BCKgF7QoGcvkJnXMYuvFzE0uH24855G06W1p8KN60GCc5 w3AISRJcAa9pqE5xgE5BO1I+3sRnfIqtX1+O8Yr9Pn4weE6p6fVN0k2Lo0w4vBSSw9FB gIiVwrnsRbguKcdGj3g/XTZpSR0eYs/GepcM7Fb39mDtvRgqnOlM4CH0tCneDxcJDdOB uhGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature:dkim-signature; bh=Pi/D+ObKWPUYVvHmawIhkFz4BQ4rVEnx3WTG7hQVC4I=; fh=+OJORHqdqTgck03oywGhM24wqLll/i7F/sjzFdEpJxw=; b=CvuE97qT89VvMyb63JJpUnE9mgOi+LPebYqSgsDNIhUhk3Z+jWubi5xxwKZF2l0OIZ 1XvjDYMos0Ms9m06AA6dbaE1tDckgYvsdt0A1zKrIdiaFXSv0MJP9R2LBDrubx4wW6NH J9ZVZ37OLu94HZy802ITwXEYqEYzAGjTknuhjAXWAJ/ltezORGdoYwyMRZGLKAmurpU9 0eDc5U2XuX3TMsBH7rGYUEIpObZ0lbhuXVPDW52ADjNB84PKAXPvSv56/Crstl2EezVY X8hRZ3L1vaatZ86gGWAjAQth4q1I2odsWvVWWsijCi3jNYnckHb5Mla1R6s4OwXPQC2M YNbQ==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@embetrix.com header.s=rsa1 header.b=NpT1HGgb; dkim=neutral (no key) header.i=@embetrix.com header.s=ed1 header.b=DADbSYEq; spf=none (google.com: ayoub.zaki@embetrix.com does not designate permitted sender hosts) smtp.mailfrom=ayoub.zaki@embetrix.com Received: from mailrelay-egress18.pub.mailoutpod2-cph3.one.com (mailrelay-egress18.pub.mailoutpod2-cph3.one.com. [2a02:2350:5:505::1]) by gmr-mx.google.com with ESMTPS id 2adb3069b0e04-5bb7c75c84esi25173e87.3.2026.10.02.01.15.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Oct 2026 01:15:49 -0700 (PDT) Received-SPF: none (google.com: ayoub.zaki@embetrix.com does not designate permitted sender hosts) client-ip=2a02:2350:5:505::1; X-HalOne-ID: 789e8820-be39-11f1-a399-4fe78d1e3c23 Received: from xps-13.fritz.box (dynamic-2a02-3102-8c10-1ae0-312a-4a20-0ea5-fb71.310.pool.telefonica.de [2a02:3102:8c10:1ae0:312a:4a20:ea5:fb71]) by mailrelay2.pub.mailoutpod2-cph3.one.com (Halon) with ESMTPSA id 789e8820-be39-11f1-a399-4fe78d1e3c23; Fri, 02 Oct 2026 08:15:47 +0000 (UTC) From: Ayoub Zaki To: swupdate@googlegroups.com Cc: Ayoub Zaki Subject: [swupdate] [PATCH v2] Add optional SELinux contexts for built-in subprocesses Date: Fri, 2 Oct 2026 10:15:45 +0200 Message-ID: <20261002081545.62356-1-ayoub.zaki@embetrix.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Original-Sender: ayoub.zaki@embetrix.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@embetrix.com header.s=rsa1 header.b=NpT1HGgb; dkim=neutral (no key) header.i=@embetrix.com header.s=ed1 header.b=DADbSYEq; spf=none (google.com: ayoub.zaki@embetrix.com does not designate permitted sender hosts) smtp.mailfrom=ayoub.zaki@embetrix.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Add CONFIG_SELINUX and selinux-context settings for Suricatta, the web server and downloaders. Startup will fail if a context cannot be set. Signed-off-by: Ayoub Zaki --- Kconfig | 17 +++++++++++++ Makefile.deps | 8 +++++++ Makefile.flags | 4 ++++ core/pctl.c | 37 ++++++++++++++++++++++++++--- core/swupdate.c | 20 ++++++++++++---- corelib/swupdate_settings.c | 26 ++++++++++++++++++++ doc/source/swupdate.rst | 26 ++++++++++++++++++++ examples/configuration/swupdate.cfg | 21 +++++++++++----- include/pctl.h | 1 + include/swupdate_settings.h | 2 ++ 10 files changed, 149 insertions(+), 13 deletions(-) diff --git a/Kconfig b/Kconfig index 615a622a..c6c0b3cc 100644 --- a/Kconfig +++ b/Kconfig @@ -97,6 +97,10 @@ config HAVE_LIBSYSTEMD bool option env="HAVE_LIBSYSTEMD" +config HAVE_LIBSELINUX + bool + option env="HAVE_LIBSELINUX" + config HAVE_LIBCRYPTO bool option env="HAVE_LIBCRYPTO" @@ -161,6 +165,19 @@ config SYSTEMD comment "systemd support needs libsystemd" depends on !HAVE_LIBSYSTEMD && HAVE_LINUX +config SELINUX + bool "enable SELinux subprocess contexts" + depends on HAVE_LINUX && HAVE_LIBSELINUX + default n + help + Allow Suricatta, web-server and downloaders to use + contexts specified by selinux-context in their configuration + sections. + Requires libselinux and a policy permitting the transitions. + +comment "SELinux support needs libselinux" + depends on !HAVE_LIBSELINUX && HAVE_LINUX + config DEFAULT_CONFIG_FILE string "File with default settings" default "/etc/swupdate.cfg" diff --git a/Makefile.deps b/Makefile.deps index 35f1bd6b..794e8eed 100644 --- a/Makefile.deps +++ b/Makefile.deps @@ -90,6 +90,14 @@ export HAVE_LIBSYSTEMD = n endif endif +ifeq ($(HAVE_LIBSELINUX),) +ifeq ($(HAVE_LINUX),y) +export HAVE_LIBSELINUX = y +else +export HAVE_LIBSELINUX = n +endif +endif + ifeq ($(HAVE_LIBCRYPTO),) export HAVE_LIBCRYPTO = y endif diff --git a/Makefile.flags b/Makefile.flags index 435bf3c8..7fb243f2 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -151,6 +151,10 @@ endif # libconfig is always compiled LDLIBS += config +ifeq ($(CONFIG_SELINUX),y) +LDLIBS += selinux +endif + # libarchive ifeq ($(CONFIG_ARCHIVE),y) LDLIBS += archive diff --git a/core/pctl.c b/core/pctl.c index 0e0edc28..9591b333 100644 --- a/core/pctl.c +++ b/core/pctl.c @@ -26,6 +26,10 @@ #include #include +#ifdef CONFIG_SELINUX +#include +#endif + #ifndef WAIT_ANY #define WAIT_ANY (-1) #endif @@ -125,6 +129,7 @@ void wait_threads_ready(void) */ static int spawn_process(struct swupdate_task *task, uid_t run_as_userid, gid_t run_as_groupid, + const char *selinux_context, const char *cfgname, int ac, char **av, swupdate_process start, @@ -177,6 +182,27 @@ static int spawn_process(struct swupdate_task *task, } } + /* Apply the requested SELinux context before starting the child process */ + if (selinux_context && selinux_context[0]) { +#ifdef CONFIG_SELINUX + if (is_selinux_enabled() <= 0) { + WARN("Ignoring SELinux context for %s: SELinux is not enabled", + task->name); + } else if (security_check_context(selinux_context) < 0) { + ERROR("Cannot validate SELinux context %s for %s: %s", + selinux_context, task->name, strerror(errno)); + return -1; + } else if (setcon(selinux_context) < 0) { + ERROR("Cannot set SELinux context %s for %s: %s", + selinux_context, task->name, strerror(errno)); + return -1; + } +#else + WARN("Ignoring SELinux context for %s: without SELinux support", + task->name); +#endif + } + /* Save new pid */ pid = getpid(); @@ -209,6 +235,7 @@ static int spawn_process(struct swupdate_task *task, static void start_swupdate_subprocess(sourcetype type, const char *name, uid_t run_as_userid, gid_t run_as_groupid, + const char *selinux_context, const char* cfgfile, int argc, char **argv, swupdate_process start, @@ -216,7 +243,8 @@ static void start_swupdate_subprocess(sourcetype type, const char *name, { procs[nprocs].name = name; procs[nprocs].type = type; - if (spawn_process(&procs[nprocs], run_as_userid, run_as_groupid, cfgfile, argc, argv, start, cmdline) < 0) { + if (spawn_process(&procs[nprocs], run_as_userid, run_as_groupid, + selinux_context, cfgfile, argc, argv, start, cmdline) < 0) { ERROR("Spawning %s failed, exiting process...", name); exit(1); } @@ -232,17 +260,20 @@ void start_subprocess_from_file(sourcetype type, const char *name, int argc, char **argv, const char *cmdline) { - start_swupdate_subprocess(type, name, run_as_userid, run_as_groupid, cfgfile, argc, argv, NULL, cmdline); + start_swupdate_subprocess(type, name, run_as_userid, run_as_groupid, + NULL, cfgfile, argc, argv, NULL, cmdline); } void start_subprocess(sourcetype type, const char *name, uid_t run_as_userid, gid_t run_as_groupid, + const char *selinux_context, const char *cfgfile, int argc, char **argv, swupdate_process start) { - start_swupdate_subprocess(type, name, run_as_userid, run_as_groupid, cfgfile, argc, argv, start, NULL); + start_swupdate_subprocess(type, name, run_as_userid, run_as_groupid, + selinux_context, cfgfile, argc, argv, start, NULL); } /* diff --git a/core/swupdate.c b/core/swupdate.c index 8e287e4d..9779d3e8 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -1146,8 +1146,11 @@ int main(int argc, char **argv) if (opt_w) { uid_t uid; gid_t gid; + const char *context; + if (read_settings_selinux_context(&handle, "webserver", &context)) + exit(EXIT_FAILURE); read_settings_user_id(&handle, "webserver", &uid, &gid); - start_subprocess(SOURCE_WEBSERVER, "webserver", uid, gid, + start_subprocess(SOURCE_WEBSERVER, "webserver", uid, gid, context, cfgfname, ac, av, start_webserver); freeargs(av); @@ -1158,8 +1161,11 @@ int main(int argc, char **argv) if (opt_u) { uid_t uid; gid_t gid; + const char *context; + if (read_settings_selinux_context(&handle, "suricatta", &context)) + exit(EXIT_FAILURE); read_settings_user_id(&handle, "suricatta", &uid, &gid); - start_subprocess(SOURCE_SURICATTA, "suricatta", uid, gid, + start_subprocess(SOURCE_SURICATTA, "suricatta", uid, gid, context, cfgfname, argcount, argvalues, start_suricatta); @@ -1171,8 +1177,11 @@ int main(int argc, char **argv) if (opt_d) { uid_t uid; gid_t gid; + const char *context; + if (read_settings_selinux_context(&handle, "download", &context)) + exit(EXIT_FAILURE); read_settings_user_id(&handle, "download", &uid, &gid); - start_subprocess(SOURCE_DOWNLOADER, "download", uid, gid, + start_subprocess(SOURCE_DOWNLOADER, "download", uid, gid, context, cfgfname, dwlac, dwlav, start_download_server); freeargs(dwlav); @@ -1182,8 +1191,11 @@ int main(int argc, char **argv) { uid_t uid; gid_t gid; + const char *context; + if (read_settings_selinux_context(&handle, "download", &context)) + exit(EXIT_FAILURE); read_settings_user_id(&handle, "download", &uid, &gid); - start_subprocess(SOURCE_CHUNKS_DOWNLOADER, "chunks_downloader", uid, gid, + start_subprocess(SOURCE_CHUNKS_DOWNLOADER, "chunks_downloader", uid, gid, context, cfgfname, 0, NULL, start_delta_downloader); } diff --git a/corelib/swupdate_settings.c b/corelib/swupdate_settings.c index 229fac9d..b9f7f3aa 100644 --- a/corelib/swupdate_settings.c +++ b/corelib/swupdate_settings.c @@ -147,6 +147,32 @@ int read_settings_user_id(swupdate_cfg_handle *handle, const char *module, uid_t } +int read_settings_selinux_context(swupdate_cfg_handle *handle, const char *module, + const char **context) +{ + config_setting_t *elem, *setting; + + *context = NULL; + elem = find_settings_node(&handle->cfg, module); + if (!elem) + return 0; + + setting = config_setting_get_member(elem, "selinux-context"); + if (!setting) + return 0; + + if (config_setting_type(setting) != CONFIG_TYPE_STRING) { + ERROR("%s.selinux-context must be a string", module); + return -EINVAL; + } + + *context = config_setting_get_string(setting); + if (!(*context)[0]) + *context = NULL; + + return 0; +} + /* * Callback to be used to put a section of configuration * into a dictionary diff --git a/doc/source/swupdate.rst b/doc/source/swupdate.rst index 216535d9..e92120a6 100644 --- a/doc/source/swupdate.rst +++ b/doc/source/swupdate.rst @@ -236,6 +236,32 @@ To configure the options: make menuconfig +SELinux subprocess contexts +--------------------------- + +Enable ``CONFIG_SELINUX`` (requires ``libselinux``) and set contexts +in ``swupdate.cfg`` for Suricatta, the web server and downloaders:: + + suricatta : { + selinux-context = "system_u:system_r:swupdate_suricatta_t:s0"; + }; + + webserver : { + selinux-context = "system_u:system_r:swupdate_webserver_t:s0"; + }; + + download : { + selinux-context = "system_u:system_r:swupdate_download_t:s0"; + }; + +Both the downloader and the delta chunks downloader use ``download``. +Omitted or empty settings preserve the inherited context. +If built without SELinux support or SELinux is not enabled at runtime, a +requested context is ignored with a warning. Otherwise, a context that cannot +be validated or applied prevents the child from starting. + +Replace these example contexts with ones defined by your SELinux policy. + Building -------- diff --git a/examples/configuration/swupdate.cfg b/examples/configuration/swupdate.cfg index 121e86da..f7515252 100644 --- a/examples/configuration/swupdate.cfg +++ b/examples/configuration/swupdate.cfg @@ -155,13 +155,15 @@ logcolors : { # retries : integer # Number of retries (0=forever) # userid : integer -# userID for Webserver process +# userID for downloader process # groupid : integer -# groupId for Webserver process +# groupId for downloader process +# selinux-context : string +# SELinux context for both regular and delta chunks downloaders # user : string -# user name for Webserver process, only if userid is 0 or unset +# user name for downloader process, only if userid is 0 or unset # group : string -# group name for Webserver process, only if groupid is 0 or unset +# group name for downloader process, only if groupid is 0 or unset # timeout : integer # it is the number of seconds that can be accepted without # receiving any packets. If it elapses, the connection is @@ -184,6 +186,7 @@ download : url = "http://example.com/software.swu"; userid = 1000; groupid = 1000; + # selinux-context = "system_u:system_r:swupdate_download_t:s0"; }; # @@ -229,9 +232,11 @@ identify : ( # number of retries to connect to server # retrywait : integer # userid : integer -# userID for Webserver process +# userID for Suricatta process # groupid : integer -# groupId for Webserver process +# groupId for Suricatta process +# selinux-context : string +# SELinux context for Suricatta process # user : string # user name for Webserver process, only if userid is 0 or unset # group : string @@ -287,6 +292,7 @@ suricatta : loglevel = 10; userid = 1000; groupid = 1000; + # selinux-context = "system_u:system_r:swupdate_suricatta_t:s0"; enable = true; initial-report-resend-period = 30; connection-timeout = 10; @@ -373,6 +379,8 @@ gservice : # userID for Webserver process # groupid : integer # groupId for Webserver process +# selinux-context : string +# SELinux context for Webserver process # listening_ports : integer # Webserver listening port # ssl_certificate : string @@ -405,6 +413,7 @@ webserver : document_root = "./www"; userid = 1000; groupid = 1000; + # selinux-context = "system_u:system_r:swupdate_webserver_t:s0"; timeout = 20; }; diff --git a/include/pctl.h b/include/pctl.h index 136c440e..83cf3b54 100644 --- a/include/pctl.h +++ b/include/pctl.h @@ -35,6 +35,7 @@ typedef server_op_res_t(*server_ipc_fn)(int fd); void start_subprocess(sourcetype type, const char *name, uid_t run_as_userid, gid_t run_as_groupid, + const char *selinux_context, const char *cfgfile, int argc, char **argv, swupdate_process start); diff --git a/include/swupdate_settings.h b/include/swupdate_settings.h index e8327fd2..5c9c8662 100644 --- a/include/swupdate_settings.h +++ b/include/swupdate_settings.h @@ -23,4 +23,6 @@ int swupdate_cfg_read_file(swupdate_cfg_handle *handle, const char *filename); void swupdate_cfg_destroy(swupdate_cfg_handle *handle); int read_module_settings(swupdate_cfg_handle *handle, const char *module, settings_callback fcn, void *data); int read_settings_user_id(swupdate_cfg_handle *handle, const char *module, uid_t *userid, gid_t *groupid); +int read_settings_selinux_context(swupdate_cfg_handle *handle, const char *module, + const char **context); int settings_into_dict(void *settings, void *data);