All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v3 0/4] Allow customization of system default PATH
@ 2018-12-20 17:55 Markus Mayer
  2018-12-20 17:58 ` [Buildroot] [PATCH v3 1/4] system cfg: introduce option BR2_SYSTEM_DEFAULT_PATH Markus Mayer
  2018-12-31 13:34 ` [Buildroot] [PATCH v3 0/4] Allow customization of system " Thomas Petazzoni
  0 siblings, 2 replies; 8+ messages in thread
From: Markus Mayer @ 2018-12-20 17:55 UTC (permalink / raw)
  To: buildroot

This series introduces a common way of configuring the system's default
PATH.

We introduce a Kconfig variable called BR2_SYSTEM_DEFAULT_PATH, which
is being used in /etc/profile of the default skeleton and for dropbear
and openssh sessions.

Changes since v2:
- Reformat the help section in system/Config.in to stay within the line
  length limit
- Swap SED and INSTALL commands in skeleton-init-common.mk
- Add Yann's Reviewed-by

Changes since v1:
- only use a single default (independent of BR2_ROOTFS_MERGED_USR)
- add a guard to system/system.mk checking the default path isn't empty
- replace PATH in etc/profile with place-holder @PATH@ and update regex
- use BR2_SYSTEM_DEFAULT_PATH unconditionally for dropbear
- update commit messages that BR2_SYSTEM_DEFAULT_PATH is a Kconfig variable
  and already quoted (which is what we need)

Markus Mayer (4):
  system cfg: introduce option BR2_SYSTEM_DEFAULT_PATH
  skeleton: use BR2_SYSTEM_DEFAULT_PATH as default PATH
  openssh: use BR2_SYSTEM_DEFAULT_PATH as default PATH
  dropbear: use BR2_SYSTEM_DEFAULT_PATH as default PATH

 package/dropbear/dropbear.mk                         |  6 ++++++
 package/openssh/openssh.mk                           |  1 +
 package/skeleton-init-common/skeleton-init-common.mk |  1 +
 system/Config.in                                     | 10 ++++++++++
 system/skeleton/etc/profile                          |  2 +-
 system/system.mk                                     |  4 ++++
 6 files changed, 23 insertions(+), 1 deletion(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH v3 1/4] system cfg: introduce option BR2_SYSTEM_DEFAULT_PATH
  2018-12-20 17:55 [Buildroot] [PATCH v3 0/4] Allow customization of system default PATH Markus Mayer
@ 2018-12-20 17:58 ` Markus Mayer
  2018-12-20 17:58   ` [Buildroot] [PATCH v3 2/4] skeleton: use BR2_SYSTEM_DEFAULT_PATH as default PATH Markus Mayer
                     ` (2 more replies)
  2018-12-31 13:34 ` [Buildroot] [PATCH v3 0/4] Allow customization of system " Thomas Petazzoni
  1 sibling, 3 replies; 8+ messages in thread
From: Markus Mayer @ 2018-12-20 17:58 UTC (permalink / raw)
  To: buildroot

The configuration option BR2_SYSTEM_DEFAULT_PATH allows the user to
override the default path, which can be used by /etc/profile and some
system daemons.

It defaults to the value previously hard-coded in /etc/profile. This
default should be suitable for most users.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 system/Config.in | 10 ++++++++++
 system/system.mk |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/system/Config.in b/system/Config.in
index 0f77b9b6721a..9941807e5d9b 100644
--- a/system/Config.in
+++ b/system/Config.in
@@ -386,6 +386,16 @@ comment "automatic network configuration via DHCP needs ifupdown or busybox or n
 
 endif # BR2_ROOTFS_SKELETON_DEFAULT
 
+config BR2_SYSTEM_DEFAULT_PATH
+	string "Set the system's default PATH"
+	default "/bin:/sbin:/usr/bin:/usr/sbin"
+	help
+	  Sets the system's default PATH. It is being used in
+	  /etc/profile in the skeleton-init-common package and by some
+	  daemons.
+
+	  The default should work in most cases.
+
 config BR2_ENABLE_LOCALE_PURGE
 	bool "Purge unwanted locales"
 	default y
