Skip to content

Commit 245cc50

Browse files
committed
fix(distroutils): 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 245cc50

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Utils/distroutils.py

+5-6
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)
@@ -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)