From ad18eb4d9cfbebf5c9d575a434d6b59005cd55ce Mon Sep 17 00:00:00 2001 From: Michael Howe Date: Sun, 4 Mar 2012 17:54:09 +0000 Subject: [PATCH] * with-creds now supports specification of user and realm --- bin/with-creds | 56 +++++++++++++++++++++++++++++++++++++----------- debian/changelog | 6 ++++++ 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/bin/with-creds b/bin/with-creds index d76e569..9e4ddea 100755 --- a/bin/with-creds +++ b/bin/with-creds @@ -6,23 +6,39 @@ # $LastChangedBy$ # -while getopts ":i:" opt; do +function usage { + cat >&2 <&2 - exit 1 + usage +# echo "Error: unsupported option -$OPTARG" >&2 ;; esac done shift $(($OPTIND - 1)) -if [ -z "$userpart" ]; then - echo "Error: no service part defined (use -i )" >&2 - exit 2 +if [ -n "$userpart" ]; then + userpart="$userpart" + userpart_slash="/$userpart" fi if [ $# -eq 0 ]; then @@ -30,13 +46,29 @@ if [ $# -eq 0 ]; then exit 3 fi -ccache=/tmp/krb5cc_${UID}_${userpart} +# Realm: +REALMARG="" +if [ -n "$realm" ]; then + REALMARG="@$realm" +fi -if klist -s -c $ccache; then - export KRB5CCNAME=$ccache -else - export KRB5CCNAME=$ccache - kinit -p $USER/$userpart +# Fix user: +KRBUSER=$USER +if [ -n "$localuser" ]; then + KRBUSER=$localuser fi +PRINC=$KRBUSER$userpart_slash$REALMARG + +export KRB5CCNAME=/tmp/krb5cc_${UID}_${KRBUSER}_${userpart} + +k5start -H 30 -u "$PRINC" + +#if klist -s -c $ccache; then +# export KRB5CCNAME=$ccache +#else +# export KRB5CCNAME=$ccache +# kinit -p $KRBUSER$userpart_slash$REALMARG +#fi + exec "$@" diff --git a/debian/changelog b/debian/changelog index 599f7b4..e67ceda 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +mh-sysadmin-tools (1.2) unstable; urgency=low + + * with-creds now supports specification of user and realm + + -- Michael Howe Sun, 04 Mar 2012 17:52:56 +0000 + mh-sysadmin-tools (1.1) unstable; urgency=low * Don't forward X11 when using SSH -- 2.39.5