Commit Graph

28 Commits

Author SHA1 Message Date
Sascha Grunert 5d723ff5ab Add errcheck linter and fix missing error check
This commit enabled the errcheck linter and fixes an uncovered stat to
`os.DevNull`. Beside this, we disable go modules within the
`tests/tools/Makefile` to allow independent offline builds.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>

Closes: #1713
Approved by: vrothberg
2019-07-10 13:03:22 +00:00
Daniel J Walsh 254a3d2e1c On Masked path, check if /dev/null already mounted before mounting
We do not want to mount /dev/null over a masked path, if the path is
already /dev/null.

This prevents an containers running buildah from requiring additional privs
to mount on a /dev/null, when the target is already mounted.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1705
Approved by: TomSweeneyRedHat
2019-07-04 10:34:44 +00:00
Valentin Rothberg 2e485df336 fix "ineffectual assignment" lint errors
Reported by golangci-lint.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

Closes: #1678
Approved by: rhatdan
2019-06-19 11:33:36 +00:00
Valentin Rothberg 2c4f388bdf chroot: only log clean-up errors
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

Closes: #1624
Approved by: TomSweeneyRedHat
2019-06-17 18:45:00 +00:00
Valentin Rothberg 113dffd78b chroot: fix error handling in deferred funcs
errors.Wrap(err) and friends will return nil if err is nil, so make
setting the error conditional.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

Closes: #1624
Approved by: TomSweeneyRedHat
2019-06-17 18:45:00 +00:00
Valentin Rothberg 8c18a2e628 chroot/run.go: check errors in deferred calls
Reported by golangci-lint.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

Closes: #1624
Approved by: TomSweeneyRedHat
2019-06-17 18:45:00 +00:00
Giuseppe Scrivano dc7b50c9da run: fix hang with run and --isolation=chroot
make the stdin pipe not blocking, so that it won't hang if the other
end is not reading from it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1668
Approved by: rhatdan
2019-06-13 13:26:46 +00:00
Giuseppe Scrivano ac346461d3 chroot: drop unused function call
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1668
Approved by: rhatdan
2019-06-13 13:26:46 +00:00
TomSweeneyRedHat e43b864952 Add default /root if empty on chroot iso
Checks to see if the $HOME envvar has been set
and if not, trys to set it as best as possible.

Fixes: #1592

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1594
Approved by: rhatdan
2019-05-22 06:53:33 +00:00
Daniel J Walsh bcc5e51a94 Add support for Overlay volumes into the container.
Overlay mounts allow buildah bud and buildah from to
specify a directory on the disk that will be mounted
as an overlay into the container, where the overlay can be written to
but when the RUN or buildah run exits, the modified files will dissapear.

The basic idea is to be able to mount cache from the disk for things like yum/dnf/apt
to be able to be used and modified in the contianer on a run command, but to be
kept fresh for each RUN.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1560
Approved by: giuseppe
2019-05-20 12:54:10 +00:00
Daniel J Walsh 135542ecf0 Move Host IDMAppings code from util to unshare
This will make vendoring in pkg/unshare easier into other
packages like skopeo.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1532
Approved by: TomSweeneyRedHat
2019-04-18 19:46:22 +00:00
Giuseppe Scrivano ac66d785d4 unshare: move to pkg/
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1475
Approved by: rhatdan
2019-04-05 03:04:46 +00:00
Nalin Dahyabhai fa8653314a run: ignore EIO when flushing at the end, avoid double log
When reading the last of the output from a child process, ignore an EIO,
since we already got the HUP indication.

Avoid double-logging errors in our I/O loop when using isolation other
than chroot (spotted by @afbjorklund).

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1273
Approved by: rhatdan
2019-01-12 12:04:54 +00:00
Daniel J Walsh 18309de5b7 Allow cgroups to be passed into chroot, read/only
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1130
Approved by: rhatdan
2018-11-16 02:34:55 +00:00
TomSweeneyRedHat aeac8e9647 Check for empty buildTime in version
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1107
Approved by: rhatdan
2018-10-19 12:46:52 +00:00
Nalin Dahyabhai 0a971ebeec chroot: set up seccomp and capabilities after supplemental groups
Move the setting of capabilites and the seccomp filter to after we've
set the supplemental groups list and set our primary GID.

