busybox/util-linux
Euan Harris 254e47372f nsenter: fix parsing of -t, -S and -G options
-t, -S and -G each take mandatory integer arguments.   getopt32long()'s
option string syntax for this type of argument is 'c:+', however nsenter's
opt_str uses 'c+', which specifies two options 'c' and '+' which do not
take arguments.   This means that giving a target PID causes nsenter to
exit and print the usage string:

  # nsenter -t1 sh
  nsenter: unrecognized option: 1
  BusyBox v1.27.2 (2017-12-12 10:41:50 GMT) multi-call binary.
  ...

The long form options are also broken:

  # nsenter --setuid=1000 --setgid=1000 sh
  BusyBox v1.29.0.git (2018-05-04 13:56:49 UTC) multi-call binary.
  ...

`nsenter --target=<pid> sh` parses correctly and appears to work, but
<pid> is ignored and set to 0.   This doesn't raise an error unless one
of the namespace arguments is also given:

  # ./busybox_unstripped nsenter --target=42 sh
  # exit

  # ./busybox_unstripped nsenter -n --target=42 sh
  BusyBox v1.29.0.git (2018-05-04 13:56:49 UTC) multi-call binary.
  ...

This has caused problems in a couple of places:

  https://github.com/linuxkit/linuxkit/issues/567
  https://github.com/gliderlabs/docker-alpine/issues/359
  https://github.com/kontena/pharos-cluster/pull/81

