Skip to content

Commit

Permalink
Merge pull request #8 from nwg-piotr/ascii
Browse files Browse the repository at this point in the history
Avoid crash on non-ASCII characters in user dirs
  • Loading branch information
nwg-piotr authored Mar 22, 2024
2 parents 0d4a86b + 80ba89f commit 0d207e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions nwg_hello/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ def list_users(log=False):
for uname in os.listdir('/home'):
try:
# ask pam about users
user = subprocess.check_output(['getent', 'passwd', uname]).decode('ascii').strip()
except subprocess.SubprocessError:
user = subprocess.check_output(['getent', 'passwd', uname]).decode('utf-8').strip()
except Exception as e:
# skip nonexistent users
eprint(e)
continue
user = user.split(':')
if int(user[2]) >= uid_min:
users.append(user[0])
if user:
user = user.split(':')
if int(user[2]) >= uid_min:
users.append(user[0])
return users


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def read(f_name):

setup(
name='nwg-hello',
version='0.1.7',
version='0.1.8',
description='GTK3-based greeter for greetd',
packages=find_packages(),
include_package_data=True,
Expand Down

0 comments on commit 0d207e1

Please sign in to comment.