Bug 10871 - samba-tool: Adding none-existent users to groups doesn't fail.
samba-tool: Adding none-existent users to groups doesn't fail.
Status: RESOLVED FIXED
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Tools
unspecified
All All
: P5 minor
: ---
Assigned To: Andrew Bartlett
Samba QA Contact
:
Depends on:
Blocks: 11924
  Show dependency treegraph
 
Reported: 2014-10-12 12:29 UTC by Marc Muehlfeld
Modified: 2016-08-26 00:20 UTC (History)
1 user (show)

See Also:


Attachments
Patch for master (1.22 KB, patch)
2014-10-12 15:01 UTC, Marc Muehlfeld
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Muehlfeld 2014-10-12 12:29:02 UTC
If you use samba-tool to add users to a group, it always returns that the members were added - even if the given account doesn't exist. Also the return code of 0 is wrong in that case.


# samba-tool group addmembers existingGroup notExistingUser
Added members to group existingGroup

# echo $?
0



This should both be avoided, to allow sucessfull scripting around samba-tool.
Comment 1 Marc Muehlfeld 2014-10-12 12:36:32 UTC
BTW: It's the same for 'removemembers':

# samba-tool group removemembers existingGroup notExistingUser
Removed members from group existingGroup


# echo $?
0
Comment 2 Marc Muehlfeld 2014-10-12 15:01:34 UTC
Created attachment 10346 [details]
Patch for master

The attached small patch solves the request here for the add/remove situation. Can you please check, if it's OK?



# samba-tool group addmembers existingGroup notExistingUser
ERROR(exception): Failed to add members "notExistingUser" to group "existingGroup" - Unable to find "notExistingUser". Operation cancelled.
  File "/usr/local/samba/lib64/python2.7/site-packages/samba/netcmd/group.py", line 217, in run
    add_members_operation=True)
  File "/usr/local/samba/lib64/python2.7/site-packages/samba/samdb.py", line 263, in add_remove_group_members
    raise Exception('Unable to find "%s". Operation cancelled.' % member)



# echo $?
255
Comment 3 Marc Muehlfeld 2016-08-26 00:20:01 UTC
This was fixed in 4.4.0.