5

linux wonders:

>su - otheruser
>whoami
root

fuck you!!!!!

it's one of those days where not even basic linux commands are working.... i'm about to give up, i'm so pissed off

Comments
  • 2
    Strace the shit out of it!
  • 0
    May it, by any chance, be that otheruser has uid 0?
  • 1
    There are several reasons why this might not work at all.

    The simplest is wrong login shell, e.g. /bin/false for the user.

    I would always recommend using --login instead of hyphen, because it reminds you what su actually does.

    You might not be in a new shell under the new user at all is the gist of what I'm saying. ;)

    Check the return code, e.g. echo ${?}, after su.

    getent passwd <username> gives you the users passwd entry, check the shell exists.
  • 1
    Its docker all the way down. Of course when you run the entrypoint script it "automatically" and "magically" switches you back to root.

    I quit.
  • 1
    @fullstackclown

    I think you misunderstood the point of entrypoint.

    Entry point is meant to be a script or something that can start a command.

    A command can have a default value, but can be overridden...

    Whats pretty common is e.g. setting an entrypoint to a shell script.

    At the end of the shell script an
    exec "${@}" appears.

    The exec just executes whatever was fed in as command - but (muey importante):

    "If exec is specified with command, it shall replace the shell
    with command without creating a new process. If arguments are
    specified, they shall be arguments to command. Redirection
    affects the current shell execution environment."

    Quote from:
    https://man7.org/linux/man-pages/...

    So the process started by the entrypoint isn't terminated, it keeps on running!

    It just gets replaced via the exec call.

    This is a very important thing in Dockerfiles - as the container starts otherwise an process that is lost.

    Sadly many tutorials explain this in very dumb or idiotic ways - exec is key to Dockerfiles entrypoint and cmd structure.

    You will most likely stumble upon exec in every larger docker image for services like MySQL etc.
  • 3
    Yeah, it’s one of those days where I don’t work anymore either.

    Also: did not read. Too tired. Segfault.
Add Comment