summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2010-11-04 09:17:39 +0000
committerAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2010-11-04 09:17:39 +0000
commitb3820fad02938cae736bb4066531c3929d307e53 (patch)
treee25bc36c1a2adc158500babc8f2eb0c4d08fc912
parent69405f4a11c194a14d7adcdae8488a952e729e4b (diff)
Make sure we don't end up using /usr/src/etc if we forget to pass the
correct option (e.g. 'sysmerge /tmp/etc48.tgz'). Use OPTIND as all args are handled by getopts we can catch misusage and we exit with an error. from Brian Poole, thanks. ok sthen@
-rw-r--r--usr.sbin/sysmerge/sysmerge.sh8
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.sbin/sysmerge/sysmerge.sh b/usr.sbin/sysmerge/sysmerge.sh
index 30ae7b14a8e..dfc67845193 100644
--- a/usr.sbin/sysmerge/sysmerge.sh
+++ b/usr.sbin/sysmerge/sysmerge.sh
@@ -1,6 +1,6 @@
#!/bin/ksh -
#
-# $OpenBSD: sysmerge.sh,v 1.63 2010/08/21 09:32:00 sthen Exp $
+# $OpenBSD: sysmerge.sh,v 1.64 2010/11/04 09:17:38 ajacoutot Exp $
#
# Copyright (c) 1998-2003 Douglas Barton <DougB@FreeBSD.org>
# Copyright (c) 2008, 2009, 2010 Antoine Jacoutot <ajacoutot@openbsd.org>
@@ -691,6 +691,12 @@ while getopts bds:x: arg; do
esac
done
+shift $(( OPTIND -1 ))
+if [ $# -ne 0 ]; then
+ usage
+ error_rm_wrkdir
+fi
+
if [ -z "${SRCDIR}" -a -z "${TGZ}" -a -z "${XTGZ}" ]; then
if [ -f "/usr/src/etc/Makefile" ]; then