[debian-edu-commits] [Git][debian-edu/debian-edu-config][personal/sunweaver/hostname-cmdline-override] share/debian-edu-config/d-i/pre-pkgsel: Tighten hostname= parsing and...

Daniel Teichmann (@dzatoah) gitlab at salsa.debian.org
Wed Aug 19 12:04:50 BST 2026



Daniel Teichmann pushed to branch personal/sunweaver/hostname-cmdline-override at Debian Edu / debian-edu-config


Commits:
49021353 by Daniel Teichmann at 2026-08-19T13:04:41+02:00
share/debian-edu-config/d-i/pre-pkgsel: Tighten hostname= parsing and sanitization from /proc/cmdline.

Handle hostname= as first cmdline token, ignore empty values and
strip characters invalid in hostnames.

- - - - -


1 changed file:

- share/debian-edu-config/d-i/pre-pkgsel


Changes:

=====================================
share/debian-edu-config/d-i/pre-pkgsel
=====================================
@@ -181,12 +181,15 @@ EOF
 
     # Check whether hostname= was given on boot's /proc/cmdline prompt
     # and use that if not installing a Main-Server.
-    PROC_CMDLINE_HOSTNAME=$(cat /proc/cmdline | grep -E " hostname=" | sed -re "s/.*\ hostname=([^ ]+).*/\1/")
+    PROC_CMDLINE_HOSTNAME=$(cat /proc/cmdline |
+        sed -n -re "s/.*(^| )hostname=([^ ]+).*/\2/p" |
+        tr A-Z a-z |
+        tr -cd 'a-z0-9-' |
+        sed -e 's/^-*//' -e 's/-*$//')
     if echo $PROFILE | grep -q Main-Server ; then
         :
     elif [ -n "${PROC_CMDLINE_HOSTNAME}" ]; then
-        # Sanitize hostname from /proc/cmdline slightly.
-        MY_HOSTNAME="$(echo ${PROC_CMDLINE_HOSTNAME} | tr A-Z a-z | sed -e "s/[^0-9a-z-]//gi")"
+        MY_HOSTNAME="${PROC_CMDLINE_HOSTNAME}"
     fi
 
     if [ ! -z "$MY_HOSTNAME" ] ; then



View it on GitLab: https://salsa.debian.org/debian-edu/debian-edu-config/-/commit/49021353fb4a83c4fb77058d1f4750b9a7103340

-- 
View it on GitLab: https://salsa.debian.org/debian-edu/debian-edu-config/-/commit/49021353fb4a83c4fb77058d1f4750b9a7103340
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-edu-commits/attachments/20260819/f3a3145a/attachment-0001.htm>


More information about the debian-edu-commits mailing list