Fixes: #2588.
Otherwise, unprivileged user accounts can read/write files that they were not
permitted to by setting the authorized_keys file to be a symlink.
Tests:
- Editing page for freshly created user (as root or as user) shows empty value
for authorized_keys.
- Setting SSH key for freshly created user works (as root or as user). File is
created. Permissions are 0o644 and ownership is the user:'users'. .ssh
directory is created with user:'users' ownership. Login works after setting
the keys.
- After setting authorized keys they are shown properly in the user edit page.
- Editing again works.
- Clearing the values work.
- Linking authorized_key to another file owned (with proper permissions,
ownership) by the user works. Values are shown properly in the edit page.
Setting values works. SSH Login works.
- Linking the authorized_keys file to /etc/shadow leads to returning empty
string.
- Linking the authorized_keys file to /etc/shadow, writing keys fails. Error
message is shown 'Unable to set SSH keys.'. Exception is shown in logs.
- Linking .ssh directory to /etc, writing keys fails. Error message is shown
'Unable to set SSH keys.'. Exception is shown in logs.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>