Exemple #1
0
    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()
Exemple #2
0
	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
Exemple #3
0
	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
				)
Exemple #4
0
    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
Exemple #5
0
	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)
Exemple #6
0
    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)
Exemple #7
0
	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()
Exemple #8
0
    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()
Exemple #9
0
	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()
Exemple #10
0
    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)
Exemple #11
0
    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)
Exemple #12
0
	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)