Commit graph

118 commits

Author SHA1 Message Date
Jhon Honce 8e145d9c9a Fix varlink API usage of psgo
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2018-07-24 12:06:16 -07:00
Valentin Rothberg 8569ed0305 AppArmor: runtime check if it's enabled on the host
Check at runtime if AppArmor is enabled on the host.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1128
Approved by: mheon
2018-07-23 18:11:09 +00:00
Giuseppe Scrivano d4f14be3a7
rootless: support a per-user mounts.conf
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-20 11:00:53 +02:00
Giuseppe Scrivano 45a92f8357
secrets: parse only one mounts configuration file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-20 11:00:53 +02:00
Giuseppe Scrivano c737d01937
rootless: allow a per-user registries.conf file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-20 11:00:52 +02:00
Giuseppe Scrivano 6372c977ea rootless: require subids to be present
Most images won't work without multiple ids/gids.  Error out
immediately if there are no multiple ids available.

The error code when the user is not present in /etc/sub{g,u}id looks
like:

$ bin/podman run --rm -ti alpine echo hello
ERRO[0000] No subuid ranges found for user "gscrivano"

Closes: https://github.com/projectatomic/libpod/issues/1087

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

Closes: #1097
Approved by: rhatdan
2018-07-16 13:40:40 +00:00
Matthew Heon 5b43a6a7ee Only print container size JSON if --size was requested
To do this, move it into a separate struct, and embed that in
the JSON we return.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-07-13 14:28:41 -04:00
Daniel J Walsh 14a6d51a84
Merge pull request #1091 from giuseppe/rootless-unshare-mount-ns
rootless: unshare mount namespace
2018-07-13 14:16:24 -04:00
Daniel J Walsh 673465a747
Merge pull request #1075 from giuseppe/rootless-no-symlinks-into-storage-path
rootless: fix usage on Fedora Silverblue/CoreOS
2018-07-13 14:15:54 -04:00
Giuseppe Scrivano 62e48e5b71
rootless: correctly propagate the exit status from the container
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-13 16:41:11 +02:00
Giuseppe Scrivano 6ffcb98a70
rootless: unshare mount namespace
unshare the mount namespace as well when creating an user namespace so
that we are the owner of the mount namespace and we can mount FUSE
file systems on Linux 4.18.  Tested on Fedora Rawhide:

podman --storage-opt overlay.fuse_program=/usr/bin/fuse-overlayfs run alpine echo hello
hello

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-13 16:37:37 +02:00
haircommander a04a8d1dd4 Added full podman pod ps, with tests and man page
Signed-off-by: haircommander <pehunt@redhat.com>
2018-07-13 09:17:33 -04:00
haircommander 1aad3fd96b Podman pod create/rm commands with man page and tests.
Includes a very stripped down version of podman pod ps, just for testing

Signed-off-by: haircommander <pehunt@redhat.com>
2018-07-13 09:05:03 -04:00
baude 4f699db8da Support multiple networks
This is a refresh of Dan William's PR #974 with a rebase and proper
vendoring of ocicni and containernetworking/cni.  It adds the ability
to define multiple networks as so:

podman run --network=net1,net2,foobar ...

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1082
Approved by: baude
2018-07-12 21:45:47 +00:00
baude 7f3f491396 create conmon sockets when getting their paths
when using the getattachsockets endpoint, which returns the sockets needed
to create and use a terminal, we should check if the container is just in the
configured state.  if so, we need to perform a container init to have conmon
create the required sockets so we can attach to them prior to starting the container.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1067
Approved by: jwhonce
2018-07-11 19:55:16 +00:00
Valentin Rothberg 06ab343bd7 podman/libpod: add default AppArmor profile
Make users of libpod more secure by adding the libpod/apparmor package
to load a pre-defined AppArmor profile.  Large chunks of libpod/apparmor
come from github.com/moby/moby.

Also check if a specified AppArmor profile is actually loaded and throw
an error if necessary.

