Skip to contentSkip to conversation

Add /etc/shells handling

PATCH New Romain Naour 3 participants 21 messages Jan 19, 2018 – May 3, 2018

lore
Share & tools
lore
#0 lore raw

v3 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 TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build.

Update bach package to use a TARGET_FINALIZE_HOOKS.

[1] 4d279697afbf8fb295274784103be2b837113d5e

Romain Naour (9):
package/skeleton-init-common: add /bin/sh to /etc/shells package/busybox: add /bin/{a,hu}sh 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/bash: add missing double-dollar for /etc/shells package/bash: use target finalize hook

 package/bash/bash.mk                                 | 10 +++++++---
 package/busybox/busybox.mk                           | 14 ++++++++++++++
 package/dash/dash.mk                                 |  8 ++++++++
 package/mksh/mksh.mk                                 |  8 ++++++++
 package/screen/screen.mk                             |  9 ++++++++-
 package/skeleton-init-common/skeleton-init-common.mk |  7 +++++++
 package/tmux/tmux.mk                                 |  8 ++++++++
 package/zsh/zsh.mk                                   |  8 ++++++++
 8 files changed, 68 insertions(+), 4 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/9 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.

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /bin/sh (Yann)
remove empty /etc/shells from skeleton (Yann, Peter) move the hook right after it's defined (Yann)

---
 package/skeleton-init-common/skeleton-init-common.mk | 7 +++++++
 1 file changed, 7 insertions(+)
package/skeleton-init-common/skeleton-init-common.mk +7 -0
index 8228a81..e8a0522 100644
@@ -79,6 +79,13 @@ 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 connection. 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
+SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_ADD_SH_TO_SHELLS
 ifneq ($(SKELETON_INIT_COMMON_BIN_SH),)
 define SKELETON_INIT_COMMON_SET_BIN_SH
 	ln -sf $(SKELETON_INIT_COMMON_BIN_SH) $(TARGET_DIR)/bin/sh
Signature · 1 line
2.7.4
#2 lore raw

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

Romain, All,

On 2018-01-19 11:15 +0100, Romain Naour spake thusly:

Quoted 4 lines

Add the default shell /bin/sh to /etc/shells only if BR2_SYSTEM_BIN_SH_NONE is not selected.

Regards,
Yann E. MORIN.

Quoted 36 lines

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /bin/sh (Yann)
remove empty /etc/shells from skeleton (Yann, Peter) move the hook right after it's defined (Yann)

---
 package/skeleton-init-common/skeleton-init-common.mk | 7 +++++++
 1 file changed, 7 insertions(+)
package/skeleton-init-common/skeleton-init-common.mk +7 -0
index 8228a81..e8a0522 100644
@@ -79,6 +79,13 @@ 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 connection. 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
+SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_ADD_SH_TO_SHELLS
 ifneq ($(SKELETON_INIT_COMMON_BIN_SH),)
 define SKELETON_INIT_COMMON_SET_BIN_SH
 	ln -sf $(SKELETON_INIT_COMMON_BIN_SH) $(TARGET_DIR)/bin/sh
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 v3 2/9 package/busybox: add /bin/{a, hu}sh to /etc/shells

In reply to Romain Naour

When ash (busybox) is selected, /bin/{a,hu}sh is not added to /etc/shells (see man shells). So, login tools like dropbear reject the ssh connections for users using {a,hu}sh as shell in /etc/passwd.

buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /bin/{a,hu}sh (Yann)
add hush handling
msh has been removed from Busybox 1.28
https://git.busybox.net/busybox/commit/?id=2e989ef232e35750df573898077dd356003705b2
msh is unlikely used.

---
 package/busybox/busybox.mk | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
package/busybox/busybox.mk +14 -0
index d0bbd3f..145bc7c 100644
@@ -258,6 +258,20 @@ define BUSYBOX_INSTALL_TELNET_SCRIPT
 	fi
 endef
 
+# Add /bin/{a,hu}sh to /etc/shells otherwise some login tools like dropbear
+# can reject the user connection. See man shells.
+define BUSYBOX_INSTALL_ADD_TO_SHELLS
+	if grep -q CONFIG_ASH=y $(@D)/.config; then \
+		grep -qsE '^/bin/ash$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/bin/ash" >> $(TARGET_DIR)/etc/shells; \
+	fi
+	if grep -q CONFIG_HUSH=y $(@D)/.config; then \
+		grep -qsE '^/bin/hush$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/bin/hush" >> $(TARGET_DIR)/etc/shells; \
+	fi
+endef
+BUSYBOX_TARGET_FINALIZE_HOOKS += BUSYBOX_INSTALL_ADD_TO_SHELLS
+
 # 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