Set capabilities after we set the seccomp filter, because we won't be
able to set a filter if we're dropping CAP_SYS_ADMIN.  Set them as the
very last thing before dropping to the runtime UID.  Leave CAP_SETUID in
if we're going to become an unprivileged user, so that we'll be allowed
to switch UIDs -- the capability will be dropped then anyway.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1069
Approved by: rhatdan
2018-10-05 13:03:02 +00:00
Nalin Dahyabhai 289c512c0d chroot: fix capabilities list setup and application
Correctly handle setting capabilities: the Clear() and Apply() methods
on the Capabilities interface take a bitmask of capability kinds, not
specific capability types.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1069
Approved by: rhatdan
2018-10-05 13:03:02 +00:00
Nalin Dahyabhai 0a8af543b2 chroot: only create user namespaces when we know we need them
When running with chroot isolation, only create a new user namespace
when we have mappings to set.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1069
Approved by: rhatdan
2018-10-05 13:03:02 +00:00
Daniel J Walsh ba012ddec6
Move buildah from projecatatomic/buildah to containers/buildah
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-09-18 08:06:11 -04:00
Nalin Dahyabhai 2358d51e74 chroot: create missing parent directories for volume mounts
When ensuring that the target for a volume mount is present, be sure to
create any leading directories which are also not yet present.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #997
Approved by: rhatdan
2018-09-14 14:11:39 +00:00
Nalin Dahyabhai e4ec46aaa0 stdin: on HUP, read everything
When we're polling to handle stdio for a container, when we detect a HUP
on our stdin, read all that we can from stdin before closing it, instead
of reading only, at most, a single chunk of bytes.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #980
Approved by: rhatdan
2018-09-04 20:08:20 +00:00
Nalin Dahyabhai 347478cccd chroot isolation: chroot() before setting up seccomp
Make the chroot() call before applying a seccomp filter, which might not
allow us to do it.  Add more debugging messages.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #979
Approved by: rhatdan
2018-08-31 13:46:10 +00:00
Nalin Dahyabhai 9175ccea84 chroot: correct a comment
We're specifying the MS_RDONLY flag, so don't suggest that we're doing a
read-write mount.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #923
Approved by: rhatdan
2018-08-10 15:45:26 +00:00
Nalin Dahyabhai ba23b7f106 chroot: bind mount an empty directory for masking
In chroot isolation, when we attempt to mask a directory, use a
read-only bind mount of an empty directory instead of a read-only mount
of a fresh tmpfs with size=0, which is more likely to be be denied by
mandatory access controls.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #923
Approved by: rhatdan
2018-08-10 15:45:26 +00:00
Daniel J Walsh 2cafe11229 unshare: make adjusting the OOM score optional
The OOM score adjustment is an optional field in the runtime spec, so
only try to set it if it's set in the spec.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #906
Approved by: rhatdan
2018-08-03 13:24:47 +00:00
Nalin Dahyabhai 35a37f36d3 chroot: handle raising process limits
When using chroot isolation, if we're configured to raise any process
limits above their current values, do so in the grandparent process,
before it transfers execution to a child that it starts in a user
namespace, which won't have the privileges to do so.

The child can still lower resource limits and set limits to the values
that it inherited, so let it continue to do so.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #891
Approved by: rhatdan
2018-08-03 09:02:08 +00:00
Nalin Dahyabhai 3160f5479e chroot: make the resource limits name map module-global
Move the resource limits name map out of the setRlimits() function, and
use it to set up a reverse of the same map in init().

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #891
Approved by: rhatdan
2018-08-03 09:02:08 +00:00
Nalin Dahyabhai 38ef1231f2 Add and implement IsolationChroot
Add an IsolationChroot that trades flexibility and isolation for being
able to do what it does in a host environment that's already isolated to
the point where we're not allowed to set up some of that isolation,
producing a result that leans more toward chroot(1) than runc(1) does.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #836
Approved by: rhatdan
2018-08-01 14:04:59 +00:00