summaryrefslogtreecommitdiff
path: root/usr.sbin/rcctl
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2023-07-13 13:54:28 +0000
committerAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2023-07-13 13:54:28 +0000
commita21908be871bf90d19d64abdea46e78908e00300 (patch)
tree6693acbdacc427d79a46b92c84d966978bb9c9bf /usr.sbin/rcctl
parent4ed2818f47d441d680e347c720ebbf10c250cacf (diff)
Check input before trying to disable a non-existing daemon to prevent parsing
bogus characters and outputing hell on the console. based on an initial submission from Anthony Coulter, thanks!
Diffstat (limited to 'usr.sbin/rcctl')
-rw-r--r--usr.sbin/rcctl/rcctl.sh20
1 files changed, 14 insertions, 6 deletions
diff --git a/usr.sbin/rcctl/rcctl.sh b/usr.sbin/rcctl/rcctl.sh
index fb87943ba00..eda191fae7d 100644
--- a/usr.sbin/rcctl/rcctl.sh
+++ b/usr.sbin/rcctl/rcctl.sh
@@ -1,6 +1,6 @@
#!/bin/ksh
#
-# $OpenBSD: rcctl.sh,v 1.116 2023/04/24 14:31:15 kn Exp $
+# $OpenBSD: rcctl.sh,v 1.117 2023/07/13 13:54:27 ajacoutot Exp $
#
# Copyright (c) 2014, 2015-2022 Antoine Jacoutot <ajacoutot@openbsd.org>
# Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -535,13 +535,17 @@ case ${action} in
shift 1
svcs="$*"
[ -z "${svcs}" ] && usage
- # it's ok to disable a non-existing daemon
- if [ "${action}" != "disable" ]; then
- for svc in ${svcs}; do
+ for svc in ${svcs}; do
+ # it's ok to disable a non-existing daemon
+ if [ "${action}" != "disable" ]; then
svc_is_avail ${svc} || \
rcctl_err "service ${svc} does not exist" 2
- done
- fi
+ # but still check for bad input
+ else
+ _rc_check_name "${svc}" || \
+ rcctl_err "service ${svc} does not exist" 2
+ fi
+ done
;;
get|getdef)
svc=$2
@@ -572,6 +576,10 @@ case ${action} in
if [ "${action} ${var} ${args}" != "set status off" ]; then
svc_is_avail ${svc} || \
rcctl_err "service ${svc} does not exist" 2
+ # but still check for bad input
+ else
+ _rc_check_name "${svc}" || \
+ rcctl_err "service ${svc} does not exist" 2
fi
[[ ${var} != @(class|execdir|flags|logger|rtable|status|timeout|user) ]] && usage
svc_is_meta ${svc} && [ "${var}" != "status" ] && \