mirror of
https://github.com/shadow-maint/shadow.git
synced 2026-01-26 14:03:17 +00:00
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 <alx@kernel.org> Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
This commit is contained in:
parent
bd5fadaf29
commit
f051423a5a
@ -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;
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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];
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user