diff options
author | Petr Vorel <petr.vorel@gmail.com> | 2019-07-08 22:39:39 +0200 |
---|---|---|
committer | Petr Vorel <petr.vorel@gmail.com> | 2019-07-12 06:20:17 +0200 |
commit | 129ad44a1a58b940cb0c1075010f5d16a750eda6 (patch) | |
tree | c61e7c16064303b2c8d44d566ab011c5343ff2cc | |
parent | eb8e3be9c395d4543a824fb645a2002ceaea665a (diff) | |
download | iputils-129ad44a1a58b940cb0c1075010f5d16a750eda6.tar.gz |
build-sys: Simplify and enhance setcap-setuid.sh
* _log() function, as prefix it prints only setcap-setuid.sh instead
of full path
* params for setcap in variable (DRY). BTW: I'd prefer not handling
the case of space or strange chars in path with executables, but
kept the functionality.
* add -v to chown and chmod
* remove unnecessary '|| true' (this is needed only if set -e is used
as we exit 0 at the end anyway)
* remove unnecessary quotes from case
* remove unnecessary square brackets from if
Acked-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
-rwxr-xr-x | build-aux/setcap-setuid.sh | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/build-aux/setcap-setuid.sh b/build-aux/setcap-setuid.sh index 7bc5a1f..7514307 100755 --- a/build-aux/setcap-setuid.sh +++ b/build-aux/setcap-setuid.sh @@ -1,31 +1,35 @@ #!/bin/sh -# # Meson install script to setcap or setuid to an executable. exec_path="$1/$2" perm_type="$3" setcap="$4" -if [ -n "${DESTDIR}" ]; then +if [ -n "$DESTDIR" ]; then exec_path="${DESTDIR%/}/${exec_path}" fi +_log() { + echo "$(basename $0): $1" +} + case "$perm_type" in - 'none') + none) # Gentoo needs build system to back off. # https://github.com/iputils/iputils/issues/175 ;; - 'caps') - echo "$0: calling: $setcap cap_net_raw+p $exec_path" - "$setcap" 'cap_net_raw+p' "$exec_path" || true + caps) + params="cap_net_raw+p" + _log "calling: $setcap $params $exec_path" + "$setcap" $params "$exec_path" ;; - 'setuid') - echo "$0: changing $exec_path to be setuid root executable" - chown root "$exec_path" || true - chmod u+s "$exec_path" || true + setuid) + _log "changing '$exec_path' to be setuid root executable" + chown -v root "$exec_path" + chmod -v u+s "$exec_path" ;; *) - echo "$0: unexpected argument: $perm_type" + _log "unexpected argument: '$perm_type'" exit 1 ;; esac |