Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F161054730
D26167.id76527.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D26167.id76527.diff
View Options
Index: usr.sbin/certctl/certctl.sh
===================================================================
--- usr.sbin/certctl/certctl.sh
+++ usr.sbin/certctl/certctl.sh
@@ -30,7 +30,7 @@
############################################################ CONFIGURATION
: ${DESTDIR:=}
-: ${FILEPAT:="\.pem$|\.crt$|\.cer$|\.crl$|\.0$"}
+: ${FILEPAT:="\.pem$|\.crt$|\.cer$|\.crl$|\.[0-9]$"}
: ${VERBOSE:=0}
############################################################ GLOBALS
@@ -56,31 +56,56 @@
fi
}
+get_decimal()
+{
+ local checkdir hash decimal
+
+ checkdir=$1
+ hash=$2
+ decimal=0
+
+ while [ -e "$checkdir/$hash.$decimal" ]; do
+ decimal=$((decimal + 1))
+ done
+
+ echo ${decimal}
+ return 0
+}
+
create_trusted_link()
{
local hash
+ local suffix
hash=$( do_hash "$1" ) || return
- if [ -e "$BLACKLISTDESTDIR/$hash.0" ]; then
- echo "Skipping blacklisted certificate $1 ($BLACKLISTDESTDIR/$hash.0)"
- return 1
- fi
- [ $VERBOSE -gt 0 ] && echo "Adding $hash.0 to trust store"
- [ $NOOP -eq 0 ] && install ${INSTALLFLAGS} -lrs $(realpath "$1") "$CERTDESTDIR/$hash.0"
+ for blistfile in $(find $BLACKLISTDESTDIR -name "$hash.*"); do
+ if diff -q "$blistfile" "$1"; then
+ echo "Skipping blacklisted certificate $1 ($blistfile)"
+ return 1
+ fi
+ done
+ suffix=$(get_decimal "$CERTDESTDIR" "$hash")
+ [ $VERBOSE -gt 0 ] && echo "Adding $hash.$suffix to trust store"
+ [ $NOOP -eq 0 ] && \
+ install ${INSTALLFLAGS} -lrs $(realpath "$1") "$CERTDESTDIR/$hash.$suffix"
}
create_blacklisted()
{
local hash srcfile filename
+ local suffix
# If it exists as a file, we'll try that; otherwise, we'll scan
if [ -e "$1" ]; then
hash=$( do_hash "$1" ) || return
srcfile=$(realpath "$1")
- filename="$hash.0"
+ suffix=$(get_decimal "$BLACKLISTDESTDIR" "$hash")
+ filename="$hash.$suffix"
elif [ -e "${CERTDESTDIR}/$1" ]; then
srcfile=$(realpath "${CERTDESTDIR}/$1")
- filename="$1"
+ hash=$(echo "$1" | sed -Ee 's/\.([0-9])+$//')
+ suffix=$(get_decimal "$BLACKLISTDESTDIR" "$hash")
+ filename="$hash.$suffix"
else
return
fi
@@ -115,7 +140,7 @@
if [ -e "$1" ]; then
cd "$1"
- for CFILE in *.0; do
+ for CFILE in *.[0-9]; do
if [ ! -s "$CFILE" ]; then
echo "Unable to read $CFILE" >&2
ERRORS=$(( $ERRORS + 1 ))
@@ -180,8 +205,12 @@
for BFILE in "$@"; do
if [ -s "$BFILE" ]; then
hash=$( do_hash "$BFILE" )
- echo "Removing $hash.0 from blacklist"
- [ $NOOP -eq 0 ] && rm -f "$BLACKLISTDESTDIR/$hash.0"
+ for BLISTEDFILE in $(find $BLACKLISTDESTDIR -name "$hash.*"); do
+ if diff -q "$BLISTEDFILE" "$BFILE"; then
+ echo "Removing $(basename "$BLISTEDFILE") from blacklist"
+ [ $NOOP -eq 0 ] && rm -f $BLISTEDFILE
+ fi
+ done
elif [ -e "$BLACKLISTDESTDIR/$BFILE" ]; then
echo "Removing $BFILE from blacklist"
[ $NOOP -eq 0 ] && rm -f "$BLACKLISTDESTDIR/$BFILE"
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 1, 4:32 AM (20 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34542257
Default Alt Text
D26167.id76527.diff (2 KB)
Attached To
Mode
D26167: certctl: fix hashed link generation with duplicate subjects
Attached
Detach File
Event Timeline
Log In to Comment