Subject: [alpine-devel] [PATCH 0/9] Revised patches for syslinux

From: Dubiousjim <[email-masked]>
Date: Sat, 29 Jun 2013 16:41:20 -0400

This set of patches makes the changes Natanael suggested (use cmp instead of
diff, eliminate the perl password utility), and bumps the pkgrel.  Some of the
commits are the same as before, but this whole set can replace what I sent
earlier.

Dubiousjim (9):
  main/syslinux: fix/refactor initramfs
  main/syslinux: use more specific COM32 (instead of KERNEL) for mboot.c32
  main/syslinux: use more specific LINUX (instead of KERNEL) for kernels
  main/syslinux: reorganize menu layout
  main/syslinux: add reboot entry
  main/syslinux: add Hardware Detection Tool entry
  main/syslinux: don't create backup when no changes
  main/syslinux: hooks for bootloader password
  main/syslinux: update checksums and bump pkgrel

 main/syslinux/APKBUILD             | 14 +++----
 main/syslinux/update-extlinux      | 76 ++++++++++++++++++++++++++++----------
 main/syslinux/update-extlinux.conf | 16 ++++++++
 3 files changed, 79 insertions(+), 27 deletions(-)

-- 
1.8.3.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Dubiousjim <[email-masked]>
Date: Sat, 29 Jun 2013 16:41:24 -0400