Signature · 1 line
2.7.4
#4 lore raw

PATCH v3 2/9 package/busybox: add /bin/{a, hu}sh to /etc/shells

Romain, All,

On 2018-01-19 11:15 +0100, Romain Naour spake thusly:

Quoted 7 lines

When ash (busybox) is selected, /bin/{a,hu}sh is not added to /etc/shells (see man shells). So, login tools like dropbear reject the ssh connections for users using {a,hu}sh as shell in /etc/passwd.

buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected

Regards,
Yann E. MORIN.

Quoted 45 lines

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /bin/{a,hu}sh (Yann)
add hush handling
msh has been removed from Busybox 1.28
https://git.busybox.net/busybox/commit/?id=2e989ef232e35750df573898077dd356003705b2
msh is unlikely used.

---
 package/busybox/busybox.mk | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
package/busybox/busybox.mk +14 -0
index d0bbd3f..145bc7c 100644
@@ -258,6 +258,20 @@ define BUSYBOX_INSTALL_TELNET_SCRIPT
 	fi
 endef
 
+# Add /bin/{a,hu}sh to /etc/shells otherwise some login tools like dropbear
+# can reject the user connection. See man shells.
+define BUSYBOX_INSTALL_ADD_TO_SHELLS
+	if grep -q CONFIG_ASH=y $(@D)/.config; then \
+		grep -qsE '^/bin/ash$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/bin/ash" >> $(TARGET_DIR)/etc/shells; \
+	fi
+	if grep -q CONFIG_HUSH=y $(@D)/.config; then \
+		grep -qsE '^/bin/hush$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/bin/hush" >> $(TARGET_DIR)/etc/shells; \
+	fi
+endef
+BUSYBOX_TARGET_FINALIZE_HOOKS += BUSYBOX_INSTALL_ADD_TO_SHELLS
+
 # 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
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.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH v3 3/9 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 connections for users using dash as shell in /etc/passwd.

buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /bin/dash (Yann)

---
 package/dash/dash.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/dash/dash.mk +8 -0
index c8b4164..2a3fd0d 100644
@@ -13,4 +13,12 @@ define DASH_INSTALL_TARGET_CMDS
 	$(INSTALL) -m 0755 $(@D)/src/dash $(TARGET_DIR)/bin/dash
 endef
 
+# Add /bin/dash to /etc/shells otherwise some login tools like dropbear
+# can reject the user connection. See man shells.
+define DASH_ADD_DASH_TO_SHELLS
+	grep -qsE '^/bin/dash$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/bin/dash" >> $(TARGET_DIR)/etc/shells
+endef
+DASH_TARGET_FINALIZE_HOOKS += DASH_ADD_DASH_TO_SHELLS
+
 $(eval $(autotools-package))
Signature · 1 line
2.7.4
#6 lore raw

PATCH v3 3/9 package/dash: add /etc/dash to /etc/shells

Romain, All,

On 2018-01-19 11:15 +0100, Romain Naour spake thusly:

Quoted 7 lines

When dash is selected, /bin/dash is not added to /etc/shells (see man shells). So, login tools like dropbear reject the ssh connections for users using dash as shell in /etc/passwd.

buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected

Regards,
Yann E. MORIN.

Quoted 33 lines

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /bin/dash (Yann)

---
 package/dash/dash.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/dash/dash.mk +8 -0
index c8b4164..2a3fd0d 100644
@@ -13,4 +13,12 @@ define DASH_INSTALL_TARGET_CMDS
 	$(INSTALL) -m 0755 $(@D)/src/dash $(TARGET_DIR)/bin/dash
 endef
 