The default profile is loaded only on Linux builds with the `apparmor`
buildtag enabled.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1063
Approved by: rhatdan
2018-07-11 16:36:24 +00:00
Giuseppe Scrivano 84cfdb2061 rootless: fix when argv[0] is not an absolute path
use execvp instead of exec so that we keep the PATH environment
variable and the lookup for the "podman" executable works.

Closes: https://github.com/projectatomic/libpod/issues/1070

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

Closes: #1072
Approved by: mheon
2018-07-10 16:13:43 +00:00
umohnani8 4855998f1c Add --volumes-from flag to podman run and create
podman now supports --volumes-from flag, which allows users
to add all the volumes an existing container has to a new one.

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

Closes: #931
Approved by: mheon
2018-07-09 19:30:03 +00:00
Daniel J Walsh 5a8e5a2b17 Mask /proc/keys to protect information leak about keys on host
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1060
Approved by: mheon
2018-07-08 13:38:20 +00:00
W. Trevor King 0660108e3e ctime: Drop 32-/64-bit distinction on Linux
We added the explicit int64 casts for 32-bit builds in 35e1ad78 (Make
libpod build on 32-bit systems, 2018-02-12, #324), but the explicit
casts work fine on 64-bit systems too.

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #1058
Approved by: mheon
2018-07-07 20:35:00 +00:00
W. Trevor King b2344b83ed pkg/ctime: Factor libpod/finished* into a separate package
This removes some boilerplate from the libpod package, so we can focus
on container stuff there.  And it gives us a tidy sub-package for
focusing on ctime extraction, so we can focus on unit testing and
portability of the extraction utility there.

For the unsupported implementation, I'm falling back to Go's ModTime
[1].  That's obviously not the creation time, but it's likely to be
closer than the uninitialized Time structure from cc6f0e85 (more
changes to compile darwin, 2018-07-04, #1047).  Especially for our use
case in libpod/oci, where we're looking at write-once exit files.

The test is more complicated than I initially expected, because on
Linux filesystem timestamps come from a truncated clock without
interpolation [2] (and network filesystems can be completely decoupled
[3]).  So even for local disks, creation times can be up to a jiffie
earlier than 'before'.  This test ensures at least monotonicity by
creating two files and ensuring the reported creation time for the
second is greater than or equal to the reported creation time for the
first.  It also checks that both creation times are within the window
from one second earlier than 'before' through 'after'.  That should be
enough of a window for local disks, even if the kernel for those
systems has an abnormally large jiffie.  It might be ok on network
filesystems, although it will not be very resilient to network clock
lagging behind the local system clock.

[1]: https://golang.org/pkg/os/#FileInfo
[2]: https://groups.google.com/d/msg/linux.kernel/mdeXx2TBYZA/_4eJEuJoAQAJ
     Subject: Re: Apparent backward time travel in timestamps on file creation
     Date: Thu, 30 Mar 2017 20:20:02 +0200
     Message-ID: <tqMPU-1Sb-21@gated-at.bofh.it>
[3]: https://groups.google.com/d/msg/linux.kernel/mdeXx2TBYZA/cTKj4OBuAQAJ
     Subject: Re: Apparent backward time travel in timestamps on file creation
     Date: Thu, 30 Mar 2017 22:10:01 +0200
     Message-ID: <tqOyl-36A-1@gated-at.bofh.it>

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #1050
Approved by: mheon
2018-07-06 17:54:32 +00:00
Daniel J Walsh aaab26fd0c Block use of /proc/acpi from inside containers
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1053
Approved by: mheon
2018-07-06 17:29:35 +00:00
W. Trevor King 4f0c0597a1 spec: Make addPrivilegedDevices and createBlockIO per-platform
b96be3af (changes to allow for darwin compilation, 2018-06-20, #1015)
made AddPrivilegedDevices per-platform and cc6f0e85 (more changes to
compile darwin, 2018-07-04, #1047) made CreateBlockIO per-platform.
But both left but left out docs for the unsupported version [1]:

  pkg/spec/config_unsupported.go:18:1⚠️ exported method
    CreateConfig.AddPrivilegedDevices should have comment or be
    unexported (golint)
  pkg/spec/config_unsupported.go:22:1⚠️ exported method
    CreateConfig.CreateBlockIO should have comment or be unexported
    (golint)

To keep the docs DRY, I've restored the public methods and their docs,
and I've added new, internal methods for the per-platform
implementations.

[1]: https://travis-ci.org/projectatomic/libpod/jobs/400555937#L160

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #1034
Approved by: baude
2018-07-06 00:48:40 +00:00
W. Trevor King 83968de28c rootless: Merge rootless.go back into rootless_linux.go
The files were split apart by b96be3af (changes to allow for darwin
compilation, 2018-06-20, #1015), but the C import and two functions
left in rootless.go are all Linux-specific as well.  This commit moves
all of the pre-b96be3af rootless.go into rootless_linux.go, just
adding the '// +build linux' header (b96be3af also scrambled the + in
that header) and keeping the new GetRootlessUID from a1545fe6
(rootless: add function to retrieve the original UID, 2018-07-05, #1048).

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #1034
Approved by: baude
2018-07-06 00:48:39 +00:00
baude cc6f0e85f9 more changes to compile darwin
this should represent the last major changes to get darwin to **compile**.  again,
the purpose here is to get darwin to compile so that we can eventually implement a
ci task that would protect against regressions for darwin compilation.

i have left the manual darwin compilation largely static still and in fact now only
interject (manually) two build tags to assist with the build.  trevor king has great
ideas on how to make this better and i will defer final implementation of those
to him.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1047
Approved by: rhatdan
2018-07-05 16:05:12 +00:00
Giuseppe Scrivano a1545fe6e4 rootless: add function to retrieve the original UID
After we re-exec in the userNS os.Getuid() returns the new UID (= 0)
which is not what we want to use.

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

Closes: #1048
Approved by: mheon
2018-07-05 13:30:15 +00:00
baude d357703e06 add image user to inspect data
Signed-off-by: baude <bbaude@redhat.com>

Closes: #1036
Approved by: rhatdan
2018-07-02 15:10:46 +00:00
baude b96be3af1b changes to allow for darwin compilation
Signed-off-by: baude <bbaude@redhat.com>

Closes: #1015
Approved by: baude
2018-06-29 20:44:09 +00:00
Daniel J Walsh 7fc1a329bd Add podman container cleanup to CLI
When we run containers in detach mode, nothing cleans up the network stack or
the mount points.  This patch will tell conmon to execute the cleanup code when
the container exits.

It can also be called to attempt to cleanup previously running containers.

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

Closes: #942
Approved by: mheon
2018-06-29 15:25:21 +00:00
Daniel J Walsh 810f2b6061 Start using github.com/seccomp/containers-golang
User newer seccomp bindings from the seccomp upstream

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

Closes: #1021
Approved by: giuseppe
2018-06-29 13:18:41 +00:00
Daniel J Walsh c9eddd22eb conmon no longer writes to syslog
If the caller sets up the app to be in logrus.DebugLevel,
then we will add the --syslog flag to conmon to get all of the
messages.

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

Closes: #1014
Approved by: TomSweeneyRedHat
2018-06-29 08:22:27 +00:00
W. Trevor King fd12c8918b *: Replace Generator.Spec() with Generator.Config
Catching up with opencontainers/runtime-tools@84a62c6a (generate: Move
Generator.spec to Generator.Config, 2016-11-06, #266, v0.6.0), now
that we've bumped runtime-tools in f6c0fc1a (Vendor in latest
runtime-tools, 2018-06-26, #1007).

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #1008
Approved by: mheon
2018-06-27 21:27:19 +00:00
baude c32c491869 generator.New() requires an OS string input variable
Signed-off-by: baude <bbaude@redhat.com>

Closes: #1007
Approved by: baude
2018-06-27 15:16:02 +00:00
Giuseppe Scrivano 20862c9746 rootless: do not configure additional groups
Additional groups are not allowed in an userNS.

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

Closes: #936
Approved by: rhatdan
2018-06-27 14:07:17 +00:00
Giuseppe Scrivano 5ff90677c8 rootless: add management for the userNS
When running podman as non root user always create an userNS and let
the OCI runtime use it.

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

Closes: #936
Approved by: rhatdan
2018-06-27 14:07:17 +00:00
umohnani8 088d5af879 Podman history now prints out intermediate image IDs
If the intermediate image exists in the store, podman history
will show the IDs of the intermediate image of each layer.

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

Closes: #982
Approved by: mheon
2018-06-22 15:19:34 +00:00
Daniel J Walsh 82a948c04e Option handling has become large and should be a shared function
Everytime we add a new option for create, we end up having to also
add it to run, this makes it error prone.  Moving these to the same
function makes it easier to develop and prevents user mistakes.

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

Closes: #975
Approved by: mheon
2018-06-22 14:30:18 +00:00
Wim 9e134576e8 Add more network info ipv4/ipv6 and be more compatible with docker
Signed-off-by: Wim <wim@42.be>

Closes: #953
Approved by: mheon
2018-06-17 21:21:27 +00:00
Giuseppe Scrivano 16ea659757 spec: remove dead code
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:19 +00:00
Giuseppe Scrivano c976d49805 network: do not attempt to create a network in rootless mode
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:18 +00:00
Giuseppe Scrivano 3861098fb3 oci: do not set resources in rootless mode
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:18 +00:00
Giuseppe Scrivano ed0261176b spec: change mount options for /dev/pts in rootless mode
The default /dev/pts has the option gid=5 that might not be mapped in
the rootless case.

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

Closes: #871
Approved by: mheon
2018-06-15 14:53:18 +00:00
Giuseppe Scrivano be66361e08 podman: provide a default UID mapping when non root
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:18 +00:00
Giuseppe Scrivano 7bdfb4f9b3 podman: accept option --rootfs to use exploded images
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:18 +00:00
Matthew Heon 4b4de5dc21 When setting a memory limit, also set a swap limit
Closes #940

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #946
Approved by: rhatdan
2018-06-15 09:25:21 +00:00
baude 06a29f0bde varlink build fixes
the varlink build was not working as designed and required some touch-ups:

* return a struct that includes logs and the new image ID
* pass namespaceoption so that networking in buildah works

Signed-off-by: baude <bbaude@redhat.com>

Closes: #903
Approved by: rhatdan
2018-06-05 19:31:13 +00:00
W. Trevor King c9f763456c libpod: Execute poststop hooks locally
Instead of delegating to the runtime, since some runtimes do not seem
to handle these reliably [1].

[1]: https://github.com/projectatomic/libpod/issues/730#issuecomment-392959938

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #864
Approved by: rhatdan
2018-06-04 18:36:40 +00:00
Matthew Heon 6d52ebdd13 Add flag to add annotations to a container
Also add annotations from the image the container was created
from.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #886
Approved by: rhatdan
2018-06-04 17:52:28 +00:00
Daniel J Walsh 3416e9f194 Want to change the log level on buildah by default to warnf
Change the level of missing /etc/containers/mount.conf to a debug, since
this is expected on most machines.

Also raised the level of some warnings to errors, so they will be better seen,
even if we are skipping.

Fixed the wording of one error, since stating is not the correct word.

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

Closes: #882
Approved by: mheon
2018-06-04 15:12:12 +00:00
W. Trevor King 41a3f48f6d hooks: Add debug logging for initial hook loading
We've had logrus logging in the monitor code since it landed in
68eb128f (pkg/hooks: Version the hook structure and add 1.0.0 hooks,
2018-04-27, #686).  This commit adds similar logging to the initial
hook.New() and Manager.Hooks() calls to make it easier to see if those
are working as expected.

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #887
Approved by: rhatdan
2018-06-04 13:01:56 +00:00