public, but it's known by members of our team and is something pretty generic, definitely not good enough for production machines.
Password: rootPassword:
is the prompt output by su,root
is the result of whoami
Password: same prompt again root same result again
root
login='root'; password='password'; salt=$(awk -F'$' -v login="$login" '$0 ~ login { print $3 }' /etc/shadow) passwordHash=$(openssl passwd -6 -salt "$salt" "$password") grep -c "$passwordHash" /etc/shadow
Flag | Usage |
---|---|
- -l --login | Make the shell a login shell :
|
-c command --command=command | Pass the command command to the shell. |
-s shell --shell=shell | Invoke the shell shell |
This behavior is caused by this uncommented line of /etc/pam.d/su which forces users to be a member of group root before they can use su :
auth required pam_wheel.so group=root
su bob -c whoami bob as expected su bob -c whoami; echo $HOME bob as above /root the echo came once the su was over, then this is no surprise su bob -c "whoami; echo $HOME" bob this is still part of the su -c , so no surprise /root thanks to the"
,$HOME
is substituted with its current value, then the whole string is passed to su -c (details) su bob -c 'whoami; echo $HOME' bob no change /home/bob thanks to the'
, the whole expression is sent as-is to su -c (no substitution), then executed as bob value=42; su bob -c "echo $HOME [$value]"; su bob -c 'echo $HOME [$value]' /root [42] this is just to emphasize /home/bob [] on the example above