summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2002-11-09 16:57:45 +0000
committerJelmer Vernooij <jelmer@samba.org>2002-11-09 16:57:45 +0000
commitdc5297f413c40f04e1fdae719e29d949e3301091 (patch)
treef806bd40f94aa39af5f2bfb9eafda514b353a90c /source3/lib
parente21ff2d500ea4709b641834a88d3dff9d6bf039b (diff)
downloadsamba-dc5297f413c40f04e1fdae719e29d949e3301091.tar.gz
samba-dc5297f413c40f04e1fdae719e29d949e3301091.tar.bz2
samba-dc5297f413c40f04e1fdae719e29d949e3301091.zip
Sync with HEAD
(This used to be commit 1a25dc776ddc36de9a214e023becff1ceb10290c)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/popt_common.c53
-rw-r--r--source3/lib/replace.c25
2 files changed, 71 insertions, 7 deletions
diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c
index 21ee94d2e6..aaec448762 100644
--- a/source3/lib/popt_common.c
+++ b/source3/lib/popt_common.c
@@ -23,9 +23,12 @@
#include "includes.h"
/* Handle command line options:
- * -d,--debuglevel
- * -s,--configfile
- * -O,--socket-options
+ * d,--debuglevel
+ * s,--configfile
+ * O,--socket-options
+ * V,--version
+ * l,--log-base
+ * n,--netbios-name
*/
extern pstring user_socket_options;
@@ -37,6 +40,23 @@ static void popt_common_callback(poptContext con,
const struct poptOption *opt,
const char *arg, const void *data)
{
+ pstring logfile;
+ const char *pname;
+
+ /* Find out basename of current program */
+ pname = strrchr_m(poptGetInvocationName(con),'/');
+
+ if (!pname)
+ pname = poptGetInvocationName(con);
+ else
+ pname++;
+
+ if (reason == POPT_CALLBACK_REASON_PRE) {
+ pstr_sprintf(logfile, "%s/log.%s", dyn_LOGFILEBASE, pname);
+ lp_set_logfile(logfile);
+ return;
+ }
+
switch(opt->val) {
case 'd':
if (arg) {
@@ -51,16 +71,29 @@ static void popt_common_callback(poptContext con,
break;
case 'O':
- pstrcpy(user_socket_options,arg);
+ if (arg) {
+ pstrcpy(user_socket_options,arg);
+ }
break;
case 's':
- pstrcpy(dyn_CONFIGFILE, arg);
+ if (arg) {
+ pstrcpy(dyn_CONFIGFILE, arg);
+ }
break;
case 'n':
- pstrcpy(global_myname,arg);
- strupper(global_myname);
+ if (arg) {
+ pstrcpy(global_myname,arg);
+ strupper(global_myname);
+ }
+ break;
+
+ case 'l':
+ if (arg) {
+ pstr_sprintf(logfile, "%s/log.%s", arg, pname);
+ lp_set_logfile(logfile);
+ }
break;
}
}
@@ -95,3 +128,9 @@ struct poptOption popt_common_netbios_name[] = {
{"netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name"},
{ 0 }
};
+
+struct poptOption popt_common_log_base[] = {
+ { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_callback },
+ { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files"},
+ { 0 }
+};
diff --git a/source3/lib/replace.c b/source3/lib/replace.c
index fd7b2cf7f0..dfc88e7028 100644
--- a/source3/lib/replace.c
+++ b/source3/lib/replace.c
@@ -430,3 +430,28 @@ char *rep_inet_ntoa(struct in_addr ip)
#endif /* HAVE_VSYSLOG */
+#ifndef HAVE_TIMEGM
+/*
+ see the timegm man page on linux
+*/
+ time_t timegm(struct tm *tm)
+{
+ time_t ret;
+ char *tz;
+ char *tzvar;
+
+ tz = getenv("TZ");
+ putenv("TZ=");
+ tzset();
+ ret = mktime(tm);
+ if (tz) {
+ asprintf(&tzvar, "TZ=%s", tz);
+ putenv(tzvar);
+ safe_free(tzvar);
+ } else {
+ putenv("TZ");
+ }
+ tzset();
+ return ret;
+}
+#endif