[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)" <[email protected]>
Newsgroups gmane.linux.skolelinux.cvs
Message-ID <[email protected]>

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

_______________________________________________
debian-edu-commits mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/debian-edu-commits
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.