File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,9 @@ PRVKEY_FILE="$HOMEDIR/$user/.ssh/hst-filemanager-key"
3434PUBKEY_FILE=" $HOMEDIR /$user /.ssh/hst-filemanager-key.pub"
3535AUTHKEY_FILE=" $HOMEDIR /$user /.ssh/authorized_keys"
3636
37- [ -L " $PRVKEY_FILE " ] && check_result $E_FORBIDEN " Private key file cannot be a symlink "
38- [ -L " $PUBKEY_FILE " ] && check_result $E_FORBIDEN " Public key file cannot be a symlink "
39- [ -L " $AUTHKEY_FILE " ] && check_result $E_FORBIDEN " Authorized keys file cannot be a symlink "
37+ [ -z " $( readlink -f " $ PRVKEY_FILE" | egrep " ^ $HOMEDIR / $user /.ssh/ " ) " ] && check_result $E_FORBIDEN " Invalid private key file path "
38+ [ -z " $( readlink -f " $ PUBKEY_FILE" | egrep " ^ $HOMEDIR / $user /.ssh/ " ) " ] && check_result $E_FORBIDEN " Invalid public key file path "
39+ [ -z " $( readlink -f " $ AUTHKEY_FILE" | egrep " ^ $HOMEDIR / $user /.ssh/ " ) " ] && check_result $E_FORBIDEN " Invalid authorized keys path "
4040
4141if [ ! -f " ${PRVKEY_FILE} " ]; then
4242
@@ -63,7 +63,7 @@ if [ ! -f "${AUTHKEY_FILE}" ] || [ "$new_pubkey" = true ]; then
6363 fi
6464
6565 # make sure authorized_keys is ending with EOL
66- sed -i ' $a\' " ${AUTHKEY_FILE} "
66+ [ -f " ${AUTHKEY_FILE} " ] && sed -i ' $a\' " ${AUTHKEY_FILE} "
6767
6868 echo " from=\" 127.0.0.1\" ,command=\" internal-sftp\" ,restrict ${pubkey_str} TS:${now} ${pubkey_desc} " >> " ${AUTHKEY_FILE} "
6969
You can’t perform that action at this time.
0 commit comments