#NEWLINE# def _changes( name , uid = None , gid = None , groups = None , optional_groups = None , remove_groups = True , home = None , createhome = True , password = None , enforce_password = True , empty_password = False , shell = None , fullname = '' , roomnumber = '' , workphone = '' , homephone = '' , loginclass = None , date = 0 , mindays = 0 , maxdays = 999999 , inactdays = 0 , warndays = 7 , expire = None , win_homedrive = None , win_profile = None , win_logonscript = None , win_description = None ) : #NEWLINE# #INDENT# '\n    Return a dict of the changes required for a user if the user is present,\n    otherwise return False.\n\n    Updated in 2015.8.0 to include support for windows homedrive, profile,\n    logonscript, and description fields.\n\n    Updated in 2014.7.0 to include support for shadow attributes, all\n    attributes supported as integers only.\n    ' #NEWLINE# if ( 'shadow.info' in __salt__ ) : #NEWLINE# #INDENT# lshad = __salt__ [ 'shadow.info' ] ( name ) #NEWLINE# #UNINDENT# lusr = __salt__ [ 'user.info' ] ( name ) #NEWLINE# if ( not lusr ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# change = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( groups is None ) : #NEWLINE# #INDENT# groups = lusr [ 'groups' ] #NEWLINE# #UNINDENT# wanted_groups = sorted ( set ( ( ( groups or [ ] ) + ( optional_groups or [ ] ) ) ) ) #NEWLINE# if ( uid and ( lusr [ 'uid' ] != uid ) ) : #NEWLINE# #INDENT# change [ 'uid' ] = uid #NEWLINE# #UNINDENT# if ( ( gid is not None ) and ( lusr [ 'gid' ] not in ( gid , __salt__ [ 'file.group_to_gid' ] ( gid ) ) ) ) : #NEWLINE# #INDENT# change [ 'gid' ] = gid #NEWLINE# #UNINDENT# default_grp = __salt__ [ 'file.gid_to_group' ] ( ( gid if ( gid is not None ) else lusr [ 'gid' ] ) ) #NEWLINE# if ( default_grp in lusr [ 'groups' ] ) : #NEWLINE# #INDENT# lusr [ 'groups' ] . remove ( default_grp ) #NEWLINE# #UNINDENT# if ( ( name in lusr [ 'groups' ] ) and ( name not in wanted_groups ) ) : #NEWLINE# #INDENT# lusr [ 'groups' ] . remove ( name ) #NEWLINE# #UNINDENT# if ( default_grp in wanted_groups ) : #NEWLINE# #INDENT# wanted_groups . remove ( default_grp ) #NEWLINE# #UNINDENT# if _group_changes ( lusr [ 'groups' ] , wanted_groups , remove_groups ) : #NEWLINE# #INDENT# change [ 'groups' ] = wanted_groups #NEWLINE# #UNINDENT# if ( home and ( lusr [ 'home' ] != home ) ) : #NEWLINE# #INDENT# change [ 'home' ] = home #NEWLINE# #UNINDENT# if createhome : #NEWLINE# #INDENT# newhome = ( home if home else lusr [ 'home' ] ) #NEWLINE# if ( ( newhome is not None ) and ( not os . path . isdir ( newhome ) ) ) : #NEWLINE# #INDENT# change [ 'homeDoesNotExist' ] = newhome #NEWLINE# #UNINDENT# #UNINDENT# if ( shell and ( lusr [ 'shell' ] != shell ) ) : #NEWLINE# #INDENT# change [ 'shell' ] = shell #NEWLINE# #UNINDENT# if ( ( 'shadow.info' in __salt__ ) and ( 'shadow.default_hash' in __salt__ ) ) : #NEWLINE# #INDENT# if password : #NEWLINE# #INDENT# default_hash = __salt__ [ 'shadow.default_hash' ] ( ) #NEWLINE# if ( ( lshad [ 'passwd' ] == default_hash ) or ( ( lshad [ 'passwd' ] != default_hash ) and enforce_password ) ) : #NEWLINE# #INDENT# if ( lshad [ 'passwd' ] != password ) : #NEWLINE# #INDENT# change [ 'passwd' ] = password #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( date and ( date is not 0 ) and ( lshad [ 'lstchg' ] != date ) ) : #NEWLINE# #INDENT# change [ 'date' ] = date #NEWLINE# #UNINDENT# if ( mindays and ( mindays is not 0 ) and ( lshad [ 'min' ] != mindays ) ) : #NEWLINE# #INDENT# change [ 'mindays' ] = mindays #NEWLINE# #UNINDENT# if ( maxdays and ( maxdays is not 999999 ) and ( lshad [ 'max' ] != maxdays ) ) : #NEWLINE# #INDENT# change [ 'maxdays' ] = maxdays #NEWLINE# #UNINDENT# if ( inactdays and ( inactdays is not 0 ) and ( lshad [ 'inact' ] != inactdays ) ) : #NEWLINE# #INDENT# change [ 'inactdays' ] = inactdays #NEWLINE# #UNINDENT# if ( warndays and ( warndays is not 7 ) and ( lshad [ 'warn' ] != warndays ) ) : #NEWLINE# #INDENT# change [ 'warndays' ] = warndays #NEWLINE# #UNINDENT# if ( expire and ( lshad [ 'expire' ] != expire ) ) : #NEWLINE# #INDENT# change [ 'expire' ] = expire #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( 'shadow.info' in __salt__ ) and salt . utils . is_windows ( ) ) : #NEWLINE# #INDENT# if ( expire and ( expire is not ( - 1 ) ) and ( salt . utils . date_format ( lshad [ 'expire' ] ) != salt . utils . date_format ( expire ) ) ) : #NEWLINE# #INDENT# change [ 'expire' ] = expire #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# fullname = sdecode_if_string ( fullname ) #NEWLINE# lusr [ 'fullname' ] = sdecode_if_string ( lusr [ 'fullname' ] ) #NEWLINE# if ( ( fullname is not None ) and ( lusr [ 'fullname' ] != fullname ) ) : #NEWLINE# #INDENT# change [ 'fullname' ] = fullname #NEWLINE# #UNINDENT# if ( win_homedrive and ( lusr [ 'homedrive' ] != win_homedrive ) ) : #NEWLINE# #INDENT# change [ 'homedrive' ] = win_homedrive #NEWLINE# #UNINDENT# if ( win_profile and ( lusr [ 'profile' ] != win_profile ) ) : #NEWLINE# #INDENT# change [ 'profile' ] = win_profile #NEWLINE# #UNINDENT# if ( win_logonscript and ( lusr [ 'logonscript' ] != win_logonscript ) ) : #NEWLINE# #INDENT# change [ 'logonscript' ] = win_logonscript #NEWLINE# #UNINDENT# if ( win_description and ( lusr [ 'description' ] != win_description ) ) : #NEWLINE# #INDENT# change [ 'description' ] = win_description #NEWLINE# #UNINDENT# if ( ( 'user.chroomnumber' in __salt__ ) and ( roomnumber is not None ) ) : #NEWLINE# #INDENT# roomnumber = sdecode_if_string ( roomnumber ) #NEWLINE# lusr [ 'roomnumber' ] = sdecode_if_string ( lusr [ 'roomnumber' ] ) #NEWLINE# if ( lusr [ 'roomnumber' ] != roomnumber ) : #NEWLINE# #INDENT# change [ 'roomnumber' ] = roomnumber #NEWLINE# #UNINDENT# #UNINDENT# if ( ( 'user.chworkphone' in __salt__ ) and ( workphone is not None ) ) : #NEWLINE# #INDENT# workphone = sdecode_if_string ( workphone ) #NEWLINE# lusr [ 'workphone' ] = sdecode_if_string ( lusr [ 'workphone' ] ) #NEWLINE# if ( lusr [ 'workphone' ] != workphone ) : #NEWLINE# #INDENT# change [ 'workphone' ] = workphone #NEWLINE# #UNINDENT# #UNINDENT# if ( ( 'user.chhomephone' in __salt__ ) and ( homephone is not None ) ) : #NEWLINE# #INDENT# homephone = sdecode_if_string ( homephone ) #NEWLINE# lusr [ 'homephone' ] = sdecode_if_string ( lusr [ 'homephone' ] ) #NEWLINE# if ( lusr [ 'homephone' ] != homephone ) : #NEWLINE# #INDENT# change [ 'homephone' ] = homephone #NEWLINE# #UNINDENT# #UNINDENT# if ( __grains__ [ 'kernel' ] in ( 'OpenBSD' , 'FreeBSD' ) ) : #NEWLINE# #INDENT# if loginclass : #NEWLINE# #INDENT# if ( __salt__ [ 'user.get_loginclass' ] ( name ) != loginclass ) : #NEWLINE# #INDENT# change [ 'loginclass' ] = loginclass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return change