Skip to content

Commit

Permalink
Forgot the syntax of sudoers apparently. Corrected.
Browse files Browse the repository at this point in the history
  • Loading branch information
Torxed committed Aug 31, 2020
1 parent b91699c commit e4b9ad9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __exit__(self, *args, **kwargs):
raise args[1]

if not (missing_steps := self.post_install_check()):
log('Installation completed without any errors.', bg='black', fg='green')
log('Installation completed without any errors. You may now reboot.', bg='black', fg='green')
return True
else:
log('Some required steps were not successfully installed/configured before leaving the installer:', bg='black', fg='red')
Expand Down Expand Up @@ -213,19 +213,23 @@ def install_profile(self, profile):
log(f'Installing network profile {profile}')
return profile.install()

def enable_sudo(self, entity :str, group=False):
log(f'Enabling sudo permissions for {entity}.')
with open(f'{self.mountpoint}/etc/sudoers', 'a') as sudoers:
sudoers.write(f'{"%" if group else ""}{entity} ALL=(ALL) ALL\n')
return True

def user_create(self, user :str, password=None, groups=[], sudo=False):
log(f'Creating user {user}')
o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} useradd -m -G wheel {user}'))
if password:
self.user_set_pw(user, password)

if groups:
for group in groups:
o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} gpasswd -a {user} {group}'))

if sudo:
with open(f'{self.mountpoint}/etc/sudoers', 'a') as sudoers:
sudoers.write(f'{user}\n')

if sudo and self.enable_sudo(user):
self.helper_flags['user'] = True

def user_set_pw(self, user, password):
Expand Down

0 comments on commit e4b9ad9

Please sign in to comment.