mirror of
https://github.com/churchers/vm-bhyve.git
synced 2025-12-11 01:10:01 +01:00
Don't override maxlen if a caller sets it
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
VERSION=1.5-devel
|
||||
VERSION_INT=105100
|
||||
VERSION_INT=105101
|
||||
VERSION_BSD=$(uname -K)
|
||||
PATH=${PATH}:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
|
||||
|
||||
|
||||
@@ -840,7 +840,7 @@ core::rename(){
|
||||
local _new="$2"
|
||||
|
||||
[ -z "${_old}" -o -z "${_new}" ] && util::usage
|
||||
util::check_name "${_new}" 46 || util::err "invalid virtual machine name - '${_name}'"
|
||||
util::check_name "${_new}" || util::err "invalid virtual machine name - '${_name}'"
|
||||
|
||||
datastore::get_guest "${_new}" && util::err "directory ${VM_DS_PATH}/${_new} already exists"
|
||||
datastore::get_guest "${_old}" || util::err "${_old} doesn't appear to be a valid virtual machine"
|
||||
|
||||
12
lib/vm-util
12
lib/vm-util
@@ -353,17 +353,19 @@ util::yesno(){
|
||||
# check name of virtual machine
|
||||
#
|
||||
# @param _name name to check
|
||||
# @param _maxlen=30 maximum name length (NOTE should be 2 less than desired)
|
||||
# @param _maxlen=30(229 on 13+) maximum name length (NOTE should be 2 less than desired)
|
||||
# @return int 0 if name is valid
|
||||
#
|
||||
util::check_name(){
|
||||
local _name="$1"
|
||||
local _maxlen="$2"
|
||||
|
||||
if [ ${VERSION_BSD} -ge 1300000 ]; then
|
||||
: ${_maxlen:=229}
|
||||
else
|
||||
: ${_maxlen:=30}
|
||||
if [ -z "${_maxlen}" ]; then
|
||||
if [ ${VERSION_BSD} -ge 1300000 ]; then
|
||||
: ${_maxlen:=229}
|
||||
else
|
||||
: ${_maxlen:=30}
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "${_name}" | egrep -iqs "^[a-z0-9][.a-z0-9_-]{0,${_maxlen}}[a-z0-9]\$"
|
||||
|
||||
Reference in New Issue
Block a user