mirror of
https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git
synced 2025-12-14 19:02:45 +03:00
validate hostname value lengths
This commit is contained in:
parent
daa31db54e
commit
3aabf9f83e
@ -6,6 +6,9 @@
|
||||
|
||||
* Alpine autoinstall - allow override disk and reboot and set swap (@ncopa)
|
||||
|
||||
* Warn when hostname is too long (per RFC-1035) instead of setting invalid
|
||||
value.
|
||||
|
||||
|
||||
## 2024-12-03 - Tiny Cloud v3.1.0
|
||||
|
||||
|
||||
@ -226,13 +226,19 @@ init__set_hostname() {
|
||||
log -i -t "$phase" info "$ACTION: no hostname set"
|
||||
return
|
||||
fi
|
||||
|
||||
local host="${fqdn%%\.*}"
|
||||
if [ -z "$host" ]; then
|
||||
log -i -t "$phase" warning "$ACTION: invalid hostname '$fqdn'"
|
||||
if [ ${#fqdn} -gt 255 ]; then
|
||||
log -i -t "$phase" warning "$ACTION: hostname exceeds 255 chars '$fqdn'"
|
||||
return 1
|
||||
fi
|
||||
local host="${fqdn%%\.*}"
|
||||
if [ -z "$host" ]; then
|
||||
log -i -t "$phase" warning "$ACTION: unable to extract short hostname from '$fqdn'"
|
||||
return 1
|
||||
fi
|
||||
if [ ${#host} -gt 63 ]; then
|
||||
log -i -t "$phase" warning "$ACTION: short hostname exceeds 63 chars '$host'"
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir -p "$ETC"
|
||||
echo "$host" > "$ETC"/hostname
|
||||
$MOCK hostname -F "$ETC"/hostname
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user