[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [UX] real names exposed
From: |
Troy Sankey |
Subject: |
Re: [UX] real names exposed |
Date: |
Sat, 03 Sep 2016 18:21:07 -0400 |
User-agent: |
alot/0.3.7 |
I suspect the scope of this UX "bug" is larger than python. I think this
probably affects every executable written in an interpreted
language and using a shebang. Here's another example with a bash
script:
$ cat > t.sh
#!/bin/bash
sed 's/\x0/\\0/g' # replaces null bytes with a visible '\0'
$ ./t.sh </proc/self/cmdline
/bin/bash\0./t.sh\0
Looks like '/bin/bash' is argv[0]. What happens when we try exec -a:
$ bash -c 'exec -a FOO bash t.sh </proc/self/cmdline'
FOO\0t.sh\0
$ bash -c 'exec -a FOO ./t.sh </proc/self/cmdline'
/bin/bash\0/tmp/t.sh\0
"t.sh" still appears. The result of that last command surprised me,
there's no FOO in /prod/self/cmdline at all (still confused)! By the
way, bash does the same as python, in that $0 always references the
script name, never the actual argv[0]:
$ cat >s.sh
#!/bin/bash
echo $0
$ ./s.sh </proc/self/cmdline
./s.sh
$ bash s.sh </proc/self/cmdline
s.sh
I'm not sure what the solution is.
Troy
signature.asc
Description: signature