Commit Graph

40 Commits

Author SHA1 Message Date
umohnani8 c50c287aa5 Add FIPS mode secret to buildah run and bud
If the host is in FIPS mode and /etc/system-fips exists
/run/secrets/system-fips is created in the container so that
the container can run in FIPS mode as well.
Vendor in libpod/pkg/secrets and remove the duplicate secrets code
in buildah.
Also remove the hidden --default-mounts-file flag that was being used for test,
as it is not needed anymore and makes the code simpler.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #603
Approved by: rhatdan
2018-04-27 18:28:39 +00:00
pixdrift 4a98b552d6 Revert update of entrypoint behaviour to match docker
Signed-off-by: pixdrift <support@pixeldrift.net>

Closes: #614
Approved by: rhatdan
2018-04-24 13:11:18 +00:00
pixdrift 15e1054820 Update entrypoint behaviour to match docker
Signed-off-by: pixdrift <support@pixeldrift.net>

Closes: #577
Approved by: rhatdan
2018-04-12 16:27:11 +00:00
Daniel J Walsh 5ce80091ba Add support for shell
Also vendor in the latest imagebuilder code and all the packages
that come with it.

Note: imagebuilder.NewBuilderForReader has been removed from imagebuilder
so I had to split the function up into two different calls.

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

Closes: #517
Approved by: rhatdan
2018-04-03 22:25:56 +00:00
Boaz Shuster 66c752bc54 Add unit tests to run.go
* Changed addHostsToFile to make it easy to test
* Changed .travis.yml and Makefile to run all unit tests except ./tests/
* Added unit-tests to addHosts, addHostsToFile and addRlimits

Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>

Closes: #529
Approved by: rhatdan
2018-03-22 11:32:58 +00:00
Daniel J Walsh 9bf5a5e52a Breaking change on CommonBuildOpts
Just have to refuse to use previous created containers when doing a run.

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

Closes: #500
Approved by: rhatdan
2018-02-27 00:05:12 +00:00
Daniel J Walsh 873ecd8791 If commonOpts do not exist, we should return rather then segfault
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #498
Approved by: TomSweeneyRedHat
2018-02-26 22:49:44 +00:00
umohnani8 4bbe6e7cc0 Implement --volume and --shm-size for bud and from
Add the remaining --volume and --shm-size flags to buildah bud and from
--volume supports the following options: rw, ro, z, Z, private, slave, shared

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #491
Approved by: rhatdan
2018-02-23 17:53:00 +00:00
Giuseppe Scrivano 9d163a50d1 run: do not open /etc/hosts if not needed
Avoid opening the file in write mode if we are not going to write
anything.

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

Closes: #487
Approved by: rhatdan
2018-02-22 13:04:38 +00:00
umohnani8 93a3c89943 Add the following flags to buildah bud and from
--add-host
	--cgroup-parent
	--cpu-period
	--cpu-quota
	--cpu-shares
	--cpuset-cpus
	--cpuset-mems
	--memory
	--memory-swap
	--security-opt
	--ulimit

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #477
Approved by: rhatdan
2018-02-19 17:00:29 +00:00
Daniel J Walsh a586779353 We are copying a directory not a single file
When populating a container from a container image with a
volume directory, we need to copy the content of the source
directory into the target.  The code was mistakenly looking
for a file not a directory.

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

Closes: #471
Approved by: nalind
2018-02-12 15:57:23 +00:00
TomSweeneyRedHat 2dbb2a13ed Make bud be really quiet
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #408
Approved by: rhatdan
2018-01-24 15:11:30 +00:00
Nalin Dahyabhai 81dfe0a964 When we say we skip a secrets config file, do so
When we warn about not processing a secrets configuration file, actually
skip anything we might have salvaged from it to make our behavior match
the warning.

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

Closes: #380
Approved by: rhatdan
2018-01-05 16:09:53 +00:00
Daniel J Walsh 01f8c7afee Remove chrootuser handling and use libpod/pkg
I have made a subpackage of libpod to handle chrootuser,
using the user code from buildah.

This patch removes user handling from buildah and uses
projectatomic/libpod/pkg/chrootuser

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

Closes: #377
Approved by: nalind
2018-01-03 15:36:10 +00:00
Daniel J Walsh 38d3cddb0c Make sure builtin volumes have the correct label
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #339
Approved by: nalind
2017-11-28 21:44:17 +00:00
Daniel J Walsh fb99d85b76 Need to block access to kernel files systems in /proc and /sys
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #333
Approved by: TomSweeneyRedHat
2017-11-22 16:13:50 +00:00
Daniel J Walsh 3e8ded8646 Add secrets patch to buildah
Signed-off-by: umohnani8 <umohnani@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-11-08 00:01:57 +00:00
Daniel J Walsh 966f32b2ac Add proper SELinux labeling to buildah run
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #294
Approved by: nalind
2017-11-07 22:40:29 +00:00
Daniel J Walsh 8ecefa978c Vendor in changes to support sirupsen/logrus
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-10-10 17:30:11 +00:00
Nalin Dahyabhai 0de0d23df4 Run: don't complain about missing volume locations
Don't worry about not being able to populate temporary volumes using the
contents of the location in the image where they're expected to be
mounted if we fail to do so because that location doesn't exist.

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

Closes: #248
Approved by: rhatdan
2017-08-24 10:41:29 +00:00
Nalin Dahyabhai 8eb7d6d610 Run(): create the right working directory
When ensuring that the working directory exists before running a
command, make sure we create the location that we set in the
configuration file that we pass to runc.

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

