Message ID | 20230122094453.1381079-1-yann.morin.1998@free.fr |
---|---|
State | Rejected |
Headers | show |
Series | system: add option for packages to require /bin/sh | expand |
On Sun, 22 Jan 2023, 10:44 Yann E. MORIN, <yann.morin.1998@free.fr> wrote: > Some packages will require that /bin/sh exists and is a valid shell. > > For example, system needs a shell, but does not care much what it is. We > could provide it with whatever the user configures as BR2_SYSTEM_BIN_SH, > but that can be empty because of BR2_SYSTEM_BIN_SH_NONE. > > So, we add an option to restrict the choice and forbid > BR2_SYSTEM_BIN_SH_NONE > from being a selectable option, this ensuring that there is a shell on > the system. As a side effect, it also ensures that /bin/sh exists. > > For systmd, we can then just tell it to unconditionally use /bin/sh as > the default user shell, and that will also match whatever the user > selected as the system-wide default shell. > > Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> > Cc: Norbert Lange <nolange79@gmail.com> > --- > Note: this is a prerequisite for the bump to systemd 252.4: > > http://patchwork.ozlabs.org/project/buildroot/patch/20230115114840.9027-1-nolange79@gmail.com/ > --- > system/Config.in | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/system/Config.in b/system/Config.in > index 806a747315..963192cb3f 100644 > --- a/system/Config.in > +++ b/system/Config.in > @@ -320,6 +320,17 @@ config BR2_TARGET_GENERIC_ROOT_PASSWD > the very least use a strong cryptographic hash for your > password! > > +config BR2_SYSTEM_NEEDS_BIN_SH > + bool > + # Busybox has a shell that does not need an MMU, but all the > + # standalone shells need one. If BR2_PACKAGE_BUSYBOX is not > + # set, BR2_PACKAGE_BUSYBOX_SHOW_OTHERS is set, so we just need > + # an MMU. > + depends on BR2_USE_MMU || BR2_PACKAGE_BUSYBOX > + help > + Have your package select this (and proapgate the dependencies) > + if it absolutely needs /bin/sh to exist and be a valid shell. > + > choice > bool "/bin/sh" > default BR2_SYSTEM_BIN_SH_DASH if !BR2_PACKAGE_BUSYBOX > @@ -360,6 +371,7 @@ comment "bash, dash, mksh, zsh need > BR2_PACKAGE_BUSYBOX_SHOW_OTHERS" > > config BR2_SYSTEM_BIN_SH_NONE > bool "none" > + depends on !BR2_SYSTEM_NEEDS_BIN_SH > > endchoice # /bin/sh > > -- > 2.25.1 > Hello Yann, I see the use of requiring /bin/sh, but that is as soon as any packet requires a shell script or wants to login. Systemd allows configuring the paths of several tools that might or might not exist. This doesn't itself change whether /bin/sh is needed or not (nor that 252.4 changes anything in that behavior). Am I missing something? Regards, Norbert
On 22/01/2023 10:44, Yann E. MORIN wrote: > Some packages will require that /bin/sh exists and is a valid shell. > > For example, system needs a shell, but does not care much what it is. We > could provide it with whatever the user configures as BR2_SYSTEM_BIN_SH, > but that can be empty because of BR2_SYSTEM_BIN_SH_NONE. > > So, we add an option to restrict the choice and forbid BR2_SYSTEM_BIN_SH_NONE > from being a selectable option, this ensuring that there is a shell on > the system. As a side effect, it also ensures that /bin/sh exists. In Buildroot, we assume that the user is smart enough to not remove the basic Unix tools from the system (sh, sed, grep, ...) unless they know very well what they're doing. BIN_SH_NONE is there for various situations where none of the other options are appropriate: - a system which doesn't have a shell (or maybe even init system) at all; - /bin/sh is already provided by a custom skeleton; - /bin/sh is provided in some other external fashion, e.g. this is not a full rootfs but just an overlay; - /bin/sh is provided by a package in BR2_EXTERNAL; - probably there are use cases that I can't even think of. Except for the first one, in all of these cases it should be possible for the user to still enable systemd (or any other init system). > For systmd, we can then just tell it to unconditionally use /bin/sh as > the default user shell, and that will also match whatever the user > selected as the system-wide default shell. Well, if we go that way, this patch should always have been there, because the other init systems rely on /bin/sh even more (for executing /etc/init.d scripts). > > Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> > Cc: Norbert Lange <nolange79@gmail.com> Norbert's feedback was also not in favour. Therefore, marked as Rejected. Regards, Arnout > --- > Note: this is a prerequisite for the bump to systemd 252.4: > http://patchwork.ozlabs.org/project/buildroot/patch/20230115114840.9027-1-nolange79@gmail.com/ > --- > system/Config.in | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/system/Config.in b/system/Config.in > index 806a747315..963192cb3f 100644 > --- a/system/Config.in > +++ b/system/Config.in > @@ -320,6 +320,17 @@ config BR2_TARGET_GENERIC_ROOT_PASSWD > the very least use a strong cryptographic hash for your > password! > > +config BR2_SYSTEM_NEEDS_BIN_SH > + bool > + # Busybox has a shell that does not need an MMU, but all the > + # standalone shells need one. If BR2_PACKAGE_BUSYBOX is not > + # set, BR2_PACKAGE_BUSYBOX_SHOW_OTHERS is set, so we just need > + # an MMU. > + depends on BR2_USE_MMU || BR2_PACKAGE_BUSYBOX > + help > + Have your package select this (and proapgate the dependencies) > + if it absolutely needs /bin/sh to exist and be a valid shell. > + > choice > bool "/bin/sh" > default BR2_SYSTEM_BIN_SH_DASH if !BR2_PACKAGE_BUSYBOX > @@ -360,6 +371,7 @@ comment "bash, dash, mksh, zsh need BR2_PACKAGE_BUSYBOX_SHOW_OTHERS" > > config BR2_SYSTEM_BIN_SH_NONE > bool "none" > + depends on !BR2_SYSTEM_NEEDS_BIN_SH > > endchoice # /bin/sh >
diff --git a/system/Config.in b/system/Config.in index 806a747315..963192cb3f 100644 --- a/system/Config.in +++ b/system/Config.in @@ -320,6 +320,17 @@ config BR2_TARGET_GENERIC_ROOT_PASSWD the very least use a strong cryptographic hash for your password! +config BR2_SYSTEM_NEEDS_BIN_SH + bool + # Busybox has a shell that does not need an MMU, but all the + # standalone shells need one. If BR2_PACKAGE_BUSYBOX is not + # set, BR2_PACKAGE_BUSYBOX_SHOW_OTHERS is set, so we just need + # an MMU. + depends on BR2_USE_MMU || BR2_PACKAGE_BUSYBOX + help + Have your package select this (and proapgate the dependencies) + if it absolutely needs /bin/sh to exist and be a valid shell. + choice bool "/bin/sh" default BR2_SYSTEM_BIN_SH_DASH if !BR2_PACKAGE_BUSYBOX @@ -360,6 +371,7 @@ comment "bash, dash, mksh, zsh need BR2_PACKAGE_BUSYBOX_SHOW_OTHERS" config BR2_SYSTEM_BIN_SH_NONE bool "none" + depends on !BR2_SYSTEM_NEEDS_BIN_SH endchoice # /bin/sh
Some packages will require that /bin/sh exists and is a valid shell. For example, system needs a shell, but does not care much what it is. We could provide it with whatever the user configures as BR2_SYSTEM_BIN_SH, but that can be empty because of BR2_SYSTEM_BIN_SH_NONE. So, we add an option to restrict the choice and forbid BR2_SYSTEM_BIN_SH_NONE from being a selectable option, this ensuring that there is a shell on the system. As a side effect, it also ensures that /bin/sh exists. For systmd, we can then just tell it to unconditionally use /bin/sh as the default user shell, and that will also match whatever the user selected as the system-wide default shell. Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> Cc: Norbert Lange <nolange79@gmail.com> --- Note: this is a prerequisite for the bump to systemd 252.4: http://patchwork.ozlabs.org/project/buildroot/patch/20230115114840.9027-1-nolange79@gmail.com/ --- system/Config.in | 12 ++++++++++++ 1 file changed, 12 insertions(+)