[SCM] Samba Shared Repository - branch master updated
Andreas Schneider
asn at samba.org
Thu May 6 13:30:02 UTC 2021
The branch, master has been updated
via 249b9650a2c lib:cmdline: Align integer types
via e8780be8a42 lib:cmdline: We need to always set a log file
via 4596211e31e lib:cmdline: Also set logfilebase for -l|--log-basename
via b1963ab784c lib:cmdline: Rename to cmdline_sanity_checker
via 03ef73ac46c lib:cmdline: Improve error message for duplicate options
from fd28e8aeb42 gpo: Correct name of files gpo
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 249b9650a2c5cdae1a0b44279b013619e47eea3e
Author: Andreas Schneider <asn at samba.org>
Date: Thu May 6 12:01:05 2021 +0200
lib:cmdline: Align integer types
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
Autobuild-Date(master): Thu May 6 13:29:28 UTC 2021 on sn-devel-184
commit e8780be8a427e56e1cc6dd5ef5a4e628ffef990d
Author: Andreas Schneider <asn at samba.org>
Date: Thu May 6 11:21:53 2021 +0200
lib:cmdline: We need to always set a log file
We need to always set a log file name based on the process name. This
defines e.g. the log file for smbd.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit 4596211e31ea7aeee7eeb962ea4a27823baba357
Author: Andreas Schneider <asn at samba.org>
Date: Fri Apr 30 16:12:29 2021 +0200
lib:cmdline: Also set logfilebase for -l|--log-basename
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlet <abartlet at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit b1963ab784c9188e2775270fae07aa55aab62ea5
Author: Andreas Schneider <asn at samba.org>
Date: Mon May 3 13:35:37 2021 +0200
lib:cmdline: Rename to cmdline_sanity_checker
Will give nicer output if we find duplicates!
$ net help
cmdline_sanity_checker: Duplicate option --long|-l detected!
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlet <abartlet at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit 03ef73ac46cf0da8b8afb77883f8652acf7c58bf
Author: Andreas Schneider <asn at samba.org>
Date: Thu Apr 29 17:04:43 2021 +0200
lib:cmdline: Improve error message for duplicate options
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Andrew Bartlet <abartlet at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/cmdline/cmdline.c | 85 +++++++++++++++++++++++++++++++++------------------
1 file changed, 55 insertions(+), 30 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c
index fd104b196cd..1802a291f4c 100644
--- a/lib/cmdline/cmdline.c
+++ b/lib/cmdline/cmdline.c
@@ -117,7 +117,8 @@ void samba_cmdline_burn(int argc, char *argv[])
bool found = false;
bool is_user = false;
char *p = NULL;
- int i, ulen = 0;
+ int i;
+ size_t ulen = 0;
for (i = 0; i < argc; i++) {
p = argv[i];
@@ -212,7 +213,7 @@ static void find_duplicates(const struct poptOption *needle,
}
}
-static bool opt_sanity_check(const struct poptOption *current_opts,
+static bool cmdline_sanity_checker(const struct poptOption *current_opts,
const struct poptOption *full_opts)
{
const struct poptOption *o = current_opts;
@@ -225,7 +226,7 @@ static bool opt_sanity_check(const struct poptOption *current_opts,
switch (o->argInfo) {
case POPT_ARG_INCLUDE_TABLE:
if (o->arg != NULL) {
- ok = opt_sanity_check(o->arg, full_opts);
+ ok = cmdline_sanity_checker(o->arg, full_opts);
if (!ok) {
return false;
}
@@ -238,7 +239,8 @@ static bool opt_sanity_check(const struct poptOption *current_opts,
find_duplicates(o, full_opts, &count);
if (count > 1) {
- DBG_ERR("Duplicate %s (%c) detected!\n",
+ DBG_ERR("Duplicate option '--%s|-%c' "
+ "detected!\n",
o->longName,
o->shortName != 0 ?
o->shortName :
@@ -256,7 +258,7 @@ static bool opt_sanity_check(const struct poptOption *current_opts,
bool samba_cmdline_sanity_check(const struct poptOption *opts)
{
- return opt_sanity_check(opts, opts);
+ return cmdline_sanity_checker(opts, opts);
}
poptContext samba_popt_get_context(const char * name,
@@ -281,6 +283,35 @@ poptContext samba_popt_get_context(const char * name,
static bool log_to_file;
+static bool set_logfile(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
+ const char *log_basename,
+ const char *process_name)
+{
+ bool ok;
+ char *new_logfile = talloc_asprintf(mem_ctx,
+ "%s/log.%s",
+ log_basename,
+ process_name);
+ if (new_logfile == NULL) {
+ return false;
+ }
+
+ ok = lpcfg_set_cmdline(lp_ctx,
+ "log file",
+ new_logfile);
+ if (!ok) {
+ fprintf(stderr,
+ "Failed to set log to %s\n",
+ new_logfile);
+ TALLOC_FREE(new_logfile);
+ return false;
+ }
+ TALLOC_FREE(new_logfile);
+
+ return true;
+}
+
static void popt_samba_callback(poptContext popt_ctx,
enum poptCallbackReason reason,
const struct poptOption *opt,
@@ -291,12 +322,27 @@ static void popt_samba_callback(poptContext popt_ctx,
const char *pname = NULL;
bool ok;
+ /* Find out basename of current program */
+ pname = strrchr_m(poptGetInvocationName(popt_ctx), '/');
+ if (pname == NULL) {
+ pname = poptGetInvocationName(popt_ctx);
+ } else {
+ pname++;
+ }
+
if (reason == POPT_CALLBACK_REASON_PRE) {
if (lp_ctx == NULL) {
fprintf(stderr,
"Command line parsing not initialized!\n");
exit(1);
}
+ ok = set_logfile(mem_ctx, lp_ctx, get_dyn_LOGFILEBASE(), pname);
+ if (!ok) {
+ fprintf(stderr,
+ "Failed to set log file for %s\n",
+ pname);
+ exit(1);
+ }
return;
}
@@ -328,14 +374,6 @@ static void popt_samba_callback(poptContext popt_ctx,
return;
}
- /* Find out basename of current program */
- pname = strrchr_m(poptGetInvocationName(popt_ctx), '/');
- if (pname == NULL) {
- pname = poptGetInvocationName(popt_ctx);
- } else {
- pname++;
- }
-
switch(opt->val) {
case OPT_LEAK_REPORT:
talloc_enable_leak_report();
@@ -373,29 +411,16 @@ static void popt_samba_callback(poptContext popt_ctx,
break;
case 'l':
if (arg != NULL) {
- char *new_logfile = talloc_asprintf(mem_ctx,
- "%s/log.%s",
- arg,
- pname);
- if (new_logfile == NULL) {
- fprintf(stderr,
- "Failed to allocate memory\n");
- exit(1);
- }
-
- ok = lpcfg_set_cmdline(lp_ctx,
- "log file",
- new_logfile);
+ ok = set_logfile(mem_ctx, lp_ctx, arg, pname);
if (!ok) {
fprintf(stderr,
- "Failed to set log file: %s\n",
- new_logfile);
- TALLOC_FREE(new_logfile);
+ "Failed to set log file for %s\n",
+ arg);
exit(1);
}
log_to_file = true;
- TALLOC_FREE(new_logfile);
+ set_dyn_LOGFILEBASE(arg);
}
break;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list