Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Avoid Timed out error when umask is 027 or 077 #435

Merged
1 commit merged into from
Dec 12, 2017

Conversation

brandon-rhodes
Copy link
Contributor

If LXC commands are run with a restrictive umask like 027 or 077, then
the root directory of new containers will lack read r and access x
permission for non-root users. The first failure to result from this
during vagrant up is that the SSH daemon cannot read the crucial file
/home/vagrant/.ssh/authorized_keys after it drops privileges to the
level of the vagrant user. The result is the familiar:

    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

So we should make sure that we run all LXC commands with a umask that at
least does not prevent group and world r and x bits from being set
in newly created files and directories.

If LXC commands are run with a restrictive umask like 027 or 077, then
the root directory of new containers will lack read `r` and access `x`
permission for non-root users.  The first failure to result from this
during `vagrant up` is that the SSH daemon cannot read the crucial file
`/home/vagrant/.ssh/authorized_keys` after it drops privileges to the
level of the `vagrant` user.  The result is the familiar:

```
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
```

So we should make sure that we run all LXC commands with a umask that at
least does not prevent group and world `r` and `x` bits from being set
in newly created files and directories.
@boltronics
Copy link

Nice. I just saw this, and unfortunately also came up with my own fix.

I took a different approach as seen here: sitepoint@61b384a

@ghost ghost self-assigned this Dec 11, 2017
@ghost
Copy link

ghost commented Dec 12, 2017

Interesting problem. I could reproduce it as well. It might be a problem with LXC directly if I look at lxc/lxc#1403 .

@boltronics I like the elegance of your solution, but @brandon-rhodes' solution has the advantage of working even when the user hasn't installed the sudo wrapper.

Testing the fix, then merging.

@ghost
Copy link

ghost commented Dec 12, 2017

Does the trick. Thanks @brandon-rhodes

@ghost ghost merged commit 8b93206 into fgrehm:master Dec 12, 2017
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants