all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Troy Sankey <sankeytms@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>,
	"Eric Bavier" <ericbavier@openmailbox.org>
Cc: help-guix@gnu.org,
	Help-Guix <help-guix-bounces+ericbavier=openmailbox.org@gnu.org>
Subject: Re: [UX] real names exposed
Date: Sat, 03 Sep 2016 11:30:18 -0400	[thread overview]
Message-ID: <147291661814.23966.15325855743314158034@what> (raw)
In-Reply-To: <87wpiwt2qx.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1976 bytes --]

Quoting Ludovic Courtès (2016-09-01 04:59:02)
> ‘exec -a’ 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

> … 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’t seem to be
> via /proc/cmdline or anything like that, and I couldn’t 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 = argv[1:]  # I made this up, but it's probably something like this

> I would really like to fix it in ‘core-updates’.
> 
> Ludo’.

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

-----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-----

  reply	other threads:[~2016-09-03 15:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-31 18:25 [UX] real names exposed Troy Sankey
2016-08-31 23:11 ` Leo Famulari
2016-08-31 23:33   ` Eric Bavier
2016-09-01  8:59     ` Ludovic Courtès
2016-09-03 15:30       ` Troy Sankey [this message]
2016-09-03 22:21         ` Troy Sankey
2016-09-04 19:38           ` Ludovic Courtès
2016-09-03 22:33       ` Ludovic Courtès
2016-09-04 19:41         ` Ludovic Courtès
2016-09-06  3:09           ` Eric Bavier
2016-09-07 22:04             ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=147291661814.23966.15325855743314158034@what \
    --to=sankeytms@gmail.com \
    --cc=ericbavier@openmailbox.org \
    --cc=help-guix-bounces+ericbavier=openmailbox.org@gnu.org \
    --cc=help-guix@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.