diff options
-rw-r--r-- | source3/Makefile.in | 8 | ||||
-rw-r--r-- | source3/nsswitch/winbindd.c | 84 |
2 files changed, 30 insertions, 62 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 81af32abae..6cfa9be4d4 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -574,7 +574,7 @@ WINBINDD_OBJ = \ $(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) \ $(LIBSMB_OBJ) $(LIBMSRPC_OBJ) $(RPC_PARSE_OBJ) \ $(PROFILE_OBJ) $(UNIGRP_OBJ) \ - $(SECRETS_OBJ) $(LIBADS_OBJ) $(KRBCLIENT_OBJ) + $(SECRETS_OBJ) $(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) WBINFO_OBJ = nsswitch/wbinfo.o libsmb/smbencrypt.o libsmb/smbdes.o $(POPT_LIB_OBJ) @@ -730,7 +730,7 @@ bin/profiles@EXEEXT@: $(PROFILES_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(PROFILES_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ -bin/editreg@EXEEXT@: utils/editreg.o @BUILD_POP@ bin/.dummy +bin/editreg@EXEEXT@: utils/editreg.o @BUILD_POPT@ bin/.dummy @echo Linking $@ @$(CC) $(FLAGS) -o $@ utils/editreg.o $(LDFLAGS) $(LIBS) @BUILD_POPT@ @@ -922,9 +922,9 @@ nsswitch/libnss_wins.@SHLIBEXT@: $(NSS_OBJ) @$(SHLD) $(LDSHFLAGS) -o $@ $(NSS_OBJ) -lc \ @SONAMEFLAG@`basename $@` -bin/winbindd@EXEEXT@: $(WINBINDD_OBJ) bin/.dummy +bin/winbindd@EXEEXT@: $(WINBINDD_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(LINK) -o $@ $(WINBINDD_OBJ) $(DYNEXP) $(LIBS) + @$(LINK) -o $@ $(WINBINDD_OBJ) $(DYNEXP) $(LIBS) @BUILD_POPT@ nsswitch/libns_winbind.@SHLIBEXT@: $(WINBIND_NSS_PICOBJS) @echo "Linking $@" diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index 4033952a6e..c9d6808316 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -5,6 +5,7 @@ Copyright (C) by Tim Potter 2000-2002 Copyright (C) Andrew Tridgell 2002 + Copyright (C) Jelmer Vernooij 2003 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,7 +32,6 @@ BOOL opt_dual_daemon = False; static BOOL reload_services_file(BOOL test) { BOOL ret; - pstring logfile; if (lp_loaded()) { pstring fname; @@ -806,27 +806,26 @@ BOOL winbind_setup_common(void) struct winbindd_state server_state; /* Server state information */ - -static void usage(void) -{ - printf("Usage: winbindd [options]\n"); - printf("\t-F daemon in foreground mode\n"); - printf("\t-S log to stdout\n"); - printf("\t-i interactive mode\n"); - printf("\t-B dual daemon mode\n"); - printf("\t-n disable cacheing\n"); - printf("\t-d level set debug level\n"); - printf("\t-s configfile choose smb.conf location\n"); - printf("\t-h show this help message\n"); -} - - int main(int argc, char **argv) +int main(int argc, char **argv) { - extern BOOL AllowDebugChange; pstring logfile; - BOOL interactive = False; - BOOL Fork = True; - BOOL log_stdout = False; + static BOOL interactive = False; + static BOOL Fork = True; + static BOOL log_stdout = False; + struct poptOption long_options[] = { + POPT_AUTOHELP + POPT_COMMON_SAMBA + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, + { "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, + { "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Daemon in foreground mode" }, + { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" }, + { "dual-daemon", 'B', POPT_ARG_VAL, &opt_dual_daemon, True, "Dual daemon mode" }, + { "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, False, "Disable caching" }, + + { 0, 0, 0, 0 } + }; + poptContext pc; int opt; /* glibc (?) likes to print "User defined signal 1" and exit if a @@ -850,56 +849,24 @@ static void usage(void) /* Initialise samba/rpc client stuff */ - while ((opt = getopt(argc, argv, "FSid:s:nhB")) != EOF) { - switch (opt) { + pc = poptGetContext("winbindd", argc, (const char **)argv, long_options, + POPT_CONTEXT_KEEP_FIRST); - case 'F': - Fork = False; - break; - case 'S': - log_stdout = True; - break; + while ((opt = poptGetNextOpt(pc)) != -1) { + switch (opt) { /* Don't become a daemon */ case 'i': interactive = True; log_stdout = True; Fork = False; break; - - /* dual daemon system */ - case 'B': - opt_dual_daemon = True; - break; - - /* disable cacheing */ - case 'n': - opt_nocache = True; - break; - - /* Run with specified debug level */ - case 'd': - DEBUGLEVEL = atoi(optarg); - AllowDebugChange = False; - break; - - /* Load a different smb.conf file */ - case 's': - pstrcpy(dyn_CONFIGFILE,optarg); - break; - - case 'h': - usage(); - exit(0); - - default: - printf("Unknown option %c\n", (char)opt); - exit(1); } } + if (log_stdout && Fork) { printf("Can't log to stdout (-S) unless daemon is in foreground +(-F) or interactive (-i)\n"); - usage(); + poptPrintUsage(pc, stderr, 0); exit(1); } @@ -950,6 +917,7 @@ static void usage(void) DEBUG(0, ("unable to initialise messaging system\n")); exit(1); } + poptFreeContext(pc); register_msg_pool_usage(); message_register(MSG_REQ_TALLOC_USAGE, return_all_talloc_info); |