s3-winbind: Create all logfiles in the same directory.
authorAndreas Schneider <asn@samba.org>
Mon, 5 Jul 2010 17:43:25 +0000 (19:43 +0200)
committerAndreas Schneider <asn@samba.org>
Tue, 6 Jul 2010 16:38:13 +0000 (18:38 +0200)
If log file is set in the config file, we should create the log files of
the winbind child processes in the same directory.

source3/winbindd/winbindd_dual.c

index e506d2a53acadb7983de5c605697d27ac68ad532..277b17430695e80b1e0a4231b086e56f7886e2be 100644 (file)
@@ -405,10 +405,31 @@ void setup_child(struct winbindd_domain *domain, struct winbindd_child *child,
                 const char *logname)
 {
        if (logprefix && logname) {
+               char *logbase = NULL;
+
+               if (lp_logfile()) {
+                       char *end = NULL;
+
+                       if (asprintf(&logbase, "%s", lp_logfile()) < 0) {
+                               smb_panic("Internal error: asprintf failed");
+                       }
+
+                       if ((end = strrchr_m(logbase, '/'))) {
+                               *end = '\0';
+                       }
+               } else {
+                       if (asprintf(&logbase, "%s", get_dyn_LOGFILEBASE()) < 0) {
+                               smb_panic("Internal error: asprintf failed");
+                       }
+               }
+
                if (asprintf(&child->logfilename, "%s/%s-%s",
-                            get_dyn_LOGFILEBASE(), logprefix, logname) < 0) {
+                            logbase, logprefix, logname) < 0) {
+                       SAFE_FREE(logbase);
                        smb_panic("Internal error: asprintf failed");
                }
+
+               SAFE_FREE(logbase);
        } else {
                smb_panic("Internal error: logprefix == NULL && "
                          "logname == NULL");