Exemplo n.º 1
0
 def cs_set_attribute(self, group, attribute, value, diff):
     """
     This function returns a ChangeSet for setting user- and group quotas
     based on the policy. In case user quotas are being changed for the 
     group, it queries for all the members of the group and returns a Change
     element for setting the quota for each of them.
     """
     cs = ChangeSet()
     if attribute == "groupquota":
         cs.extend(self.c_set_quota(diff, "group", group))
     elif attribute == "userquota":
         try:
             gid = shadow.get_group_by_name(group).gr_gid
             for user in shadow.list_users_with_gid(gid):
                 cs.extend(self.c_set_quota(diff, "user", user.pw_name))
         except:
             pass
     return cs
Exemplo n.º 2
0
 def cs_set_attribute(self, group, attribute, value, diff):
     """
     This function returns a ChangeSet respective to a changed policy attribute.
     
     In case the changed attribute affects existing users, the group
     members' accounts will be updated as well. For example, when
     the shell of the group was changed, you probably want all the accounts
     to be updated.
     """
     cs = ChangeSet()
     p = {attribute: value}
     
     # check if we need to update group members
     if attribute in ['shell', 'inactive'] and group_exists(group):
         gid = get_group_by_name(group).gr_gid
         for user in list_users_with_gid(gid):
             # modify each user in the group
             cs.merge(self.cs_mod_user(user.pw_name, policy=p))
     return cs