Yes, exactly! That confuses me so much.
I’ve checked, and the user definitely can read the chain. That’s not a problem. The user can even see the contents of /usr/lib/cargo/bin/sudo (using view). I’ve gone so far as to delete the link /usr/bin/sudo and hard-link /usr/lib/cargo/bin/sudo to it or to copy the file (remembering setuid).
Do you mean chmod -s /usr/lib/cargo/bin/sudo? I’ve just tried that, but it didn’t help.
Good question. When I last tried to understand how to use AppArmor, I completely failed; it was above my comprehension level. So, I have no idea how to check!
Returning to the error message:
sudo: sudo must be owned by uid 0 and have the setuid bit set
We can look at the links and sudo itself:
alice@abercorn:~$ ls -l /usr/bin/sudo /etc/alternatives/sudo /usr/lib/cargo/bin/sudo
lrwxrwxrwx 1 root root 23 Jun 27 16:25 /etc/alternatives/sudo -> /usr/lib/cargo/bin/sudo
lrwxrwxrwx 1 root root 22 Mar 13 11:02 /usr/bin/sudo -> /etc/alternatives/sudo
-rwsr-xr-x 1 root root 1082656 Mar 11 13:27 /usr/lib/cargo/bin/sudo
We see that the setuid bit is set.
We see that it’s owned by root, which has uid 0:
alice@abercorn:~$ id root
uid=0(root) gid=0(root) groups=0(root)
Plus, Alice belongs to the sudo group:
alice@abercorn:~$ id
uid=1002(alice) gid=1002(alice) groups=1002(alice),27(sudo),100(users)
So, what exactly is the error message telling us? It’s obviously telling us something other than what it appears to be telling us.