krbroot: harden the shell settings
authorAlex Dehnert <adehnert@mit.edu>
Fri, 17 May 2013 06:31:04 +0000 (02:31 -0400)
committerAlex Dehnert <adehnert@mit.edu>
Fri, 17 May 2013 06:31:04 +0000 (02:31 -0400)
See https://sipb.mit.edu/doc/safe-shell/ for the logic.

krbroot

diff --git a/krbroot b/krbroot
index 5f0515dc01a36f6a7a8f189e90e78cfdfd3972a5..37e04294f6b2ec103a56ded9352323d54e03a6f5 100755 (executable)
--- a/krbroot
+++ b/krbroot
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+set -euf
+
 usage="Usage: $0 [-i instance] [-p principal] [-a addrend] subcommand [args]"
 
 principal="$ATHENA_USER/root@ATHENA.MIT.EDU"
@@ -23,7 +25,7 @@ init () {
     kinit -F -5 -l15m "$principal" "$@"
 }
 
-case $1 in
+case ${1:-} in
     init)
         shift;
         exec kinit -F -5 -l15m "$principal" "$@"