Add /etc/shells handling
cover Add /etc/shells handling
Started with commit [1], all package providing a shell interpreter should be listed in /etc/shells file to avoid issues with dropbear or other tools.
Although a macro could be added to pkg-generic.mk to avoid duplicating the /etc/shells handling, there is less than ten shell packages in Buildroot. So add /etc/shells handling as a POST_INSTALL_TARGET_HOOKS or inside INSTALL_TARGET_CMDS.
[1] 4d279697afbf8fb295274784103be2b837113d5e
Romain Naour (7):
package/skeleton-init-common: add /bin/sh to /etc/shells package/busybox: add /bin/ash to /etc/shells package/dash: add /etc/dash to /etc/shells package/screen: add /usr/bin/screen to /etc/shells package/tmux: add /usr/bin/tmux to /etc/shells package/zsh: add /bin/zsh to /etc/shells package/mksh: add /bin/mksh to /etc/shells
package/busybox/busybox.mk | 10 ++++++++++ package/dash/dash.mk | 4 ++++ package/mksh/mksh.mk | 9 +++++++++ package/screen/screen.mk | 12 +++++++++++- package/skeleton-init-common/skeleton-init-common.mk | 7 +++++++ package/tmux/tmux.mk | 9 +++++++++ package/zsh/zsh.mk | 10 +++++++++- system/skeleton/etc/shells | 1 + 8 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 system/skeleton/etc/shells
Signature · 1 line
2.7.4
PATCH 1/7 package/skeleton-init-common: add /bin/sh to /etc/shells
Add the default shell /bin/sh to /etc/shells only if BR2_SYSTEM_BIN_SH_NONE is not selected.
Add an empty /etc/shells in the rootfs skeleton.
--- package/skeleton-init-common/skeleton-init-common.mk | 7 +++++++ system/skeleton/etc/shells | 1 + 2 files changed, 8 insertions(+) create mode 100644 system/skeleton/etc/shells
package/skeleton-init-common/skeleton-init-common.mk +7 -0
@@ -79,6 +79,12 @@ define SKELETON_INIT_COMMON_SET_BIN_SH rm -f $(TARGET_DIR)/bin/sh endef else +# Add /bin/sh to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +define SKELETON_INIT_COMMON_ADD_SH_TO_SHELLS + grep -qsE '^/bin/sh' $(TARGET_DIR)/etc/shells \ + || echo "/bin/sh" >> $(TARGET_DIR)/etc/shells +endef ifneq ($(SKELETON_INIT_COMMON_BIN_SH),) define SKELETON_INIT_COMMON_SET_BIN_SH ln -sf $(SKELETON_INIT_COMMON_BIN_SH) $(TARGET_DIR)/bin/sh
@@ -86,5 +92,6 @@ endef endif endif SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_BIN_SH +SKELETON_INIT_COMMON_POST_INSTALL_TARGET_HOOKS += SKELETON_INIT_COMMON_ADD_SH_TO_SHELLS $(eval $(generic-package))
system/skeleton/etc/shells new file +1 -0
@@ -0,0 +1 @@ +# /etc/shells: valid login shells
Signature · 1 line
2.7.4
PATCH 1/7 package/skeleton-init-common: add /bin/sh to /etc/shells
On 2018-01-14 22:03 +0100, Romain Naour spake thusly:
Quoted 30 lines
Add the default shell
/bin/shto/etc/shellsonly ifBR2_SYSTEM_BIN_SH_NONEis not selected.Add an empty
/etc/shellsin the rootfs skeleton.Signed-off-by Romain Naour <[email protected]>--- package/skeleton-init-common/skeleton-init-common.mk | 7 +++++++ system/skeleton/etc/shells | 1 + 2 files changed, 8 insertions(+) create mode 100644 system/skeleton/etc/shellspackage/skeleton-init-common/skeleton-init-common.mk +6
-0@@ -79,6 +79,12 @@ define SKELETON_INIT_COMMON_SET_BIN_SH rm -f $(TARGET_DIR)/bin/sh endef else +# Add /bin/sh to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +define SKELETON_INIT_COMMON_ADD_SH_TO_SHELLS + grep -qsE '^/bin/sh' $(TARGET_DIR)/etc/shells \ + || echo "/bin/sh" >> $(TARGET_DIR)/etc/shells +endef ifneq ($(SKELETON_INIT_COMMON_BIN_SH),) define SKELETON_INIT_COMMON_SET_BIN_SH ln -sf $(SKELETON_INIT_COMMON_BIN_SH) $(TARGET_DIR)/bin/sh
package/skeleton-init-common/skeleton-init-common.mk endef · line 95
Quoted 4 lines
package/skeleton-init-common/skeleton-init-common.mk +1
-0@@ -86,5 +92,6 @@ endef endif endif SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_BIN_SH +SKELETON_INIT_COMMON_POST_INSTALL_TARGET_HOOKS += SKELETON_INIT_COMMON_ADD_SH_TO_SHELLS
Rgister your new hook right after it's defined.
The existing one is registered after the if-block, becasue it is the same hook-name for the two cases of the condition, b ut your new hook is only defined in the else case, so register it there.
Regards,
Yann E. MORIN.
Quoted 15 lines
package/skeleton-init-common/skeleton-init-common.mk +0
-0$(eval $(generic-package))system/skeleton/etc/shells new file +1
-0@@ -0,0 +1 @@ +# /etc/shells: valid login shellsSignature · 6 lines
2.7.4 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/7 package/skeleton-init-common: add /bin/sh to /etc/shells
In reply to Romain NaourQuoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Romain" == Romain Naour <[email protected]> writes:
Add the default shell
/bin/shto/etc/shellsonly ifBR2_SYSTEM_BIN_SH_NONEis not selected.Add an empty
/etc/shellsin the rootfs skeleton.
Is there any specific reason to have an empty /etc/shells?
It is a bit noisy to have this extra file in the BIN_SH_NONE case, and it afaik changes behaviour (E.G. getusershell() will return default values if there is no /etc/shells, but will now presumably return the empty string).
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/7 package/skeleton-init-common: add /bin/sh to /etc/shells
Peter, All,
On 2018-01-15 15:41 +0100, Peter Korsgaard spake thusly:
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Romain" == Romain Naour <[email protected]> writes:
Add the default shell
/bin/shto/etc/shellsonly ifBR2_SYSTEM_BIN_SH_NONEis not selected.Add an empty
/etc/shellsin the rootfs skeleton.Is there any specific reason to have an empty
/etc/shells?
In fact, I don't see the point of an empty one, indeed...
Quoted 4 lines
It is a bit noisy to have this extra file in the
BIN_SH_NONEcase, and it afaik changes behaviour (E.G.getusershell()will return default values if there is no/etc/shells, but will now presumably return the empty string).
Woah.. I did not know about getusershell(), but its API is ugly... :-/
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 2/7 package/busybox: add /bin/ash to /etc/shells
In reply to Romain NaourWhen ash (busybox) is selected, /bin/ash is not added to /etc/shells (see man shells). So, login tools like dropbear reject the ssh connexions for users using ash as shell in /etc/passwd.
buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
ash is disabled for MMUless systems, so don't add /bin/ash in /etc/shells in this case.
--- package/busybox/busybox.mk | 10 ++++++++++ 1 file changed, 10 insertions(+)
package/busybox/busybox.mk +10 -0
@@ -258,6 +258,15 @@ define BUSYBOX_INSTALL_TELNET_SCRIPT fi endef +# Add /bin/ash to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +ifeq ($(BR2_USE_MMU),y) +define BUSYBOX_INSTALL_ADD_ASH_TO_SHELLS + grep -qsE '^/bin/ash' $(TARGET_DIR)/etc/shells \ + || echo "/bin/ash" >> $(TARGET_DIR)/etc/shells +endef +endif + # Enable "noclobber" in install.sh, to prevent BusyBox from overwriting any # full-blown versions of apps installed by other packages with sym/hard links. define BUSYBOX_NOCLOBBER_INSTALL
@@ -291,6 +300,7 @@ define BUSYBOX_INSTALL_TARGET_CMDS $(BUSYBOX_INSTALL_INITTAB) $(BUSYBOX_INSTALL_UDHCPC_SCRIPT) $(BUSYBOX_INSTALL_MDEV_CONF) + $(BUSYBOX_INSTALL_ADD_ASH_TO_SHELLS) endef define BUSYBOX_INSTALL_INIT_SYSV
Signature · 1 line
2.7.4
PATCH 2/7 package/busybox: add /bin/ash to /etc/shells
Romain, All,
On 2018-01-14 22:03 +0100, Romain Naour spake thusly:
Quoted 19 lines
When ash (busybox) is selected,
/bin/ashis not added to/etc/shells(see man shells). So, login tools like dropbear reject the ssh connexions for users using ash as shell in/etc/passwd.buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
ash is disabled for MMUless systems, so don't add
/bin/ashin/etc/shellsin this case.Signed-off-by Romain Naour <[email protected]>--- package/busybox/busybox.mk | 10 ++++++++++ 1 file changed, 10 insertions(+)package/busybox/busybox.mk +0
-0
package/busybox/busybox.mk define BUSYBOX_INSTALL_TELNET_SCRIPT · line 266
Quoted 9 lines
package/busybox/busybox.mk +6
-0@@ -258,6 +258,15 @@ define BUSYBOX_INSTALL_TELNET_SCRIPT fi endef +# Add /bin/ash to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +ifeq ($(BR2_USE_MMU),y) +define BUSYBOX_INSTALL_ADD_ASH_TO_SHELLS + grep -qsE '^/bin/ash' $(TARGET_DIR)/etc/shells \ + || echo "/bin/ash" >> $(TARGET_DIR)/etc/shells
What if the user uses a custom config file where ash is not enabled? What about the other shells busybox may install?
define BUSYBOX_INSTALL_ADD_TO_SHELLS
if grep -qsE '^CONFIG_ASH=y$$' $(@D)/.config; then
grep -qsE '^/bin/ash' $(TARGET_DIR)/etc/shells \
|| echo "/bin/ash" >> $(TARGET_DIR)/etc/shells; \
fi
if grep -qsE '^CONFIG_HUSH=y$$' $(@D)/.config; then
grep -qsE '^/bin/hush' $(TARGET_DIR)/etc/shells \
|| echo "/bin/hush" >> $(TARGET_DIR)/etc/shells; \
fi
if grep -qsE '^CONFIG_MSH=y$$' $(@D)/.config; then
grep -qsE '^/bin/msh' $(TARGET_DIR)/etc/shells \
|| echo "/bin/msh" >> $(TARGET_DIR)/etc/shells; \
fi
endef(msh is just an alias for hush, but it can be a shell nonethless...)
Regards,
Yann E. MORIN.
Quoted 21 lines
package/busybox/busybox.mk +4
-0+endef +endif + # Enable "noclobber" in install.sh, to prevent BusyBox from overwriting any # full-blown versions of apps installed by other packages with sym/hard links. define BUSYBOX_NOCLOBBER_INSTALL@@ -291,6 +300,7 @@ define BUSYBOX_INSTALL_TARGET_CMDS $(BUSYBOX_INSTALL_INITTAB) $(BUSYBOX_INSTALL_UDHCPC_SCRIPT) $(BUSYBOX_INSTALL_MDEV_CONF) + $(BUSYBOX_INSTALL_ADD_ASH_TO_SHELLS) endef define BUSYBOX_INSTALL_INIT_SYSVSignature · 6 lines
2.7.4 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 2/7 package/busybox: add /bin/ash to /etc/shells
Hi Yann,
Le 14/01/2018 ? 23:43, Yann E. MORIN a ?crit?:
Quoted 50 lines
Romain, All,
On 2018-01-14 22:03 +0100, Romain Naour spake thusly:
Quoted 19 lines
When ash (busybox) is selected,
/bin/ashis not added to/etc/shells(see man shells). So, login tools like dropbear reject the ssh connexions for users using ash as shell in/etc/passwd.buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
ash is disabled for MMUless systems, so don't add
/bin/ashin/etc/shellsin this case.Signed-off-by Romain Naour <[email protected]>--- package/busybox/busybox.mk | 10 ++++++++++ 1 file changed, 10 insertions(+)package/busybox/busybox.mk +0
-0package/busybox/busybox.mk define BUSYBOX_INSTALL_TELNET_SCRIPT · line 266
Quoted 9 lines
package/busybox/busybox.mk +6
-0@@ -258,6 +258,15 @@ define BUSYBOX_INSTALL_TELNET_SCRIPT fi endef +# Add /bin/ash to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +ifeq ($(BR2_USE_MMU),y) +define BUSYBOX_INSTALL_ADD_ASH_TO_SHELLS + grep -qsE '^/bin/ash' $(TARGET_DIR)/etc/shells \ + || echo "/bin/ash" >> $(TARGET_DIR)/etc/shellsWhat if the user uses a custom config file where ash is not enabled? What about the other shells busybox may install?
define BUSYBOX_INSTALL_ADD_TO_SHELLS if grep -qsE '^CONFIG_ASH=y$$' $(@D)/.config; then grep -qsE '^/bin/ash' $(TARGET_DIR)/etc/shells \ || echo "/bin/ash" >> $(TARGET_DIR)/etc/shells; \ fi if grep -qsE '^CONFIG_HUSH=y$$' $(@D)/.config; then grep -qsE '^/bin/hush' $(TARGET_DIR)/etc/shells \ || echo "/bin/hush" >> $(TARGET_DIR)/etc/shells; \ fi if grep -qsE '^CONFIG_MSH=y$$' $(@D)/.config; then grep -qsE '^/bin/msh' $(TARGET_DIR)/etc/shells \ || echo "/bin/msh" >> $(TARGET_DIR)/etc/shells; \ fi endef
Quoted 1 line
(msh is just an alias for hush, but it can be a shell nonethless...)
I didn't know about msh and hush...
Btw msh has been removed from Busybox 1.28.0
https://git.busybox.net/busybox/commit/?id=2e989ef232e35750df573898077dd356003705b2
Best regards,
Romain
Quoted 26 lines
Regards,
Yann E. MORIN.Quoted 21 lines
package/busybox/busybox.mk +4
-0+endef +endif + # Enable "noclobber" in install.sh, to prevent BusyBox from overwriting any # full-blown versions of apps installed by other packages with sym/hard links. define BUSYBOX_NOCLOBBER_INSTALL@@ -291,6 +300,7 @@ define BUSYBOX_INSTALL_TARGET_CMDS $(BUSYBOX_INSTALL_INITTAB) $(BUSYBOX_INSTALL_UDHCPC_SCRIPT) $(BUSYBOX_INSTALL_MDEV_CONF) + $(BUSYBOX_INSTALL_ADD_ASH_TO_SHELLS) endef define BUSYBOX_INSTALL_INIT_SYSVSignature · 6 lines
2.7.4 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
PATCH 3/7 package/dash: add /etc/dash to /etc/shells
In reply to Romain NaourWhen dash is selected, /bin/dash is not added to /etc/shells (see man shells). So, login tools like dropbear reject the ssh connexions for users using dash as shell in /etc/passwd.
buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
--- package/dash/dash.mk | 4 ++++ 1 file changed, 4 insertions(+)
package/dash/dash.mk +4 -0
@@ -9,8 +9,12 @@ DASH_SITE = http://gondor.apana.org.au/~herbert/dash/files DASH_LICENSE = BSD-3-Clause, GPL-2.0+ (mksignames.c) DASH_LICENSE_FILES = COPYING +# Add /bin/dash to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. define DASH_INSTALL_TARGET_CMDS $(INSTALL) -m 0755 $(@D)/src/dash $(TARGET_DIR)/bin/dash + grep -qsE '^/bin/dash' $(TARGET_DIR)/etc/shells \ + || echo "/bin/dash" >> $(TARGET_DIR)/etc/shells endef $(eval $(autotools-package))
Signature · 1 line
2.7.4
PATCH 3/7 package/dash: add /etc/dash to /etc/shells
Romain, All,
On 2018-01-14 22:03 +0100, Romain Naour spake thusly:
Quoted 16 lines
When dash is selected,
/bin/dashis not added to/etc/shells(see man shells). So, login tools like dropbear reject the ssh connexions for users using dash as shell in/etc/passwd.buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
Signed-off-by Romain Naour <[email protected]>--- package/dash/dash.mk | 4 ++++ 1 file changed, 4 insertions(+)package/dash/dash.mk +0
-0
package/dash/dash.mk DASH_SITE = http://gondor.apana.org.au/~herbert/dash/files · line 17
Quoted 9 lines
package/dash/dash.mk +4
-0@@ -9,8 +9,12 @@ DASH_SITE = http://gondor.apana.org.au/~herbert/dash/files DASH_LICENSE = BSD-3-Clause, GPL-2.0+ (mksignames.c) DASH_LICENSE_FILES = COPYING +# Add /bin/dash to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. define DASH_INSTALL_TARGET_CMDS $(INSTALL) -m 0755 $(@D)/src/dash $(TARGET_DIR)/bin/dash + grep -qsE '^/bin/dash' $(TARGET_DIR)/etc/shells \ + || echo "/bin/dash" >> $(TARGET_DIR)/etc/shells
Very unlikely, but what if there already is a shell named /bin/dashfoo ? You should make sure to also match the end of the line (double-dollar because of make...):
grep -qsE '^/bin/dash$$'
Note: comment valid for all the patches in the series, of course...
And now that I re-read your bash patch, I missed it during the review. Or I did suggest you do, but you missed it, and then I missed it in the second review...
http://lists.busybox.net/pipermail/buildroot/2018-January/211338.html
Regards,
Yann E. MORIN.
Quoted 10 lines
package/dash/dash.mk +0
-0endef $(eval $(autotools-package))Signature · 6 lines
2.7.4 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 4/7 package/screen: add /usr/bin/screen to /etc/shells
In reply to Romain NaourWhen screen is selected, /usr/bin/screen is not added to /etc/shells (see man shells). So, login tools like dropbear reject the ssh connexions for users using screen as shell in /etc/passwd.
buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
--- package/screen/screen.mk | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
package/screen/screen.mk +11 -1
@@ -16,8 +16,18 @@ SCREEN_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) SCREEN=screen install_bin define SCREEN_INSTALL_SCREENRC $(INSTALL) -m 0755 -D $(@D)/etc/screenrc $(TARGET_DIR)/etc/screenrc + grep -qsE '^/usr/bin/screen' $(TARGET_DIR)/etc/shells \ + || echo "/usr/bin/screen" >> $(TARGET_DIR)/etc/shells endef -SCREEN_POST_INSTALL_TARGET_HOOKS += SCREEN_INSTALL_SCREENRC +# Add /usr/bin/screen to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +define SCREEN_INSTALL_ADD_SCREEN_TO_SHELLS + grep -qsE '^/usr/bin/screen' $(TARGET_DIR)/etc/shells \ + || echo "/usr/bin/screen" >> $(TARGET_DIR)/etc/shells +endef + +SCREEN_POST_INSTALL_TARGET_HOOKS += SCREEN_INSTALL_SCREENRC \ + SCREEN_INSTALL_ADD_SCREEN_TO_SHELLS $(eval $(autotools-package))
Signature · 1 line
2.7.4
PATCH 4/7 package/screen: add /usr/bin/screen to /etc/shells
On 2018-01-14 22:03 +0100, Romain Naour spake thusly:
Quoted 20 lines
When screen is selected,
/usr/bin/screenis not added to/etc/shells(see man shells). So, login tools like dropbear reject the ssh connexions for users using screen as shell in/etc/passwd.buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
Signed-off-by Romain Naour <[email protected]>--- package/screen/screen.mk | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)package/screen/screen.mk +1
-0@@ -16,8 +16,18 @@ SCREEN_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) SCREEN=screen install_bin define SCREEN_INSTALL_SCREENRC $(INSTALL) -m 0755 -D $(@D)/etc/screenrc $(TARGET_DIR)/etc/screenrc + grep -qsE '^/usr/bin/screen' $(TARGET_DIR)/etc/shells \
package/screen/screen.mk SCREEN_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) SCREEN=screen install_bin · line 28
Quoted 10 lines
package/screen/screen.mk +7
-1+ || echo "/usr/bin/screen" >> $(TARGET_DIR)/etc/shells endef -SCREEN_POST_INSTALL_TARGET_HOOKS += SCREEN_INSTALL_SCREENRC +# Add /usr/bin/screen to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +define SCREEN_INSTALL_ADD_SCREEN_TO_SHELLS + grep -qsE '^/usr/bin/screen' $(TARGET_DIR)/etc/shells \ + || echo "/usr/bin/screen" >> $(TARGET_DIR)/etc/shells +endef
Uh? Why are you doing it twice?
I prefer indeed that we have a macro for each thing.
package/screen/screen.mk SCREEN_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) SCREEN=screen install_bin · line 31
Quoted 2 lines
package/screen/screen.mk +2
-0+SCREEN_POST_INSTALL_TARGET_HOOKS += SCREEN_INSTALL_SCREENRC \ + SCREEN_INSTALL_ADD_SCREEN_TO_SHELLS
For multi=line assignments, we usually try to have a single assignment per line and the first line is just a continuation line. Besides, not need for a append-assign (+=), here, it is a sinmple assignment (=):
SCREEN_POST_INSTALL_TARGET_HOOKS = \
SCREEN_INSTALL_SCREENRC \
SCREEN_INSTALL_ADD_SCREEN_TO_SHELLSRegards,
Yann E. MORIN.
Quoted 8 lines
package/screen/screen.mk +0
-0$(eval $(autotools-package))Signature · 6 lines
2.7.4 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 4/7 package/screen: add /usr/bin/screen to /etc/shells
Romain, All,
On 2018-01-14 23:29 +0100, Yann E. MORIN spake thusly:
Quoted 43 lines
On 2018-01-14 22:03 +0100, Romain Naour spake thusly:
Quoted 20 lines
When screen is selected,
/usr/bin/screenis not added to/etc/shells(see man shells). So, login tools like dropbear reject the ssh connexions for users using screen as shell in/etc/passwd.buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
Signed-off-by Romain Naour <[email protected]>--- package/screen/screen.mk | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)package/screen/screen.mk +1
-0@@ -16,8 +16,18 @@ SCREEN_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) SCREEN=screen install_bin define SCREEN_INSTALL_SCREENRC $(INSTALL) -m 0755 -D $(@D)/etc/screenrc $(TARGET_DIR)/etc/screenrc + grep -qsE '^/usr/bin/screen' $(TARGET_DIR)/etc/shells \package/screen/screen.mk SCREEN_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) SCREEN=screen install_bin · line 28
Quoted 10 lines
package/screen/screen.mk +7
-1+ || echo "/usr/bin/screen" >> $(TARGET_DIR)/etc/shells endef -SCREEN_POST_INSTALL_TARGET_HOOKS += SCREEN_INSTALL_SCREENRC +# Add /usr/bin/screen to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +define SCREEN_INSTALL_ADD_SCREEN_TO_SHELLS + grep -qsE '^/usr/bin/screen' $(TARGET_DIR)/etc/shells \ + || echo "/usr/bin/screen" >> $(TARGET_DIR)/etc/shells +endefUh? Why are you doing it twice?
I prefer indeed that we have a macro for each thing.
package/screen/screen.mk SCREEN_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) SCREEN=screen install_bin · line 31
Quoted 2 lines
package/screen/screen.mk +2
-0+SCREEN_POST_INSTALL_TARGET_HOOKS += SCREEN_INSTALL_SCREENRC \ + SCREEN_INSTALL_ADD_SCREEN_TO_SHELLSFor multi=line assignments, we usually try to have a single assignment per line and the first line is just a continuation line. Besides, not need for a append-assign (+=), here, it is a sinmple assignment (=):
Quoted 3 lines
SCREEN_POST_INSTALL_TARGET_HOOKS = \
SCREEN_INSTALL_SCREENRC \
SCREEN_INSTALL_ADD_SCREEN_TO_SHELLSIn fact, jsut register the hooks right after they are defined; do not try to commonalise the asignment.
Since the existign one isalready an append-assinn (+=), just register your new hook before the existing one, but assign yours with a plain assignement (=).
Regards,
Yann E. MORIN.
Quoted 23 lines
Regards,
Yann E. MORIN.Quoted 8 lines
package/screen/screen.mk +0
-0$(eval $(autotools-package))Signature · 6 lines
2.7.4 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildrootSignature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 5/7 package/tmux: add /usr/bin/tmux to /etc/shells
In reply to Romain NaourWhen tmux is selected, /usr/bin/tmux is not added to /etc/shells (see man shells). So, login tools like dropbear reject the ssh connexions for users using tmux as shell in /etc/passwd.
buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
--- package/tmux/tmux.mk | 9 +++++++++ 1 file changed, 9 insertions(+)
package/tmux/tmux.mk +9 -0
@@ -10,4 +10,13 @@ TMUX_LICENSE = ISC TMUX_LICENSE_FILES = README TMUX_DEPENDENCIES = libevent ncurses host-pkgconf +# Add /usr/bin/tmux to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +define TMUX_INSTALL_ADD_TMUX_TO_SHELLS + grep -qsE '^/usr/bin/tmux' $(TARGET_DIR)/etc/shells \ + || echo "/usr/bin/tmux" >> $(TARGET_DIR)/etc/shells +endef + +TMUX_POST_INSTALL_TARGET_HOOKS += TMUX_INSTALL_ADD_TMUX_TO_SHELLS + $(eval $(autotools-package))
Signature · 1 line
2.7.4
PATCH 5/7 package/tmux: add /usr/bin/tmux to /etc/shells
Romain, All,
On 2018-01-14 22:03 +0100, Romain Naour spake thusly:
Quoted 18 lines
When tmux is selected,
/usr/bin/tmuxis not added to/etc/shells(see man shells). So, login tools like dropbear reject the ssh connexions for users using tmux as shell in/etc/passwd.buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
Signed-off-by Romain Naour <[email protected]>Cc "Yann E. MORIN" <[email protected]>--- package/tmux/tmux.mk | 9 +++++++++ 1 file changed, 9 insertions(+)package/tmux/tmux.mk +0
-0@@ -10,4 +10,13 @@ TMUX_LICENSE = ISC TMUX_LICENSE_FILES = README
package/tmux/tmux.mk TMUX_LICENSE = ISC · line 20
Quoted 10 lines
package/tmux/tmux.mk +8
-0TMUX_DEPENDENCIES = libevent ncurses host-pkgconf +# Add /usr/bin/tmux to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +define TMUX_INSTALL_ADD_TMUX_TO_SHELLS + grep -qsE '^/usr/bin/tmux' $(TARGET_DIR)/etc/shells \ + || echo "/usr/bin/tmux" >> $(TARGET_DIR)/etc/shells +endef + +TMUX_POST_INSTALL_TARGET_HOOKS += TMUX_INSTALL_ADD_TMUX_TO_SHELLS
No need for an append-assign (+=) here, just use a plain asignment (=).
Regards,
Yann E. MORIN.
Quoted 4 lines
package/tmux/tmux.mk +0
-0$(eval $(autotools-package))Signature · 1 line
2.7.4
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 6/7 package/zsh: add /bin/zsh to /etc/shells
In reply to Romain NaourWhen zsh is selected, /bin/zsh is not added to /etc/shells (see man shells). So, login tools like dropbear reject the ssh connexions for users using zsh as shell in /etc/passwd.
buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
--- package/zsh/zsh.mk | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
package/zsh/zsh.mk +9 -1
@@ -34,10 +34,18 @@ else ZSH_CONF_OPTS += --disable-pcre endif +# Add /bin/zsh to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +define ZSH_INSTALL_ADD_ZSH_TO_SHELLS + grep -qsE '^/bin/zsh' $(TARGET_DIR)/etc/shells \ + || echo "/bin/zsh" >> $(TARGET_DIR)/etc/shells +endef + # Remove versioned zsh-x.y.z binary taking up space define ZSH_TARGET_INSTALL_FIXUPS rm -f $(TARGET_DIR)/bin/zsh-$(ZSH_VERSION) endef -ZSH_POST_INSTALL_TARGET_HOOKS += ZSH_TARGET_INSTALL_FIXUPS +ZSH_POST_INSTALL_TARGET_HOOKS += ZSH_TARGET_INSTALL_FIXUPS \ + ZSH_INSTALL_ADD_ZSH_TO_SHELLS $(eval $(autotools-package))
Signature · 1 line
2.7.4
PATCH 6/7 package/zsh: add /bin/zsh to /etc/shells
Romain, All,
On 2018-01-14 22:03 +0100, Romain Naour spake thusly:
Quoted 23 lines
When zsh is selected,
/bin/zshis not added to/etc/shells(see man shells). So, login tools like dropbear reject the ssh connexions for users using zsh as shell in/etc/passwd.buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
Signed-off-by Romain Naour <[email protected]>--- package/zsh/zsh.mk | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)package/zsh/zsh.mk +4
-0@@ -34,10 +34,18 @@ else ZSH_CONF_OPTS += --disable-pcre endif +# Add /bin/zsh to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +define ZSH_INSTALL_ADD_ZSH_TO_SHELLS + grep -qsE '^/bin/zsh' $(TARGET_DIR)/etc/shells \
package/zsh/zsh.mk else · line 49
Quoted 10 lines
package/zsh/zsh.mk +5
-1+ || echo "/bin/zsh" >> $(TARGET_DIR)/etc/shells +endef + # Remove versioned zsh-x.y.z binary taking up space define ZSH_TARGET_INSTALL_FIXUPS rm -f $(TARGET_DIR)/bin/zsh-$(ZSH_VERSION) endef -ZSH_POST_INSTALL_TARGET_HOOKS += ZSH_TARGET_INSTALL_FIXUPS +ZSH_POST_INSTALL_TARGET_HOOKS += ZSH_TARGET_INSTALL_FIXUPS \ + ZSH_INSTALL_ADD_ZSH_TO_SHELLS
The usual dance here... ;-)
ZSH_POST_INSTALL_TARGET_HOOKS = \
ZSH_TARGET_INSTALL_FIXUPS \
ZSH_INSTALL_ADD_ZSH_TO_SHELLSAlthough I wonder if we don;t in fact prefer to assign right after the definition if the hooks...
define ZSH_INSTALL_ADD_ZSH_TO_SHELLS
grep -qsE '^/bin/zsh' $(TARGET_DIR)/etc/shells \
|| echo "/bin/zsh" >> $(TARGET_DIR)/etc/shells
endef
ZSH_POST_INSTALL_TARGET_HOOKS = ZSH_INSTALL_ADD_ZSH_TO_SHELLS
# Remove versioned zsh-x.y.z binary taking up space
define ZSH_TARGET_INSTALL_FIXUPS
rm -f $(TARGET_DIR)/bin/zsh-$(ZSH_VERSION)
endef
ZSH_POST_INSTALL_TARGET_HOOKS += ZSH_TARGET_INSTALL_FIXUPSNote that we register before the existign hook, but use a simple assignment, so that we don;t need to change the xisting append-assign to a simple assign...
Regards,
Yann E. MORIN.
Quoted 8 lines
package/zsh/zsh.mk +0
-0$(eval $(autotools-package))Signature · 6 lines
2.7.4 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 7/7 package/mksh: add /bin/mksh to /etc/shells
In reply to Romain NaourWhen mksh is selected, /bin/mksh is not added to /etc/shells (see man shells). So, login tools like dropbear reject the ssh connexions for users using mksh as shell in /etc/passwd.
buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
--- package/mksh/mksh.mk | 9 +++++++++ 1 file changed, 9 insertions(+)
package/mksh/mksh.mk +9 -0
@@ -21,4 +21,13 @@ define MKSH_INSTALL_TARGET_CMDS $(INSTALL) -m 0755 -D $(@D)/mksh $(TARGET_DIR)/bin/mksh endef +# Add /bin/mksh to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +define MKSH_INSTALL_ADD_MKSH_TO_SHELLS + grep -qsE '^/bin/mksh' $(TARGET_DIR)/etc/shells \ + || echo "/bin/mksh" >> $(TARGET_DIR)/etc/shells +endef + +MKSH_POST_INSTALL_TARGET_HOOKS += MKSH_INSTALL_ADD_MKSH_TO_SHELLS + $(eval $(generic-package))
Signature · 1 line
2.7.4
PATCH 7/7 package/mksh: add /bin/mksh to /etc/shells
Romain, All,
On 2018-01-14 22:03 +0100, Romain Naour spake thusly:
Quoted 17 lines
When mksh is selected,
/bin/mkshis not added to/etc/shells(see man shells). So, login tools like dropbear reject the ssh connexions for users using mksh as shell in/etc/passwd.buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
Signed-off-by Romain Naour <[email protected]>--- package/mksh/mksh.mk | 9 +++++++++ 1 file changed, 9 insertions(+)package/mksh/mksh.mk +0
-0@@ -21,4 +21,13 @@ define MKSH_INSTALL_TARGET_CMDS $(INSTALL) -m 0755 -D $(@D)/mksh $(TARGET_DIR)/bin/mksh
package/mksh/mksh.mk define MKSH_INSTALL_TARGET_CMDS · line 31
Quoted 10 lines
package/mksh/mksh.mk +8
-0endef +# Add /bin/mksh to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +define MKSH_INSTALL_ADD_MKSH_TO_SHELLS + grep -qsE '^/bin/mksh' $(TARGET_DIR)/etc/shells \ + || echo "/bin/mksh" >> $(TARGET_DIR)/etc/shells +endef + +MKSH_POST_INSTALL_TARGET_HOOKS += MKSH_INSTALL_ADD_MKSH_TO_SHELLS
Use a simple assignement here.
Regards,
Yann E. MORIN.
Quoted 8 lines
package/mksh/mksh.mk +0
-0$(eval $(generic-package))Signature · 6 lines
2.7.4 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 7/7 package/mksh: add /bin/mksh to /etc/shells
Hello,
Quoted 20 lines · Yann E. MORIN
On 2018-01-14 22:03 +0100, Romain Naour spake thusly:
Quoted 19 lines
When mksh is selected,
/bin/mkshis not added to/etc/shells(see man shells). So, login tools like dropbear reject the ssh connexions for users using mksh as shell in/etc/passwd.buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected
Signed-off-by Romain Naour <[email protected]>--- package/mksh/mksh.mk | 9 +++++++++ 1 file changed, 9 insertions(+)package/mksh/mksh.mk +0
-0@@ -21,4 +21,13 @@ define MKSH_INSTALL_TARGET_CMDS $(INSTALL) -m 0755 -D $(@D)/mksh $(TARGET_DIR)/bin/mksh endef
Quoted 10 lines
package/mksh/mksh.mk define MKSH_INSTALL_TARGET_CMDS · line 31
Quoted 8 lines
package/mksh/mksh.mk +8
-0+# Add /bin/mksh to /etc/shells otherwise some login tools like dropbear +# can reject the user connexion. See man shells. +define MKSH_INSTALL_ADD_MKSH_TO_SHELLS + grep -qsE '^/bin/mksh' $(TARGET_DIR)/etc/shells \ + || echo "/bin/mksh" >> $(TARGET_DIR)/etc/shells +endef + +MKSH_POST_INSTALL_TARGET_HOOKS += MKSH_INSTALL_ADD_MKSH_TO_SHELLSUse a simple assignement here.
Well, actually, I'm quite happy with using += for hooks, even if there's only one registered.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com