+# Add /bin/dash to /etc/shells otherwise some login tools like dropbear
+# can reject the user connection. See man shells.
+define DASH_ADD_DASH_TO_SHELLS
+	grep -qsE '^/bin/dash$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/bin/dash" >> $(TARGET_DIR)/etc/shells
+endef
+DASH_TARGET_FINALIZE_HOOKS += DASH_ADD_DASH_TO_SHELLS
+
 $(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.  |
'------------------------------^-------^------------------^--------------------'
#7 lore raw

PATCH v3 4/9 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 connections for users using screen as shell in /etc/passwd.

buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /usr/bin/screen (Yann)
remove /etc/shells handling from SCREEN_INSTALL_SCREENRC (Yann) fix conding style (Yann)

---
 package/screen/screen.mk | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
package/screen/screen.mk +8 -1
index 8d67c04..37d4336 100644
@@ -17,7 +17,14 @@ 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
 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 connection. See man shells.
+define SCREEN_ADD_SCREEN_TO_SHELLS
+	grep -qsE '^/usr/bin/screen$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/usr/bin/screen" >> $(TARGET_DIR)/etc/shells
+endef
+SCREEN_TARGET_FINALIZE_HOOKS += SCREEN_ADD_SCREEN_TO_SHELLS
+
 $(eval $(autotools-package))
Signature · 1 line
2.7.4
#8 lore raw

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

Romain, All,

On 2018-01-19 11:15 +0100, Romain Naour spake thusly:

Quoted 23 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 connections for users using screen as shell in /etc/passwd.

buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /usr/bin/screen (Yann)
remove /etc/shells handling from SCREEN_INSTALL_SCREENRC (Yann) fix conding style (Yann)

---
 package/screen/screen.mk | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
package/screen/screen.mk +0 -0
index 8d67c04..37d4336 100644

package/screen/screen.mk SCREEN_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) SCREEN=screen install_bin · line 20

Quoted 4 lines
package/screen/screen.mk +0 -1
@@ -17,7 +17,14 @@ 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
 endef
-

Spurious empty line removal.

package/screen/screen.mk SCREEN_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) SCREEN=screen install_bin · line 28

Quoted 9 lines
package/screen/screen.mk +7 -0
 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 connection. See man shells.
+define SCREEN_ADD_SCREEN_TO_SHELLS
+	grep -qsE '^/usr/bin/screen$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/usr/bin/screen" >> $(TARGET_DIR)/etc/shells
+endef
+SCREEN_TARGET_FINALIZE_HOOKS += SCREEN_ADD_SCREEN_TO_SHELLS

In this case, I would have kept the existing code-style, and I would have left an empty line between the hook declaration and registration (even though my preference is to do as you did, I still think we should keep existign code-style, unless too ugly).

Otherwise:

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

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

Hello,

Quoted 11 lines · Yann E. MORIN

package/screen/screen.mk SCREEN_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) SCREEN=screen install_bin · line 20

Quoted 9 lines
package/screen/screen.mk +0 -1
index 8d67c04..37d4336 100644
@@ -17,7 +17,14 @@ 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
 endef
-  

Spurious empty line removal.

Indeed, but I believe it's fairly OK, as it allows the hook addition below to follow the coding style. I've updated the commit log to include the following paragraph:

While at it, drop an empty line between an existing hook definition and its registration, to be consistent with the coding style used in the rest of Buildroot.

Thanks for the review!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#10 lore raw

PATCH v3 5/9 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 connections 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]>

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /usr/bin/tmux (Yann)

---
 package/tmux/tmux.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/tmux/tmux.mk +8 -0
index 6e03d01..e380227 100644
@@ -10,4 +10,12 @@ 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 connection. See man shells.
+define TMUX_ADD_TMUX_TO_SHELLS
+	grep -qsE '^/usr/bin/tmux$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/usr/bin/tmux" >> $(TARGET_DIR)/etc/shells
+endef
+TMUX_TARGET_FINALIZE_HOOKS += TMUX_ADD_TMUX_TO_SHELLS
+
 $(eval $(autotools-package))
Signature · 1 line
2.7.4
#11 lore raw

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

Romain, All,

On 2018-01-19 11:15 +0100, Romain Naour spake thusly:

Quoted 8 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 connections 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]>

Regards,
Yann E. MORIN.

Quoted 29 lines

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /usr/bin/tmux (Yann)

---
 package/tmux/tmux.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/tmux/tmux.mk +8 -0
index 6e03d01..e380227 100644
@@ -10,4 +10,12 @@ 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 connection. See man shells.
+define TMUX_ADD_TMUX_TO_SHELLS
+	grep -qsE '^/usr/bin/tmux$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/usr/bin/tmux" >> $(TARGET_DIR)/etc/shells
+endef
+TMUX_TARGET_FINALIZE_HOOKS += TMUX_ADD_TMUX_TO_SHELLS
+
 $(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.  |
'------------------------------^-------^------------------^--------------------'
#12 lore raw

PATCH v3 6/9 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 connections for users using zsh as shell in /etc/passwd.

buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /bin/zsh (Yann)

---
 package/zsh/zsh.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/zsh/zsh.mk +8 -0
index bfd0a1a..e19a896 100644
@@ -34,6 +34,14 @@ else
 ZSH_CONF_OPTS += --disable-pcre
 endif
 
+# Add /bin/zsh to /etc/shells otherwise some login tools like dropbear
+# can reject the user connection. See man shells.
+define ZSH_ADD_ZSH_TO_SHELLS
+	grep -qsE '^/bin/zsh$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/bin/zsh" >> $(TARGET_DIR)/etc/shells
+endef
+ZSH_TARGET_FINALIZE_HOOKS += ZSH_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)
Signature · 1 line
2.7.4
#13 lore raw

