Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

login: T5875: fix corner case for KeyError: 'getpwuid(): uid not found: XXXX' #3270

Merged
merged 1 commit into from
Apr 7, 2024

Conversation

c-po
Copy link
Member

@c-po c-po commented Apr 6, 2024

Change Summary

Commit 1b36442 ("login: T5875: restore home directory permissions only when needed") added logic to chown the users home directory if it's UID changes. This might happen when a user account is deleted and re-added to the system.

Under rar e circumstances it was possible that the implementation triggered

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'getpwuid(): uid not found: XXXX'

This has been fixed by re-arranging the code path with an additional try/except if the PW database information could not be retrieved leading to an implicit chown() of the home directory to the user beeing added.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

Component(s) name

login

Proposed changes

How to test

Smoketest result

vyos@LR1.wue3:~$ /usr/libexec/vyos/tests/smoke/cli/test_system_login.py
test_add_linux_system_user (__main__.TestSystemLogin.test_add_linux_system_user) ... ok
test_radius_kernel_features (__main__.TestSystemLogin.test_radius_kernel_features) ... ok
test_system_login_max_login_session (__main__.TestSystemLogin.test_system_login_max_login_session) ... ok
test_system_login_otp (__main__.TestSystemLogin.test_system_login_otp) ... ok
test_system_login_radius_ipv4 (__main__.TestSystemLogin.test_system_login_radius_ipv4) ... ok
test_system_login_radius_ipv6 (__main__.TestSystemLogin.test_system_login_radius_ipv6) ... ok
test_system_login_tacacs (__main__.TestSystemLogin.test_system_login_tacacs) ... ok
test_system_login_user (__main__.TestSystemLogin.test_system_login_user) ... ok
test_system_user_ssh_key (__main__.TestSystemLogin.test_system_user_ssh_key) ... ok

----------------------------------------------------------------------
Ran 9 tests in 233.063s

OK

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

…d: XXXX'

Commit 1b36442 ("login: T5875: restore home directory permissions only when
needed") added logic to chown the users home directory if it's UID changes.
This might happen when a user account is deleted and re-added to the system.

Under rar e circumstances it was possible that the implementation triggered

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'getpwuid(): uid not found: XXXX'

This has been fixed by re-arranging the code path with an additional try/except
if the PW database information could not be retrieved leading to an implicit
chown() of the home directory to the user beeing added.
@vyosbot vyosbot requested review from a team, dmbaturin and sarthurdev and removed request for a team April 6, 2024 19:13
@vyosbot vyosbot requested review from zdc, jestabro and sever-sever April 6, 2024 19:13
@c-po
Copy link
Member Author

c-po commented Apr 6, 2024

@Mergifyio backport sagitta

Copy link
Contributor

mergify bot commented Apr 6, 2024

backport sagitta

✅ Backports have been created

@dmbaturin dmbaturin merged commit 157e5c4 into vyos:current Apr 7, 2024
9 checks passed
c-po added a commit that referenced this pull request Apr 7, 2024
login: T5875: fix corner case for KeyError: 'getpwuid(): uid not found: XXXX' (backport #3270)
@c-po c-po deleted the login-T5875 branch April 9, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants