Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

run apps as non-root user (diagexec setresuid) - #805

Merged
vcaputo merged 3 commits into
rkt:masterfrom
endocode:alban/diagexec_setuid
Apr 24, 2015
Merged

run apps as non-root user (diagexec setresuid)#805
vcaputo merged 3 commits into
rkt:masterfrom
endocode:alban/diagexec_setuid

Conversation

@alban

@alban alban commented Apr 22, 2015

Copy link
Copy Markdown
Member

Fix #539 by adding setresuid and setresgid in diagexec.

I preferred a solution based on RootDirectory (#679) but this was not ready yet.

@alban

alban commented Apr 22, 2015

Copy link
Copy Markdown
Member Author

Warning about the functional test in this PR: gexpect has a bug with some timing (ThomasRooney/gexpect#5) and I work around the gexpect bug with a sleep.

Comment thread stage1/rootfs/diagexec/diagexec.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if the user we get is in text format?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't handle that. I'm not sure what we should do in that case...
See also appc/spec#231

Comment thread tests/inspect/inspect.go Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The fix ThomasRooney/gexpect#6 is merged.
I will update this...

@alban
alban force-pushed the alban/diagexec_setuid branch from 61a4ffd to a66145e Compare April 22, 2015 15:03
alban added a commit to endocode/rkt that referenced this pull request Apr 22, 2015
We need the new version of gexpect for
rkt#805
@alban

alban commented Apr 22, 2015

Copy link
Copy Markdown
Member Author

Branch updated. It contains the fix for gexpect and the sleep has been removed.

@vcaputo

vcaputo commented Apr 22, 2015

Copy link
Copy Markdown
Contributor

Does it look like this will all be obsoleted by using a version of systemd newer than 215?

@alban
alban force-pushed the alban/diagexec_setuid branch from a66145e to 11704cd Compare April 23, 2015 09:56
alban added a commit to endocode/rkt that referenced this pull request Apr 23, 2015
We need the new version of gexpect for
rkt#805
@alban
alban force-pushed the alban/diagexec_setuid branch 2 times, most recently from 0565e3c to 0a373bc Compare April 23, 2015 10:50
@alban

alban commented Apr 23, 2015

Copy link
Copy Markdown
Member Author

github hid some comments after I rebased this branch.

@vcaputo @iaguis : I didn't want to support for all forms of user/group but only numeric uid/gid for now. I added a check with error reporting. The only non-numeric user/group I accept is the string "root" because it was working before so I don't want to introduce the regression. (sytemd has special-case code for "root")

It is a stop-gap and should be revisited either when we get a better idea from appc/spec#231 or when we let systemd do the setuid instead of diagexec.

This stop-gap would stay even when using systemd v219 because support for ExecFail=/usr/bin/diagexec is not implemented yet.

I reduced the verbosity in diagexec by using the first code snippet from your review. setresuid and setresgid are optional if we want to run as root and we are already root.

@alban
alban force-pushed the alban/diagexec_setuid branch from 0a373bc to 76e6ea6 Compare April 23, 2015 11:22
alban added a commit to endocode/rkt that referenced this pull request Apr 23, 2015
We need the new version of gexpect for
rkt#805
@alban

alban commented Apr 23, 2015

Copy link
Copy Markdown
Member Author

I'm not sure why Travis failed to test this.

Semaphore passed the tests successfully on this branch (commit 76e6ea6). I don't know why I don't see the link to the Semaphore results.

@alban
alban force-pushed the alban/diagexec_setuid branch from 76e6ea6 to d5f3dec Compare April 23, 2015 13:09
alban added a commit to endocode/rkt that referenced this pull request Apr 23, 2015
We need the new version of gexpect for
rkt#805
@krnowak

krnowak commented Apr 23, 2015

Copy link
Copy Markdown
Collaborator

I also had some bogus failure in #799. I suppose that travis was simply overloaded.

Comment thread stage1/rootfs/diagexec/diagexec.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it expected that either cwd or root would be "" and should be silently ignored if so?

It seems incorrect for diagexec to have a successful code path which potentially doesn't attempt to chroot or chdir. I'd much rather we error out on unexpected/unsupported inputs than simply skip the associated actions.

@alban
alban force-pushed the alban/diagexec_setuid branch from d5f3dec to 2ad1473 Compare April 24, 2015 08:48
@alban

alban commented Apr 24, 2015

Copy link
Copy Markdown
Member Author

Thanks for the review @vcaputo. I updated the branch.

@vcaputo

vcaputo commented Apr 24, 2015

Copy link
Copy Markdown
Contributor

ok cool, lgtm

vcaputo added a commit that referenced this pull request Apr 24, 2015
run apps as non-root user (diagexec setresuid)
@vcaputo
vcaputo merged commit 6b3549b into rkt:master Apr 24, 2015
@jonboulle

Copy link
Copy Markdown
Contributor

awwwwwwwwwwwwwwww yeah

@jonboulle

Copy link
Copy Markdown
Contributor

@alban what is the latest on ExecFail?

@alban

alban commented Apr 24, 2015

Copy link
Copy Markdown
Member Author

@jonboulle I have not tried to implement ExecFail in systemd yet...
The bug is open on:
https://bugs.freedesktop.org/show_bug.cgi?id=89840

@jonboulle

Copy link
Copy Markdown
Contributor

@alban something that came up in OOB discussion, it's unclear how ExecFail would actually work w.r.t. the chroot - is it going to inject a diagnostic exec into the chroot itself? or expected do the chroot itself? which would make it inconsistent with the other Exec* parameters in that case...

@kayrus
kayrus deleted the alban/diagexec_setuid branch February 5, 2016 11:40
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.

rkt cannot run applications as non-root

5 participants