[devel] [PATCH hasher-priv v3 4/7] Link with libsetproctitle by Dmitry V. Levin

Arseny Maslennikov arseny на altlinux.org
Вт Авг 24 11:24:33 MSK 2021


This being a shared library is an implementation detail: to overcome the
lack of such an interface on Linux, we need to run some preparation code
before main() and pass argv/envp memory buffers to it. A function
declared with __attribute__((constructor)) gets called with no
arguments, we can't pass the argv/envp buffers to it, so we put an
implementation of setproctitle(3) in a shared object and hijack its
_init().

Signed-off-by: Arseny Maslennikov <arseny на altlinux.org>
---
 hasher-priv/Makefile         | 3 ++-
 hasher-priv/hasher-priv.spec | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/hasher-priv/Makefile b/hasher-priv/Makefile
index 8ccf99d..a08f6a8 100644
--- a/hasher-priv/Makefile
+++ b/hasher-priv/Makefile
@@ -42,6 +42,7 @@ CPPFLAGS = -std=gnu99 -D_GNU_SOURCE $(CHDIRUID_FLAGS) \
 CFLAGS = -pipe -O2
 override CFLAGS += $(WARNINGS)
 LDLIBS =
+server_LDLIBS = -lsetproctitle
 
 SRC = hasher-priv.c cmdline.c fds.c sockets.c logging.c communication.c xmalloc.c pass.c
 OBJ = $(SRC:.c=.o)
@@ -65,7 +66,7 @@ $(PROJECT): $(OBJ)
 	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
 
 hasher-privd: $(server_OBJ)
-	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) $(server_LDLIBS) -o $@
 
 install: all
 	$(MKDIR_P) -m710 $(DESTDIR)$(configdir)/user.d
diff --git a/hasher-priv/hasher-priv.spec b/hasher-priv/hasher-priv.spec
index 8ec0013..e21dec1 100644
--- a/hasher-priv/hasher-priv.spec
+++ b/hasher-priv/hasher-priv.spec
@@ -20,6 +20,7 @@ Obsoletes: pkg-build-priv
 Conflicts: hasher < 1.4.0
 
 BuildPreReq: help2man, sisyphus_check >= 0:0.7.11
+BuildRequires: setproctitle-devel
 
 %description
 This package provides helpers for executing privileged operations
-- 
2.32.0



Подробная информация о списке рассылки Devel