From mboxrd@z Thu Jan 1 00:00:00 1970 From: Troy Sankey Subject: Re: [UX] real names exposed Date: Sat, 03 Sep 2016 11:30:18 -0400 Message-ID: <147291661814.23966.15325855743314158034@what> References: <147266794967.23966.13712862947716543821@what> <20160831231110.GB18814@jasmine> <87wpiwt2qx.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha256"; boundary="===============1320259123==" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgCtt-0001Mm-UF for help-guix@gnu.org; Sat, 03 Sep 2016 11:30:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgCts-0004Py-NK for help-guix@gnu.org; Sat, 03 Sep 2016 11:30:33 -0400 Content-Disposition: inline In-Reply-To: <87wpiwt2qx.fsf@gnu.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: Ludovic =?utf-8?Q?Court=C3=A8s?= , Eric Bavier Cc: help-guix@gnu.org, Help-Guix --===============1320259123== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Quoting Ludovic Court=C3=A8s (2016-09-01 04:59:02) > =E2=80=98exec -a=E2=80=99 works as advertised: > = > --8<---------------cut here---------------start------------->8--- > $ sh -c 'exec -a FOO guile -c "(pk (command-line))"' > = > ;;; (("FOO")) > --8<---------------cut here---------------end--------------->8--- So, here /proc/self/cmdline would be: guile\0 and bash changed it to: FOO\0 > Yet: > = > --8<---------------cut here---------------start------------->8--- > $ sh -c 'exec -a FOO /gnu/store/6vmniz83k46l8jpry50wdvwxsncz1r5w-khal-0.7= .0/bin/.khal-wrap-01 --version' > .khal-real, version 0.7.0 > --8<---------------cut here---------------end--------------->8--- here it's: python3\0.khal-real\0--version\0 bash changed it to: FOO\0.khal-real\0--version\0 > And in fact: > = > --8<---------------cut here---------------start------------->8--- > $ cat > t.py > import sys > print(sys.argv[0]) > $ sh -c 'exec -a FOO python3 t.py' > t.py > --8<---------------cut here---------------end--------------->8--- here it's: python3\0t.py\0 bash changed it to: FOO\0t.py\0 > =E2=80=A6 even though argv[0] is initially correct: > = > --8<---------------cut here---------------start------------->8--- > $ sh -c 'exec -a FOO python3 --help' | head -1 > usage: FOO [option] ... [-c cmd | -m mod | file | -] [arg] ... > --8<---------------cut here---------------end--------------->8--- > = > So somewhere, Python finds out the real name, but it doesn=E2=80=99t seem= to be > via /proc/cmdline or anything like that, and I couldn=E2=80=99t find the = exact > hack in the source. > > Ideas? Seems that there is no reason to think python doesn't simply use /proc/self/cmdline. Before script interpretation, but after spawning, the python interpreter appears to modify the arguments list to hide the first element: argv =3D argv[1:] # I made this up, but it's probably something like this > I would really like to fix it in =E2=80=98core-updates=E2=80=99. > = > Ludo=E2=80=99. --===============1320259123== MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Description: signature Content-Type: application/pgp-signature; name="signature.asc"; charset="us-ascii" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJXyuyHAAoJEIRGmXXw0dCUTPoP/AwtT9EbEt+4ksuXZ+0p3ECs 7NQSfgyAuA2FihJExuC3OlVjYhi8+Ncb/LKXbEmC7rF0S6bIs2CS6Eqrv5Rbjl5S heMmXXbErXv8kt1UB9ngTaOE7DKhcLn2SxGt/d5spZYStun1Z6y4Q5eUJN2YOXqG oXXd5xayLo//YeRmwzjOAaiKPkuF9nVpicZzhEMj21Z05vfWilAlKlgp3q0Dbp9m ggNjfoCwek4pt9NvJubZdWIuzvUdmYRcYonKWYWEiFqjApdwSXQHQhoANRLdOq4T hsWyT0aRDjsWHUMpa85K4qNTOGCakDb2dbEs+VyS9duAwRbW2euufyeJF2SrqXLh xijYzbLfaXLJxv/AwBGu4/qP6OS5Tb6VVzMu4/4khSOzoEKEumiPrYdQc7UA476Q mmJjs8hTowzlEkn5OGHHwbqIFaZG63x1VmUVVKYKwNa5DpvPagHrwnasHAyzQ2RZ NA9mWj7w7lzly0xDxkfj33WhECqyKgY/JrPl+sSw4pXO6kiX7COu0jvJVxkswGhM 6VauHWjiJhHdoTSGPNWsHQbEFKlZlCK/GzdJ4+2XTTHDUYp6krkOolSvwsDGFQds /FT+6AwWMvwkdvba9nLfRsz039tunV3TYVLltLBGDr4S1eFrt/hpLfarfpt3dtK0 hcV5NnyZDOVgc279a15W =gMuy -----END PGP SIGNATURE----- --===============1320259123==--