I have an architecture using network namespaces (netns). I would like to allow regular users to do some operations in these netns.
I could write a script netns-exec.sh
, inspired by this post, executed with sudo
, containing:
ip netns exec $1 su $USER -c "$2"
and add to my sudoer file:
user ALL=(ALL) /path/to/netns-exec.sh
But I find it so ugly I could totally have nightmares about it. Is there a better solution to allow regular users to use namespaces? Is it possible to put users to some useful groups? I searched about it but found nothing.
Cmd_Alias CMD_NETNS = ip netns exec [regexp matching your namespace] su [regexp matching allowed used] -c [regexp matching allowed namespace command]
in your sudoers file and then create a group in which you put your allowed users, and associate this group to this command alias. – netmonk Sep 14 '15 at 11:50sudo
containing asu
that annoys me, not the script itself. Anyway I'll write a script to wrap the thing. It makes 2 user switches, that's really ugly, don't you think ? – Raspbeguy Sep 14 '15 at 12:09sudo
provided a specific variable$SUDO_USER
, which is safer. But that's still ugly. – Raspbeguy Dec 14 '15 at 16:17