Skip to content

Enter the toolbox as non root, self user #28

Closed

Description

@mildred

Running fedora-toolbox 0.0.2-1.fc29, when I'm in the toolbox, I am root.

When I'm working, I'm mostly working as a simple user, and I'd like to enter the toolbox as my own user and not have to use su after entering the toolbox. Also, I had to manually set up my own user in /etc/passwd inside the toolbox on first use.

Additionally, it would be nice if I could run specific commands after toolbox enter. For example, being able to run toolbox enter su $USER would help my use case (I could just create an alias then)

Activity

  1. debarshiray commented on Jan 11, 2019

    @debarshiray
    Member

    Running fedora-toolbox 0.0.2-1.fc29, when I'm in the toolbox, I am root.

    Oh, really? That's surprising. We definitely try to retain the same user inside the container as on the host. Grep for $USER and $UID inside the fedora-toolbox script. Also, see commit cfcf4eb

    Do you have any fancy or non-standard set-up? For example, are you logging via LDAP or Kerberos, as opposed to having a simple local user?

  2. debarshiray commented on Jan 11, 2019

    @debarshiray
    Member

    Additionally, it would be nice if I could run specific commands after
    toolbox enter

    Yes, this does sound like a good thing to have. I wonder if run would be a better name for the command in that case. It could also just be an alias for enter.

  3. mildred commented on Feb 1, 2019

    @mildred
    Author

    Oh, really? That's surprising. We definitely try to retain the same user inside the container as on the host. Grep for $USER and $UID inside the fedora-toolbox script. Also, see commit cfcf4eb

    Uid mapping works as intended:

    • uid 0 inside the container corresponds to uid 100000 outside
    • uid 1000 inside the container corresponds to uid 1000 outside

    grepping gives:

    $ egrep 'USER|UID' /usr/bin/fedora-toolbox
                         --uid $UID \
                         $USER \
                echo "$0: failed to create user $USER with UID $UID"
            if ! $prefix_sudo buildah run $working_container_name -- passwd -d $USER >/dev/null 2>&42; then
                echo "$0: failed to remove password for user $USER"
            if ! $prefix_sudo buildah config --user $USER $working_container_name >/dev/null 2>&42; then
                echo "$0: failed to configure the default user as $USER"
        max_minus_uid=$((max_uid_count-UID))
        uid_plus_one=$((UID+1))
                     --uidmap $UID:0:1 \
                     --uidmap 0:1:$UID \
    [ "$toolbox_container" = "" ] && toolbox_container="fedora-toolbox-$USER:$release"
    toolbox_image="fedora-toolbox-$USER:$release"
                echo "$0: failed to remove password for user $USER"
    

    Do you have any fancy or non-standard set-up? For example, are you logging via LDAP or Kerberos, as opposed to having a simple local user?

    Nope, laptop running fedora silverblue with a single user uid 1000

    Possibly, creating the toolbox image the first time did not happen correctly, I remember that I had difficulties with it. I had to manually create the user inside the toolbox and perhaps configure sudo too. I think I used the following command to create the toolbox

    fedora-toolbox create --image fedora
    

    Not specifying --image did not work for some reason.

  4. mildred commented on Feb 1, 2019

    @mildred
    Author

    The problem I had (when not specifying --image) is:

    $ fedora-toolbox --verbose  --container test create
    error looking up container "test": no container with name or ID test found: no such container
    Trying to pull docker.io/fedora-toolbox-mildred:29...Failed
    Trying to pull registry.fedoraproject.org/fedora-toolbox-mildred:29...Failed
    Trying to pull quay.io/fedora-toolbox-mildred:29...Failed
    Trying to pull registry.access.redhat.com/fedora-toolbox-mildred:29...Failed
    Trying to pull registry.centos.org/fedora-toolbox-mildred:29...Failed
    unable to pull fedora-toolbox-mildred:29: 5 errors occurred:
    
    * Error determining manifest MIME type for docker://fedora-toolbox-mildred:29: Error reading manifest 29 in docker.io/library/fedora-toolbox-mildred: errors:
    denied: requested access to the resource is denied
    unauthorized: authentication required
    
    * Error determining manifest MIME type for docker://registry.fedoraproject.org/fedora-toolbox-mildred:29: Error reading manifest 29 in registry.fedoraproject.org/fedora-toolbox-mildred: manifest unknown: manifest unknown
    * Error determining manifest MIME type for docker://quay.io/fedora-toolbox-mildred:29: Error reading manifest 29 in quay.io/fedora-toolbox-mildred: error parsing HTTP 404 response body: invalid character '<' looking for beginning of value: "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n<title>404 Not Found</title>\n<h1>Not Found</h1>\n<p>The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.</p>\n"
    * Error determining manifest MIME type for docker://registry.access.redhat.com/fedora-toolbox-mildred:29: Error reading manifest 29 in registry.access.redhat.com/fedora-toolbox-mildred: unknown: Not Found
    * Error determining manifest MIME type for docker://registry.centos.org/fedora-toolbox-mildred:29: Error reading manifest 29 in registry.centos.org/fedora-toolbox-mildred: manifest unknown: manifest unknown
    /home/mildred/.local/bin/fedora-toolbox: failed to create container test
    

    That being said, it should be possible to enter the toolbox as simple user for containers created from other images than fedora-toolbox.

  5. debarshiray commented on Feb 1, 2019

    @debarshiray
    Member

    Uid mapping works as intended:

    * uid 0 inside the container corresponds to uid 100000 outside
    
    * uid 1000 inside the container corresponds to uid 1000 outside
    

    You can build a fedora-toolbox image for yourself locally using one of the Dockerfiles in the images sub-directory. If you do that, does this work as expected:

    host $ fedora-toolbox create
    host $ fedora-toolbox enter
    toolbox $
    

    Just so I understand this correctly. :)

  6. debarshiray commented on Feb 1, 2019

    @debarshiray
    Member

    The problem I had (when not specifying --image) is:

    You might be hitting either #37 or #42

    That being said, it should be possible to enter the toolbox as simple user for containers
    created from other images than fedora-toolbox.

    The problem is that the base fedora image has some missing pieces (eg., the passwd RPM) that the fedora-toolbox script expects to be present when setting up the toolbox for the user.

    If one uses a heavily customized image, then it becomes a bit of an adventure. :/

  7. mildred commented on Feb 1, 2019

    @mildred
    Author

    Thank you, I was hit by #37 (comment), I removed ~/.config/containers/libpod.conf, ~/.config/containers/mounts.conf and ~/.local/share/containers and fedora-toolbox create now works.

    However, I looked at the Dockerfile of fedora-toolbox, and I don't understand what makes it possible for it to automatically log-in to my user instead of root, and why my image based on fedora (where I manually added the user 1000) was unable to do so.

  8. debarshiray commented on Feb 1, 2019

    @debarshiray
    Member

    However, I looked at the Dockerfile of fedora-toolbox, and I don't understand what
    makes it possible for it to automatically log-in to my user instead of root, and why my
    image based on fedora (where I manually added the user 1000) was unable to do so.

    Could it be that passwd was missing from your image?

  9. mildred commented on Feb 1, 2019

    @mildred
    Author

    At first, yes, I remember installing it manually. And that's probably the reason. I was looking for reasons inside the enter() function but the problem was in create().

    So, when fedora-toolbox creates a toolbox, it sets the default user (similar to USER 1000 in a Dockerfile), but it does it after having created the user, and for that, passwd needs to be available within the base image you choose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions