package/chrony: add default unprivileged user option
PATCH v2 1/1 package/chrony: add default unprivileged user option
Configurable option to define and enable by default an unprivileged user which the Chrony daemon will assume once initialised. The functionality requires libcap which is selected as necessary.
This option supports the good security practice of dropping elevated privileges for daemon runtime.
The package configuration layout has been updated to current working practice.
--- package/chrony/Config.in | 12 +++++++++++- package/chrony/chrony.mk | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
package/chrony/Config.in +11 -1
@@ -7,10 +7,20 @@ config BR2_PACKAGE_CHRONY http://chrony.tuxfamily.org/ +if BR2_PACKAGE_CHRONY + config BR2_PACKAGE_CHRONY_DEBUG_LOGGING bool "enable debug logging support" - depends on BR2_PACKAGE_CHRONY help Enable support for debug logging output from Chrony when enabled at runtime. If disabled, code for debug logging will not be compiled in. + +config BR2_PACKAGE_CHRONY_USER + bool "chrony default unprivileged user" + select BR2_PACKAGE_LIBCAP + help + Define and enable default unprivileged user for the Chrony + daemon to run as. + +endif
package/chrony/chrony.mk +8 -0
@@ -21,6 +21,14 @@ CHRONY_CONF_OPTS = \ ifeq ($(BR2_PACKAGE_LIBCAP),y) CHRONY_DEPENDENCIES += libcap + +ifeq ($(BR2_PACKAGE_CHRONY_USER),y) +CHRONY_CONF_OPTS += --with-user=chrony +define CHRONY_USERS + chrony -1 chrony -1 * /run/chrony - - Time daemon +endef +endif + else CHRONY_CONF_OPTS += --without-libcap endif
Signature · 6 lines
2.35.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi James,
Quoted 26 lines · James Kent
Configurable option to define and enable by default an unprivileged user which the Chrony daemon will assume once initialised. The functionality requires libcap which is selected as necessary.
This option supports the good security practice of dropping elevated privileges for daemon runtime.
The package configuration layout has been updated to current working practice.
Signed-off-by James Kent <[email protected]>--- package/chrony/Config.in | 12 +++++++++++- package/chrony/chrony.mk | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-)package/chrony/Config.in +2
-0@@ -7,10 +7,20 @@ config BR2_PACKAGE_CHRONY http://chrony.tuxfamily.org/ +if BR2_PACKAGE_CHRONY +
package/chrony/Config.in config BR2_PACKAGE_CHRONY · line 20
Quoted 10 lines
package/chrony/Config.in +3
-1config BR2_PACKAGE_CHRONY_DEBUG_LOGGING bool "enable debug logging support" - depends on BR2_PACKAGE_CHRONY help Enable support for debug logging output from Chrony when enabled at runtime. If disabled, code for debug logging will not be compiled in. + +config BR2_PACKAGE_CHRONY_USER + bool "chrony default unprivileged user"
Is there any reason to do this conditionally? For all other packages, we do it
unconditionally.
Regards,
Arnout
Quoted 15 lines
package/chrony/Config.in +6
-0+ select BR2_PACKAGE_LIBCAP + help + Define and enable default unprivileged user for the Chrony + daemon to run as. + +endifpackage/chrony/chrony.mk +1
-0@@ -21,6 +21,14 @@ CHRONY_CONF_OPTS = \ ifeq ($(BR2_PACKAGE_LIBCAP),y) CHRONY_DEPENDENCIES += libcap +
package/chrony/chrony.mk CHRONY_CONF_OPTS = \ · line 34
Quoted 10 lines
package/chrony/chrony.mk +7
-0+ifeq ($(BR2_PACKAGE_CHRONY_USER),y) +CHRONY_CONF_OPTS += --with-user=chrony +define CHRONY_USERS + chrony -1 chrony -1 * /run/chrony - - Time daemon +endef +endif + else CHRONY_CONF_OPTS += --without-libcap endif
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Yann E. MORIN
AppliedArnout, James, All,
On 2023-02-09 21:22 +0100, Arnout Vandecappelle spake thusly:
Quoted 5 lines · James Kent
Quoted 4 lines
Configurable option to define and enable by default an unprivileged user which the Chrony daemon will assume once initialised. The functionality requires libcap which is selected as necessary.
Quoted 8 lines
Quoted 8 lines
This option supports the good security practice of dropping elevated privileges for daemon runtime.
The package configuration layout has been updated to current working practice.
Signed-off-by James Kent <[email protected]>---
[--SNIP--]
Quoted 4 lines
package/chrony/Config.in config BR2_PACKAGE_CHRONY · line 20
Quoted 2 lines
package/chrony/Config.in +2
-0+config BR2_PACKAGE_CHRONY_USER + bool "chrony default unprivileged user"Is there any reason to do this conditionally? For all other packages, we do
it unconditionally.
From what I read, there are three situation to run chrony:
- start as root and stay running as root;
- start as root, setuid to a user either with a commandline option, or
a configuration directive;
- start as root, and setuid to a user defined at build-time (which can still be overriden on the commandline or a configuration directive).
What this patch does, is to allow for the third option.
As it was previously already possible to run as non-root, by just enabling libcap in Buildroot's config, and adding the user configuration directive in chrony's config file (or run it with -u), some people may already do that in their setups, and we do not want to break that. So those people do have eithe the config directive or the -u option, which both take precendence over the build-time configuration.
As for those that do run as root, switching to a non-root user should not have any impact in functionality.
So, we can safely unconditionally default to a compile-time non-root user. Except, a linux kernel may only have the root user, see CONFIG_MULTIUSER. But in that case we'd have tons of other packages that are gonna whine...
Applied to master without the condition, thanks.
Regards,
Yann E. MORIN.
Quoted 27 lines
Regards,
ArnoutQuoted 24 lines
package/chrony/Config.in +6
-0+ select BR2_PACKAGE_LIBCAP + help + Define and enable default unprivileged user for the Chrony + daemon to run as. + +endifpackage/chrony/chrony.mk +8
-0@@ -21,6 +21,14 @@ CHRONY_CONF_OPTS = \ ifeq ($(BR2_PACKAGE_LIBCAP),y) CHRONY_DEPENDENCIES += libcap + +ifeq ($(BR2_PACKAGE_CHRONY_USER),y) +CHRONY_CONF_OPTS += --with-user=chrony +define CHRONY_USERS + chrony -1 chrony -1 * /run/chrony - - Time daemon +endef +endif + else CHRONY_CONF_OPTS += --without-libcap endif
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot