1

I am the only user on my machine, and prefer not to type sudo every time I use dhclient. Therefore, I tried sudo chmod u+s /sbin/dhclient.

However, when I subsequently run dhclient wlan0 from a non-root shell, I still get RTNETLINK answers: Operation not permitted

I am running Ubuntu 13.10.

Why does setting the UID bit not achieve the desired effect, and are there any workarounds?

1
  • Try sudo chmod u+s /sbin/ip as well. dhclient runs the shell script /usr/sbin/dhclient-script, and shells invoked with uid != euid generally drop their privileges down to the uid. The error message you see, according to my testing, is from /sbin/ip, which is run by the shell script and thus with your (non-root) uid. Jan 22, 2014 at 22:22

1 Answer 1

1

sudo sets both the real and effective uids. Making an executable setuid only causes the effective uid to be set when the executable is run. If the executable juggles uids to fork unprivileged children as dhclient does, you can easily trip it up by running it with a non-root real uid.

A workaround would be to write a wrapper executable that does nothing but set the real uid to match the effective uid and then run dhclient. Make the wrapper setuid root and remove the setuid bit from dhclient.

2
  • how would the wrapper executable set the real uid? Would the wrapper simply say sudo dhclient?
    – merlin2011
    Jan 22, 2014 at 22:00
  • 1
    I'm assuming a C program which would call setreuid(), then execve().
    – Kyle Jones
    Jan 22, 2014 at 22:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .