Commit graph

71 commits

Author SHA1 Message Date
Debarshi Ray
ca41e387d7 Give access to the FUSE kernel module
https://github.com/debarshiray/fedora-toolbox/issues/15
2019-01-11 16:02:01 +01:00
Debarshi Ray
4873850da2 Separate fedora-toolbox debug output from those originating elsewhere 2019-01-11 15:01:43 +01:00
Debarshi Ray
1f9007cc2c Replace tabs with spaces 2019-01-11 15:00:21 +01:00
Debarshi Ray
b71609580b Improve the readability of the debug output
... by annotating the different stages of activity. This makes it
easier to understand the rest of the spew coming from buildah and
podman.

https://github.com/debarshiray/fedora-toolbox/issues/31
2019-01-11 14:52:24 +01:00
Mildred Ki'Lya
e2315f183e Try to enter the same directory inside the toolbox
The intermediate /bin/sh process will reset the values of PS1 and PWD.
Therefore, it's necessary to pass those as arguments to the script.

https://github.com/debarshiray/fedora-toolbox/issues/20
2019-01-10 17:14:43 +00:00
Debarshi Ray
d7ec66c8ab Prepare 0.0.3 2019-01-04 12:41:43 +00:00
Debarshi Ray
0ed1be57e4 Update copyright notices 2019-01-04 12:37:52 +00:00
Debarshi Ray
62e20f9df3 Clean up the Buildah working containers on error
Working containers are removed with 'buildah rm', while 'buildah rmi'
is for images.
2019-01-03 13:00:43 +00:00
Milos Vyletel
c713908e8b Unbreak creating the toolbox if the toolbox image already exists
Fallout from cc0caef627

https://github.com/debarshiray/fedora-toolbox/issues/19
2019-01-02 17:36:02 +01:00
Debarshi Ray
dd4394c32c README.md: Tweak
There's a build system and various Fedora packages now. Therefore, most
people don't need to run the script from the Git tree.
2018-11-12 15:11:33 +00:00
Debarshi Ray
cfefaf368a Prepare 0.0.2 2018-11-12 14:49:04 +00:00
Debarshi Ray
606c2da224 Don't fallback to /bin/bash when exiting with a failure return code
If the last command that was run interactively inside the toolbox
container had returned with a non-zero return code, then exiting the
toolbox would trigger the fallback to /bin/bash, just like it would
happen if $SHELL was missing from the toolbox. This is because
'podman exec ...' relays the return code of the last command.

Therefore, don't rely on the return code of 'podman exec ...' and check
the availability of $SHELL upfront. This does leave it vulnerable to
races caused by the availability of $SHELL changing between the check
and the actual attempt to use it. However, file I/O is inherently racy,
and this is better than a spurious fallback.

Keep the name of the default interactive shell localized to 'enter' by
using a subshell because 'local' is not mandated by POSIX.
2018-11-12 15:33:04 +01:00
Debarshi Ray
be719eac89 Hide the error output from sed(1) unless --verbose is used
It's unlikely that sed(1) will generate any error output, but still
it's good to handle it for the sake of completeness.
2018-11-09 12:30:15 +00:00
Debarshi Ray
cc0caef627 Give access to the system D-Bus instance
It bind mounts $DBUS_SYSTEM_BUS_ADDRESS, if present, and sets the
DBUS_SYSTEM_BUS_ADDRESS environment variable inside the toolbox.
Otherwise, it defaults to "unix:path=/var/run/dbus/system_bus_socket"
as defined in the D-Bus specification [1].

[1] https://dbus.freedesktop.org/doc/dbus-specification.html
2018-11-09 12:27:40 +00:00
Debarshi Ray
9b9cdf2179 Don't assume the value of XDG_RUNTIME_DIR in the error message 2018-11-09 10:58:18 +00:00
Debarshi Ray
02f9650b5f Split out the code to check for an integer 2018-11-08 13:37:57 +00:00
Debarshi Ray
fdc00a2778 Make shm_open work
Rootless podman shuld mount a tmpfs at /dev/shm by default. Until that
happens, it's worked around by explicitly specifying the mount point.
Also, the --shm-size flag isn't working with rootless podman [1], so
--tmpfs is used instead.

It tries to mimic the in-kernel tmpfs default [2] of using half the
amount of total RAM. If for some reason /proc/meminfo can't be parsed,
it falls back to using podman's default of 65536k for tmpfs. It's not
clear whether podman uses kibibytes or kilobytes for 'k'. The former
was picked here for consistency.

[1] https://github.com/containers/libpod/issues/1770
[2] https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt

https://github.com/debarshiray/fedora-toolbox/issues/9
2018-11-08 13:37:57 +00:00
Debarshi Ray
cf2347fe56 Allow an 'F' or 'f' prefix when specifying the release
This means that one can now use 'F30' or 'f30' in addition to '30' with
the --release flag.
2018-10-26 14:07:33 +02:00
Debarshi Ray
74bf0e4eb7 Avoid a Bash-ism (ie. ==) and stick to POSIX (ie. =) 2018-10-26 11:41:30 +00:00
Debarshi Ray
912f3000a9 Fallback to /bin/bash if $SHELL doesn't exist in the toolbox container
It's the user's responsibility to install any non-default shell inside
the toolbox container.

NB: /bin/bash is the default shell according to /etc/default/useradd.
2018-10-26 11:24:46 +02:00
Debarshi Ray
48ddba6306 Use the $SHELL from the host when customizing the toolbox image
... instead of relying on the defaults from /etc/default/useradd.
2018-10-26 11:24:46 +02:00
Debarshi Ray
beadcec0da README.md: Tweak
Titles are sweeter when they are shorter.
2018-10-25 17:27:29 +02:00
Debarshi Ray
e5b2800dd3 Prepare 0.0.1 2018-10-19 19:25:13 +02:00
Debarshi Ray
6b5a9710c2 Rename LICENSE as COPYING
No need to do away with this particular tradition. :)
2018-10-19 18:24:23 +02:00
Debarshi Ray
44c44566b9 Add a Meson-based build system for ease of distribution 2018-10-19 17:45:31 +02:00
Debarshi Ray
93bde90c24 README.md: Remove the step about building the base fedora-toolbox image
The base fedora-toolbox images for Fedoras 28, 29 and 30 are now
available from registry.fedoraproject.org. Hence it's no longer
mandatory to build them locally. If they are built locally, then the
local images will be preferred over the ones from the registry.

https://pagure.io/releng/issue/7874
2018-10-19 16:53:02 +02:00
Debarshi Ray
c95a4c1e85 Give access to the GPUs for OpenGL and Vulkan
This makes the "OpenGL Area" example in gtk3-demo that uses GtkGLArea
work.
2018-10-17 17:08:21 +02:00
Debarshi Ray
31de3ff96f Allow having multiple toolbox images from the same base image
This adds an --image flag that overrides the default name of the
customized toolbox image from which the toolbox container is created.
2018-10-16 19:35:34 +02:00
Debarshi Ray
ef05b5c7c1 Reformat the --help output to fit narrower terminals
Hard coding 'fedora-toolbox' instead of $0 was necessary to get a
pleasant layout while keeping the code simple. It's not a big deal
because once there's a build system in place most people will type
'fedora-toolbox', instead of the full path to the script.
2018-10-16 19:21:46 +02:00
Debarshi Ray
5739d4b2a9 Allow having multiple toolbox containers from the same image
This adds a --container flag that overrides the default name of the
toolbox container.
2018-10-16 19:07:41 +02:00
Debarshi Ray
80f25c6924 Allow decoupling the toolbox's OS version from the host's
This adds a --release flag that overrides the VERSION_ID value read
from the host's /etc/os-release when creating and entering toolboxes.
2018-10-15 19:24:12 +02:00
Debarshi Ray
f3eab6afca Refactor common code into a function 2018-10-15 17:05:49 +02:00
Debarshi Ray
a0a9e7dc03 Look up the base image from the registry if it's absent locally
Normally, registry.fedoraproject.org will be used. The newly added
--candidate-registry flag can be used to change the default and query
candidate-registry.fedoraproject.org instead.
2018-10-15 15:07:52 +02:00
Debarshi Ray
bf830ac21c Make room for specifying command-specific options
A subsequent commit will add a --candidate-registry option to the
create command. This will make it possible to do so.
2018-10-12 17:38:59 +02:00
Debarshi Ray
a2d39e04bc Use the correct variable in the error message
This doesn't matter right now, but a subsequent commit will make
changes to accommodate command-specific options, where this will start
to matter. After all, the case statement is running against $op, not
$1, so this the right thing to do anyway.