Add a blank line between any entries added from /etc/update-extlinux.d/*.

Move the memtest entry (if any) after a separator line, below these.
---
 main/syslinux/update-extlinux | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/main/syslinux/update-extlinux b/main/syslinux/update-extlinux
index 014df1b..0dc3601 100755
--- a/main/syslinux/update-extlinux
+++ b/main/syslinux/update-extlinux
@@ -134,20 +134,24 @@ for kernel in $(find /boot -name "vmlinuz-*" -type f); do
 	lst=$(($lst + 1))
 done
 
+everbose "$lst entries found."
+
+for entry in /etc/update-extlinux.d/*; do
+	[ -f "$entry" ] && { cat $entry; echo ""; } >> $conf.new
+done
+
+echo "MENU SEPARATOR" >> $conf.new
+echo "" >> $conf.new
+
 if [ -f "/boot/memtest" ]; then
 	everbose "Found memtest86+: /boot/memtest"
 	echo "LABEL memtest" >> $conf.new
 	echo "  MENU LABEL Memtest86+" >> $conf.new
         echo "  KERNEL memtest" >> $conf.new
 	echo "" >> $conf.new
-	lst=$(($lst + 1))
 fi
 
-everbose "$lst entries found."
 
-for entry in /etc/update-extlinux.d/*; do
-	[ -f "$entry" ] && cat $entry >> $conf.new
-done
 
 if [ "$overwrite" != "1" ]; then
 	exit 0
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Sat, 29 Jun 2013 16:41:23 -0400

---
 main/syslinux/update-extlinux | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main/syslinux/update-extlinux b/main/syslinux/update-extlinux
index e46eadf..014df1b 100755
--- a/main/syslinux/update-extlinux
+++ b/main/syslinux/update-extlinux
@@ -124,7 +124,7 @@ for kernel in $(find /boot -name "vmlinuz-*" -type f); do
 		echo "  MENU DEFAULT" >> $conf.new
 	fi
 	echo "  MENU LABEL Linux $tag" >> $conf.new
-	echo "  KERNEL $(basename $kernel)" >> $conf.new
+	echo "  LINUX $(basename $kernel)" >> $conf.new
 	if [ -f "/boot/initramfs-$tag" ]; then
 		everbose "Found initramfs: /boot/initramfs-$tag"
 		echo "  INITRD initramfs-$tag" >> $conf.new
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Sat, 29 Jun 2013 16:41:25 -0400

We don't install /boot/reboot.c32, but if it's present (it can be copied from
/usr/share/syslinux/reboot.c32), we add a menu entry for it---just like
with memtest.

Add a comment to /etc/update-extlinux.conf stating this.

It'd already be possible to get a reboot entry using the
/etc/update-extlinux.d/ folder, but this patch provides a more intelligent
framework with nicer layout.

The syslinux sourceball also provides a shutdown module, but I couldn't get this to
work and looking at the sources reveals it to be for machines with APM enabled.
Not sure how many machines that applies to anymore.
---
 main/syslinux/update-extlinux      | 7 +++++++
 main/syslinux/update-extlinux.conf | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/main/syslinux/update-extlinux b/main/syslinux/update-extlinux
index 0dc3601..1c5fc5c 100755
--- a/main/syslinux/update-extlinux
+++ b/main/syslinux/update-extlinux
@@ -151,6 +151,13 @@ if [ -f "/boot/memtest" ]; then
 	echo "" >> $conf.new
 fi
 
+if [ -f "/boot/reboot.c32" ]; then
+	everbose "Found reboot"
+	echo "LABEL reboot" >> $conf.new
+	echo "  MENU LABEL Reboot" >> $conf.new
+        echo "  COM32 reboot.c32" >> $conf.new
+	echo "" >> $conf.new
+fi

 if [ "$overwrite" != "1" ]; then
diff --git a/main/syslinux/update-extlinux.conf b/main/syslinux/update-extlinux.conf
index 59f9e60..5a36a1f 100644
--- a/main/syslinux/update-extlinux.conf
+++ b/main/syslinux/update-extlinux.conf
@@ -42,3 +42,7 @@ default=grsec
 # options to hand to xen hypervisor, useful ones are:
 #    dom0_mem=256M (give domain-0 environment 256M ram)
 xen_opts=dom0_mem=256M
+
+# if you copy /usr/share/syslinux/reboot.c32 to /boot/, a menu entry will be auto-generated for it
+
+# a menu entry will also be auto-generated for /boot/memtest, if you download it and install it
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Sat, 29 Jun 2013 16:41:27 -0400

---
 main/syslinux/update-extlinux | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/main/syslinux/update-extlinux b/main/syslinux/update-extlinux
index 66bc0ed..0ba4bbf 100755
--- a/main/syslinux/update-extlinux
+++ b/main/syslinux/update-extlinux
@@ -169,18 +169,22 @@ if [ -f "/boot/reboot.c32" ]; then
 	echo "" >> $conf.new
 fi
 
+if cmp --quiet $conf.new $conf; then
+	everbose "Configuration unchanged."
+	rm $conf.new
+fi
 
 if [ "$overwrite" != "1" ]; then
 	exit 0
-fi
+elif [ -f "$conf.new" ]; then
+	# keep a backup just in case
+	if [ -f "$conf" ]; then
+		mv $conf $conf.old
+	fi
 
-# keep a backup just in case
-if [ -f "$conf" ]; then
-	mv $conf $conf.old
+	mv $conf.new $conf
 fi
 
-mv $conf.new $conf
-
 everbose "Installing libutil.c32 libcom32.c32 mboot.c32 menu.c32 vesamenu.c32 to /boot."
 cp /usr/share/syslinux/libutil.c32 \
 	/usr/share/syslinux/libcom32.c32 \
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Sat, 29 Jun 2013 16:41:26 -0400

HDT provides a curses-like interface to display lots of hardware info
about your machine at bootloader time.

We don't install /boot/hdt.c32, but if it's present (it can be copied from
/usr/share/syslinux/hdt.c32), we add a menu entry for it---in preference to,
rather than in addition to, memtest, since HDT has a menu entry which invokes
memtest.

Using HDT to its full capacity requires finding or generating modules.pcimap
and pci.ids files for your machine, and installing them in /boot. We might want
to document this, which I don't here (but the online docs for HDT do). These
aren't required to use other functionality of HDT; and it's pretty useful
already without those.
---
 main/syslinux/update-extlinux      | 12 +++++++++++-
 main/syslinux/update-extlinux.conf |  5 ++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/main/syslinux/update-extlinux b/main/syslinux/update-extlinux
index 1c5fc5c..66bc0ed 100755
--- a/main/syslinux/update-extlinux
+++ b/main/syslinux/update-extlinux
@@ -143,7 +143,17 @@ done
 echo "MENU SEPARATOR" >> $conf.new
 echo "" >> $conf.new
 
-if [ -f "/boot/memtest" ]; then
+if [ -f "/boot/hdt.c32" ]; then
+	everbose "Found Hardware Detection Tool: /boot/hdt.c32"
+	echo "LABEL hdt" >> $conf.new
+	echo "  MENU LABEL Hardware info" >> $conf.new
+	echo "  COM32 hdt.c32" >> $conf.new
+	if [ -f "/boot/memtest" ]; then
+		everbose "Found memtest86+: /boot/memtest"
+		echo "  APPEND memtest=memtest" >> $conf.new
+	fi
+	echo "" >> $conf.new
+elif [ -f "/boot/memtest" ]; then
 	everbose "Found memtest86+: /boot/memtest"
 	echo "LABEL memtest" >> $conf.new
 	echo "  MENU LABEL Memtest86+" >> $conf.new
diff --git a/main/syslinux/update-extlinux.conf b/main/syslinux/update-extlinux.conf
index 5a36a1f..6c83349 100644
--- a/main/syslinux/update-extlinux.conf
+++ b/main/syslinux/update-extlinux.conf
@@ -45,4 +45,7 @@ xen_opts=dom0_mem=256M
 
 # if you copy /usr/share/syslinux/reboot.c32 to /boot/, a menu entry will be auto-generated for it
 
-# a menu entry will also be auto-generated for /boot/memtest, if you download it and install it
+# if you copy /usr/share/syslinux/hdt.c32 to /boot/, a menu entry will be auto-generated for it
+
+# if you download and install /boot/memtest, then if HDT is present it will use it, else a separate
+# menu entry will be auto-generated for memtest
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Sat, 29 Jun 2013 16:41:29 -0400

---
 main/syslinux/APKBUILD | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/main/syslinux/APKBUILD b/main/syslinux/APKBUILD
index 79d7e6c..0b93640 100644
--- a/main/syslinux/APKBUILD
+++ b/main/syslinux/APKBUILD
@@ -1,7 +1,7 @@
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=syslinux
 pkgver=5.10
-pkgrel=0
+pkgrel=1
 _ver=${pkgver/_/-}
 pkgdesc="Boot loader for the Linux operating system"
 url="http://syslinux.org"
@@ -48,11 +48,11 @@ package() {
 }
 
 md5sums="67c8a85ca275d13b4f7f6139dd47d999  syslinux-5.10.tar.xz
-7ef73a7a858b8aa1ac6635d6391ac8e5  update-extlinux.conf
-e52bf17d58790ff10275ec4e870c6702  update-extlinux"
+ca2b5435e838b5938064f93edb2cd897  update-extlinux.conf
+d3c240a6da92ed251570ef55186dd54f  update-extlinux"
 sha256sums="4b52d7647d5584c69764c06a836e0d524e5246bf2e94f68cf86342c415508422  syslinux-5.10.tar.xz
-ee970729e981ee1756ffe97f0cdda652d1e82773993310eeecfca1f2ddbe718b  update-extlinux.conf
-a30d92f3d47122b635078a5c9c9e124e368ebe6150e510a3b8649ed8c44258a6  update-extlinux"
+b72ac21426bbd52a55b130d5e4ca13f685780fd6719ee12235cd6bf3df30e32c  update-extlinux.conf
+18a3518e08a38dc015d7905fc71bb74c74cad10cfd30638fa950e40d9e28d002  update-extlinux"
 sha512sums="56422e14b4aa53ca1a5811da0582dbbb349aa52b9e78868bbedc24c67ef2420c4d0ac63fd68c7f0adc2c22606196276265d503b5b6f9d3d796d9ce42845bbdb5  syslinux-5.10.tar.xz
-d0c5a0891841623c8905864caadf58866d4b9f1f893725712c6813af6cb6d64f0c08f2a3783fda56fcb1cbcc1a0a73e65562339f5591f38ee5cb213b2d16c680  update-extlinux.conf
-18ddbcf07d357d5bdb0a82b8fd69a09826bfac6a065527404fab8f98af5d3e760d8ea149118bc792cfa717a4c94271f1ba85e3b358aa2b1c998a66c330c1fbc0  update-extlinux"
+372bea3eb7e91207af6e227b1ffad1cb877b1f97292004fc7c05820250b8c42ab76775e086e57ea90bbdc80b8efb9e1f3b5cbe2ec1e95be69506ebddf26a89ae  update-extlinux.conf
+39580f356e61462f850deb456568534017eacce219e2805412fa898f0425e7f70fa9b154511c5b0a87624dc20bda51f3d304ee0955b0963df2c66f44db173900  update-extlinux"
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Sat, 29 Jun 2013 16:41:28 -0400

We allow a password to be set in /etc/update-extlinux.conf. Instructions for
generating this are in /etc/update-extlinux.conf. For reference, here is another
(equivalent) way to generate the MD5 password: openssl passwd -1 -salt yy pass

If one sets a password, one will presumably want to make
/etc/update-extlinux.conf world-unreadable. We don't do that for you; however
we do make sure when a password is present to make the /boot/extlinux.conf
files we generate be world-unreadable.

Of the auto-generated entries, only HDT (if this is generated) is now
configured to respect the password; however, you can include "MENU PASSWD" in
any entries you put in /etc/update-extlinux.d/.

For example, I configure my BIOS to only boot from the internal drive, but I
have an entry in /etc/update-extlinux.d that permits chain-booting from a USB
key, and I have this entry configured to also require the password. (The BIOS
is also passworded, so that these settings can't be changed willy-nilly.)

Conflicts:
	main/syslinux/update-extlinux.conf
---
 main/syslinux/update-extlinux      | 10 ++++++++++
 main/syslinux/update-extlinux.conf |  9 +++++++++
 2 files changed, 19 insertions(+)

diff --git a/main/syslinux/update-extlinux b/main/syslinux/update-extlinux
index 0ba4bbf..0499f5f 100755
--- a/main/syslinux/update-extlinux
+++ b/main/syslinux/update-extlinux
@@ -134,6 +134,13 @@ for kernel in $(find /boot -name "vmlinuz-*" -type f); do
 	lst=$(($lst + 1))
 done
 
+if [ -n "$password" ]; then
+	echo "NOESCAPE 1" >> $conf.new
+	echo "MENU MASTER PASSWD $password" >> $conf.new
+	echo "" >> $conf.new
+	chmod o-r $conf.new
+fi
+
 everbose "$lst entries found."
 
 for entry in /etc/update-extlinux.d/*; do
@@ -147,6 +154,9 @@ if [ -f "/boot/hdt.c32" ]; then
 	everbose "Found Hardware Detection Tool: /boot/hdt.c32"
 	echo "LABEL hdt" >> $conf.new
 	echo "  MENU LABEL Hardware info" >> $conf.new
+	if [ -n "$password" ]; then
+		echo "  MENU PASSWD" >> $conf.new
+	fi
 	echo "  COM32 hdt.c32" >> $conf.new
 	if [ -f "/boot/memtest" ]; then
 		everbose "Found memtest86+: /boot/memtest"
diff --git a/main/syslinux/update-extlinux.conf b/main/syslinux/update-extlinux.conf
index 6c83349..947dfde 100644
--- a/main/syslinux/update-extlinux.conf
+++ b/main/syslinux/update-extlinux.conf
@@ -49,3 +49,12 @@ xen_opts=dom0_mem=256M
 
 # if you download and install /boot/memtest, then if HDT is present it will use it, else a separate
 # menu entry will be auto-generated for memtest
+
+# optional passwd
+# you can generate a MD5 password using: mkpasswd --salt=yy --method=md5
+# you can generate a SHA1 password using: printf '$4$%s$%s$\n' xxxxxx $(printf xxxxxxpass | openssl sha1 -binary | base64 | sed 's/=$//')
+# where yy are two "salt" characters from the set [./a-zA-Z0-9], and xxxxxx can be a longer "salt" from the same set
+# if you assign a password, you should make this file world-unreadable
+# if a password is assigned, the menu entries can't be edited at boot time, and HDT if present is password-protected
+# you can also include "MENU PASSWD" in any custom entries you have in /etc/update-extlinux.d/
+password=''
-- 
1.8.3.1

---

---

From: Natanael Copa <[email-masked]>
Date: Sun, 30 Jun 2013 13:23:10 +0200

On Sat, 29 Jun 2013 16:41:20 -0400
Dubiousjim <[email-masked]> wrote:

> This set of patches makes the changes Natanael suggested (use cmp
> instead of diff, eliminate the perl password utility), and bumps the
> pkgrel.  Some of the commits are the same as before, but this whole
> set can replace what I sent earlier.
> 
> Dubiousjim (9):
>   main/syslinux: use more specific COM32 (instead of KERNEL) for
> mboot.c32 main/syslinux: use more specific LINUX (instead of KERNEL)
> for kernels main/syslinux: reorganize menu layout
> main/syslinux/update-extlinux.conf | 16 ++++++++ 3 files changed, 79
> insertions(+), 27 deletions(-)
> 

Applied them all as-is. Thanks!

-nc

-- 

-nc

---