The Samba-Bugzilla – Bug 9501
Adding/deleting users/groups through "sudo sambaCtl.sh" on Ubuntu 12.04 LTS is broken
Last modified: 2012-12-13 23:01:28 UTC
Created attachment 8345 [details]
A fixed version of the /usr/sbin/sambaCtl.sh file.
On Ubuntu 12.04 LTS, running a command such as this:
/usr/bin/sudo /usr/sbin/sambaCtl.sh useradd 'test' 'password'
sometimes fails with this error message:
/usr/sbin/sambaCtl.sh: line 63: useradd: command not found
Failed to add entry for user test.
This worked fine on Ubuntu 10.04.4 LTS. The issue appears to be that the sudo command in Ubuntu 12.04 LTS does not append the path /usr/sbin/ to the PATH of the user that commands run as.
We noticed this while giving Apache's www-data user privileges (through the sudoers.d directory) to execute the command /usr/sbin/sudo /usr/sbin/sambaCtl.sh. This user does not have /usr/sbin/ in his path, though, so running the command "useradd" fails.
The solution to this is to use full paths for the commands. Specifically, the useradd, userdel, groupadd, groupdel, and usermod commands need to have /usr/sbin/ prepended to them. The attached file has a fixed version of the /usr/sbin/sambaCtl.sh file.
My apologies. It turns out that this was an internal script that one of ours developers wrote, not one that was shipped with Samba.