Skip to content

Commit

Permalink
fix(accounting): use /etc/pw.conf to discern accounting information.
Browse files Browse the repository at this point in the history
/etc/user.defs is the shadow configuration file. FreeBSD user management
uses the pw utility.
  • Loading branch information
kro-cat committed Aug 23, 2024
1 parent b22c688 commit 5153b97
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Utils/distroutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def get_my_distro(config, os_name=None):
if 'FreeBSD' in platform.system():
return FreeBSDDistro(config)

if os_name is None:
if os.path.isfile(constants.os_release):
os_name = ext_utils.get_line_starting_with("NAME", constants.os_release)
Expand Down Expand Up @@ -274,7 +274,7 @@ def __init__(self, config):
"""
super(FreeBSDDistro, self).__init__(config)
self.selinux = False
self.ssh_service_name = 'sshd'
self.ssh_service_name = 'openssh'
self.sudoers_dir_base = '/usr/local/etc'
self.distro_name = 'FreeBSD'

Expand All @@ -296,8 +296,8 @@ def create_account(self, user, password, expiration, thumbprint, enable_nopasswd
pass
uidmin = None
try:
if os.path.isfile("/etc/login.defs"):
uidmin = int(ext_utils.get_line_starting_with("UID_MIN", "/etc/login.defs").split()[1])
if os.path.isfile("/etc/pw.conf"):
uidmin = int(ext_utils.get_line_starting_with("minuid", "/etc/pw.conf").split('=')[1].strip(' "'))
except (ValueError, KeyError, AttributeError, EnvironmentError):
pass
pass
Expand Down Expand Up @@ -374,9 +374,8 @@ def delete_account(self, user):
return
uidmin = None
try:
if os.path.isfile("/etc/login.defs"):
uidmin = int(
ext_utils.get_line_starting_with("UID_MIN", "/etc/login.defs").split()[1])
if os.path.isfile("/etc/pw.conf"):
uidmin = int(ext_utils.get_line_starting_with("minuid", "/etc/pw.conf").split('=')[1].strip(' "'))
except (ValueError, KeyError, AttributeError, EnvironmentError):
pass
if uidmin is None:
Expand Down

0 comments on commit 5153b97

Please sign in to comment.