Skip to content

Fix incorrect permissions for /etc/hosts#772

Merged
brianmay merged 1 commit intosshuttle:masterfrom
skuhl:fix-hosts-permission
Jun 25, 2022
Merged

Fix incorrect permissions for /etc/hosts#772
brianmay merged 1 commit intosshuttle:masterfrom
skuhl:fix-hosts-permission

Conversation

@skuhl
Copy link
Contributor

@skuhl skuhl commented Jun 24, 2022

If we modify /etc/hosts, we read/copy the ownership and permissions
from the existing /etc/hosts before we make our new temporary file
which will eventually overwrite /etc/hosts. If we fail to retrieve the
permissions of the existing /etc/hosts file, we made the temporary
file owned by root 0o600 permissions. It should have 0o644 permissions
so that /etc/hosts has the correct permissions once we rename it.

It is unlikely many encoutered this bug since most machines have
/etc/hosts prior to sshuttle running and we should be able to read the
permission/ownership of that existing file.

If we modify /etc/hosts, we read/copy the ownership and permissions
from the existing /etc/hosts before we make our new temporary file
which will eventually overwrite /etc/hosts. If we fail to retrieve the
permissions of the existing /etc/hosts file, we made the temporary
file owned by root 0o600 permissions. It should have 0o644 permissions
so that /etc/hosts has the correct permissions once we rename it.

It is unlikely many encoutered this bug since most machines have
/etc/hosts prior to sshuttle running and we should be able to read the
permission/ownership of that existing file.
@brianmay
Copy link
Member

Looks like I did this... 191df92

I agree, this file should be 0o644.

@brianmay brianmay merged commit df98790 into sshuttle:master Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants