mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-22 18:21:53 +01:00
Add proper name valoidation in rename command, don't allow blanks in names
This commit is contained in:
@@ -445,8 +445,8 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
## don't allow for dots(.) in container names
|
## don't allow for dots(.) in container names
|
||||||
if echo "${NAME}" | grep -q "[.]"; then
|
if echo "${NAME}" | grep -Eq '[.]|\ '; then
|
||||||
echo -e "${COLOR_RED}Container names may not contain a dot(.)!${COLOR_RESET}"
|
echo -e "${COLOR_RED}Container names may not contain a dot(.) nor spaces!${COLOR_RESET}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ TARGET="${1}"
|
|||||||
NEWNAME="${2}"
|
NEWNAME="${2}"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if echo "${NEWNAME}" | grep -q "[.]"; then
|
if echo "${NEWNAME}" | grep -Eq '[.]|\ '; then
|
||||||
echo -e "${COLOR_RED}Container names may not contain a dot(.)!${COLOR_RESET}"
|
echo -e "${COLOR_RED}Container names may not contain a dot(.) nor spaces!${COLOR_RESET}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -125,9 +125,11 @@ change_name() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if container is running
|
## check if a running jail matches name or already exist
|
||||||
if [ -n "$(jls name | awk "/^${TARGET}$/")" ]; then
|
if [ "$(jls name | awk "/^${TARGET}$/")" ]; then
|
||||||
error_notify "${COLOR_RED}${TARGET} is running, See 'bastille stop'.${COLOR_RESET}"
|
error_notify "${COLOR_RED}Warning: ${TARGET} is running or the name does match.${COLOR_RESET}"
|
||||||
|
elif [ -d "${bastille_jailsdir}/${NEWNAME}" ]; then
|
||||||
|
error_notify "${COLOR_RED}Jail: ${NEWNAME} already exist.${COLOR_RESET}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
change_name
|
change_name
|
||||||
|
|||||||
Reference in New Issue
Block a user