octeon: make syspatch copy /bsd to real boot directory

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

octeon: make syspatch copy /bsd to real boot directory

gwes-2
Install on octeon correctly copies /bsd to the MSDOS filesystem
where the manufacturer's boot program finds it

It appears that syspatch doesn't. If so, fixing this is important
because as it stands security patches won't actually be installed
in running systems.

This is an * untested * * conceptual * patch. My only octeon
system is my firewall. Another can be purchased if consensus is
that this should be tested here.

I haven't looked for update-link yet

geoff steckel

Index: Makefile.octeon
===================================================================
RCS file: /cvs/src/sys/arch/octeon/conf/Makefile.octeon,v
retrieving revision 1.49
diff -u -p -r1.49 Makefile.octeon
--- Makefile.octeon 9 Feb 2018 03:59:15 -0000 1.49
+++ Makefile.octeon 20 May 2019 17:40:17 -0000
@@ -28,6 +28,14 @@ S!= cd ../../../..; pwd
 _machdir?= $S/arch/${_mach}
 _archdir?= $S/arch/${_arch}
 
+# as long as there is no boot program which loads from ufs,
+# we must copy any kernels to the FAT filesystem where the
+# manufacturer provided finds it
+# this script assumes a valid partition and filesystem exist
+
+BOOTROOTDIR?= /mnt/
+BOOTROOTDEV?= /dev/sd0i
+
 INCLUDES= -nostdinc -I$S -I${.OBJDIR} -I$S/arch
 CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D__${_mach}__ -MD -MP
 CWARNFLAGS= -Werror -Wall -Wimplicit-function-declaration \
@@ -154,12 +162,22 @@ context.o cp0access.o exception.o locore
 lcore_access.o lcore_ddb.o lcore_float.o tlbhandler.o: assym.h
 mips64r2.o: assym.h
 
-hardlink-obsd:
+hardlink-obsd: mount_bootroot
  [[ ! -f /bsd ]] || cmp -s bsd /bsd || ln -f /bsd /obsd
+ [[ -z $BOOTROOTDIR && ! -f $BOOTROOTDIR/bsd ]] || \
+ cmp -s bsd $BOOTROOTDIR/bsd || \
+ ln -f $BOOTROOTDIR/bsd $BOOTROOTDIR/obsd
 
-newinstall:
+newinstall: mount_bootroot
  umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \
     sha256 -h /var/db/kernel.SHA256 /bsd
+ [[ -z $BOOTROOTDIR ]] || \
+    cp /bsd $BOOTROOTDIR/nbsd && \
+ mv $BOOTROOTDIR/nbsd $BOOTROOTDIR/bsd
+
+mount_bootroot:
+ [[ -z $BOOTROOTDIR ]] || \
+ mount -t $BOOTROOTDEV /mnt
 
 install: update-link hardlink-obsd newinstall
 

Reply | Threaded
Open this post in threaded view
|

Re: octeon: make syspatch copy /bsd to real boot directory

gwes-2
A few corrections to the previous diff, sorry
Index: Makefile.octeon
===================================================================
RCS file: /cvs/src/sys/arch/octeon/conf/Makefile.octeon,v
retrieving revision 1.49
diff -u -p -r1.49 Makefile.octeon
--- Makefile.octeon 9 Feb 2018 03:59:15 -0000 1.49
+++ Makefile.octeon 20 May 2019 21:50:55 -0000
@@ -28,6 +28,14 @@ S!= cd ../../../..; pwd
 _machdir?= $S/arch/${_mach}
 _archdir?= $S/arch/${_arch}
 
+# as long as there is no boot program which loads from ufs,
+# we must copy any kernels to the FAT filesystem where the
+# manufacturer provided finds it
+# this script assumes a valid partition and filesystem exist
+
+BOOTROOTDIR?= /mnt/
+BOOTROOTDEV?= /dev/sd0i
+
 INCLUDES= -nostdinc -I$S -I${.OBJDIR} -I$S/arch
 CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D__${_mach}__ -MD -MP
 CWARNFLAGS= -Werror -Wall -Wimplicit-function-declaration \
@@ -139,6 +147,7 @@ vers.o: ${SYSTEM_DEP:Ngap.o}
 clean:
  rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* \
     gap.link ld.script lorder makegap.sh param.c
+ [[ -z ${BOOTROOTDIR} ]] || umount -f ${BOOTROOtDEV}
 
 cleandir: clean
  rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c
@@ -154,14 +163,28 @@ context.o cp0access.o exception.o locore
 lcore_access.o lcore_ddb.o lcore_float.o tlbhandler.o: assym.h
 mips64r2.o: assym.h
 
-hardlink-obsd:
+hardlink-obsd: mount_bootroot
  [[ ! -f /bsd ]] || cmp -s bsd /bsd || ln -f /bsd /obsd
+ [[ -z ${BOOTROOTDIR} && ! -f ${BOOTROOTDIR}/bsd ]] || \
+ cmp -s bsd ${BOOTROOTDIR}/bsd || \
+ ln -f ${BOOTROOTDIR}/bsd ${BOOTROOTDIR}/obsd
 
-newinstall:
+newinstall: mount_bootroot
  umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \
     sha256 -h /var/db/kernel.SHA256 /bsd
+ [[ -z ${BOOTROOTDIR} ]] || \
+    cp /bsd ${BOOTROOTDIR}/nbsd && \
+ mv ${BOOTROOTDIR}/nbsd ${BOOTROOTDIR}/bsd
+
+mount_bootroot:
+ [[ -z ${BOOTROOTDIR} ]] || \
+ mount ${BOOTROOTDEV} /mnt
+
+umount_bootroot:
+ [[ -z ${BOOTROOTDIR} ]] || \
+ umount -f ${BOOTROOTDEV}
 
-install: update-link hardlink-obsd newinstall
+install: update-link hardlink-obsd newinstall umount_bootroot
 
 # pull in the dependency information
 .ifnmake clean