Changeset - 7a0c4fe01dcb
[Not reviewed]
0 1 0
Branko Majic (branko) - 4 years ago 2020-06-29 04:18:33
branko@majic.rs
Added support for specifying a path to configuration directory instead of using one of the default locations.
1 file changed with 26 insertions and 12 deletions:
0 comments (0 inline, 0 general) First comment
x509/crlpublisher.sh
Show inline comments
 
@@ -19,7 +19,7 @@
 
#
 

	
 
program="crlpublisher.sh"
 
version="0.1.1"
 
version="0.1.2"
 

	
 
function usage() {
 
    cat <<EOF
 
@@ -47,7 +47,8 @@ supported publishers are:
 
      base64-encoded CRLs, DER for binary CRLs).
 

	
 
Publishing options are kept within configuration files. Configuration files
 
should be placed in one of the following directories:
 
should be placed in the explicitly set configurtion directory (set with the -c
 
option), or one of the following default locations:
 

	
 
    - /etc/crlpublisher/
 
    - ~/.crlpublisher/
 
@@ -87,6 +88,9 @@ Configuration options for 'archiver' publisher:
 

	
 
$program accepts the following options:
 

	
 
    -c dir    Explicit configuration directory from which the publisher
 
              configuration files should be read.
 

	
 
    -v        show script version and licensing information
 
    -h        show usage help
 

	
 
@@ -145,7 +149,9 @@ function readCrlInfo() {
 

	
 
    # Read the CRL information
 
    crlIssuerDn=$(openssl crl -issuer -inform "$crlFormat" -noout -in "$crlFile" | sed -e 's#^issuer=/##;s#/#,#g')
 
    crlNumber=$(echo "ibase=16;obase=A;$(openssl crl -crlnumber -inform "$crlFormat" -noout -in "$crlFile" | sed -e 's/crlNumber=//')" | bc)
 
    # @TODO: The -crlnumber option was added only to more recent versions of OpenSSL.
 
    #crlNumber=$(echo "ibase=16;obase=A;$(openssl crl -crlnumber -inform "$crlFormat" -noout -in "$crlFile" | sed -e 's/crlNumber=//')" | bc)
 
    crlNumber=$(openssl crl -text -inform "$crlFormat" -noout -in "$crlFile"  | grep -A1 'X509v3 CRL Number' | tail -n1 | grep -o '[[:digit:]]\+')
 
    crlLastUpdate=$(openssl crl -lastupdate -inform "$crlFormat" -noout -in "$crlFile" | sed -e 's/lastUpdate=//')
 
    crlNextUpdate=$(openssl crl -nextupdate -inform "$crlFormat" -noout -in "$crlFile" | sed -e 's/nextUpdate=//')
 

	
 
@@ -248,8 +254,9 @@ if [[ -z $1 ]]; then
 
fi
 

	
 
# Parse the arguments
 
while getopts "vh" opt; do
 
while getopts "c:vh" opt; do
 
    case "$opt" in
 
        c) configDir="$OPTARG";;
 
        v) version
 
           exit 0;;
 
        h) usage
 
@@ -261,20 +268,27 @@ done
 
i=$OPTIND
 
shift $(($i-1))
 

	
 
# Determine the configuration directory to be used
 
configDir="/etc/crlpublisher"
 
# Figure out which configuration directory to use.
 
if [[ -n $configDir && ! -d $configDir ]]; then
 
    echo "Specified configuration directory '$configDir' does not exist." >&2
 
    exit 2
 
# If no configuration directory was provided, try one of the default ones.
 
elif [[ -z $configDir ]]; then
 
    configDir="/etc/crlpublisher"
 

	
 
[[ ! -d $configDir ]] && configDir="$HOME/.crlpublisher"
 
    [[ ! -d $configDir ]] && configDir="$HOME/.crlpublisher"
 

	
 
if [[ ! -d $configDir ]]; then
 
    cat <<EOF >&2
 
No configuration directory could be found. Please create configuration directory
 
and the necessary configuration files in one of the following locations:
 
    if [[ ! -d $configDir ]]; then
 
        cat <<EOF >&2
 
No configuration directory could be found. Please provide configuration
 
directory path using the -c option, or create configuration directory and the
 
necessary configuration files in one of the following locations:
 

	
 
- /etc/crlpublisher/
 
- $HOME/crlpublisher/
 
EOF
 
    exit 2
 
        exit 2
 
    fi
 
fi
 

	
 
# The first argument should be a CRL file
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now