@@ -769,9 +769,14 @@ and initialize a fresh PKI here."
769
769
init-pki complete; you may now create a CA or requests.
770
770
771
771
Your newly created PKI dir is:
772
- * $EASYRSA_PKI
772
+ * $EASYRSA_PKI "
773
773
774
+ if [ " $user_vars_true " ]; then
775
+ : # ok - No message required
776
+ else
777
+ notice " \
774
778
IMPORTANT: Easy-RSA 'vars' file has now been moved to your PKI above."
779
+ fi
775
780
} # => init_pki()
776
781
777
782
# Copy data-files from various sources
@@ -863,31 +868,35 @@ install_data_to_pki () {
863
868
set_var EASYRSA_EXT_DIR " $EASYRSA_PKI /x509-types"
864
869
fi
865
870
866
- # If this is init-pki then create PKI/vars from PKI/example
867
- case " $context " in
868
- init-pki)
869
- if [ -e " ${EASYRSA_PKI} /${vars_file_example} " ]; then
870
- [ -e " ${EASYRSA_PKI} /${vars_file} " ] || \
871
- cp " ${EASYRSA_PKI} /${vars_file_example} " \
872
- " ${EASYRSA_PKI} /${vars_file} " || :
873
- fi
874
- ;;
875
- vars-setup)
876
- if [ " $found_vars " ]; then
877
- : # ok - Do not make a PKI/vars if another vars exists
878
- else
871
+ if [ user_vars_true ]; then
872
+ : # ok - No PKI/vars required
873
+ else
874
+ # Create PKI/vars from PKI/example
875
+ case " $context " in
876
+ init-pki)
879
877
if [ -e " ${EASYRSA_PKI} /${vars_file_example} " ]; then
880
878
[ -e " ${EASYRSA_PKI} /${vars_file} " ] || \
881
879
cp " ${EASYRSA_PKI} /${vars_file_example} " \
882
880
" ${EASYRSA_PKI} /${vars_file} " || :
883
881
fi
884
- fi
885
- ;;
886
- ' ' )
887
- die " install_data_to_pki - unspecified context" ;;
888
- * )
889
- die " install_data_to_pki - unknown context: $context "
890
- esac
882
+ ;;
883
+ vars-setup)
884
+ if [ " $found_vars " ]; then
885
+ : # ok - Do not make a PKI/vars if another vars exists
886
+ else
887
+ if [ -e " ${EASYRSA_PKI} /${vars_file_example} " ]; then
888
+ [ -e " ${EASYRSA_PKI} /${vars_file} " ] || \
889
+ cp " ${EASYRSA_PKI} /${vars_file_example} " \
890
+ " ${EASYRSA_PKI} /${vars_file} " || :
891
+ fi
892
+ fi
893
+ ;;
894
+ ' ' )
895
+ die " install_data_to_pki - unspecified context" ;;
896
+ * )
897
+ die " install_data_to_pki - unknown context: $context "
898
+ esac
899
+ fi
891
900
892
901
# Check PKI is updated - Omit unnecessary checks
893
902
# [ -e "${EASYRSA_PKI}/${vars_file}" ] || return
@@ -2935,14 +2944,15 @@ vars_setup() {
2935
2944
# If the --vars option does not point to a file, show helpful error.
2936
2945
die " The file '$EASYRSA_VARS_FILE ' was not found."
2937
2946
fi
2947
+ unset -v prog_vars pwd_vars easy_vars pki_vars expected_pki_vars
2938
2948
2939
2949
# Otherwise, find vars 'the new way' followed by 'the old way' ..
2940
2950
else
2941
2951
# if PKI is required
2942
2952
if [ -z " $no_pki_required " ]; then
2943
2953
2944
2954
# Clear flags - This is the preferred order to find:
2945
- unset -v e_pki_vars e_easy_vars e_pwd_vars e_prog_vars found_vars
2955
+ unset -v e_pki_vars e_easy_vars e_pwd_vars e_prog_vars found_vars vars_in_pki
2946
2956
2947
2957
# PKI location, if present:
2948
2958
[ -e " $pki_vars " ] && e_pki_vars=1
@@ -2986,7 +2996,7 @@ Priority should be given to your PKI vars file:
2986
2996
[ " $prog_vars " ] && vars=" $prog_vars "
2987
2997
[ " $pwd_vars " ] && vars=" $pwd_vars "
2988
2998
[ " $easy_vars " ] && vars=" $easy_vars "
2989
- [ " $pki_vars " ] && vars=" $pki_vars "
2999
+ [ " $pki_vars " ] && vars=" $pki_vars " && vars_in_pki=1
2990
3000
fi
2991
3001
# END: Find vars
2992
3002
fi
@@ -3011,7 +3021,7 @@ recommended - please remove it from there before continuing."
3011
3021
fi
3012
3022
3013
3023
# Sanitize vars further but ONLY if it is in PKI folder
3014
- if [ " $pki_vars " ]; then
3024
+ if [ " $vars_in_pki " ]; then
3015
3025
# Warning: Single quote
3016
3026
if grep ' ^[[:blank:]]*set_var[[:blank:]]\+.*' " $vars " | \
3017
3027
grep -q -e ' &' -e " '" -e ' `' -e ' \$' -e ' #' ; then
@@ -3031,8 +3041,13 @@ Failed to source the vars file, remove any unsupported characters."
3031
3041
# shellcheck disable=1090 # can't follow non-constant source. vars
3032
3042
. " $vars " 2> /dev/null
3033
3043
notice " Using Easy-RSA configuration from: $vars "
3034
- [ " $pki_vars " ] || \
3035
- warn " Move your vars file to your PKI folder, where it is safe!"
3044
+ if [ " $user_vars_true " ]; then
3045
+ : # ok - No message required
3046
+ else
3047
+ [ " $vars_in_pki " ] || \
3048
+ warn " \
3049
+ Move your vars file to your PKI folder, where it is safe!"
3050
+ fi
3036
3051
fi
3037
3052
fi
3038
3053
@@ -3758,7 +3773,7 @@ NL='
3758
3773
[ -z " $EASYRSA_NO_UMASK " ] && umask " ${EASYRSA_UMASK:- 077} "
3759
3774
3760
3775
# Initialisation requirements
3761
- unset -v easyrsa_error_exit user_san_true
3776
+ unset -v easyrsa_error_exit user_san_true user_vars_true
3762
3777
3763
3778
# Parse options
3764
3779
while : ; do
@@ -3841,6 +3856,7 @@ while :; do
3841
3856
--subca-len)
3842
3857
export EASYRSA_SUBCA_LEN=" $val " ;;
3843
3858
--vars)
3859
+ user_vars_true=1
3844
3860
export EASYRSA_VARS_FILE=" $val " ;;
3845
3861
--copy-ext)
3846
3862
empty_ok=1
@@ -3904,6 +3920,7 @@ vars_setup
3904
3920
# determine how we were called, then hand off to the function responsible
3905
3921
case " $cmd " in
3906
3922
init-pki|clean-all)
3923
+ no_pki_required=1
3907
3924
init_pki " $@ "
3908
3925
;;
3909
3926
build-ca)
0 commit comments