Commit c568ed50 authored by John Hixson's avatar John Hixson
Browse files

Don't map groups that have the same name as a username

parent 29c5c9cf
No related merge requests found
Showing with 26 additions and 3 deletions
+26 -3
......@@ -59,13 +59,23 @@ group_membership()
samba_groupmap()
{
local group="${1}"
local net="/usr/local/bin/net"
net groupmap list ntgroup="${group}" >/dev/null 2>&1
#
# Don't map groups with a name the same as the username,
# it really pisses windows off.
#
/usr/bin/getent passwd "${group}" >/dev/null 2>&1
if [ "$?" = "0" ] ; then
return
fi
/usr/local/bin/net groupmap add type="local" \
${net} groupmap list ntgroup="${group}" >/dev/null 2>&1
if [ "$?" = "0" ] ; then
return
fi
${net} groupmap add type="local" \
unixgroup="${group}" ntgroup="${group}" >/dev/null 2>&1
}
......
......@@ -771,13 +771,26 @@ def smb4_group_mapped(groupmap, group):
return False
# Windows no likey
def smb4_groupname_is_username(group):
cmd = "/usr/bin/getent passwd '%s'" % group
p = pipeopen(cmd)
p.communicate()
if p.returncode == 0:
return True
return False
def smb4_map_groups():
cmd = "/usr/local/bin/net groupmap add type=local unixgroup='%s' ntgroup='%s'"
groupmap = smb4_get_groupmap()
groups = get_groups()
for g in groups:
if not smb4_group_mapped(groupmap, g):
if not smb4_group_mapped(groupmap, g) and \
not smb4_groupname_is_username(g):
pipeopen(cmd % (g, g)).communicate()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment