From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8kfN-0001ce-Lj for guix-patches@gnu.org; Sun, 29 Oct 2017 06:18:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8kfK-0002os-FQ for guix-patches@gnu.org; Sun, 29 Oct 2017 06:18:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:59317) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e8kfK-0002oI-9y for guix-patches@gnu.org; Sun, 29 Oct 2017 06:18:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e8kfJ-000450-Up for guix-patches@gnu.org; Sun, 29 Oct 2017 06:18:01 -0400 Subject: [bug#29035] [PATCH 1/2] skel: Test for interactive shell instead of $SSH_CLIENT in .bashrc. Resent-Message-ID: From: Marius Bakke In-Reply-To: <87lgjv7lhu.fsf@gnu.org> References: <87mv4cxi9n.fsf@fastmail.com> <20171027235357.28600-1-mbakke@fastmail.com> <87lgjv7lhu.fsf@gnu.org> Date: Sun, 29 Oct 2017 11:17:10 +0100 Message-ID: <8760ay5kd5.fsf@fastmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 29035@debbugs.gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s writes: > Heya, > > Marius Bakke skribis: > >> * gnu/system/shadow.scm (default-skeletons): Instead of testing for >> $SSH_CLIENT, check whether '$-' includes the letter 'i'. > > That=E2=80=99s 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? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=bashrc.patch Content-Transfer-Encoding: quoted-printable From=20fc37dd6dfb6beab9cc4e52de7b7c98946125e7cc Mon Sep 17 00:00:00 2001 From: Marius Bakke 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. =2D-- 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 =2D-- 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=3D/etc/ssh" =20 ;; Default value of 'PATH' used by sshd. =2D "--with-default-path=3D/run/current-system/pro= file/bin" + ,(string-append "--with-default-path=3D" + "/run/current-system/profile/bi= n:" + "~/.guix-profile/bin") =20 ;; configure needs to find krb5-config ,(string-append "--with-kerberos5=3D" =2D-=20 2.14.3 From=20cc817dd809c85571d3e54a226ff16a7a3aa5bdae Mon Sep 17 00:00:00 2001 From: Marius Bakke 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_C= LIENT. =2D-- 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 =2D-- 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 =20 =2Dif [ -n \"$SSH_CLIENT\" -a -z \"`type -P cat`\" ] =2Dthen =2D # We are being invoked from a non-interactive SSH session =2D # (as in \"ssh host command\") but 'cat' cannot be found =2D # in $PATH. Source /etc/profile so we get $PATH and other =2D # essential variables. =2D source /etc/profile =2Dfi =2D # Adjust the prompt depending on whether we're in 'guix environment'. if [ -n \"$GUIX_ENVIRONMENT\" ] then =2D-=20 2.14.3 From=2053761ac682cf0de4161c40aa7ec5372a2070c2b2 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Sat, 28 Oct 2017 01:19:01 +0200 Subject: [PATCH 3/3] system: Return early in skeleton '.bashrc' when the sh= ell is non-interactive. * gnu/system/shadow.scm (default-skeletons)[bashrc]: Test if $- includes the letter 'i', and return if it doesn't. =2D-- 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 =2D-- 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 =20 +# If not running interactively, don't do anything else. +if [[ $- !=3D *i* ]] +then + return +fi + # Adjust the prompt depending on whether we're in 'guix environment'. if [ -n \"$GUIX_ENVIRONMENT\" ] then =2D-=20 2.14.3 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAln1qqYACgkQoqBt8qM6 VPryFggA1G4sayn5KVKr75W77Fl/7k7ZIHHp7mnmG0vb6QqHgI/0abnFp0ZMvvO1 +jDjVHGFiI0KsTriZVJvwQ7zRWCY7sndtOShTDKLcQy0MW6QmMDvmtlOATbuZpOS Qkl6zmQKAWSRO9cHnxM8Eq499UBOU1KVcg7MHwQrVm/o4LLYM9IbXkYr843+zxH/ 4n9vHW1q6qBkCR2G7P5obLayU8xvLAWmR66fUaFH7/eutHbk8ZtVzULB28HkGBw/ d0nMOKJjaFzXSjw9iPX48p75ZwICp/GL03cXpiHT13ShQ3uv/X1Pdb4JpCmLJKti aUjnO1OYnmMGeIf2dWZlpNGlSi+f8A== =0px6 -----END PGP SIGNATURE----- --==-=-=--