Skip to contentSkip to conversation

package/bash: add /bin/bash to /etc/shells

PATCH New Romain Naour 4 participants 9 messages Jan 11, 2018 – Jan 14, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/bash: add /bin/bash to /etc/shells

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

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

---
The same issue can happend with other shells.

---
 package/bash/bash.mk | 3 +++
 1 file changed, 3 insertions(+)
package/bash/bash.mk +3 -0
index 089d062..eec6559 100644
@@ -40,10 +40,13 @@ 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
+	echo "/bin/bash" >> $(TARGET_DIR)/etc/shells
 endef
 
 $(eval $(autotools-package))
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 package/bash: add /bin/bash to /etc/shells

Romain, All,

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

Quoted 20 lines

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

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

---
The same issue can happend with other shells.

---
 package/bash/bash.mk | 3 +++
 1 file changed, 3 insertions(+)
package/bash/bash.mk +0 -0
index 089d062..eec6559 100644

package/bash/bash.mk endif · line 49

Quoted 10 lines
package/bash/bash.mk +3 -0
@@ -40,10 +40,13 @@ 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
+	echo "/bin/bash" >> $(TARGET_DIR)/etc/shells

What if the user uses a custom skeleton and bash is already listed there?

I would do:

    grep -E '^/bin/bash$' $(TARGET_DIR)/etc/shells >/dev/null 2>&1 \
    || echo "/bin/bash" >> $(TARGET_DIR)/etc/shells

That way, we only install it if not already present.

Regards,
Yann E. MORIN.

Quoted 6 lines
package/bash/bash.mk +0 -0
 endef
 
 $(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.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH 1/1 package/bash: add /bin/bash to /etc/shells

Hello,

Quoted 3 lines · Yann E. MORIN

I would do:

    grep -E '^/bin/bash$' $(TARGET_DIR)/etc/shells >/dev/null 2>&1 \

grep -q ?

Quoted 3 lines
    || echo "/bin/bash" >> $(TARGET_DIR)/etc/shells

That way, we only install it if not already present.

Otherwise, yes, agreed.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#3 lore raw

PATCH 1/1 package/bash: add /bin/bash to /etc/shells

Hi Yann, Thomas,

Le 12/01/2018 ? 09:59, Thomas Petazzoni a ?crit?:

Quoted 8 lines

Hello,

Quoted 3 lines · Yann E. MORIN

I would do:

    grep -E '^/bin/bash$' $(TARGET_DIR)/etc/shells >/dev/null 2>&1 \
Quoted 7 lines

grep -q ?

Quoted 3 lines
    || echo "/bin/bash" >> $(TARGET_DIR)/etc/shells

That way, we only install it if not already present.

Otherwise, yes, agreed.

Ok, I'll fix this.
But the same issue should happen with other shell (not tested though).

For example, it ash (busybox) is not the default shell and a user use it to login, it will be rejected.
So busybox should also add /bin/ash in /etc/shells.

Thoughts?

Best regards,
Romain

Quoted 3 lines

Thomas

#4 lore raw

PATCH 1/1 package/bash: add /bin/bash to /etc/shells

Romain, All,

On 2018-01-12 10:06 +0100, Romain Naour spake thusly:

Quoted 6 lines

Le 12/01/2018 ? 09:59, Thomas Petazzoni a ?crit?:

Quoted 3 lines · Yann E. MORIN
Quoted 2 lines

I would do:

    grep -E '^/bin/bash$' $(TARGET_DIR)/etc/shells >/dev/null 2>&1 \

Ok, I'll fix this.
But the same issue should happen with other shell (not tested though).

You are fixing bash with thispatch. Other patches could fix the other shells. ;-)

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 1/1 package/bash: add /bin/bash to /etc/shells

In reply to Thomas Petazzoni

Thomas, All,

On 2018-01-12 09:59 +0100, Thomas Petazzoni spake thusly:

Quoted 3 lines · Yann E. MORIN
Quoted 1 line
    grep -E '^/bin/bash$' $(TARGET_DIR)/etc/shells >/dev/null 2>&1 \

grep -q ?

-q is not POSIX. Redirecting is guaranteed to always work.

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

PATCH 1/1 package/bash: add /bin/bash to /etc/shells

Hello,

Quoted 6 lines · Yann E. MORIN

On 2018-01-12 09:59 +0100, Thomas Petazzoni spake thusly:

Quoted 3 lines · Yann E. MORIN
Quoted 1 line
    grep -E '^/bin/bash$' $(TARGET_DIR)/etc/shells >/dev/null 2>&1 \  

grep -q ?

-q is not POSIX. Redirecting is guaranteed to always work.

Knowing that Buildroot only supports Linux hosts, do we care about -q not being POSIX ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#7 lore raw

PATCH 1/1 package/bash: add /bin/bash to /etc/shells

Thomas, All,

On 2018-01-12 21:21 +0100, Thomas Petazzoni spake thusly:

Quoted 10 lines · Yann E. MORIN
Quoted 6 lines

On 2018-01-12 09:59 +0100, Thomas Petazzoni spake thusly:

Quoted 3 lines · Yann E. MORIN
Quoted 1 line
    grep -E '^/bin/bash$' $(TARGET_DIR)/etc/shells >/dev/null 2>&1 \  

grep -q ?

-q is not POSIX. Redirecting is guaranteed to always work.

Knowing that Buildroot only supports Linux hosts, do we care about -q not being POSIX ?

Linux host does not mean GNU extensions. For example, Alpine is using busybox, so not GNU grep...

But I back-pedal on this, it seems that -q has been added to POSIX now:

    http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html

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

PATCH 1/1 package/bash: add /bin/bash to /etc/shells

Quoted 12 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Thomas, All,
On 2018-01-12 21:21 +0100, Thomas Petazzoni spake thusly:

Quoted 8 lines · Yann E. MORIN
Quoted 6 lines

On 2018-01-12 09:59 +0100, Thomas Petazzoni spake thusly:

Quoted 3 lines · Yann E. MORIN
Quoted 1 line
    grep -E '^/bin/bash$' $(TARGET_DIR)/etc/shells >/dev/null 2>&1 \  

grep -q ?

-q is not POSIX. Redirecting is guaranteed to always work.

Quoted 8 lines
Quoted 2 lines

Knowing that Buildroot only supports Linux hosts, do we care about -q not being POSIX ?

Linux host does not mean GNU extensions. For example, Alpine is using busybox, so not GNU grep...

But I back-pedal on this, it seems that -q has been added to POSIX now:

    http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html

And busybox grep DOES support -q.

Signature · 1 line
Bye, Peter Korsgaard