diff --git a/system/system.mk b/system/system.mk
index ca6bf1388f39..8db87cb12930 100644
--- a/system/system.mk
+++ b/system/system.mk
@@ -86,3 +86,7 @@ define SYSTEM_REMOUNT_ROOT_INITTAB
 	$(SED) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR)/etc/inittab
 endef
 endif
+
+ifeq ($(BR_BUILDING)$(BR2_SYSTEM_DEFAULT_PATH),y"")
+$(error BR2_SYSTEM_DEFAULT_PATH can't be empty)
+endif
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH v3 2/4] skeleton: use BR2_SYSTEM_DEFAULT_PATH as default PATH
  2018-12-20 17:58 ` [Buildroot] [PATCH v3 1/4] system cfg: introduce option BR2_SYSTEM_DEFAULT_PATH Markus Mayer
@ 2018-12-20 17:58   ` Markus Mayer
  2018-12-30 21:52     ` Thomas Petazzoni
  2018-12-20 17:58   ` [Buildroot] [PATCH v3 3/4] openssh: " Markus Mayer
  2018-12-20 17:58   ` [Buildroot] [PATCH v3 4/4] dropbear: " Markus Mayer
  2 siblings, 1 reply; 8+ messages in thread
From: Markus Mayer @ 2018-12-20 17:58 UTC (permalink / raw)
  To: buildroot

We substitute the path specified in system/skeleton/etc/profile with
the path specified in the configuration variable
$(BR2_SYSTEM_DEFAULT_PATH).

$(BR2_SYSTEM_DEFAULT_PATH) is a Kconfig string. So it is already
quoted, which is exactly what we want.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 package/skeleton-init-common/skeleton-init-common.mk | 1 +
 system/skeleton/etc/profile                          | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/package/skeleton-init-common/skeleton-init-common.mk b/package/skeleton-init-common/skeleton-init-common.mk
index e8a052205268..7d2c68ada308 100644
--- a/package/skeleton-init-common/skeleton-init-common.mk
+++ b/package/skeleton-init-common/skeleton-init-common.mk
@@ -20,6 +20,7 @@ define SKELETON_INIT_COMMON_INSTALL_TARGET_CMDS
 	$(call SYSTEM_RSYNC,$(SKELETON_INIT_COMMON_PATH),$(TARGET_DIR))
 	$(call SYSTEM_USR_SYMLINKS_OR_DIRS,$(TARGET_DIR))
 	$(call SYSTEM_LIB_SYMLINK,$(TARGET_DIR))
+	$(SED) 's, at PATH@,$(BR2_SYSTEM_DEFAULT_PATH),' $(TARGET_DIR)/etc/profile
 	$(INSTALL) -m 0644 support/misc/target-dir-warning.txt \
 		$(TARGET_DIR_WARNING_FILE)
 endef
diff --git a/system/skeleton/etc/profile b/system/skeleton/etc/profile
index 1255d23ff40d..db29e44920e8 100644
--- a/system/skeleton/etc/profile
+++ b/system/skeleton/etc/profile
@@ -1,4 +1,4 @@
-export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+export PATH=@PATH@
 
 if [ "$PS1" ]; then
 	if [ "`id -u`" -eq 0 ]; then
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH v3 3/4] openssh: use BR2_SYSTEM_DEFAULT_PATH as default PATH
  2018-12-20 17:58 ` [Buildroot] [PATCH v3 1/4] system cfg: introduce option BR2_SYSTEM_DEFAULT_PATH Markus Mayer
  2018-12-20 17:58   ` [Buildroot] [PATCH v3 2/4] skeleton: use BR2_SYSTEM_DEFAULT_PATH as default PATH Markus Mayer
@ 2018-12-20 17:58   ` Markus Mayer
  2018-12-20 17:58   ` [Buildroot] [PATCH v3 4/4] dropbear: " Markus Mayer
  2 siblings, 0 replies; 8+ messages in thread
From: Markus Mayer @ 2018-12-20 17:58 UTC (permalink / raw)
  To: buildroot

We use the configuration option $(BR2_SYSTEM_DEFAULT_PATH) to set the
default PATH in OpenSSH sessions.

$(BR2_SYSTEM_DEFAULT_PATH) is a Kconfig string. So it is already
quoted, which is exactly what we want.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 package/openssh/openssh.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/package/openssh/openssh.mk b/package/openssh/openssh.mk
index 07f3e0d663f6..4ee7727fb9e8 100644
--- a/package/openssh/openssh.mk
+++ b/package/openssh/openssh.mk
@@ -11,6 +11,7 @@ OPENSSH_LICENSE_FILES = LICENCE
 OPENSSH_CONF_ENV = LD="$(TARGET_CC)" LDFLAGS="$(TARGET_CFLAGS)"
 OPENSSH_CONF_OPTS = \
 	--sysconfdir=/etc/ssh \
+	--with-default-path=$(BR2_SYSTEM_DEFAULT_PATH) \
 	--disable-lastlog \
 	--disable-utmp \
 	--disable-utmpx \
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH v3 4/4] dropbear: use BR2_SYSTEM_DEFAULT_PATH as default PATH
  2018-12-20 17:58 ` [Buildroot] [PATCH v3 1/4] system cfg: introduce option BR2_SYSTEM_DEFAULT_PATH Markus Mayer
  2018-12-20 17:58   ` [Buildroot] [PATCH v3 2/4] skeleton: use BR2_SYSTEM_DEFAULT_PATH as default PATH Markus Mayer
  2018-12-20 17:58   ` [Buildroot] [PATCH v3 3/4] openssh: " Markus Mayer
