def ChangePassword(self, display, sender, connection): """ This method returns the object path for the given user. """ if not get_user(sender) in self.set_privileges and ( self.polkit_policy and not is_authorized( sender, connection, self.polkit_policy, True # user interaction )): raise Exception("Not authorized") # Create changepassword dialog usersd_ui._initialize(display, get_user(sender), self.service.get_uids_with_users()) change_password_dialog = usersd_ui.ChangePasswordDialog( self.is_locked()) # Connect response change_password_dialog.connect("response", self.on_change_password_dialog_response, change_password_dialog) change_password_dialog.show()
def DeleteUser(self, with_home, sender, connection): """ Deletes the user. If with_home is True, the user's home directory will be deleted as well. Returns True if the user has been deleted successfully, False if not. """ if get_user(sender) == self.uid: # The sender can't remove itself! raise Exception("The sender can't remove itself!") if self.polkit_policy and not is_authorized( sender, connection, self.polkit_policy, True # user interaction ): raise Exception("Not authorized") deluser_call = ["/usr/sbin/deluser", self.user] # deluser is picky with blank arguments, so we can't put an "" # in the place of --remove-home if with_home: deluser_call.append("--remove-home") if subprocess.call(deluser_call) == 0: self.service.remove_from_user_list(self.user) return True else: return False
def AddGroupsToUser(self, user, groups, sender=None, connection=None): """ Adds the given user to every group specified in the specfied groups list. """ if sender and connection and not is_authorized( sender, connection, "org.semplicelinux.usersd.add-user", True # user interaction ): raise Exception("Not authorized") for group in groups: if not group in self._groups: continue members = self._groups[group].members if not user in members: members.append(user) self._groups[group].Set( "org.semplicelinux.usersd.group", "Members", members )
def ShowUserCreationUI(self, display, groups, sender, connection): """ This method shows the user interface that permits to create a new user. """ if not is_authorized( sender, connection, "org.semplicelinux.usersd.add-user", True # user interaction ): raise Exception("Not authorized") usersd.user.User.add_graphically(sender, self, display, groups)
def CreateUser(self, user, fullname, sender, connection): """ This method returns the object path for the given user. """ if not is_authorized( sender, connection, "org.semplicelinux.usersd.add-user", True # user interaction ): raise Exception("Not authorized") if usersd.user.User.add(user, fullname): # User created successfully, we should refresh the user list self._generate_users()
def ChangePassword(self, display, sender, connection): """ This method returns the object path for the given user. """ if not get_user(sender) in self.set_privileges and (self.polkit_policy and not is_authorized( sender, connection, self.polkit_policy, True # user interaction )): raise Exception("Not authorized") # Create changepassword dialog usersd_ui._initialize(display, get_user(sender), self.service.get_uids_with_users()) change_password_dialog = usersd_ui.ChangePasswordDialog(self.is_locked()) # Connect response change_password_dialog.connect("response", self.on_change_password_dialog_response, change_password_dialog) change_password_dialog.show()
def Set(self, interface_name, property_name, new_value, sender=None, connection=None): """ An implementation of the Set() method of the properties interface. """ if sender and connection and not get_user( sender) in self.set_privileges and ( self.polkit_policy and not is_authorized( sender, connection, self.polkit_policy, True # user interaction )): raise Exception("E: Not authorized") self.store_property(property_name, new_value)
def AddGroupsToUser(self, user, groups, sender=None, connection=None): """ Adds the given user to every group specified in the specfied groups list. """ if sender and connection and not is_authorized( sender, connection, "org.semplicelinux.usersd.add-user", True # user interaction ): raise Exception("Not authorized") for group in groups: if not group in self._groups: continue members = self._groups[group].members if not user in members: members.append(user) self._groups[group].Set("org.semplicelinux.usersd.group", "Members", members)
def Set(self, interface_name, property_name, new_value, sender=None, connection=None): """ An implementation of the Set() method of the properties interface. """ if sender and connection and not get_user(sender) in self.set_privileges and (self.polkit_policy and not is_authorized( sender, connection, self.polkit_policy, True # user interaction )): raise Exception("E: Not authorized") self.store_property(property_name, new_value)