Skip to content

Commit d3b9c63

Browse files
committed
add htdestroytoken, and htdecodetoken symlink
1 parent 1c28f13 commit d3b9c63

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

htdestroytoken

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
VERBOSE=true
4+
if [ "$1" = "-q" ]; then
5+
VERBOSE=false
6+
shift
7+
fi
8+
9+
if [ $# != 0 ]; then
10+
echo "Usage: htdestroytoken [-q]" >&2
11+
echo "Removes bearer and vault tokens" >&2
12+
echo "-q means to do it silently" >&2
13+
exit 2
14+
fi
15+
16+
# UID is a standard bash variable
17+
TOKENFILE="${BEARER_TOKEN_FILE:-${XDG_RUNTIME_DIR:-/tmp}/bt_u$UID}"
18+
for FILE in $TOKENFILE /tmp/vt_u$UID*; do
19+
if [ -f "$FILE" ]; then
20+
if $VERBOSE; then
21+
echo "Removing $FILE"
22+
fi
23+
rm -f $FILE
24+
fi
25+
done

htgettoken.spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ cat > $RPM_BUILD_ROOT%{_bindir}/%{name} <<'!EOF!'
104104
#!/bin/bash
105105
exec %{_libexecdir}/%{name}/%{name} "$@"
106106
!EOF!
107+
cp htdestroytoken $RPM_BUILD_ROOT%{_bindir}
107108
cp httokendecode $RPM_BUILD_ROOT%{_bindir}
109+
ln -s httokendecode $RPM_BUILD_ROOT%{_bindir}/htdecodetoken
108110
chmod +x $RPM_BUILD_ROOT%{_bindir}/*
109111
gzip -c %{name}.1 >$RPM_BUILD_ROOT%{_datadir}/man/man1/%{name}.1.gz
110112

@@ -125,6 +127,8 @@ rm -rf $RPM_BUILD_ROOT
125127
# Fix httokendecode -H functionality to only attempt to convert a parsed word
126128
# if it is entirely numeric, not if it just contains one digit. At the same
127129
# time, rewrite the functionality in native bash instead of using grep and sed.
130+
# Add htdestroytoken command.
131+
# Add a symlink htdecodetoken pointing to httokendecode.
128132

129133
* Thu Jun 16 2022 Dave Dykstra <[email protected]> 1.15-1
130134
- Revert to prior method for allowing --vaultalias as an alternate name

0 commit comments

Comments
 (0)