@ 2018-12-20 17:58   ` Markus Mayer
  2 siblings, 0 replies; 8+ messages in thread
From: Markus Mayer @ 2018-12-20 17:58 UTC (permalink / raw)
  To: buildroot

We use the configuration option $(BR2_SYSTEM_DEFAULT_PATH) to set the
default PATH in dropbear sessions.

$(BR2_SYSTEM_DEFAULT_PATH) is a Kconfig string. So it is already
quoted, which is exactly what we want.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 package/dropbear/dropbear.mk | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/package/dropbear/dropbear.mk b/package/dropbear/dropbear.mk
index 7b1468cfb100..a5a8243bd431 100644
--- a/package/dropbear/dropbear.mk
+++ b/package/dropbear/dropbear.mk
@@ -81,6 +81,12 @@ define DROPBEAR_DISABLE_STANDALONE
 	echo '#define NON_INETD_MODE 0'                 >> $(@D)/localoptions.h
 endef
 
+define DROPBEAR_CUSTOM_PATH
+	echo '#define DEFAULT_PATH $(BR2_SYSTEM_DEFAULT_PATH)' >>$(@D)/localoptions.h
+endef
+
+DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_CUSTOM_PATH
+
 define DROPBEAR_INSTALL_INIT_SYSTEMD
 	$(INSTALL) -D -m 644 package/dropbear/dropbear.service \
 		$(TARGET_DIR)/usr/lib/systemd/system/dropbear.service
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH v3 2/4] skeleton: use BR2_SYSTEM_DEFAULT_PATH as default PATH
  2018-12-20 17:58   ` [Buildroot] [PATCH v3 2/4] skeleton: use BR2_SYSTEM_DEFAULT_PATH as default PATH Markus Mayer
@ 2018-12-30 21:52     ` Thomas Petazzoni
  2018-12-31  0:13       ` Markus Mayer
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2018-12-30 21:52 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 20 Dec 2018 09:58:12 -0800, Markus Mayer wrote:
> We substitute the path specified in system/skeleton/etc/profile with
> the path specified in the configuration variable
> $(BR2_SYSTEM_DEFAULT_PATH).
> 
> $(BR2_SYSTEM_DEFAULT_PATH) is a Kconfig string. So it is already
> quoted, which is exactly what we want.

I am curious about this sentence: why is it "exactly what we want" ?

> diff --git a/system/skeleton/etc/profile b/system/skeleton/etc/profile
> index 1255d23ff40d..db29e44920e8 100644
> --- a/system/skeleton/etc/profile
> +++ b/system/skeleton/etc/profile
> @@ -1,4 +1,4 @@
> -export PATH=/bin:/sbin:/usr/bin:/usr/sbin
> +export PATH=@PATH@

Indeed, the variable assignment was not double quoted before, and now
it becomes double quoted:

export PATH="/bin:/sbin:/usr/bin:/usr/sbin"

is what I have in the resulting /etc/profile.

