mirror of
https://github.com/churchers/vm-bhyve.git
synced 2026-01-03 19:43:42 +01:00
Don't override maxlen if a caller sets it
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
VERSION=1.5-devel
|
VERSION=1.5-devel
|
||||||
VERSION_INT=105100
|
VERSION_INT=105101
|
||||||
VERSION_BSD=$(uname -K)
|
VERSION_BSD=$(uname -K)
|
||||||
PATH=${PATH}:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
|
PATH=${PATH}:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
|
||||||
|
|
||||||
|
|||||||
@@ -840,7 +840,7 @@ core::rename(){
|
|||||||
local _new="$2"
|
local _new="$2"
|
||||||
|
|
||||||
[ -z "${_old}" -o -z "${_new}" ] && util::usage
|
[ -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 "${_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"
|
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
|
# check name of virtual machine
|
||||||
#
|
#
|
||||||
# @param _name name to check
|
# @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
|
# @return int 0 if name is valid
|
||||||
#
|
#
|
||||||
util::check_name(){
|
util::check_name(){
|
||||||
local _name="$1"
|
local _name="$1"
|
||||||
local _maxlen="$2"
|
local _maxlen="$2"
|
||||||
|
|
||||||
if [ ${VERSION_BSD} -ge 1300000 ]; then
|
if [ -z "${_maxlen}" ]; then
|
||||||
: ${_maxlen:=229}
|
if [ ${VERSION_BSD} -ge 1300000 ]; then
|
||||||
else
|
: ${_maxlen:=229}
|
||||||
: ${_maxlen:=30}
|
else
|
||||||
|
: ${_maxlen:=30}
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${_name}" | egrep -iqs "^[a-z0-9][.a-z0-9_-]{0,${_maxlen}}[a-z0-9]\$"
|
echo "${_name}" | egrep -iqs "^[a-z0-9][.a-z0-9_-]{0,${_maxlen}}[a-z0-9]\$"
|
||||||
|
|||||||
Reference in New Issue
Block a user