* [PR PATCH] bash: define SSH_SOURCE_BASHRC
@ 2024-05-11 20:54 tornaria
2024-05-11 23:06 ` tornaria
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: tornaria @ 2024-05-11 20:54 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1227 bytes --]
There is a new pull request by tornaria against master on the void-packages repository
https://github.com/tornaria/void-packages bash
https://github.com/void-linux/void-packages/pull/50280
bash: define SSH_SOURCE_BASHRC
This makes bash agree with its documentation at
https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
Bash attempts to determine when it is being run with its standard
input connected to a network connection, as when executed by the
historical remote shell daemon, usually rshd, or the secure shell
daemon sshd. If Bash determines it is being run non-interactively in
this fashion, it reads and executes commands from ~/.bashrc, if that
file exists and is readable. [...]
Notes:
- Disabled by upstream in 2.05a (2001), manual never changed
- This is enabled in Debian, Fedora, Gentoo, ...
To avoid this feature, add
```
[[ $- != *i* ]] && return
```
to the top of ~/.bashrc to skip running it in non-interactive mode.
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **YES**
A patch file from https://github.com/void-linux/void-packages/pull/50280.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-bash-50280.patch --]
[-- Type: text/x-diff, Size: 2168 bytes --]
From 2480028d65ac1e14e753664150c647bf9b3b7325 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sat, 11 May 2024 17:22:47 -0300
Subject: [PATCH] bash: define SSH_SOURCE_BASHRC
This makes bash agree with its documentation at
https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
Bash attempts to determine when it is being run with its standard
input connected to a network connection, as when executed by the
historical remote shell daemon, usually rshd, or the secure shell
daemon sshd. If Bash determines it is being run non-interactively in
this fashion, it reads and executes commands from ~/.bashrc, if that
file exists and is readable. [...]
Notes:
- Disabled by upstream in 2.05a (2001), manual never changed
- This is enabled in Debian, Fedora, Gentoo, ...
---
srcpkgs/bash/template | 4 ++--
srcpkgs/bash/update | 5 -----
2 files changed, 2 insertions(+), 7 deletions(-)
delete mode 100644 srcpkgs/bash/update
diff --git a/srcpkgs/bash/template b/srcpkgs/bash/template
index a977c3a7d5c0af..03a5652b21e9e5 100644
--- a/srcpkgs/bash/template
+++ b/srcpkgs/bash/template
@@ -1,7 +1,7 @@
# Template file for 'bash'
pkgname=bash
version=5.2.21
-revision=1
+revision=2
build_style=gnu-configure
configure_args="--without-bash-malloc --with-curses --without-installed-readline"
make_build_args="TERMCAP_LIB=${XBPS_CROSS_BASE}/usr/lib/libncursesw.a"
@@ -24,7 +24,7 @@ alternatives="
sh:sh:/usr/bin/bash
sh:sh.1:/usr/share/man/man1/bash.1"
-CFLAGS="-DNON_INTERACTIVE_LOGIN_SHELLS -DSYS_BASHRC='\"/etc/bash/bashrc\"'"
+CFLAGS="-DSSH_SOURCE_BASHRC -DNON_INTERACTIVE_LOGIN_SHELLS -DSYS_BASHRC='\"/etc/bash/bashrc\"'"
post_install() {
rm -r ${DESTDIR}/usr/share/doc
diff --git a/srcpkgs/bash/update b/srcpkgs/bash/update
deleted file mode 100644
index 89e82249c5e3c2..00000000000000
--- a/srcpkgs/bash/update
+++ /dev/null
@@ -1,5 +0,0 @@
-site="http://git.savannah.gnu.org/cgit/bash.git/log/"
-pattern="Bash-\K\d(\.\d)+( patch \d+|-testing)?"
-version="$_bash_distver"
-[ ! -z "$_bash_patchlevel" ] && version+=" patch $_bash_patchlevel"
-ignore="*testing"
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bash: define SSH_SOURCE_BASHRC
2024-05-11 20:54 [PR PATCH] bash: define SSH_SOURCE_BASHRC tornaria
@ 2024-05-11 23:06 ` tornaria
2024-05-13 21:57 ` tornaria
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: tornaria @ 2024-05-11 23:06 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 548 bytes --]
New comment by tornaria on void-packages repository
https://github.com/void-linux/void-packages/pull/50280#issuecomment-2106052686
Comment:
Note also that the `DEFAULT_PATH_VALUE` is set to
```
"/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:."
```
I wonder if we should remove the trailing `.` there and/or reorder to match our `/etc/profile`.
This default path applies only if `PATH` is unset when starting bash as in
```
$ env -i bash -c 'echo $PATH'
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:.
```
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bash: define SSH_SOURCE_BASHRC
2024-05-11 20:54 [PR PATCH] bash: define SSH_SOURCE_BASHRC tornaria
2024-05-11 23:06 ` tornaria
@ 2024-05-13 21:57 ` tornaria
2024-05-19 0:03 ` ahesford
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: tornaria @ 2024-05-13 21:57 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]
New comment by tornaria on void-packages repository
https://github.com/void-linux/void-packages/pull/50280#issuecomment-2108871504
Comment:
The following would "fix" the default `PATH` in bash (to exclude `.`):
```diff
--- a/srcpkgs/bash/template
+++ b/srcpkgs/bash/template
@@ -24,7 +24,11 @@ alternatives="
sh:sh:/usr/bin/bash
sh:sh.1:/usr/share/man/man1/bash.1"
-CFLAGS="-DSSH_SOURCE_BASHRC -DNON_INTERACTIVE_LOGIN_SHELLS -DSYS_BASHRC='\"/etc/bash/bashrc\"'"
+CFLAGS="\
+ -DSSH_SOURCE_BASHRC \
+ -DNON_INTERACTIVE_LOGIN_SHELLS \
+ -DDEFAULT_PATH_VALUE='\"/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin\"' \
+ -DSYS_BASHRC='\"/etc/bash/bashrc\"'"
post_install() {
rm -r ${DESTDIR}/usr/share/doc
```
It's not a very common situation to start bash with unset `PATH`, so this is not that important.
----
On the other hand, adding `-DSSH_SOURCE_BASAHRC` is IMHO very, very, necessary, and the only way (afaik) to have a reasonable bash startup that works fine with ssh (e.g. to setup `PATH`, etc).
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bash: define SSH_SOURCE_BASHRC
2024-05-11 20:54 [PR PATCH] bash: define SSH_SOURCE_BASHRC tornaria
2024-05-11 23:06 ` tornaria
2024-05-13 21:57 ` tornaria
@ 2024-05-19 0:03 ` ahesford
2024-05-19 16:58 ` tornaria
2024-06-13 23:28 ` [PR PATCH] [Closed]: " abenson
4 siblings, 0 replies; 6+ messages in thread
From: ahesford @ 2024-05-19 0:03 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 414 bytes --]
New comment by ahesford on void-packages repository
https://github.com/void-linux/void-packages/pull/50280#issuecomment-2119034744
Comment:
I'm torn about this. On the one hand, I've often been frustrated working around default PATH settings to get access to remote executables in non-standard locations. On the other hand, having a non-interactive shell source the interactive configuration seems a bit skeevy.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bash: define SSH_SOURCE_BASHRC
2024-05-11 20:54 [PR PATCH] bash: define SSH_SOURCE_BASHRC tornaria
` (2 preceding siblings ...)
2024-05-19 0:03 ` ahesford
@ 2024-05-19 16:58 ` tornaria
2024-06-13 23:28 ` [PR PATCH] [Closed]: " abenson
4 siblings, 0 replies; 6+ messages in thread
From: tornaria @ 2024-05-19 16:58 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 576 bytes --]
New comment by tornaria on void-packages repository
https://github.com/void-linux/void-packages/pull/50280#issuecomment-2119299995
Comment:
I'm not sure about a reasonable alternative. The closest one is:
- set `PermitUserEnvironment BASH_ENV` in `sshd_config` (needs root)
- set `BASH_ENV=~/.bashrc` in `~/.ssh/environment`
However, this will end up running `~/.bashrc` also in subshells, which is not what we want.
The original feature, when `SSH_SOURCE_BASHRC` is set, will source `~/.bashrc` only when `SHLVL=1`, so in principle it will only get run once per ssh.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PR PATCH] [Closed]: bash: define SSH_SOURCE_BASHRC
2024-05-11 20:54 [PR PATCH] bash: define SSH_SOURCE_BASHRC tornaria
` (3 preceding siblings ...)
2024-05-19 16:58 ` tornaria
@ 2024-06-13 23:28 ` abenson
4 siblings, 0 replies; 6+ messages in thread
From: abenson @ 2024-06-13 23:28 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]
There's a closed pull request on the void-packages repository
bash: define SSH_SOURCE_BASHRC
https://github.com/void-linux/void-packages/pull/50280
Description:
This makes bash agree with its documentation at
https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
```
Bash attempts to determine when it is being run with its standard
input connected to a network connection, as when executed by the
historical remote shell daemon, usually rshd, or the secure shell
daemon sshd. If Bash determines it is being run non-interactively in
this fashion, it reads and executes commands from ~/.bashrc, if that
file exists and is readable. [...]
```
Notes:
- Disabled by upstream in 2.05a (2001), manual never changed
- This is enabled in Debian, Fedora, Gentoo, ...
To avoid this feature, add
```
[[ $- != *i* ]] && return
```
to the top of ~/.bashrc to skip running it in non-interactive mode.
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **YES**
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-06-13 23:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-11 20:54 [PR PATCH] bash: define SSH_SOURCE_BASHRC tornaria
2024-05-11 23:06 ` tornaria
2024-05-13 21:57 ` tornaria
2024-05-19 0:03 ` ahesford
2024-05-19 16:58 ` tornaria
2024-06-13 23:28 ` [PR PATCH] [Closed]: " abenson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).