Signed-off-by: Euan Harris <euan.harris@docker.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-13 20:14:07 +02:00
..
volume_id volume_id: add LittleFS detection 2018-01-19 20:37:13 +01:00
acpid.c getopt32: remove opt_complementary 2017-08-08 21:55:02 +02:00
blkdiscard.c blkdiscard: Only build on Linux 2017-10-30 14:55:01 +01:00
blkid.c blkid: make it NOEXEC, make FEATURE_BLKID_TYPE=y default 2017-08-06 20:16:28 +02:00
blockdev.c blockdev, fsfreeze, fstrim, mountpoint: make NOEXEC 2017-08-05 01:29:12 +02:00
cal.c cal: make it NOEXEC 2018-01-14 14:32:11 +01:00
chrt.c chrt: code shrink 2018-01-25 09:34:23 +01:00
Config.src config: deindent all help texts 2017-07-21 09:50:55 +02:00
dmesg.c config: deindent all help texts 2017-07-21 09:50:55 +02:00
eject.c getopt32: remove opt_complementary 2017-08-08 21:55:02 +02:00
fallocate.c regularize format of source file headers, no code changes 2017-09-18 16:28:43 +02:00
fatattr.c fatattr: make NOEXEC 2017-08-07 22:21:54 +02:00
fbset.c config: deindent all help texts 2017-07-21 09:50:55 +02:00
fdformat.c whitespace and comment format fixes, no code changes 2017-10-05 15:33:28 +02:00
fdisk_aix.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
fdisk_gpt.c libbb: commonalize a bit of little-endian CRC32 table generation code 2018-02-01 10:56:19 +01:00
fdisk_osf.c Fix build failures if MAXHOSTNAMELEN or MAXPATHLEN is not defined 2017-10-31 15:59:19 +01:00
fdisk_sgi.c randomconfig fixes 2016-06-19 18:15:33 +02:00
fdisk_sun.c fdisk_sun: fix partition alignment 2013-02-11 00:22:59 +01:00
fdisk.c whitespace and comment format fixes, no code changes 2017-10-05 15:33:28 +02:00
findfs.c config: trim/improve item names and help texts, take 2 2017-07-27 10:53:09 +02:00
flock.c getopt32: remove opt_complementary 2017-08-08 21:55:02 +02:00
freeramdisk.c freeramdisk: make NOEXEC 2017-08-07 23:17:14 +02:00
fsck_minix.c fsck_minix,mkfs_minix: fix "strict-aliasing" warnings 2017-08-16 11:53:48 +02:00
fsfreeze.c regularize format of source file headers, no code changes 2017-09-18 16:28:43 +02:00
fstrim.c fstrim: do not check that specified file is on a block device 2018-03-29 16:05:10 +02:00
getopt.c whitespace and comment format fixes, no code changes 2017-10-05 14:40:24 +02:00
hexdump_xxd.c getopt32: remove opt_complementary 2017-08-08 21:55:02 +02:00
hexdump.c config: deindent all help texts 2017-07-21 09:50:55 +02:00
hwclock.c getopt32: remove opt_complementary 2017-08-08 21:55:02 +02:00
ionice.c make 17 state-changing execing applets (ex: "nice PROG ARGS") noexec 2017-08-04 19:55:01 +02:00
ipcrm.c ipcrm,ipcs: make them NOEXEC 2017-08-09 19:24:19 +02:00
ipcs.c ipcs: further code shrink 2018-03-08 13:23:06 +01:00
Kbuild.src Convert all util-linux/* applets to "new style" applet definitions 2016-11-23 11:46:32 +01:00
last_fancy.c Sort some miscutils/ applets into coreutils or util-linux 2017-04-12 13:58:40 +02:00
last.c config: deindent all help texts 2017-07-21 09:50:55 +02:00
losetup.c getopt32: remove opt_complementary 2017-08-08 21:55:02 +02:00
lspci.c lspci,lsscsi,lsusb: make them NOEXEC 2017-08-05 23:28:19 +02:00
lsusb.c lspci,lsscsi,lsusb: make them NOEXEC 2017-08-05 23:28:19 +02:00
mdev.c regularize format of source file headers, no code changes 2017-09-18 16:28:43 +02:00
mesg.c regularize format of source file headers, no code changes 2017-09-18 16:28:43 +02:00
minix.h more bionic fixes 2016-03-14 19:34:15 +01:00
mkfs_ext2_test.sh fix more instances of ": $((a++))" in shell scripts 2017-07-15 19:20:45 +02:00
mkfs_ext2.c mkfs_ext2, mkfs_vfat: fix warnings in STORE_LE on big-endian platforms 2018-02-15 13:46:34 +01:00
mkfs_ext2.txt
mkfs_minix.c fsck_minix,mkfs_minix: fix "strict-aliasing" warnings 2017-08-16 11:53:48 +02:00
mkfs_reiser.c getopt32: remove opt_complementary 2017-08-08 21:55:02 +02:00
mkfs_vfat.c mkfs_ext2, mkfs_vfat: fix warnings in STORE_LE on big-endian platforms 2018-02-15 13:46:34 +01:00
mkswap.c whitespace and comment format fixes, no code changes 2017-10-05 15:33:28 +02:00
more.c config: deindent all help texts 2017-07-21 09:50:55 +02:00
mount.c inetd,mount: add comment with example of flags to build with libtirpc 2018-02-13 18:20:28 +01:00
mountpoint.c getopt32: remove opt_complementary 2017-08-08 21:55:02 +02:00
nsenter.c nsenter: fix parsing of -t, -S and -G options 2018-05-13 20:14:07 +02:00
pivot_root.c pivot_root: make it NOFORK 2017-08-05 01:51:12 +02:00
rdate.c libbb: new option FEATURE_ETC_SERVICES: if off, /etc/services reads often avoided 2018-04-17 12:43:54 +02:00
rdev.c regularize format of source file headers, no code changes 2017-09-18 16:28:43 +02:00
readprofile.c readprofile: code shrink 2018-03-11 19:35:58 +01:00
renice.c libbb.h: always include sys/resource.h 2018-04-08 17:23:27 +02:00
rev.c config: deindent all help texts 2017-07-21 09:50:55 +02:00
rtcwake.c getopt32: remove opt_complementary 2017-08-08 21:55:02 +02:00
script.c getopt32: remove opt_complementary 2017-08-08 21:55:02 +02:00
scriptreplay.c script: make -t independent of scriptreplay 2017-08-07 01:53:17 +02:00
setarch.c make 17 state-changing execing applets (ex: "nice PROG ARGS") noexec 2017-08-04 19:55:01 +02:00
setpriv.c setpriv: placete "declaration of 'index' shadows a global declaration" warning 2017-08-29 15:34:38 +02:00
setsid.c getopt32: remove opt_complementary 2017-08-08 21:55:02 +02:00
swaponoff.c swapon: do not use FEATURE_MOUNT_LABEL, have your own FEATURE_SWAPONOFF_LABEL 2017-07-27 10:58:08 +02:00
switch_root.c libbb: compile capability code only if FEATURE_SETPRIV_CAPABILITIES or RUN_INIT 2018-02-21 20:13:39 +01:00
taskset.c regularize format of source file headers, no code changes 2017-09-18 16:28:43 +02:00
uevent.c uevent: placate gcc 2017-08-16 11:45:09 +02:00
umount.c umount: fix "umount -t FSTYPE MNTPOINT" acting as if -a is specified 2018-02-20 17:58:19 +01:00
unshare.c unshare: -r should map root to user, not the other way around 2017-11-09 16:06:33 +01:00
wall.c regularize format of source file headers, no code changes 2017-09-18 16:28:43 +02:00