Skip to content

Commit

Permalink
Handling of ktstrip temp files (#38)
Browse files Browse the repository at this point in the history
* Handling of ktstrip temp files
  • Loading branch information
Yash-Khatri committed Aug 9, 2022
1 parent 8d22a77 commit 137ef71
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Unix/tools/ktstrip
Expand Up @@ -44,20 +44,22 @@ then
exit 2
fi

list=$(mktemp)
delete_list=$(mktemp)
cmd=$(mktemp)
# Generate random string.
rand_str=`cat /dev/urandom | tr -cd 'a-zA-Z0-9' | head -c 10`
tmp_kt="/tmp/tmp.$rand_str"
tmp_dir=$(mktemp -d)
if [ $? -ne 0 ]; then
echo "Could not create temp directory " 2>&1
exit 1
fi

list=$(mktemp -p $tmp_dir)
delete_list=$(mktemp -p $tmp_dir)
cmd=$(mktemp -p $tmp_dir)
tmp_kt="$tmp_dir/tmp.kt"

# clean temp files
CleanTempFiles()
{
echo "Cleaning temp files..." 2>&1
rm -f $list > /dev/null 2>&1
rm -f $delete_list > /dev/null 2>&1
rm -f $cmd > /dev/null 2>&1
rm -rf $tmp_dir > /dev/null 2>&1
}

#
Expand Down Expand Up @@ -100,21 +102,22 @@ if [ $? -ne 0 ]
then
echo "The keytab $tmp_kt is invalid." 2>&1
CleanTempFiles
rm -f $tmp_kt
exit 1
fi

CleanTempFiles

if [ ! -f $tmp_kt ]
then
echo "File " $tmp_kt " is not generated, so we skip configure Kerberos authentication for omi." 2>&1
CleanTempFiles
exit 0
fi

printf "Move $tmp_kt to $DST_KT\n"
mv $tmp_kt $DST_KT

CleanTempFiles

# and we adjust the ownership of the keytab so the omi user can see it.
chown $user $DST_KT
if [ $? -ne 0 ]
Expand Down

0 comments on commit 137ef71

Please sign in to comment.