commit 024ad693fd76d375d8e7ba451bb12f68c4dfae2f
parent cbbcc0c116164ef6ec875bfda3de9a47ecde1d9b
Author: Claudio Alessi <smoppy@gmail.com>
Date: Fri, 12 Jul 2024 00:03:07 +0200
Run with sudo when starts as unprivileged user with setuid.
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/iwpick b/src/iwpick
@@ -116,7 +116,13 @@ main() {
esac
done
- [ "$(id -u)" -ne 0 -a ! -u "$0" ] && die "You must be root"
+ uid="$(id -u)"
+ if [ "$uid" -ne 0 ]; then
+ [ ! -u "$0" ] && die "You must be root."
+ sudo HOME="$HOME" $0 $@
+ exit $?
+ fi
+
if [ -n "$alias" ]; then
net="$(sed -n "/^${alias}:/p" "$file")"
[ -z "$net" ] && die "alias '${alias}' not found"