Sign inSign up

shinsenter/su-exec

Sponsored OSS

By SHIN Company

•Updated 4 months ago

Switch user and group, then exec.

Image
Developer tools
Operating systems
1

8.8K

shinsenter/su-exec repository overview

⁠su-exec

Switch user and group, then exec.

⁠Table of contents

⁠Introduction

su-exec is a minimal re-write of gosu⁠ in C, resulting in a smaller binary.

This simple tool executes a program with different privileges. Unlike su and sudo, it runs the program directly, avoiding TTY and signal issues.

Important: su-exec requires root privileges to run. Non-root users do not have permission to change uid/gid.

⁠Credits

This project is based on the inactive project ncopa/su-exec⁠ and improvements from songdongsheng/su-exec⁠. Special thanks to them.

⁠Installation Using Docker

FROM <base-image>
COPY --from=shinsenter/su-exec:latest \
	--chown=root:root --chmod=4755 \
	/su-exec /usr/sbin/su-exec

⁠Usage

su-exec user-spec command [arguments...]

The user-spec can be either a username (e.g., nobody) or a username and group name separated by a colon (e.g., www-data:www-data). You can also use numeric uid/gid values.

⁠Examples:
su-exec tianon bash
su-exec nobody:root bash -c 'whoami && id'
su-exec 1000:1 id

⁠Supported platforms

  • linux/386
  • linux/amd64
  • linux/arm/v6
  • linux/arm/v7
  • linux/arm64/v8
  • linux/ppc64le
  • linux/riscv64
  • linux/s390x

⁠Linux distribution compatibility

The su-exec in this repository has been tested on various Linux distributions. See test-results.txt⁠ for details.

Tag summary

Content type

Image

Digest

sha256:d8bdfad53…

Size

29.4 kB

Last updated

4 months ago

docker pull shinsenter/su-exec

This week's pulls

Pulls:

18

Last week