Skip to contentSkip to conversation

Add /etc/shells handling

PATCH Superseded Romain Naour 4 participants 20 messages Jan 14, 2018 – Jan 17, 2018

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 8228a81..707f1aa 100644
@@ -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
new file mode 100644
index 0000000..b5fd584
@@ -0,0 +1 @@
+# /etc/shells: valid login shells
Signature · 1 line
2.7.4
#2 lore raw

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/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 +6 -0
index 8228a81..707f1aa 100644
@@ -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
new file mode 100644
index 0000000..b5fd584
@@ -0,0 +1 @@
+# /etc/shells: valid login shells
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.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH 1/7 package/skeleton-init-common: add /bin/sh to /etc/shells

In reply to Romain Naour
Quoted 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/sh to /etc/shells only if BR2_SYSTEM_BIN_SH_NONE is not selected.

Add an empty /etc/shells in 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
#4 lore raw

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/sh to /etc/shells only if BR2_SYSTEM_BIN_SH_NONE is not selected.

Add an empty /etc/shells in 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_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).

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.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH 2/7 package/busybox: add /bin/ash to /etc/shells

In reply to Romain Naour

When 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
index d0bbd3f..37d064a 100644
@@ -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
#6 lore raw

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/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 +0 -0
index d0bbd3f..37d064a 100644

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_SYSV
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.  |
'------------------------------^-------^------------------^--------------------'
#7 lore raw

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/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 +0 -0
index d0bbd3f..37d064a 100644

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
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_SYSV
Signature · 6 lines
2.7.4

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
#8 lore raw

PATCH 3/7 package/dash: add /etc/dash to /etc/shells

In reply to Romain Naour

When 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
index c8b4164..391c06e 100644
@@ -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
#9 lore raw

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/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 +0 -0
index c8b4164..391c06e 100644

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 -0
 endef
 
 $(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.  |
'------------------------------^-------^------------------^--------------------'
#10 lore raw

PATCH 4/7 package/screen: add /usr/bin/screen to /etc/shells

In reply to Romain Naour

When 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
index 8d67c04..5f2eb1e 100644
@@ -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
#11 lore raw

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/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 +1 -0
index 8d67c04..5f2eb1e 100644
@@ -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_SHELLS

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/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.  |
'------------------------------^-------^------------------^--------------------'
#12 lore raw

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/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 +1 -0
index 8d67c04..5f2eb1e 100644
@@ -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 (=):

Quoted 3 lines
    SCREEN_POST_INSTALL_TARGET_HOOKS = \
        SCREEN_INSTALL_SCREENRC \
        SCREEN_INSTALL_ADD_SCREEN_TO_SHELLS

In 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/buildroot
Signature · 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.  |
'------------------------------^-------^------------------^--------------------'
#13 lore raw

PATCH 5/7 package/tmux: add /usr/bin/tmux to /etc/shells

In reply to Romain Naour

When 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

Cc "Yann E. MORIN" <[email protected]>
---
 package/tmux/tmux.mk | 9 +++++++++
 1 file changed, 9 insertions(+)
package/tmux/tmux.mk +9 -0
index 6e03d01..27727fe 100644
@@ -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
#14 lore raw

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/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

Cc "Yann E. MORIN" <[email protected]>
---
 package/tmux/tmux.mk | 9 +++++++++
 1 file changed, 9 insertions(+)
package/tmux/tmux.mk +0 -0
index 6e03d01..27727fe 100644
@@ -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 -0
 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

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.  |
'------------------------------^-------^------------------^--------------------'
#15 lore raw

PATCH 6/7 package/zsh: add /bin/zsh to /etc/shells

In reply to Romain Naour

When 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
index bfd0a1a..c2b0270 100644
@@ -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
#16 lore raw

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/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 +4 -0
index bfd0a1a..c2b0270 100644
@@ -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_SHELLS

Although 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_FIXUPS

Note 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.  |
'------------------------------^-------^------------------^--------------------'
#17 lore raw

PATCH 7/7 package/mksh: add /bin/mksh to /etc/shells

In reply to Romain Naour

When 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
index b5706db..52d4b00 100644
@@ -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
#18 lore raw

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/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 +0 -0
index b5706db..52d4b00 100644
@@ -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 -0
 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

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.  |
'------------------------------^-------^------------------^--------------------'
#19 lore raw

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/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 +0 -0
index b5706db..52d4b00 100644
@@ -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_SHELLS  

Use 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