PATCH v3 6/9 package/zsh: add /bin/zsh to /etc/shells

Romain, All,

On 2018-01-19 11:15 +0100, Romain Naour spake thusly:

Quoted 7 lines

When zsh is selected, /bin/zsh is not added to /etc/shells (see man shells). So, login tools like dropbear reject the ssh connections for users using zsh as shell in /etc/passwd.

buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected

Regards,
Yann E. MORIN.

Quoted 35 lines

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /bin/zsh (Yann)

---
 package/zsh/zsh.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/zsh/zsh.mk +8 -0
index bfd0a1a..e19a896 100644
@@ -34,6 +34,14 @@ else
 ZSH_CONF_OPTS += --disable-pcre
 endif
 
+# Add /bin/zsh to /etc/shells otherwise some login tools like dropbear
+# can reject the user connection. See man shells.
+define ZSH_ADD_ZSH_TO_SHELLS
+	grep -qsE '^/bin/zsh$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/bin/zsh" >> $(TARGET_DIR)/etc/shells
+endef
+ZSH_TARGET_FINALIZE_HOOKS += ZSH_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)
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.  |
'------------------------------^-------^------------------^--------------------'
#14 lore raw

PATCH v3 7/9 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 connections for users using mksh as shell in /etc/passwd.

buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /bin/mksh (Yann)

---
 package/mksh/mksh.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/mksh/mksh.mk +8 -0
index b5706db..4fa0e02 100644
@@ -21,4 +21,12 @@ 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 connection. See man shells.
+define MKSH_ADD_MKSH_TO_SHELLS
+	grep -qsE '^/bin/mksh$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/bin/mksh" >> $(TARGET_DIR)/etc/shells
+endef
+MKSH_TARGET_FINALIZE_HOOKS += MKSH_ADD_MKSH_TO_SHELLS
+
 $(eval $(generic-package))
Signature · 1 line
2.7.4
#15 lore raw

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

Romain, All,

On 2018-01-19 11:15 +0100, Romain Naour spake thusly:

Quoted 7 lines

When mksh is selected, /bin/mksh is not added to /etc/shells (see man shells). So, login tools like dropbear reject the ssh connections for users using mksh as shell in /etc/passwd.

buildroot authpriv.warn dropbear[853]: User 'kubu' has invalid shell, rejected

Regards,
Yann E. MORIN.

Quoted 33 lines

---
v3: Fix typo (Thomas)
Use TARGET_FINALIZE_HOOKS to avoid issues with the upcoming top-level parallel build (Arnout)
v2: add double-dollar after /bin/mksh (Yann)

---
 package/mksh/mksh.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/mksh/mksh.mk +8 -0
