Skip to content

Commit 5153b97

Browse files
committed
fix(accounting): use /etc/pw.conf to discern accounting information.
/etc/user.defs is the shadow configuration file. FreeBSD user management uses the pw utility.
1 parent b22c688 commit 5153b97

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Utils/distroutils.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def get_my_distro(config, os_name=None):
1414
if 'FreeBSD' in platform.system():
1515
return FreeBSDDistro(config)
16-
16+
1717
if os_name is None:
1818
if os.path.isfile(constants.os_release):
1919
os_name = ext_utils.get_line_starting_with("NAME", constants.os_release)
@@ -274,7 +274,7 @@ def __init__(self, config):
274274
"""
275275
super(FreeBSDDistro, self).__init__(config)
276276
self.selinux = False
277-
self.ssh_service_name = 'sshd'
277+
self.ssh_service_name = 'openssh'
278278
self.sudoers_dir_base = '/usr/local/etc'
279279
self.distro_name = 'FreeBSD'
280280

@@ -296,8 +296,8 @@ def create_account(self, user, password, expiration, thumbprint, enable_nopasswd
296296
pass
297297
uidmin = None
298298
try:
299-
if os.path.isfile("/etc/login.defs"):
300-
uidmin = int(ext_utils.get_line_starting_with("UID_MIN", "/etc/login.defs").split()[1])
299+
if os.path.isfile("/etc/pw.conf"):
300+
uidmin = int(ext_utils.get_line_starting_with("minuid", "/etc/pw.conf").split('=')[1].strip(' "'))
301301
except (ValueError, KeyError, AttributeError, EnvironmentError):
302302
pass
303303
pass
@@ -374,9 +374,8 @@ def delete_account(self, user):
374374
return
375375
uidmin = None
376376
try:
377-
if os.path.isfile("/etc/login.defs"):
378-
uidmin = int(
379-
ext_utils.get_line_starting_with("UID_MIN", "/etc/login.defs").split()[1])
377+
if os.path.isfile("/etc/pw.conf"):
378+
uidmin = int(ext_utils.get_line_starting_with("minuid", "/etc/pw.conf").split('=')[1].strip(' "'))
380379
except (ValueError, KeyError, AttributeError, EnvironmentError):
381380
pass
382381
if uidmin is None:

0 commit comments

Comments
 (0)