All of lore.kernel.org
 help / color / mirror / Atom feed
From: eahariha@linux.microsoft.com
To: openembedded-devel@lists.openembedded.org
Subject: [PATCH] chrony: Fix privdrop packageconfig
Date: Wed, 25 Aug 2021 15:43:41 -0700	[thread overview]
Message-ID: <1629931421-18317-1-git-send-email-eahariha@linux.microsoft.com> (raw)

From: Easwar Hariharan <easwar.hariharan@microsoft.com>

To drop root privileges on Linux-based systems, chrony requires a
standard user to switch to and the use of capabilities. Fix up the
privdrop packageconfig to account for this.

Signed-off-by: Easwar Hariharan <easwar.hariharan@microsoft.com>
---
 meta-networking/recipes-support/chrony/chrony_4.1.bb | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/meta-networking/recipes-support/chrony/chrony_4.1.bb b/meta-networking/recipes-support/chrony/chrony_4.1.bb
index 6a450c3..f009bae 100644
--- a/meta-networking/recipes-support/chrony/chrony_4.1.bb
+++ b/meta-networking/recipes-support/chrony/chrony_4.1.bb
@@ -47,6 +47,11 @@ DEPENDS = "pps-tools"
 #       chrony does not use GNU Autotools.
 inherit update-rc.d systemd
 
+# Add chronyd user if privdrop packageconfig is selected
+inherit ${@bb.utils.contains('PACKAGECONFIG', 'privdrop', 'useradd', '', d)}
+USERADD_PACKAGES = "${@bb.utils.contains('PACKAGECONFIG', 'privdrop', '${PN}', '', d)}"
+USERADD_PARAM_${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'privdrop', '--system -d / -M --shell /bin/nologin chronyd;', '', d)}"
+
 # Configuration options:
 # - For command line editing support in chronyc, you may specify either
 #   'editline' or 'readline' but not both.  editline is smaller, but
@@ -68,7 +73,7 @@ PACKAGECONFIG ??= "editline \
 PACKAGECONFIG[readline] = "--without-editline,--without-readline,readline"
 PACKAGECONFIG[editline] = ",--without-editline,libedit"
 PACKAGECONFIG[sechash] = "--without-tomcrypt,--disable-sechash,nss"
-PACKAGECONFIG[privdrop] = ",--disable-privdrop,libcap"
+PACKAGECONFIG[privdrop] = "--with-libcap,--disable-privdrop --without-libcap,libcap"
 PACKAGECONFIG[scfilter] = "--enable-scfilter,--without-seccomp,libseccomp"
 PACKAGECONFIG[ipv6] = ",--disable-ipv6,"
 PACKAGECONFIG[nss] = "--with-nss,--without-nss,nss"
@@ -97,6 +102,10 @@ do_install() {
     # Config file
     install -d ${D}${sysconfdir}
     install -m 644 ${WORKDIR}/chrony.conf ${D}${sysconfdir}
+    if ${@bb.utils.contains('PACKAGECONFIG', 'privdrop', 'true', 'false', d)}; then
+        echo "# Define user to drop to after dropping root privileges" >> ${D}${sysconfdir}/chrony.conf
+        echo "user chronyd" >> ${D}${sysconfdir}/chrony.conf
+    fi
 
     # System V init script
     install -d ${D}${sysconfdir}/init.d
-- 
1.8.3.1


                 reply	other threads:[~2021-08-25 22:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1629931421-18317-1-git-send-email-eahariha@linux.microsoft.com \
    --to=eahariha@linux.microsoft.com \
    --cc=openembedded-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.