I have two bash scripts, which are binary identical, have the same permissions, are unique on my drive and are not found in sudoers. Still one passes the uid test for root, the other one not. If I call the first one with ./ in the bin folder, it behaves like the second.
The script (sync-samuel):
#!/usr/bin/env bash
echo "[$0]"
whoami
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root"
exit 1
fi
id -u
exit
The output:
samuel@xeon:~$ sync-samuel
[sudo] password for samuel:
[/home/samuel/bin/sync-samuel]
root
0
samuel@xeon:~$ sync-samuel2
[/home/samuel/bin/sync-samuel2]
samuel
This script must be run as root
samuel@xeon:~$ cd bin
samuel@xeon:~/bin$ ./sync-samuel
[./sync-samuel]
samuel
This script must be run as root
The permissions:
-rwxr-xr-x 1 samuel samuel 435 Feb 1 22:36 sync-samuel
-rwxr-xr-x 1 samuel samuel 435 Feb 1 22:37 sync-samuel2
File:
samuel@xeon:~/bin$ file sync-samuel
sync-samuel: a /usr/bin/env bash script, ASCII text executable
samuel@xeon:~/bin$ file sync-samuel2
sync-samuel2: a /usr/bin/env bash script, ASCII text executable
Does anyone know, what triggers this behaviour or how I can view extended properties of these two files? I'm using Lubuntu 14.04 LTS w/ bash 4.3.11(1)-release.
Edit: G-Man ist the man! The first one is also an alias:
samuel@xeon:~/bin$ type sync-samuel2
sync-samuel2 is hashed (/home/samuel/bin/sync-samuel2)
samuel@xeon:~/bin$ type sync-samuel
sync-samuel is aliased to `sudo /home/samuel/bin/sync-samuel'
sync-samuelis giving you asudodialog when it doesn't callsudo? Typetype sync-samuelandtype sync-samuel2and see whether that helps you. Please do not post clarifying information in comments; if you have additional information to provide, edit your question to make it clearer and more complete.