Fallout from 678bdbaf4e
2018-10-12 17:38:59 +02:00
Debarshi Ray
1b08b259fe Fix typo
Fallout from 169f91669f
2018-09-27 11:59:24 +02:00
Debarshi Ray
bcd55f84fb Make su(1) work
... by deleting the root password.
2018-09-26 17:39:33 +02:00
Debarshi Ray
f30dd246dc Use a more direct way to check for the customized toolbox image
... than grepping the output of something else. One nice side-effect
is that the --verbose output becomes more meaningful.
2018-09-26 17:35:29 +02:00
Debarshi Ray
65ce3f76e8 Remove redundant if branch
Trust the exit status of 'buildah from ...' to have created a working
container instead of checking for its presence once again.
2018-09-26 17:10:42 +02:00
Debarshi Ray
07b37dbc2a Style fix
This reduces one level of indentation and makes the code more readable.
2018-09-26 16:59:38 +02:00
Debarshi Ray
573b156b92 Add fedora-toolbox image definitions for Fedoras 29 and 30 2018-09-26 16:37:46 +02:00
Debarshi Ray
169f91669f Make room for Dockerfiles for multiple operating system versions
It would be good to have Dockerfiles for multiple Fedora versions, and
possibly even other operating systems like Red Hat Enterprise Linux or
CentOS, so that people can use the toolbox on different host OSes.

In the future, it would be nice to have multiple toolbox containers
corresponding to different OSes exist side by side. One could then
have a Fedora 29 environment on a Fedora 28 host and so on.
2018-09-26 16:33:17 +02:00
Debarshi Ray
b103571d77 Dockerfile: Simplify the package installation 2018-09-26 12:07:13 +02:00
Debarshi Ray
913e3ea5e7 Dockerfile: Rely on an updated base image build for package updates
... instead of updating them while building the fedora-toolbox image.

https://bugzilla.redhat.com/show_bug.cgi?id=1628914
2018-09-24 18:01:56 +02:00
Debarshi Ray
188e625dcb Dockerfile: Add a usage label
... as mandated by the Fedora Container Guidelines:
https://fedoraproject.org/wiki/Container:Guidelines#LABELS
2018-09-24 17:16:13 +02:00
Debarshi Ray
31a3469fa9 Dockerfile: Fix the build on Fedora OpenShift Build Service
... by removing the docker:// scheme prefix.

https://bugzilla.redhat.com/show_bug.cgi?id=1628914
2018-09-24 17:11:11 +02:00
Debarshi Ray
68a19bcfd7 Clarify the error message if the container already exists 2018-09-21 12:31:41 +02:00
Debarshi Ray
66ab4da724 Allow running under sudo(8) when desired
This adds a --sudo flag, and the corresponding /etc/sudoers.d
configuration snippet, to run everything under sudo(8) for debugging.
2018-09-20 21:15:09 +02:00
Debarshi Ray
4bda42d414 Ensure that the toolbox user runs with 'wheel' as an additional group 2018-09-20 20:37:00 +02:00
Debarshi Ray
cfcf4eb31e Map the host UID into the container
Assuming a host UID of 1000, the UID mapping inside the user namespace
created by rootless podman for the toolbox container was:
         0       1000          1
         1     100000      65536

... which was the same as seen from the host:
         0       1000          1
         1     100000      65536

Therefore, when running with an UID of 1000 inside the container, it
got mapped to UID 100999 on the host. That means, for example, files
created by the user inside the container end up looking funny from the
host.

This is addressed by creating another user namespace that's a child of
the initial user namespace created by rootless podman. Assuming a host
UID of 1000, the UID mapping inside this child namespace is:
      1000          0          1
         0          1       1000
      1001       1001      64536

... which when seen from the host is:
      1000       1000          1
         0     100000       1000
      1001     101000      64536

This means that UID 1000 inside the child namespace is mapped to the
same UID 1000 on the host via the intermediate namespace created by
rootless podman. UIDs 0 to 999 inside the child namespace are mapped
to UIDs 100000 to 100999 in the host.

This change requires this runc pull request to work:
https://github.com/opencontainers/runc/pull/1862

As suggested by Giuseppe Scrivano.
2018-09-20 16:27:19 +02:00