Skip to content

Commit

Permalink
Correct --sub-key-name usage in inline-remove
Browse files Browse the repository at this point in the history
inline-remove does not require the Sub-key name because the inline
Hash is always unique.

Signed-off-by: Richard Bonhomme <[email protected]>
  • Loading branch information
TinCanTech committed Jan 20, 2021
1 parent aa76b19 commit da151ca
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions easytls
Original file line number Diff line number Diff line change
Expand Up @@ -1269,22 +1269,19 @@ inline_index_update ()
easytls_verbose " ADD: $new_record"
;;
del)

# Note: Inline HASH is unique, regardless of --sub-key-name
# Identify old record
old_record='${name}[[:blank:]]${inline_serial}[[:blank:]]${inline_hash}'
[ $EASYTLS_TLSCV2_SUBKNAME ] && \
old_record='${old_record}[[:blank:]]$EASYTLS_TLSCV2_SUBKNAME'
eval old_record=${old_record}
old_record="${name}[[:blank:]]${inline_serial}[[:blank:]]${inline_hash}"

# Verify old record
grep "^${old_record}$" "$EASYTLS_INLINE_INDEX" 1>/dev/null || {
# Find old record
grep "^${old_record}" "$EASYTLS_INLINE_INDEX" 1>/dev/null || {
help_note="Missing record: $old_record"
die "inline_index_update del: Failed verify"
die "inline_index_update del: Failed to find old record"
}

# Remove old record
easytls_verbose " DEL: $old_record"
sed -i -e "/^${old_record}$/d" "$EASYTLS_INLINE_INDEX" || {
sed -i -e "/^${old_record}.*$/d" "$EASYTLS_INLINE_INDEX" || {
help_note="Missing record: $old_record"
die "inline_index_update del: Failed write"
}
Expand Down Expand Up @@ -1561,10 +1558,11 @@ inline_remove ()
# Check .inline HASH prior to removal
verify_inline_hash || die "inline_remove Failed HASH: $inline_file"

rm "$inline_file" || die "Failed to remove: $inline_file"

# Update the index first
inline_index_update del

rm "$inline_file" || die "Failed to remove: $inline_file"

# Inline file and record deleted - Forget the HASH
# Otherwise 'inline_renew add' still has the HASH
# Logically, this *cannot* be removed -- tct
Expand Down

1 comment on commit da151ca

@TinCanTech
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.