Closes: #241
Approved by: rhatdan
2017-08-10 20:14:54 +00:00
Nalin Dahyabhai b37a981500 Stop trying to set the Platform in runtime specs
run: The latest version of runtime-spec dropped the Platform field, so
stop trying to set it when generating a configuration for a runtime.

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

Closes: #201
Approved by: rhatdan
2017-07-20 18:38:19 +00:00
Nalin Dahyabhai 8efeb7f4ac Handle "run" without an explicit command correctly
When "run" isn't explicitly given a command, mix the command and
entrypoint options and configured values together correctly.

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

Closes: #160
Approved by: rhatdan
2017-06-26 13:21:53 +00:00
Nalin Dahyabhai 303a8df35d Ensure volume points get created, and with perms
Ensure that volume points are created, if they don't exist, when they're
defined in a Dockerfile (#151), and that if we create them, we create
them with 0755 permissions (#152).

When processing RUN instructions or the run command, if we're not
mounting something in a volume's location, create a copy of the volume's
initial contents under the container directory and bind mount that.

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

Closes: #154
Approved by: rhatdan
2017-06-24 10:37:13 +00:00
Nalin Dahyabhai 0d13621874 Add a --volume flag to "buildah run"
Add a --volume/-v flag to "buildah run" to allow volume bind mounts to
be specified on the command line.

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

Closes: #144
Approved by: rhatdan
2017-06-13 21:43:40 +00:00
Dan Walsh 8ced1276e5 Change functions that use a fmt.Errorf to wrap an err to error.Wrapf
Impove error reporting by wrapping all returned err functions with
error.Wrapf

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

Closes: #124
Approved by: nalind

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

Closes: #125
Approved by: nalind
2017-06-02 14:17:04 +00:00
Nalin Dahyabhai 80ca77674c Tweak volume handling in Run()
Make sure that we don't mount a tmpfs in volume locations where Run()
has been told to mount something else.

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

Closes: #121
Approved by: rhatdan
2017-05-31 20:12:07 +00:00
Nalin Dahyabhai 3748b31c04 Defaul to the configured hostname in Run()
If Run() isn't passed a hostname to set, but we have one that was set
directly or inherited from the source image, use that value.

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

Closes: #121
Approved by: rhatdan
2017-05-31 20:12:07 +00:00
Nalin Dahyabhai fc880bcc86 Maintain multiple working container configs
Maintain the container configuration in multiple formats in the Buildah
object, initializing one based on the other, depending on which format
the source image used for its configuration.

Replace directly manipulated fields in the Buildah object (Annotations,
CreatedBy, OS, Architecture, Maintainer, User, Workdir, Env, Cmd,
Entrypoint, Expose, Labels, and Volumes) with accessor functions which
update both configurations and which read from whichever one we consider
to be authoritative.  Drop Args because we weren't using them.

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

Closes: #102
Approved by: rhatdan
2017-05-18 18:28:44 +00:00
Nalin Dahyabhai b7a598ca21 Fixup metalinter errors
Fix a number of issues flagged by gometalinter.

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

Closes: #62
Approved by: rhatdan
2017-04-12 21:25:35 +00:00
Nalin Dahyabhai 96d15578e4 Fixup golint warnings
Fix a number of issues flagged by golint.

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

Closes: #62
Approved by: rhatdan
2017-04-12 21:25:35 +00:00
Nalin Dahyabhai b1bb73e01c Teach "Run" to dig user IDs out of containers
When we have cgo, use fgetpwent() to try to look up user IDs and primary
GIDs in containers.  If that fails for any reason (or if we don't have
cgo), fall back to doing what we were doing before (i.e., trying to look
up the information on the host).

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

Closes: #63
Approved by: rhatdan
2017-04-11 18:41:54 +00:00
Nalin Dahyabhai ccfa6a8bd4 Make Run() use a terminal only if it has one
Make Run() default to running the command with a PTY if we're being run
with stdout connected to terminal, and provide options to force the
decision one way or the other.

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

Closes: #64
Approved by: rhatdan
2017-04-11 16:55:52 +00:00
Nalin Dahyabhai e96ba381a2 Add some more options for Run
Add options to Run() for passing in additional environment variables,
overriding the default command, user, and working directory, and a flag
for controlling whether or not we attach to the host's network.

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

Closes: #46
Approved by: rhatdan
2017-03-27 19:07:38 +00:00
Nalin Dahyabhai c6a4a06454 Bind mount /etc/hosts, /etc/resolv.conf in Run()
When we run a command in Run(), since it's sharing the host's network
namespace, also have it share the host's DNS settings.

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

Closes: #34
Approved by: rhatdan
2017-03-24 20:37:06 +00:00
Nalin Dahyabhai e202577172 Make Run() commands share the host's network
Make commands we run in Run() use the host's networking.

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

Closes: #34
Approved by: rhatdan
2017-03-24 20:37:06 +00:00
Nalin Dahyabhai ae1fffb3fd Always make sure the working directory exists
Always make sure the working directory exists before attempting to run
anything inside of it, and before attempting to copy contents into it or
one of its subdirectories.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-03-23 14:57:00 -04:00
Nalin Dahyabhai 691266d40c Handle volumes in "run"
Default to mounting tmpfs over a container's volume mount points.  Add a
RunOption for adding mounts to a run container, and use it as the
default set, adding any volume mounts and others that don't conflict
with them to it before running the container.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-02-17 13:58:34 -05:00
Nalin Dahyabhai c46716525c Make the runtime for "run" more configurable
Provide RunOptions which can be used to change the runtime to something
other than "runc", and add an option that allows passing in additional
global arguments for the runtime.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-02-17 13:58:11 -05:00
Nalin Dahyabhai 2963474e17 Add a "run" command, using runc
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-02-13 17:21:45 -05:00