Esempio n. 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()
Esempio n. 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
Esempio n. 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
				)
Esempio n. 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
Esempio n. 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)
Esempio n. 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)
Esempio n. 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()
Esempio n. 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()
Esempio n. 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()
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)