Removed global debugf. Replaced with lp_set_logfile(name).
authorJeremy Allison <jra@samba.org>
Thu, 20 Dec 2001 22:27:05 +0000 (22:27 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 20 Dec 2001 22:27:05 +0000 (22:27 +0000)
Fixed winbindd to finally stop leaving log. file droppings :-).
Jeremy.

source/client/client.c
source/nmbd/nmbd.c
source/nsswitch/winbindd.c
source/param/loadparm.c
source/rpcclient/rpcclient.c
source/rpcclient/samsync.c
source/smbd/server.c
source/torture/rpctorture.c

index 52c032e1309ac606a1778d7c66c4c97fad110c61..a5654a0eafbd9105721f76b5a2213015e76a5c18 100644 (file)
@@ -63,8 +63,6 @@ static int cmd_help(void);
 time_t newer_than = 0;
 int archive_level = 0;
 
-extern pstring debugf;
-
 BOOL translation = False;
 
 static BOOL have_ip;
@@ -2402,6 +2400,7 @@ static int do_message_op(void)
        extern char tar_type;
        pstring term_code;
        pstring new_name_resolve_order;
+       pstring logfile;
        char *p;
        int rc = 0;
 
@@ -2569,7 +2568,8 @@ static int do_message_op(void)
                        port = atoi(optarg);
                        break;
                case 'l':
-                       slprintf(debugf,sizeof(debugf)-1, "%s.client",optarg);
+                       slprintf(logfile,sizeof(logfile)-1, "%s.client",optarg);
+                       lp_set_logfile(logfile);
                        break;
                case 'h':
                        usage(pname);
index 963e26533008587f211b59a1b125c370a7dfdfdb..80d712036da1441c265dfaeaed95075a896b187d 100644 (file)
@@ -26,8 +26,6 @@
 
 #include "includes.h"
 
-extern pstring debugf;
-
 int ClientNMB       = -1;
 int ClientDGRAM     = -1;
 int global_nmb_port = -1;
@@ -103,7 +101,7 @@ static BOOL dump_core(void)
 {
   char *p;
   pstring dname;
-  pstrcpy( dname, debugf );
+  pstrcpy( dname, lp_logfile() );
   if ((p=strrchr_m(dname,'/')))
     *p=0;
   pstrcat( dname, "/corefiles" );
@@ -662,6 +660,7 @@ static void usage(char *pname)
   extern char *optarg;
   extern BOOL  append_log;
   BOOL opt_interactive = False;
+  pstring logfile;
 
   append_log = True;  /* Default, override with '-o' option. */
 
@@ -672,7 +671,8 @@ static void usage(char *pname)
 
   sys_srandom(time(NULL) ^ sys_getpid());
 
-  slprintf(debugf, sizeof(debugf)-1, "%s/log.nmbd", dyn_LOGFILEBASE);
+  slprintf(logfile, sizeof(logfile)-1, "%s/log.nmbd", dyn_LOGFILEBASE);
+  lp_set_logfile(logfile);
 
   /* this is for people who can't start the program correctly */
   while (argc > 1 && (*argv[1] != '-'))
@@ -728,7 +728,8 @@ static void usage(char *pname)
           strupper(global_myname);
           break;
         case 'l':
-          slprintf(debugf, sizeof(debugf)-1, "%s/log.nmbd", optarg);
+          slprintf(logfile, sizeof(logfile)-1, "%s/log.nmbd", optarg);
+          lp_set_logfile(logfile);
           break;
         case 'a':
           append_log = True;
index c10cd9e2caa0488e005ea56b9d2ec5838d9232ca..e68708469c83078d0a84f21678dc1dba9afc918b 100644 (file)
@@ -23,8 +23,6 @@
 
 #include "winbindd.h"
 
-extern pstring debugf;
-
 /* List of all connected clients */
 
 struct winbindd_cli_state *client_list;
@@ -36,6 +34,7 @@ BOOL opt_nocache;
 static BOOL reload_services_file(BOOL test)
 {
        BOOL ret;
+       pstring logfile;
 
        if (lp_loaded()) {
                pstring fname;
@@ -47,9 +46,15 @@ static BOOL reload_services_file(BOOL test)
                }
        }
 
+       snprintf(logfile, sizeof(logfile), "%s/log.winbindd", dyn_LOGFILEBASE);
+       lp_set_logfile(logfile);
+
        reopen_logs();
        ret = lp_load(dyn_CONFIGFILE,False,False,True);
 
+       snprintf(logfile, sizeof(logfile), "%s/log.winbindd", dyn_LOGFILEBASE);
+       lp_set_logfile(logfile);
+
        reopen_logs();
        load_interfaces();
 
@@ -66,7 +71,7 @@ static BOOL dump_core(void)
 {
        char *p;
        pstring dname;
-       pstrcpy( dname, debugf );
+       pstrcpy( dname, lp_logfile() );
        if ((p=strrchr(dname,'/')))
                *p=0;
        pstrcat( dname, "/corefiles" );
@@ -725,6 +730,7 @@ int main(int argc, char **argv)
 {
        extern pstring global_myname;
        extern fstring global_myworkgroup;
+       pstring logfile;
        int accept_sock;
        BOOL interactive = False;
        int opt, new_debuglevel = -1;
@@ -735,7 +741,8 @@ int main(int argc, char **argv)
        CatchSignal(SIGUSR1, SIG_IGN);
 
        fault_setup((void (*)(void *))fault_quit );
-       snprintf(debugf, sizeof(debugf), "%s/log.winbindd", dyn_LOGFILEBASE);
+       snprintf(logfile, sizeof(logfile), "%s/log.winbindd", dyn_LOGFILEBASE);
+       lp_set_logfile(logfile);
 
        /* Initialise for running in non-root mode */
 
@@ -777,7 +784,8 @@ int main(int argc, char **argv)
                }
        }
 
-       snprintf(debugf, sizeof(debugf), "%s/log.winbindd", dyn_LOGFILEBASE);
+       snprintf(logfile, sizeof(logfile), "%s/log.winbindd", dyn_LOGFILEBASE);
+       lp_set_logfile(logfile);
        setup_logging("winbindd", interactive);
        reopen_logs();
 
index f88361f7abe8a2ce101e1ae285d55a1c40f7b461..335995b0dd2dcb8748464328bc79948e33b95cb4 100644 (file)
@@ -3881,4 +3881,13 @@ BOOL is_netbios_alias_or_name(char *name)
        return False;
 }
 
