SILENT KILLERPanel

Current Path: > > lib > python3.6 > site-packages > > up2date_client


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //lib/python3.6/site-packages//up2date_client

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
__init__.py File 0 bytes May 29 2025 13:37:22.
capabilities.py File 7452 bytes May 29 2025 13:37:22.
clientCaps.py File 2208 bytes May 29 2025 13:37:22.
clpwd.py File 3643 bytes May 29 2025 13:37:22.
config.py File 14803 bytes May 29 2025 13:37:22.
debUtils.py File 2830 bytes May 29 2025 13:37:22.
getMethod.py File 4302 bytes May 29 2025 13:37:22.
haltree.py File 4642 bytes May 29 2025 13:37:22.
hardware.py File 32675 bytes May 29 2025 13:37:22.
hardware_gudev.py File 13216 bytes May 29 2025 13:37:22.
hardware_hal.py File 11604 bytes May 29 2025 13:37:22.
hardware_udev.py File 13300 bytes May 29 2025 13:37:22.
pkgUtils.py File 295 bytes May 29 2025 13:37:22.
pkgplatform.py File 309 bytes May 29 2025 13:47:19.
pmPlugin.py File 2859 bytes May 29 2025 13:37:22.
rhnChannel.py File 5031 bytes May 29 2025 13:37:22.
rhnHardware.py File 328 bytes May 29 2025 13:37:22.
rhnPackageInfo.py File 2396 bytes May 29 2025 13:37:22.
rhncli.py File 9335 bytes May 29 2025 13:37:22.
rhnreg.py File 32101 bytes May 29 2025 13:37:22.
rhnreg_constants.py File 18569 bytes May 29 2025 13:37:22.
rhnserver.py File 9531 bytes May 29 2025 13:37:22.
rpcServer.py File 11999 bytes May 29 2025 13:37:22.
rpmUtils.py File 5321 bytes May 29 2025 13:37:22.
transaction.py File 4193 bytes May 29 2025 13:37:22.
tui.py File 44749 bytes May 29 2025 13:37:22.
up2dateAuth.py File 10944 bytes May 29 2025 13:37:22.
up2dateErrors.py File 10502 bytes May 29 2025 13:37:22.
up2dateLog.py File 2108 bytes May 29 2025 13:37:22.
up2dateUtils.py File 5180 bytes May 29 2025 13:47:19.

Reading File: //lib/python3.6/site-packages//up2date_client/clpwd.py

import pwd
import os

class ClPwd:
    class NoSuchUserException(Exception):
        def __init__(self, user):
            Exception.__init__(self, "No such user (%s)" % (user,))

    def __init__(self, min_uid = None):
        self._user_key_map = {}
        self._uid_key_map = {}
        self._user_full_map = {}
        self._uid_full_map = {}
        if min_uid is None:
            self._min_uid = self.get_sys_min_uid(500)
        else:
            self._min_uid = min_uid

    def get_user_dict(self):
        self._load_passwd_database()
        return self._user_key_map

    def get_uid_dict(self):
        self._load_passwd_database()
        return self._uid_key_map

    def get_user_full_dict(self):
        self._load_passwd_database()
        return self._user_full_map

    def get_uid_full_dict(self):
        self._load_passwd_database()
        return self._uid_full_map

    def get_pw_by_name(self, user):
        """
        Return pw_entry for user
        """
        try:
            return self.get_user_full_dict()[user]
        except KeyError:
            raise ClPwd.NoSuchUserException(user)

    def get_pw_by_uid(self, uid):
        """
        Return list of passwd entries for uid
        """
        try:
            return self.get_uid_full_dict()[uid]
        except KeyError:
            raise ClPwd.NoSuchUserException(uid)

    def get_uid(self, user):
        """
        Returns uid for user
        """
        try:
            return self.get_user_full_dict()[user].pw_uid
        except KeyError:
            raise ClPwd.NoSuchUserException(user)

    def get_homedir(self, user):
        """
        Returns homedir for a user
        @param user: string
        @return: string
        """
        try:
            return self.get_user_full_dict()[user].pw_dir
        except KeyError:
            raise ClPwd.NoSuchUserException(user)

    def _load_passwd_database(self):
        """
        Loads the passwd database and fills user_to_uid and user_to_homedir maps
        """
        if not self._uid_full_map:
            for entry in pwd.getpwall():
                self._user_full_map[entry.pw_name] = entry
                if entry.pw_uid not in self._uid_full_map:
                    self._uid_full_map[entry.pw_uid] = []
                self._uid_full_map[entry.pw_uid].append(entry)
                if entry.pw_uid >= self._min_uid:
                    self._user_key_map[entry.pw_name] = entry
                    if entry.pw_uid not in self._uid_key_map:
                        self._uid_key_map[entry.pw_uid] = []
                    self._uid_key_map[entry.pw_uid].append(entry)

    def get_names(self, uid):
        """
        Return names of users with uid specified
        @param uid: int
        @return: list of strings
        """
        try:
            entries = self.get_uid_full_dict()[uid]
        except KeyError:
            raise ClPwd.NoSuchUserException(uid)

        return [entry.pw_name for entry in entries]


    def get_sys_min_uid(self, def_min_uid = 500):
        """
        Return system defined MIN_UID from /etc/login.def or def_min_uid
        @param def_min_uid: int
        @return: MIN_UID: int
        """

        LOGIN_DEF_FILE = '/etc/login.defs'
        if (os.path.exists(LOGIN_DEF_FILE)):
            with open(LOGIN_DEF_FILE, 'r') as lines:
                for line in lines:
                    if line.startswith('UID_MIN'):
                        try:
                            return int(line.split('UID_MIN')[1].strip())
                        except ValueError:
                            pass

        return def_min_uid

SILENT KILLER Tool