Example #1
0
	def del_user(self, user):
		if user not in self.ro_users and user not in self.rw_users:
			return True
		
		ret = True
		if user in self.ro_users:
			cmd = "deluser %s %s_ro"%(user, self.group)
		else:
			cmd = "deluser %s %s_rw"%(user, self.group)
		
		p = System.execute(cmd)
		if p.returncode is not 0:
			ret = False
			Logger.error("FS: unable to del user in group")
			Logger.debug("FS: command '%s' return %d: %s"%(cmd, p.returncode, p.stdout.read().decode("UTF-8")))
		
		htgroup = HTGroup(Config.dav_group_file)
		
		if user in self.ro_users:
			self.ro_users.remove(user)
			htgroup.delete(user, self.group+"_ro")
		if user in self.rw_users:
			self.rw_users.remove(user)
			htgroup.delete(user, self.group+"_rw")
		
		if (len(self.ro_users) + len(self.rw_users)) == 0:
			return self.disable()
		
		return True
Example #2
0
    def purgeGroup(self):
        users = System.groupMember(Config.group)
        if users is None:
            return False

        ret = True
        for user in users:
            if user == Config.dav_user:
                continue

            Logger.debug("FileServer:: deleting user '%s'" % (user))

            u = User(user)
            u.clean()
            if u.existSomeWhere():
                Logger.error("FS: unable to del user %s" % (user))
                ret = False

        htgroup = HTGroup(Config.dav_group_file)
        htgroup.purge()

        try:
            groups = [
                g.gr_name for g in grp.getgrall()
                if g.gr_name.startswith("ovd_share_")
            ]
            for g in groups:
                System.groupDelete(g)
        except Exception:
            Logger.exception("Failed to purge groups")
            ret = False

        return ret
Example #3
0
	def purgeGroup(self):
		users = System.groupMember(Config.group)
		if users is None:
			return False
		
		ret = True
		for user in users:
			if user == Config.dav_user:
				continue
			
			Logger.debug("FileServer:: deleting user '%s'"%(user))
			
			u = User(user)
			u.clean()
			if u.existSomeWhere():
				Logger.error("FS: unable to del user %s"%(user))
				ret =  False
		
		htgroup = HTGroup(Config.dav_group_file)
		htgroup.purge()
		
		try:
			groups = [g.gr_name for g in grp.getgrall() if g.gr_name.startswith("ovd_share_")]
			for g in groups:
				System.groupDelete(g)
                except Exception:
                        Logger.exception("Failed to purge groups")
           		ret = False
		
		return ret
Example #4
0
	def add_user(self, user, mode):
		if not self.active:
			self.enable(mode)
		
		cmd = "adduser %s %s_%s"%(user, self.group, mode)
		p = System.execute(cmd)
		if p.returncode is not 0:
			Logger.error("FS: unable to add user in group")
			Logger.debug("FS: command '%s' return %d: %s"%(cmd, p.returncode, p.stdout.read().decode("UTF-8")))
			return False
		
		htgroup = HTGroup(Config.dav_group_file)
		
		if mode == 'rw':
			self.rw_users.append(user)
			htgroup.add(user, self.group+"_rw")
		else:
			self.ro_users.append(user)
			htgroup.add(user, self.group+"_ro")

		return True
Example #5
0
    def del_user(self, user):
        if user not in self.ro_users and user not in self.rw_users:
            return True

        ret = True
        if user in self.ro_users:
            cmd = "deluser %s %s_ro" % (user, self.group)
        else:
            cmd = "deluser %s %s_rw" % (user, self.group)

        p = System.execute(cmd)
        if p.returncode is not 0:
            ret = False
            Logger.error("FS: unable to del user in group")
            Logger.debug("FS: command '%s' return %d: %s" %
                         (cmd, p.returncode, p.stdout.read().decode("UTF-8")))

        htgroup = HTGroup(Config.dav_group_file)

        if user in self.ro_users:
            self.ro_users.remove(user)
            htgroup.delete(user, self.group + "_ro")
        if user in self.rw_users:
            self.rw_users.remove(user)
            htgroup.delete(user, self.group + "_rw")

        if (len(self.ro_users) + len(self.rw_users)) == 0:
            return self.disable()

        return True
Example #6
0
    def add_user(self, user, mode):
        if not self.active:
            self.enable(mode)

        cmd = "adduser %s %s_%s" % (user, self.group, mode)
        p = System.execute(cmd)
        if p.returncode is not 0:
            Logger.error("FS: unable to add user in group")
            Logger.debug("FS: command '%s' return %d: %s" %
                         (cmd, p.returncode, p.stdout.read().decode("UTF-8")))
            return False

        htgroup = HTGroup(Config.dav_group_file)

        if mode == 'rw':
            self.rw_users.append(user)
            htgroup.add(user, self.group + "_rw")
        else:
            self.ro_users.append(user)
            htgroup.add(user, self.group + "_ro")

        return True