From 055190b9ac55bef66f1b847d01153530b7738ece Mon Sep 17 00:00:00 2001 From: anton Date: Mon, 11 Oct 2021 05:46:42 +0000 Subject: [PATCH] quote sudo and handle arguments --- regress/usr.sbin/switchd/Makefile | 4 ++-- regress/usr.sbin/switchd/Proc.pm | 6 +++--- regress/usr.sbin/switchd/Switchd.pm | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/regress/usr.sbin/switchd/Makefile b/regress/usr.sbin/switchd/Makefile index d0fc7b78c53..478e68e42e8 100644 --- a/regress/usr.sbin/switchd/Makefile +++ b/regress/usr.sbin/switchd/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.10 2020/12/16 23:10:48 bluhm Exp $ +# $OpenBSD: Makefile,v 1.11 2021/10/11 05:46:42 anton Exp $ # The following ports must be installed for the regression tests: # p5-Net-Pcap Perl interface for libpcap @@ -47,7 +47,7 @@ PERLPATH = ${.CURDIR}/ .for a in ${ARGS} REGRESS_TARGETS += run-$a run-$a: $a - time SUDO=${SUDO} KTRACE=${KTRACE} SWITCHD=${SWITCHD} \ + time SUDO="${SUDO}" KTRACE=${KTRACE} SWITCHD=${SWITCHD} \ perl ${PERLINC} ${PERLPATH}run.pl ${PERLPATH}$a .endfor diff --git a/regress/usr.sbin/switchd/Proc.pm b/regress/usr.sbin/switchd/Proc.pm index 074ad24b40f..5dc55953f1d 100644 --- a/regress/usr.sbin/switchd/Proc.pm +++ b/regress/usr.sbin/switchd/Proc.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Proc.pm,v 1.1 2017/06/22 20:06:14 bluhm Exp $ +# $OpenBSD: Proc.pm,v 1.2 2021/10/11 05:46:42 anton Exp $ # Copyright (c) 2010-2017 Alexander Bluhm # @@ -35,9 +35,9 @@ sub kill_children { push @perms, $pid; } } - if (my $sudo = $ENV{SUDO} and @perms) { + if (my @sudo = split(' ', $ENV{SUDO}) and @perms) { local $?; # do not modify during END block - my @cmd = ($sudo, '/bin/kill', '-TERM', @perms); + my @cmd = (@sudo, '/bin/kill', '-TERM', @perms); system(@cmd); } delete @CHILDREN{@pids}; diff --git a/regress/usr.sbin/switchd/Switchd.pm b/regress/usr.sbin/switchd/Switchd.pm index d70d9beecf7..3fb227e9012 100644 --- a/regress/usr.sbin/switchd/Switchd.pm +++ b/regress/usr.sbin/switchd/Switchd.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Switchd.pm,v 1.1 2017/06/22 20:06:14 bluhm Exp $ +# $OpenBSD: Switchd.pm,v 1.2 2021/10/11 05:46:42 anton Exp $ # Copyright (c) 2010-2017 Alexander Bluhm # @@ -63,7 +63,7 @@ sub new { sub child { my $self = shift; - my @sudo = $ENV{SUDO} ? $ENV{SUDO} : (); + my @sudo = $ENV{SUDO} ? split(' ', $ENV{SUDO}) : (); my @ktrace = $ENV{KTRACE} ? ($ENV{KTRACE}, "-i") : (); my $switchd = $ENV{SWITCHD} ? $ENV{SWITCHD} : "switchd"; my @cmd = (@sudo, @ktrace, $switchd, "-dvv", "-f", $self->{conffile}); -- 2.20.1