index b5706db..4fa0e02 100644
@@ -21,4 +21,12 @@ 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 connection. See man shells.
+define MKSH_ADD_MKSH_TO_SHELLS
+	grep -qsE '^/bin/mksh$$' $(TARGET_DIR)/etc/shells \
+		|| echo "/bin/mksh" >> $(TARGET_DIR)/etc/shells
+endef
+MKSH_TARGET_FINALIZE_HOOKS += MKSH_ADD_MKSH_TO_SHELLS
+
 $(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.  |
'------------------------------^-------^------------------^--------------------'
#16 lore raw

PATCH v3 8/9 package/bash: add missing double-dollar for /etc/shells

In reply to Romain Naour

Commit 4d279697afbf8fb295274784103be2b837113d5e missed one comment from Yann E. Morin about the double-dollar.

---
 package/bash/bash.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/bash/bash.mk +1 -1
index 03f8f28..ab6b43b 100644
@@ -46,7 +46,7 @@ define BASH_INSTALL_TARGET_CMDS
 	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
 		DESTDIR=$(TARGET_DIR) exec_prefix=/ install
 	rm -f $(TARGET_DIR)/bin/bashbug
-	grep -qsE '^/bin/bash' $(TARGET_DIR)/etc/shells \
+	grep -qsE '^/bin/bash$$' $(TARGET_DIR)/etc/shells \
 		|| echo "/bin/bash" >> $(TARGET_DIR)/etc/shells
 endef
 
Signature · 1 line
2.7.4
#17 lore raw

PATCH v3 8/9 package/bash: add missing double-dollar for /etc/shells

Romain, All,

On 2018-01-19 11:15 +0100, Romain Naour spake thusly:

Quoted 4 lines

Commit 4d279697afbf8fb295274784103be2b837113d5e missed one comment from Yann E. Morin about the double-dollar.

Regards,
Yann E. MORIN.

Quoted 24 lines
---
 package/bash/bash.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/bash/bash.mk +1 -1
index 03f8f28..ab6b43b 100644
@@ -46,7 +46,7 @@ define BASH_INSTALL_TARGET_CMDS
 	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
 		DESTDIR=$(TARGET_DIR) exec_prefix=/ install
 	rm -f $(TARGET_DIR)/bin/bashbug
-	grep -qsE '^/bin/bash' $(TARGET_DIR)/etc/shells \
+	grep -qsE '^/bin/bash$$' $(TARGET_DIR)/etc/shells \
 		|| echo "/bin/bash" >> $(TARGET_DIR)/etc/shells
 endef
 
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.  |
'------------------------------^-------^------------------^--------------------'
#18 lore raw

PATCH v3 9/9 package/bash: use target finalize hook

In reply to Romain Naour

Arnout reported an issue with the upcoming top-level parallel build. The file /etc/shells can be modified by several packages (shell providers)

Cc Arnout Vandecappelle <[email protected]>
---
 package/bash/bash.mk | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
package/bash/bash.mk +6 -2
index ab6b43b..12f33f1 100644
@@ -40,14 +40,18 @@ endif
 endif
 
 # Make /bin/sh -> bash (no other shell, better than busybox shells)
-# Add /bin/bash to /etc/shells otherwise some login tools like dropbear
-# can reject the user connexion. See man shells.
 define BASH_INSTALL_TARGET_CMDS
 	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
 		DESTDIR=$(TARGET_DIR) exec_prefix=/ install
 	rm -f $(TARGET_DIR)/bin/bashbug
+endef
+
+# Add /bin/bash to /etc/shells otherwise some login tools like dropbear
+# can reject the user connection. See man shells.
+define BASH_ADD_MKSH_TO_SHELLS
 	grep -qsE '^/bin/bash$$' $(TARGET_DIR)/etc/shells \
 		|| echo "/bin/bash" >> $(TARGET_DIR)/etc/shells
 endef
+BASH_TARGET_FINALIZE_HOOKS += BASH_ADD_MKSH_TO_SHELLS
 
 $(eval $(autotools-package))
Signature · 1 line
2.7.4
#19 lore raw

PATCH v3 9/9 package/bash: use target finalize hook

Romain, All,

On 2018-01-19 11:15 +0100, Romain Naour spake thusly:

Quoted 5 lines

Arnout reported an issue with the upcoming top-level parallel build. The file /etc/shells can be modified by several packages (shell providers)

Cc Arnout Vandecappelle <[email protected]>

package/bash/bash.mk endif · line 42

Quoted 12 lines
---
 package/bash/bash.mk | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
package/bash/bash.mk +0 -0
index ab6b43b..12f33f1 100644
@@ -40,14 +40,18 @@ endif
 endif
 
 # Make /bin/sh -> bash (no other shell, better than busybox shells)

While reviewing this patch, I was really puzzled at what this comment meant. It turns out I was not careful years ago when I made /bin/sh configurable.

Patch sent: https://patchwork.ozlabs.org/patch/868907/

Regards,
Yann E. MORIN.

Quoted 24 lines
package/bash/bash.mk +6 -2
-# Add /bin/bash to /etc/shells otherwise some login tools like dropbear
-# can reject the user connexion. See man shells.
 define BASH_INSTALL_TARGET_CMDS
 	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
 		DESTDIR=$(TARGET_DIR) exec_prefix=/ install
 	rm -f $(TARGET_DIR)/bin/bashbug
+endef
+
+# Add /bin/bash to /etc/shells otherwise some login tools like dropbear
+# can reject the user connection. See man shells.
+define BASH_ADD_MKSH_TO_SHELLS
 	grep -qsE '^/bin/bash$$' $(TARGET_DIR)/etc/shells \
 		|| echo "/bin/bash" >> $(TARGET_DIR)/etc/shells
 endef
+BASH_TARGET_FINALIZE_HOOKS += BASH_ADD_MKSH_TO_SHELLS
 
 $(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.  |
'------------------------------^-------^------------------^--------------------'
#20 lore raw

v3 cover Add /etc/shells handling

In reply to Romain Naour

Hello,

Quoted 10 lines · Romain Naour

Romain Naour (9):
package/skeleton-init-common: add /bin/sh to /etc/shells package/busybox: add /bin/{a,hu}sh 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/bash: add missing double-dollar for /etc/shells package/bash: use target finalize hook

All applied, thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com