From: b Date: Sat, 17 Jun 2023 20:48:24 +0000 (+0000) Subject: setuid & exec wrapper X-Git-Tag: v1.0.0~3 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=e95c217eba6c77d86c54787162e85b0691c8b7c5;p=ott%2Fpost setuid & exec wrapper --- diff --git a/.gitmodules b/.gitmodules index 18429c3..2c3fd5a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "botm-common"] path = botm-common url = ../../botm/common-perl +[submodule "exec"] + path = exec + url = ../../botm/exec diff --git a/exec b/exec new file mode 160000 index 0000000..e95a720 --- /dev/null +++ b/exec @@ -0,0 +1 @@ +Subproject commit e95a720dc218bda573b24d2ba52af79b4be48da9 diff --git a/makefile b/makefile index 1878986..e1a2399 100644 --- a/makefile +++ b/makefile @@ -21,10 +21,14 @@ TARGET = debug # make -B TARGET=target_name makefile endif +CC =gcc +CF =-g -Wall + CHMOD=/usr/bin/chmod CP =/usr/bin/cp MKDIR=/usr/bin/mkdir RM =/usr/bin/rm +PERL =/usr/bin/perl BIN_PATH = /botm/bin/test-post LIB_PATH = /botm/lib/test-post @@ -43,7 +47,8 @@ GENERATE_FROM=\ sendpost.1.pl TO_GENERATE=\ -sendpost +sendpost.pl + DIR=\ $(BIN_PATH)\ @@ -53,18 +58,24 @@ $(TMP_PATH) HIDDEN_DIR=\ $(TMP_PATH) -SETUID= +SETUID=\ +sendpost.pl EXEC=\ +sendpost.pl + +PERL_WRAP_EXEC=\ sendpost + BIN=\ -$(EXEC) +$(EXEC)\ +$(PERL_WRAP_EXEC) LIB=\ botm-common/botm_common.pm -all: $(BIN) +all: $(BIN) setuid exec makefile: makefile.1.mak $(CONFIGFILE) $(CONFIGURE_CMD) < makefile.1.mak > makefile @@ -73,13 +84,18 @@ makefile: makefile.1.mak $(CONFIGFILE) $(TO_GENERATE): $(GENERATE_FROM) $(CONFIGFILE) $(CONFIGURE_CMD) --in $(GENERATE_FROM) --out $(TO_GENERATE) +$(PERL_WRAP_EXEC): %: exec/exec.c exec/settings.txt + $(PERL) $(CONFIGURE) path=$(BIN_PATH) target=$*.pl exec/settings.txt --in exec/exec.c --out $*.c + $(CC) $(CF) -o $@ $*.c exec: $(EXEC) $(CHMOD) +x $(EXEC) +wrap_exec: + setuid: $(SETUID) -# $(CHMOD) u+s,g+s $(SETUID) - + $(CHMOD) u+s,g+s $(SETUID) + mktree: $(MKDIR) -p $(DIR) @@ -100,7 +116,7 @@ endif install: all cp_bin cp_lib clean: - $(RM) -f $(TO_GENERATE) + $(RM) -f $(TO_GENERATE) $(PERL_WRAP_EXEC) $(PERL_WRAP_EXEC:=.c) PHONY: all clean install cp_bin cp_lib diff --git a/makefile.1.mak b/makefile.1.mak index c2c6e97..d894999 100644 --- a/makefile.1.mak +++ b/makefile.1.mak @@ -21,10 +21,14 @@ TARGET = debug ###MAKE_TARGET: # make -B TARGET=target_name makefile endif +###MAKE_CC: CC=gcc +###MAKE_CF: CF=-g -Wall + ###MAKE_CHMOD: CHMOD = chmod ###MAKE_CP: CP = cp ###MAKE_MKDIR: MKDIR = mkdir ###MAKE_RM: RM = rm +###MAKE_PERL: PERL = perl ###MAKE_BIN_PATH: BIN_PATH = /botm/bin/post ###MAKE_LIB_PATH: LIB_PATH = /botm/lib/post @@ -43,7 +47,8 @@ GENERATE_FROM=\ sendpost.1.pl TO_GENERATE=\ -sendpost +sendpost.pl + DIR=\ $(BIN_PATH)\ @@ -53,18 +58,24 @@ $(TMP_PATH) HIDDEN_DIR=\ $(TMP_PATH) -SETUID= +SETUID=\ +sendpost.pl EXEC=\ +sendpost.pl + +PERL_WRAP_EXEC=\ sendpost + BIN=\ -$(EXEC) +$(EXEC)\ +$(PERL_WRAP_EXEC) LIB=\ botm-common/botm_common.pm -all: $(BIN) +all: $(BIN) setuid exec makefile: makefile.1.mak $(CONFIGFILE) $(CONFIGURE_CMD) < makefile.1.mak > makefile @@ -73,13 +84,18 @@ makefile: makefile.1.mak $(CONFIGFILE) $(TO_GENERATE): $(GENERATE_FROM) $(CONFIGFILE) $(CONFIGURE_CMD) --in $(GENERATE_FROM) --out $(TO_GENERATE) +$(PERL_WRAP_EXEC): %: exec/exec.c exec/settings.txt + $(PERL) $(CONFIGURE) path=$(BIN_PATH) target=$*.pl exec/settings.txt --in exec/exec.c --out $*.c + $(CC) $(CF) -o $@ $*.c exec: $(EXEC) $(CHMOD) +x $(EXEC) +wrap_exec: + setuid: $(SETUID) -# $(CHMOD) u+s,g+s $(SETUID) - + $(CHMOD) u+s,g+s $(SETUID) + mktree: $(MKDIR) -p $(DIR) @@ -100,7 +116,7 @@ endif install: all cp_bin cp_lib clean: - $(RM) -f $(TO_GENERATE) + $(RM) -f $(TO_GENERATE) $(PERL_WRAP_EXEC) $(PERL_WRAP_EXEC:=.c) PHONY: all clean install cp_bin cp_lib diff --git a/settings-debug.txt b/settings-debug.txt index a183570..ce4b63a 100644 --- a/settings-debug.txt +++ b/settings-debug.txt @@ -26,3 +26,6 @@ mkdir: /usr/bin/mkdir perl: /usr/bin/perl rm: /usr/bin/rm wget: /usr/bin/wget + +CC: gcc +CF: -g -Wall \ No newline at end of file diff --git a/settings-release.txt b/settings-release.txt index e8c91c7..3289226 100644 --- a/settings-release.txt +++ b/settings-release.txt @@ -26,3 +26,6 @@ mkdir: /usr/bin/mkdir perl: /usr/bin/perl rm: /usr/bin/rm wget: /usr/bin/wget + +CC: gcc +CF: -g -Wall \ No newline at end of file diff --git a/settings.txt b/settings.txt index 9b845a0..ebb76d2 100644 --- a/settings.txt +++ b/settings.txt @@ -28,8 +28,12 @@ MAKE_TARGET = TARGET = $target MAKE_CHMOD = CHMOD=$chmod MAKE_CP = CP =$cp MAKE_MKDIR = MKDIR=$mkdir +MAKE_PERL = PERL =$perl MAKE_RM = RM =$rm +MAKE_CC = CC =$CC +MAKE_CF = CF =$CF + MAKE_BIN_PATH = BIN_PATH = $bin_path MAKE_LIB_PATH = LIB_PATH = $lib_path MAKE_TMP_PATH = TMP_PATH = $tmp_path