+/***********************************************************
+ Allow daemons such as winbindd to fix their logfile name.
+************************************************************/
 
+void lp_set_logfile(const char *name)
+{
+       extern pstring debugf;
+       pstrcpy(Globals.szLogFile, name);
+       pstrcpy(debugf, name);
+}
index 81fb47c525e43a9ff28694188d9edc44d69bc967..dd490f906609bbda3e0f5873de42d945ab5c8d71 100644 (file)
@@ -23,8 +23,6 @@
 #include "includes.h"
 #include "rpcclient.h"
 
-extern pstring debugf;
-
 DOM_SID domain_sid;
 
 /* List to hold groups of commands */
@@ -590,7 +588,8 @@ static void usage(void)
                        break;
 
                case 'l':
-                       slprintf(debugf, sizeof(debugf) - 1, "%s.client", optarg);
+                       slprintf(logfile, sizeof(logfile) - 1, "%s.client", optarg);
+                       lp_set_logfile(logfile);
                        interactive = False;
                        break;
 
index 4d3e15550e8940fcaf299497cb28a9ccff6eaaca..532517f2efa7d30b6809a29f7375837f37a70c75 100644 (file)
@@ -481,7 +481,7 @@ static struct cli_state *init_connection(struct cli_state *cli,
         struct cli_state cli;
         NTSTATUS result;
         int opt;
-        extern pstring debugf;
+        pstring logfile;
         BOOL interactive = False, do_smbpasswd_output = False;
         BOOL verbose = False;
         uint32 low_serial = 0;
@@ -554,8 +554,9 @@ static struct cli_state *init_connection(struct cli_state *cli,
 
         /* Initialise samba */
 
-       slprintf(debugf, sizeof(debugf) - 1, "%s/log.%s", dyn_LOGFILEBASE, 
+       slprintf(logfile, sizeof(logfile) - 1, "%s/log.%s", dyn_LOGFILEBASE, 
                  "samsync");
+       lp_set_logfile(logfile);
 
         setup_logging("samsync", interactive);
 
index df56dfe9ab015b2abc2abfea6f0bd7668bb9082f..c6eed4b9bb476192f7a0e6eccfc25de267b7b8d4 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "includes.h"
 
-extern pstring debugf;
 extern fstring global_myworkgroup;
 extern pstring global_myname;
 
@@ -425,7 +424,7 @@ static BOOL dump_core(void)
 {
        char *p;
        pstring dname;
-       pstrcpy(dname,debugf);
+       pstrcpy(dname,lp_logfile());
        if ((p=strrchr_m(dname,'/'))) *p=0;
        pstrcat(dname,"/corefiles");
        mkdir(dname,0700);
@@ -583,12 +582,13 @@ static void usage(char *pname)
  int main(int argc,char *argv[])
 {
        extern BOOL append_log;
+       extern char *optarg;
        /* shall I run as a daemon */
        BOOL is_daemon = False;
        BOOL specified_logfile = False;
        int port = SMB_PORT;
        int opt;
-       extern char *optarg;
+       pstring logfile;
 
 #ifdef HAVE_SET_AUTH_PARAMETERS
        set_auth_parameters(argc,argv);
@@ -612,7 +612,8 @@ static void usage(char *pname)
 
                case 'l':
                        specified_logfile = True;
-                       slprintf(debugf, sizeof(debugf)-1, "%s/log.smbd", optarg);
+                       slprintf(logfile, sizeof(logfile)-1, "%s/log.smbd", optarg);
+                       lp_set_logfile(logfile);
                        break;
 
                case 'a':
@@ -670,8 +671,9 @@ static void usage(char *pname)
        append_log = True;
 
        if(!specified_logfile) {
-               slprintf(debugf, sizeof(debugf)-1, "%s/log.smbd",
+               slprintf(logfile, sizeof(logfile)-1, "%s/log.smbd",
                         dyn_LOGFILEBASE);
+               lp_set_logfile(logfile);
        }
 
        pstrcpy(remote_machine, "smbd");
index 231e3a75f567c18149ada2350f5847ada9084734..6844440fbec4ad4b65bbf82cdc5edec19a965740 100644 (file)
@@ -30,8 +30,6 @@ extern pstring global_myname;
 extern pstring user_socket_options;
 
 
-extern pstring debugf;
-
 extern file_info def_finfo;
 
 #define CNV_LANG(s) dos2unix_format(s,False)
@@ -232,6 +230,7 @@ enum client_action
        enum client_action cli_action = CLIENT_NONE;
        int nprocs = 1;
        int numops = 100;
+       pstring logfile;
 
        struct client_info cli_info;
 
@@ -445,8 +444,9 @@ enum client_action
 
                        case 'l':
                        {
-                               slprintf(debugf, sizeof(debugf)-1,
+                               slprintf(logfile, sizeof(logfile)-1,
                                         "%s.client",optarg);
+                               lp_set_logfile(logfile);
                                break;
                        }