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

Disable drivers based on whether nomad is running as root. #89

Merged
merged 7 commits into from
Sep 23, 2015

Conversation

dadgar
Copy link
Contributor

@dadgar dadgar commented Sep 23, 2015

The isolation capabilities of drivers other than "docker" go down dramatically if nomad is not running as root. Driver fingerprinters now check for this case and disable themselves.

@@ -52,6 +54,12 @@ func NewQemuDriver(ctx *DriverContext) Driver {
}

func (d *QemuDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) {
// Only enable if we are root. This check also disables on Windows as
// Geteuid() returns -1.
if syscall.Geteuid() != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Windows supports QEMU so we should have the if runtime.GOOS != "windows" check here too.

@@ -7,6 +7,8 @@ import (
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/testutil"

clientTestUtil "github.com/hashicorp/nomad/client/testutil"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird for the package to have uppercasing. Just do ctestutil or something

@cbednarski
Copy link
Contributor

👍

dadgar added a commit that referenced this pull request Sep 23, 2015
Disable drivers based on whether nomad is running as root.
@dadgar dadgar merged commit eb0d358 into master Sep 23, 2015
@ryanuber
Copy link
Member

@dadgar @cbednarski This makes sense in most cases, but I am wondering about the getting started guide and other super-basic use cases. It was pretty helpful for me to be able to just use the exec driver as it's the lowest common denominator and I could coax it into doing whatever I wanted on my local machine, but now I would need to run Nomad as root locally on my laptop, even in dev mode.

I may have missed some slack backlog somewhere, but I don't understand why drivers such as exec would make a decision such that "oh, you aren't root? then you can't exec anything". Operators might want to force Nomad clients down into a super unprivileged user anyways, using the OS as the isolation mechanism and only allowing binding on certain ports, access to certain paths on the filesystem, etc. rather than depending on Nomad to do the right thing for them. For those cases you are kind of SOL, when you see the "this has to run as root" message, and I'm guessing the security crowd would have a field day with that.

Just thinking out loud here - let me know if I missed anything.

@cbednarski
Copy link
Contributor

@ryanuber I agree completely. Dev / test / demo QOL is poorer with the root requirement. However, I think we can resolve this with additional time after 0.1. The tradeoff we're making now is developer convenience vs. production readiness and doing actual scheduling (i.e. resource constraints).

As @dadgar posted out we need root for various features like cgroups, chroot, and mount, which are key components of nomad's isolation functionality. Even something as simple as setuid so nomad can fork/exec as "nobody" requires root permissions. FWIW docker has to run as root for the same reasons. I don't think it's too bad of a requirement for running nomad even though the dev workflow has some extra hoops for now.

@cbednarski cbednarski deleted the f-root-disable-drivers branch September 25, 2015 20:56
schmichael pushed a commit that referenced this pull request Jan 30, 2020
@github-actions
Copy link

github-actions bot commented May 9, 2023

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2023
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.

4 participants