From f051423a5a367e35919767b430ff2ea47bea4299 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Sun, 11 Jan 2026 12:46:24 +0100 Subject: [PATCH] src/: Properly set up libsubid tools Do not call any shadowlog functions directly from program source files which are also linked with libsubid. Both, the program and the library, will have their own version of the static variables within shadowlog.c and thus would have different logging mechanisms. Use subid_init instead. Reviewed-by: Alejandro Colomar Signed-off-by: Tobias Stoeckmann --- src/free_subid_range.c | 7 +++---- src/get_subid_owners.c | 6 +++--- src/getsubids.c | 6 +++--- src/new_subid_range.c | 7 +++---- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/free_subid_range.c b/src/free_subid_range.c index c3e94d5dc..fcce80b4b 100644 --- a/src/free_subid_range.c +++ b/src/free_subid_range.c @@ -5,10 +5,9 @@ #include #include "atoi/a2i.h" +#include "string/strerrno.h" #include "subid.h" #include "stdlib.h" -#include "prototypes.h" -#include "shadowlog.h" /* Test program for the subid freeing routine */ @@ -29,8 +28,8 @@ int main(int argc, char *argv[]) struct subordinate_range range; bool group = false; // get subuids by default - log_set_progname(Prog); - log_set_logfd(stderr); + if (!subid_init(Prog, stderr)) + fprintf(stderr, "subid_init: %s\n", strerrno()); while ((c = getopt(argc, argv, "g")) != EOF) { switch(c) { case 'g': group = true; break; diff --git a/src/get_subid_owners.c b/src/get_subid_owners.c index ca6cf99c6..653691374 100644 --- a/src/get_subid_owners.c +++ b/src/get_subid_owners.c @@ -6,9 +6,9 @@ #include "atoi/getnum.h" #include "attr.h" #include "prototypes.h" -#include "shadowlog.h" #include "stdlib.h" #include "string/strcmp/streq.h" +#include "string/strerrno.h" #include "subid.h" @@ -24,8 +24,8 @@ int main(int argc, char *argv[]) uid_t u; uid_t *uids; - log_set_progname(Prog); - log_set_logfd(stderr); + if (!subid_init(Prog, stderr)) + fprintf(stderr, "subid_init: %s\n", strerrno()); if (argc < 2) { usage(); } diff --git a/src/getsubids.c b/src/getsubids.c index 9e29879f2..386c66d6f 100644 --- a/src/getsubids.c +++ b/src/getsubids.c @@ -6,8 +6,8 @@ #include "attr.h" #include "prototypes.h" -#include "shadowlog.h" #include "string/strcmp/streq.h" +#include "string/strerrno.h" #include "subid.h" static const char Prog[] = "getsubids"; @@ -22,8 +22,8 @@ int main(int argc, char *argv[]) struct subid_range *ranges; const char *owner; - log_set_progname(Prog); - log_set_logfd(stderr); + if (!subid_init(Prog, stderr)) + fprintf(stderr, "subid_init: %s\n", strerrno()); if (argc < 2) usage(); owner = argv[1]; diff --git a/src/new_subid_range.c b/src/new_subid_range.c index e423b1aba..bca379d8b 100644 --- a/src/new_subid_range.c +++ b/src/new_subid_range.c @@ -4,10 +4,9 @@ #include #include "atoi/a2i.h" +#include "string/strerrno.h" #include "subid.h" #include "stdlib.h" -#include "prototypes.h" -#include "shadowlog.h" /* Test program for the subid creation routine */ @@ -31,8 +30,8 @@ int main(int argc, char *argv[]) bool group = false; // get subuids by default bool ok; - log_set_progname(Prog); - log_set_logfd(stderr); + if (!subid_init(Prog, stderr)) + fprintf(stderr, "subid_init: %s\n", strerrno()); while ((c = getopt(argc, argv, "gn")) != EOF) { switch(c) { case 'n': makenew = true; break; -- 2.47.3