Bug 9501 - Adding/deleting users/groups through "sudo sambaCtl.sh" on Ubuntu 12.04 LTS is broken
Summary: Adding/deleting users/groups through "sudo sambaCtl.sh" on Ubuntu 12.04 LTS i...
Status: RESOLVED INVALID
Alias: None
Product: Samba 3.6
Classification: Unclassified
Component: Client Tools (show other bugs)
Version: 3.6.3
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: Volker Lendecke
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-13 22:32 UTC by vestigal
Modified: 2012-12-13 23:01 UTC (History)
0 users

See Also:


Attachments
A fixed version of the /usr/sbin/sambaCtl.sh file. (7.73 KB, text/x-shellscript)
2012-12-13 22:32 UTC, vestigal
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description vestigal 2012-12-13 22:32:47 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.
Comment 1 vestigal 2012-12-13 23:01:28 UTC
My apologies. It turns out that this was an internal script that one of ours developers wrote, not one that was shipped with Samba.