[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
UID|EUID variables lose their ro properties
From: |
mike b |
Subject: |
UID|EUID variables lose their ro properties |
Date: |
Fri, 3 Nov 2017 17:09:34 +0100 |
Hi!
Below is some odd stuff I recently noticed, looks to me as a bug, though
it's better if smarter people than me look at it as well to confirm that.
:)
Configuration Information:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
-DCONF_VENDOR='unknown' -DLOCALEDIR='/root/git_repos/bash/out/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib
-g -O2 -Wno-parentheses -Wno-format-security
uname output: Linux test 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2
(2016-10-19) x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu
Bash Version: 4.4
Patch Level: 12
Release Status: release
Description:
Whenever UID|EUID are exported to the env of newly exec Bash
instance said variables lose their ro properties. Here's example:
#!/bin/bash
if (( ! UID )) \
&& (( ! EUID )) ; then
printf 'I am root (%u)\n' "$UID"
# at this point, you can change UID|EUID to whatever
# you like
UID=BANANA
EUID=PEANUTS
printf 'UID=%s\nEUID=%s\n' "$UID" "$EUID"
exit
else
printf 'I am %u, not root\n' "$UID"
fi
export UID EUID
exec bash -c "UID=0 EUID=0 $0"
Here's example of an output:
$ ./test
I am 1000, not root
I am root (0)
UID=BANANA
EUID=PEANUTS
To my understanding, those variables should not be changed at any
point, just like e.g. PPID (which is not affected by the above).
Regards,
Michal
- UID|EUID variables lose their ro properties,
mike b <=