So does "exactly what we want" means "preserves the existing behavior"
or means "is better than the existing behavior" for some reason ?

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH v3 2/4] skeleton: use BR2_SYSTEM_DEFAULT_PATH as default PATH
  2018-12-30 21:52     ` Thomas Petazzoni
@ 2018-12-31  0:13       ` Markus Mayer
  0 siblings, 0 replies; 8+ messages in thread
From: Markus Mayer @ 2018-12-31  0:13 UTC (permalink / raw)
  To: buildroot

On Sun, 30 Dec 2018 at 13:52, Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello,
>
> On Thu, 20 Dec 2018 09:58:12 -0800, Markus Mayer wrote:
> > We substitute the path specified in system/skeleton/etc/profile with
> > the path specified in the configuration variable
> > $(BR2_SYSTEM_DEFAULT_PATH).
> >
> > $(BR2_SYSTEM_DEFAULT_PATH) is a Kconfig string. So it is already
> > quoted, which is exactly what we want.
>
> I am curious about this sentence: why is it "exactly what we want" ?
>
> > diff --git a/system/skeleton/etc/profile b/system/skeleton/etc/profile
> > index 1255d23ff40d..db29e44920e8 100644
> > --- a/system/skeleton/etc/profile
> > +++ b/system/skeleton/etc/profile
> > @@ -1,4 +1,4 @@
> > -export PATH=/bin:/sbin:/usr/bin:/usr/sbin
> > +export PATH=@PATH@
>
> Indeed, the variable assignment was not double quoted before, and now
> it becomes double quoted:
>
> export PATH="/bin:/sbin:/usr/bin:/usr/sbin"
>
> is what I have in the resulting /etc/profile.
>
> So does "exactly what we want" means "preserves the existing behavior"
> or means "is better than the existing behavior" for some reason ?

I hadn't actually noticed this difference in quoting, but it does seem
like a good idea to have them.

"Exactly what we want" was just meant to indicate that we get a quoted
string out of Kconfig, and we can use that quoted string in our code
unchanged (explaining why there are no quotes being added in the code
and why they aren't being stripped, either).

This can be reworded if you think it is too confusing.

Regards,
-Markus

> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH v3 0/4] Allow customization of system default PATH
  2018-12-20 17:55 [Buildroot] [PATCH v3 0/4] Allow customization of system default PATH Markus Mayer
  2018-12-20 17:58 ` [Buildroot] [PATCH v3 1/4] system cfg: introduce option BR2_SYSTEM_DEFAULT_PATH Markus Mayer
@ 2018-12-31 13:34 ` Thomas Petazzoni
  1 sibling, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2018-12-31 13:34 UTC (permalink / raw)
  To: buildroot

Hello Markus,

On Thu, 20 Dec 2018 09:55:04 -0800, Markus Mayer wrote:

> Markus Mayer (4):
>   system cfg: introduce option BR2_SYSTEM_DEFAULT_PATH
>   skeleton: use BR2_SYSTEM_DEFAULT_PATH as default PATH
>   openssh: use BR2_SYSTEM_DEFAULT_PATH as default PATH
>   dropbear: use BR2_SYSTEM_DEFAULT_PATH as default PATH

Thanks, series applied with minor tweaks to the commit titles, and a
minor tweak to the commit log of PATCH 2/4 related to the double quotes
addition. Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-12-31 13:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20 17:55 [Buildroot] [PATCH v3 0/4] Allow customization of system default PATH Markus Mayer
2018-12-20 17:58 ` [Buildroot] [PATCH v3 1/4] system cfg: introduce option BR2_SYSTEM_DEFAULT_PATH Markus Mayer
2018-12-20 17:58   ` [Buildroot] [PATCH v3 2/4] skeleton: use BR2_SYSTEM_DEFAULT_PATH as default PATH Markus Mayer
2018-12-30 21:52     ` Thomas Petazzoni
2018-12-31  0:13       ` Markus Mayer
2018-12-20 17:58   ` [Buildroot] [PATCH v3 3/4] openssh: " Markus Mayer
2018-12-20 17:58   ` [Buildroot] [PATCH v3 4/4] dropbear: " Markus Mayer
2018-12-31 13:34 ` [Buildroot] [PATCH v3 0/4] Allow customization of system " Thomas Petazzoni

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.