GNU bug report logs -
#29035
.bashrc updates
Previous Next
Reported by: Marius Bakke <mbakke <at> fastmail.com>
Date: Fri, 27 Oct 2017 23:51:02 UTC
Severity: normal
Done: Marius Bakke <mbakke <at> fastmail.com>
Bug is archived. No further changes may be made.
Full log
Message #20 received at 29035 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:
> Heya,
>
> Marius Bakke <mbakke <at> fastmail.com> skribis:
>
>> * gnu/system/shadow.scm (default-skeletons): Instead of testing for
>> $SSH_CLIENT, check whether '$-' includes the letter 'i'.
>
> That’s an improvement indeed, LGTM!
I realized this will source /etc/profile twice when bash is invoked as
'bash -l -c foo', which isn't great. It also assumes /etc/profile
exists at all, which might not hold true e.g. in a container.
The main motivation for this commit is to make things like
'git-receive-pack', 'rsync' etc work out-of-the-box when installed in
a user profile. The test for `cat` was ineffective on OpenSSH since it
has a default PATH set to "/run/current-system/profile/bin".
I've tested adding ~/.guix-profile/bin to the compiled-in default
OpenSSH PATH instead, and it works. WDYT of this series?
[bashrc.patch (text/x-patch, inline)]
From fc37dd6dfb6beab9cc4e52de7b7c98946125e7cc Mon Sep 17 00:00:00 2001
From: Marius Bakke <mbakke <at> fastmail.com>
Date: Sun, 29 Oct 2017 10:31:25 +0100
Subject: [PATCH 1/3] gnu: openssh: Add user profiles to the default PATH.
* gnu/packages/ssh.scm (openssh)[arguments]<#:configure-flags>: Add
'~/guix-profile/bin' to '--with-default-path' arguments.
---
gnu/packages/ssh.scm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/ssh.scm b/gnu/packages/ssh.scm
index 8317f29cd..2aeeeae1e 100644
--- a/gnu/packages/ssh.scm
+++ b/gnu/packages/ssh.scm
@@ -149,7 +149,9 @@ a server that supports the SSH-2 protocol.")
#:configure-flags `("--sysconfdir=/etc/ssh"
;; Default value of 'PATH' used by sshd.
- "--with-default-path=/run/current-system/profile/bin"
+ ,(string-append "--with-default-path="
+ "/run/current-system/profile/bin:"
+ "~/.guix-profile/bin")
;; configure needs to find krb5-config
,(string-append "--with-kerberos5="
--
2.14.3
From cc817dd809c85571d3e54a226ff16a7a3aa5bdae Mon Sep 17 00:00:00 2001
From: Marius Bakke <mbakke <at> fastmail.com>
Date: Sun, 29 Oct 2017 11:07:49 +0100
Subject: [PATCH 2/3] system: Don't try to source /etc/profile in '.bashrc'
skeleton.
* gnu/system/shadow.scm (default-skeletons)[bashrc]: Remove test for $SSH_CLIENT.
---
gnu/system/shadow.scm | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index 236807c70..f6484f85e 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -157,15 +157,6 @@ if [ -f ~/.bashrc ]; then . ~/.bashrc; fi\n"))
# honor it and otherwise use /bin/sh.
export SHELL
-if [ -n \"$SSH_CLIENT\" -a -z \"`type -P cat`\" ]
-then
- # We are being invoked from a non-interactive SSH session
- # (as in \"ssh host command\") but 'cat' cannot be found
- # in $PATH. Source /etc/profile so we get $PATH and other
- # essential variables.
- source /etc/profile
-fi
-
# Adjust the prompt depending on whether we're in 'guix environment'.
if [ -n \"$GUIX_ENVIRONMENT\" ]
then
--
2.14.3
From 53761ac682cf0de4161c40aa7ec5372a2070c2b2 Mon Sep 17 00:00:00 2001
From: Marius Bakke <mbakke <at> fastmail.com>
Date: Sat, 28 Oct 2017 01:19:01 +0200
Subject: [PATCH 3/3] system: Return early in skeleton '.bashrc' when the shell
is non-interactive.
* gnu/system/shadow.scm (default-skeletons)[bashrc]: Test if $- includes the
letter 'i', and return if it doesn't.
---
gnu/system/shadow.scm | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index f6484f85e..e1ff3c42d 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -157,6 +157,12 @@ if [ -f ~/.bashrc ]; then . ~/.bashrc; fi\n"))
# honor it and otherwise use /bin/sh.
export SHELL
+# If not running interactively, don't do anything else.
+if [[ $- != *i* ]]
+then
+ return
+fi
+
# Adjust the prompt depending on whether we're in 'guix environment'.
if [ -n \"$GUIX_ENVIRONMENT\" ]
then
--
2.14.3
[signature.asc (application/pgp-signature, inline)]
This bug report was last modified 7 years and 207 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.