]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/: Properly set up libsubid tools master
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 11 Jan 2026 11:46:24 +0000 (12:46 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Mon, 12 Jan 2026 00:56:27 +0000 (01:56 +0100)
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 <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
src/free_subid_range.c
src/get_subid_owners.c
src/getsubids.c
src/new_subid_range.c

index c3e94d5dc4d8d54c729efece66b66a312392d45f..fcce80b4b5756ccd2513a000b8684b06f14b75de 100644 (file)
@@ -5,10 +5,9 @@
 #include <unistd.h>
 
 #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;
index ca6cf99c653eb49b7c2bdd3d34b38dd46707d282..653691374a096422c9db12f8bd93e46795bd7001 100644 (file)
@@ -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();
        }
index 9e29879f2db422b38a227e7078a65779ca5a0107..386c66d6faeab0d5f55187fd26df323dca212dd3 100644 (file)
@@ -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];
index e423b1aba5eb80d892b64c8eb4e9454f21070d62..bca379d8b6d0a3a16e3620eb581db5b619ee35b4 100644 (file)
@@ -4,10 +4,9 @@
 #include <unistd.h>
 
 #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;