mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
commit
c6f575ebed
@ -83,6 +83,16 @@ def gid_to_group(gid):
|
||||
|
||||
salt '*' file.gid_to_group 0
|
||||
'''
|
||||
try:
|
||||
gid = int(gid)
|
||||
except ValueError:
|
||||
# This is not an integer, maybe it's already the group name?
|
||||
gid = group_to_gid(gid)
|
||||
|
||||
if not gid:
|
||||
# Don't even bother to feed it to grp
|
||||
return ''
|
||||
|
||||
try:
|
||||
return grp.getgrgid(gid).gr_name
|
||||
except KeyError:
|
||||
|
@ -23,10 +23,12 @@ as either absent or present
|
||||
user.absent
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _changes(
|
||||
name,
|
||||
uid=None,
|
||||
@ -129,7 +131,7 @@ def present(
|
||||
|
||||
gid
|
||||
The default group id
|
||||
|
||||
|
||||
gid_from_name
|
||||
If True, the default group id will be set to the id of the group with
|
||||
the same name as the user.
|
||||
@ -205,25 +207,29 @@ def present(
|
||||
for missing_optgroup in [x for x in optional_groups
|
||||
if x not in present_optgroups]:
|
||||
log.debug('Optional group "{0}" for user "{1}" is not '
|
||||
'present'.format(missing_optgroup,name))
|
||||
'present'.format(missing_optgroup, name))
|
||||
else:
|
||||
present_optgroups = None
|
||||
|
||||
|
||||
# Log a warning for all groups specified in both "groups" and
|
||||
# "optional_groups" lists.
|
||||
if groups and optional_groups:
|
||||
for x in set(groups).intersection(optional_groups):
|
||||
log.warning('Group "{0}" specified in both groups and '
|
||||
'optional_groups for user {1}'.format(x,name))
|
||||
'optional_groups for user {1}'.format(x, name))
|
||||
|
||||
if fullname is None: fullname = ''
|
||||
if roomnumber is None: roomnumber = ''
|
||||
if workphone is None: workphone = ''
|
||||
if homephone is None: homephone = ''
|
||||
if fullname is None:
|
||||
fullname = ''
|
||||
if roomnumber is None:
|
||||
roomnumber = ''
|
||||
if workphone is None:
|
||||
workphone = ''
|
||||
if homephone is None:
|
||||
homephone = ''
|
||||
|
||||
if gid_from_name:
|
||||
gid = __salt__['file.group_to_gid'](name)
|
||||
|
||||
changes = _changes(
|
||||
name,
|
||||
uid,
|
||||
@ -239,6 +245,7 @@ def present(
|
||||
roomnumber,
|
||||
workphone,
|
||||
homephone)
|
||||
|
||||
if changes:
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
|
Loading…
Reference in New Issue
Block a user