From ef2e26c91b80556af033d3335e55f5dfa6fff31d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Aug 2003 01:53:07 +0000 Subject: first public release of samba4 code (This used to be commit b0510b5428b3461aeb9bbe3cc95f62fc73e2b97f) --- source4/lib/cmdline/popt_common.c | 327 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 327 insertions(+) create mode 100644 source4/lib/cmdline/popt_common.c (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c new file mode 100644 index 0000000000..ccdecc91cc --- /dev/null +++ b/source4/lib/cmdline/popt_common.c @@ -0,0 +1,327 @@ +/* + Unix SMB/CIFS implementation. + Common popt routines + + Copyright (C) Tim Potter 2001,2002 + Copyright (C) Jelmer Vernooij 2002,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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* Handle command line options: + * -d,--debuglevel + * -s,--configfile + * -O,--socket-options + * -V,--version + * -l,--log-base + * -n,--netbios-name + * -W,--workgroup + * -i,--scope + */ + +extern pstring user_socket_options; +extern BOOL AllowDebugChange; + +struct user_auth_info cmdline_auth_info; + +static void popt_common_callback(poptContext con, + enum poptCallbackReason reason, + 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_cmdline("log file", logfile); + return; + } + + switch(opt->val) { + case 'd': + lp_set_cmdline("log level", arg); + break; + + case 'V': + printf( "Version %s\n", SAMBA_VERSION ); + exit(0); + break; + + case 's': + if (arg) { + pstrcpy(dyn_CONFIGFILE, arg); + } + break; + + case 'l': + if (arg) { + pstr_sprintf(logfile, "%s/log.%s", arg, pname); + lp_set_cmdline("log file", logfile); + } + break; + + case 'W': + lp_set_cmdline("workgroup", arg); + break; + + case 'n': + lp_set_cmdline("netbios name", arg); + break; + + case 'i': + lp_set_cmdline("netbios scope", arg); + break; + } +} + +struct poptOption popt_common_connection[] = { + { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, + { "socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use", + "SOCKETOPTIONS" }, + { "netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name", "NETBIOSNAME" }, + { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, + { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" }, + POPT_TABLEEND +}; + +struct poptOption popt_common_samba[] = { + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_callback }, + { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, + { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, + { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" }, + { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, + POPT_TABLEEND +}; + +struct poptOption popt_common_version[] = { + { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, + { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, + POPT_TABLEEND +}; + + + +/**************************************************************************** + * get a password from a a file or file descriptor + * exit on failure + * ****************************************************************************/ +static void get_password_file(struct user_auth_info *a) +{ + int fd = -1; + char *p; + BOOL close_it = False; + pstring spec; + char pass[128]; + + if ((p = getenv("PASSWD_FD")) != NULL) { + pstrcpy(spec, "descriptor "); + pstrcat(spec, p); + sscanf(p, "%d", &fd); + close_it = False; + } else if ((p = getenv("PASSWD_FILE")) != NULL) { + fd = sys_open(p, O_RDONLY, 0); + pstrcpy(spec, p); + if (fd < 0) { + fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n", + spec, strerror(errno)); + exit(1); + } + close_it = True; + } + + for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */ + p && p - pass < sizeof(pass);) { + switch (read(fd, p, 1)) { + case 1: + if (*p != '\n' && *p != '\0') { + *++p = '\0'; /* advance p, and null-terminate pass */ + break; + } + case 0: + if (p - pass) { + *p = '\0'; /* null-terminate it, just in case... */ + p = NULL; /* then force the loop condition to become false */ + break; + } else { + fprintf(stderr, "Error reading password from file %s: %s\n", + spec, "empty password\n"); + exit(1); + } + + default: + fprintf(stderr, "Error reading password from file %s: %s\n", + spec, strerror(errno)); + exit(1); + } + } + pstrcpy(a->password, pass); + if (close_it) + close(fd); +} + +static void get_credentials_file(const char *file, struct user_auth_info *info) +{ + XFILE *auth; + fstring buf; + uint16 len = 0; + char *ptr, *val, *param; + + if ((auth=x_fopen(file, O_RDONLY, 0)) == NULL) + { + /* fail if we can't open the credentials file */ + d_printf("ERROR: Unable to open credentials file!\n"); + exit(-1); + } + + while (!x_feof(auth)) + { + /* get a line from the file */ + if (!x_fgets(buf, sizeof(buf), auth)) + continue; + len = strlen(buf); + + if ((len) && (buf[len-1]=='\n')) + { + buf[len-1] = '\0'; + len--; + } + if (len == 0) + continue; + + /* break up the line into parameter & value. + * will need to eat a little whitespace possibly */ + param = buf; + if (!(ptr = strchr_m (buf, '='))) + continue; + + val = ptr+1; + *ptr = '\0'; + + /* eat leading white space */ + while ((*val!='\0') && ((*val==' ') || (*val=='\t'))) + val++; + + if (strwicmp("password", param) == 0) + { + pstrcpy(info->password, val); + info->got_pass = True; + } + else if (strwicmp("username", param) == 0) + pstrcpy(info->username, val); + //else if (strwicmp("domain", param) == 0) + // set_global_myworkgroup(val); + memset(buf, 0, sizeof(buf)); + } + x_fclose(auth); +} + +/* Handle command line options: + * -U,--user + * -A,--authentication-file + * -k,--use-kerberos + * -N,--no-pass + */ + + +static void popt_common_credentials_callback(poptContext con, + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, const void *data) +{ + char *p; + + if (reason == POPT_CALLBACK_REASON_PRE) { + cmdline_auth_info.use_kerberos = False; + cmdline_auth_info.got_pass = False; + pstrcpy(cmdline_auth_info.username, "GUEST"); + + if (getenv("LOGNAME"))pstrcpy(cmdline_auth_info.username,getenv("LOGNAME")); + + if (getenv("USER")) { + pstrcpy(cmdline_auth_info.username,getenv("USER")); + + if ((p = strchr_m(cmdline_auth_info.username,'%'))) { + *p = 0; + pstrcpy(cmdline_auth_info.password,p+1); + cmdline_auth_info.got_pass = True; + memset(strchr_m(getenv("USER"),'%')+1,'X',strlen(cmdline_auth_info.password)); + } + } + + if (getenv("PASSWD")) { + pstrcpy(cmdline_auth_info.password,getenv("PASSWD")); + cmdline_auth_info.got_pass = True; + } + + if (getenv("PASSWD_FD") || getenv("PASSWD_FILE")) { + get_password_file(&cmdline_auth_info); + cmdline_auth_info.got_pass = True; + } + + return; + } + + switch(opt->val) { + case 'U': + { + char *lp; + + pstrcpy(cmdline_auth_info.username,arg); + if ((lp=strchr_m(cmdline_auth_info.username,'%'))) { + *lp = 0; + pstrcpy(cmdline_auth_info.password,lp+1); + cmdline_auth_info.got_pass = True; + memset(strchr_m(arg,'%')+1,'X',strlen(cmdline_auth_info.password)); + } + } + break; + + case 'A': + get_credentials_file(arg, &cmdline_auth_info); + break; + + case 'k': +#ifndef HAVE_KRB5 + d_printf("No kerberos support compiled in\n"); + exit(1); +#else + cmdline_auth_info.use_kerberos = True; + cmdline_auth_info.got_pass = True; +#endif + break; + } +} + + + +struct poptOption popt_common_credentials[] = { + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_credentials_callback }, + { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "USERNAME" }, + { "no-pass", 'N', POPT_ARG_NONE, &cmdline_auth_info.got_pass, True, "Don't ask for a password" }, + { "kerberos", 'k', POPT_ARG_NONE, &cmdline_auth_info.use_kerberos, True, "Use kerberos (active directory) authentication" }, + { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, + POPT_TABLEEND +}; -- cgit From 0b1b3850a084be52fcb2abc5985cf6b06e7a54fa Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 27 Nov 2003 04:00:21 +0000 Subject: added -m for 'max protocol' as a standard option (This used to be commit 8fe4058711c12b8116982357723c36e862aa0bef) --- source4/lib/cmdline/popt_common.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index ccdecc91cc..8a6cce7e5b 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -94,6 +94,10 @@ static void popt_common_callback(poptContext con, case 'i': lp_set_cmdline("netbios scope", arg); break; + + case 'm': + lp_set_cmdline("max protocol", arg); + break; } } @@ -104,6 +108,7 @@ struct poptOption popt_common_connection[] = { { "netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name", "NETBIOSNAME" }, { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" }, + { "maxprotocol", 'm', POPT_ARG_STRING, NULL, 'm', "Set max protocol level", "MAXPROTOCOL" }, POPT_TABLEEND }; -- cgit From b8cbd9181efabbc360ef335e214a696011839b41 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Dec 2003 01:59:24 +0000 Subject: don't use c++ comments (This used to be commit 3d48fa8f37a510959c8958b5c025c7f19f632c54) --- source4/lib/cmdline/popt_common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 8a6cce7e5b..3c9a5eb231 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -236,8 +236,10 @@ static void get_credentials_file(const char *file, struct user_auth_info *info) } else if (strwicmp("username", param) == 0) pstrcpy(info->username, val); - //else if (strwicmp("domain", param) == 0) - // set_global_myworkgroup(val); +#if 0 + else if (strwicmp("domain", param) == 0) + set_global_myworkgroup(val); +#endif memset(buf, 0, sizeof(buf)); } x_fclose(auth); -- cgit From e06687eb174d5ca785a6c67fa63a99ea019182c4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2004 12:47:52 +0000 Subject: merge the version.h autogeneration stuff from 3.0 metze (This used to be commit 24dc237e109f6dce69814b22e0fb7878a7f6bfa8) --- source4/lib/cmdline/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 3c9a5eb231..1b8e3bd93e 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -66,7 +66,7 @@ static void popt_common_callback(poptContext con, break; case 'V': - printf( "Version %s\n", SAMBA_VERSION ); + printf( "Version %s\n", SAMBA_VERSION_STRING ); exit(0); break; -- cgit From f88bf54c7f6d1c2ef833047eb8327953c304b5ff Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 May 2004 17:24:24 +0000 Subject: r889: convert samba4 to use [u]int16_t instead of [u]int16 metze (This used to be commit af6f1f8a01bebbecd99bc8c066519e89966e65e3) --- source4/lib/cmdline/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 1b8e3bd93e..f659468561 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -191,7 +191,7 @@ static void get_credentials_file(const char *file, struct user_auth_info *info) { XFILE *auth; fstring buf; - uint16 len = 0; + uint16_t len = 0; char *ptr, *val, *param; if ((auth=x_fopen(file, O_RDONLY, 0)) == NULL) -- cgit From bca24a19ebfc8943b46fdb900418e396aef96aa4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 19 Aug 2004 12:16:48 +0000 Subject: r1911: merge a few popt parameters from 3.0 move some to better places and deal with users DOMAIN and lp_workgroup() of the local workstation metze (This used to be commit 1fc0100e44a8640cfc15effb99f5824cb7817da8) --- source4/lib/cmdline/popt_common.c | 94 ++++++++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 15 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index f659468561..ef75d7be1f 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -33,10 +33,7 @@ * -i,--scope */ -extern pstring user_socket_options; -extern BOOL AllowDebugChange; - -struct user_auth_info cmdline_auth_info; +struct cmdline_auth_info cmdline_auth_info; static void popt_common_callback(poptContext con, enum poptCallbackReason reason, @@ -70,6 +67,12 @@ static void popt_common_callback(poptContext con, exit(0); break; + case 'O': + if (arg) { + lp_set_cmdline("socket options", arg); + } + break; + case 's': if (arg) { pstrcpy(dyn_CONFIGFILE, arg); @@ -98,13 +101,17 @@ static void popt_common_callback(poptContext con, case 'm': lp_set_cmdline("max protocol", arg); break; + + case 'R': + lp_set_cmdline("name resolve order", arg); + break; } } struct poptOption popt_common_connection[] = { { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - { "socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use", - "SOCKETOPTIONS" }, + { "name-resolve", 'R', POPT_ARG_STRING, NULL, 'R', "Use these name resolution services only", "NAME-RESOLVE-ORDER" }, + { "socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use", "SOCKETOPTIONS" }, { "netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name", "NETBIOSNAME" }, { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" }, @@ -117,7 +124,6 @@ struct poptOption popt_common_samba[] = { { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" }, - { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, POPT_TABLEEND }; @@ -133,7 +139,7 @@ struct poptOption popt_common_version[] = { * get a password from a a file or file descriptor * exit on failure * ****************************************************************************/ -static void get_password_file(struct user_auth_info *a) +static void get_password_file(struct cmdline_auth_info *a) { int fd = -1; char *p; @@ -187,7 +193,7 @@ static void get_password_file(struct user_auth_info *a) close(fd); } -static void get_credentials_file(const char *file, struct user_auth_info *info) +static void get_credentials_file(const char *file, struct cmdline_auth_info *info) { XFILE *auth; fstring buf; @@ -236,10 +242,8 @@ static void get_credentials_file(const char *file, struct user_auth_info *info) } else if (strwicmp("username", param) == 0) pstrcpy(info->username, val); -#if 0 else if (strwicmp("domain", param) == 0) - set_global_myworkgroup(val); -#endif + pstrcpy(info->domain,val); memset(buf, 0, sizeof(buf)); } x_fclose(auth); @@ -250,13 +254,15 @@ static void get_credentials_file(const char *file, struct user_auth_info *info) * -A,--authentication-file * -k,--use-kerberos * -N,--no-pass + * -S,--signing + * -P --machine-pass */ static void popt_common_credentials_callback(poptContext con, - enum poptCallbackReason reason, - const struct poptOption *opt, - const char *arg, const void *data) + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, const void *data) { char *p; @@ -268,8 +274,17 @@ static void popt_common_credentials_callback(poptContext con, if (getenv("LOGNAME"))pstrcpy(cmdline_auth_info.username,getenv("LOGNAME")); if (getenv("USER")) { + pstring tmp; + pstrcpy(cmdline_auth_info.username,getenv("USER")); + pstrcpy(tmp,cmdline_auth_info.username); + if ((p = strchr_m(tmp,'\\'))) { + *p = 0; + pstrcpy(cmdline_auth_info.domain,tmp); + pstrcpy(cmdline_auth_info.username,p+1); + } + if ((p = strchr_m(cmdline_auth_info.username,'%'))) { *p = 0; pstrcpy(cmdline_auth_info.password,p+1); @@ -278,6 +293,10 @@ static void popt_common_credentials_callback(poptContext con, } } + if (getenv("DOMAIN")) { + pstrcpy(cmdline_auth_info.domain,getenv("DOMAIN")); + } + if (getenv("PASSWD")) { pstrcpy(cmdline_auth_info.password,getenv("PASSWD")); cmdline_auth_info.got_pass = True; @@ -295,8 +314,17 @@ static void popt_common_credentials_callback(poptContext con, case 'U': { char *lp; + pstring tmp; pstrcpy(cmdline_auth_info.username,arg); + + pstrcpy(tmp,cmdline_auth_info.username); + if ((p = strchr_m(tmp,'\\'))) { + *p = 0; + pstrcpy(cmdline_auth_info.domain,tmp); + pstrcpy(cmdline_auth_info.username,p+1); + } + if ((lp=strchr_m(cmdline_auth_info.username,'%'))) { *lp = 0; pstrcpy(cmdline_auth_info.password,lp+1); @@ -319,6 +347,40 @@ static void popt_common_credentials_callback(poptContext con, cmdline_auth_info.got_pass = True; #endif break; + + case 'S': + lp_set_cmdline("client signing", arg); + break; + + case 'P': + { + char *opt_password = NULL; + /* it is very useful to be able to make ads queries as the + machine account for testing purposes and for domain leave */ + + if (!secrets_init()) { + d_printf("ERROR: Unable to open secrets database\n"); + exit(1); + } + + opt_password = secrets_fetch_machine_password(lp_workgroup()); + + if (!opt_password) { + d_printf("ERROR: Unable to fetch machine password\n"); + exit(1); + } + pstr_sprintf(cmdline_auth_info.username, "%s$", + lp_netbios_name()); + pstrcpy(cmdline_auth_info.password,opt_password); + SAFE_FREE(opt_password); + + pstrcpy(cmdline_auth_info.password, lp_workgroup()); + + /* machine accounts only work with kerberos */ + cmdline_auth_info.use_kerberos = True; + cmdline_auth_info.got_pass = True; + } + break; } } @@ -330,5 +392,7 @@ struct poptOption popt_common_credentials[] = { { "no-pass", 'N', POPT_ARG_NONE, &cmdline_auth_info.got_pass, True, "Don't ask for a password" }, { "kerberos", 'k', POPT_ARG_NONE, &cmdline_auth_info.use_kerberos, True, "Use kerberos (active directory) authentication" }, { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, + { "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" }, + { "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password" }, POPT_TABLEEND }; -- cgit From c2e2921bada17aae84e6c29f48401fa467e8ed9c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 20 Aug 2004 09:48:25 +0000 Subject: r1949: provide functions to access the username, userdomain and userpassword now you're prompted when cmdline_get_userpassword() is called and the password is not yet known metze (This used to be commit d14a01533c5d465ff3709c48576b798b3be807e0) --- source4/lib/cmdline/popt_common.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index ef75d7be1f..20b9aac201 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -33,7 +33,7 @@ * -i,--scope */ -struct cmdline_auth_info cmdline_auth_info; +static struct cmdline_auth_info cmdline_auth_info; static void popt_common_callback(poptContext con, enum poptCallbackReason reason, @@ -396,3 +396,38 @@ struct poptOption popt_common_credentials[] = { { "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password" }, POPT_TABLEEND }; + +const char *cmdline_get_username(void) +{ + return cmdline_auth_info.username; +} + +const char *cmdline_get_userdomain(void) +{ + if (cmdline_auth_info.domain[0]) { + return cmdline_auth_info.domain; + } + + /* I think this should be lp_netbios_name() + * instead of lp_workgroup(), because if you're logged in + * as domain user the getenv("USER") contains the domain + * and this code path isn't used + * --metze + */ + return lp_netbios_name(); +} + +const char *cmdline_get_userpassword(void) +{ + pstring prompt; + + if (cmdline_auth_info.got_pass) { + return cmdline_auth_info.password; + } + + pstr_sprintf(prompt, "Password for [%s\\%s]:", + cmdline_get_userdomain(), + cmdline_get_username()); + + return getpass(prompt); +} -- cgit From 8115bf6e2ceba588b3d503380a530297b0f03f2c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 20 Aug 2004 13:24:28 +0000 Subject: r1957: add cmdline_set_* functions and let smbclient use the cmdline _* functions metze (This used to be commit ffb87ebc33e728bf8506383f95b80605adec3c68) --- source4/lib/cmdline/popt_common.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 20b9aac201..7acdb34bba 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -397,11 +397,21 @@ struct poptOption popt_common_credentials[] = { POPT_TABLEEND }; +void cmdline_set_username(const char *name) +{ + pstrcpy(cmdline_auth_info.username, name); +} + const char *cmdline_get_username(void) { return cmdline_auth_info.username; } +void cmdline_set_userdomain(const char *domain) +{ + pstrcpy(cmdline_auth_info.domain, domain); +} + const char *cmdline_get_userdomain(void) { if (cmdline_auth_info.domain[0]) { @@ -431,3 +441,19 @@ const char *cmdline_get_userpassword(void) return getpass(prompt); } + +void cmdline_set_userpassword(const char *pass) +{ + cmdline_auth_info.got_pass = True; + pstrcpy(cmdline_auth_info.password, pass); +} + +void cmdline_set_use_kerberos(BOOL use_kerberos) +{ + cmdline_auth_info.use_kerberos = use_kerberos; +} + +BOOL cmdline_get_use_kerberos(void) +{ + return cmdline_auth_info.use_kerberos; +} -- cgit From b49dc085afe744c17c064ea8086c523aca663933 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 10 Sep 2004 03:37:29 +0000 Subject: r2272: fixed another couple of errors in the popt option arrays (This used to be commit 89acbf4f02ae03f0546e1633c030765a563ce958) --- source4/lib/cmdline/popt_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 7acdb34bba..51018facb8 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -389,8 +389,8 @@ static void popt_common_credentials_callback(poptContext con, struct poptOption popt_common_credentials[] = { { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_credentials_callback }, { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "USERNAME" }, - { "no-pass", 'N', POPT_ARG_NONE, &cmdline_auth_info.got_pass, True, "Don't ask for a password" }, - { "kerberos", 'k', POPT_ARG_NONE, &cmdline_auth_info.use_kerberos, True, "Use kerberos (active directory) authentication" }, + { "no-pass", 'N', POPT_ARG_NONE, &cmdline_auth_info.got_pass, 0, "Don't ask for a password" }, + { "kerberos", 'k', POPT_ARG_NONE, &cmdline_auth_info.use_kerberos, 'k', "Use kerberos (active directory) authentication" }, { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, { "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" }, { "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password" }, -- cgit From 871604e3101edfd4c17eec5b05077eeb5674b26b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Sep 2004 01:27:37 +0000 Subject: r2302: added a '--option' option, allowing any global or default option in smb.conf to be set on the command line. For example, you can use: smbtorture --option 'unicode=false' or smbtorture --option 'netbios name=myname' (This used to be commit 360a6b530e2295976ddefc138d1333411a94484d) --- source4/lib/cmdline/popt_common.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 51018facb8..e2deb5db96 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -33,6 +33,9 @@ * -i,--scope */ + +enum {OPT_OPTION=1}; + static struct cmdline_auth_info cmdline_auth_info; static void popt_common_callback(poptContext con, @@ -40,7 +43,6 @@ 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 */ @@ -52,8 +54,9 @@ static void popt_common_callback(poptContext con, pname++; if (reason == POPT_CALLBACK_REASON_PRE) { - pstr_sprintf(logfile, "%s/log.%s", dyn_LOGFILEBASE, pname); + char *logfile = talloc_asprintf(NULL, "%s/log.%s", dyn_LOGFILEBASE, pname); lp_set_cmdline("log file", logfile); + talloc_free(logfile); return; } @@ -81,8 +84,9 @@ static void popt_common_callback(poptContext con, case 'l': if (arg) { - pstr_sprintf(logfile, "%s/log.%s", arg, pname); + char *logfile = talloc_asprintf(NULL, "%s/log.%s", arg, pname); lp_set_cmdline("log file", logfile); + talloc_free(logfile); } break; @@ -105,6 +109,13 @@ static void popt_common_callback(poptContext con, case 'R': lp_set_cmdline("name resolve order", arg); break; + + case OPT_OPTION: + if (!lp_set_option(arg)) { + fprintf(stderr, "Error setting option '%s'\n", arg); + exit(1); + } + break; } } @@ -123,6 +134,7 @@ struct poptOption popt_common_samba[] = { { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_callback }, { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, + { "option", 0, POPT_ARG_STRING, NULL, OPT_OPTION, "Set smb.conf option from command line", "name=value" }, { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" }, POPT_TABLEEND }; -- cgit From b295256ea2f71a4fe3b16e0348b907f6ef73167b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 26 Sep 2004 01:14:26 +0000 Subject: r2640: valgrind does a great job on some types of memory leaks, but is slow and can't properly handle leaks of doubly linked lists which we use a lot (as the memory is always reachable). Even with --show-reachable its hard to track leaks down sometimes. I realised that talloc does have the necessary information to track these, and by using the cascading property of the new talloc it can report on leaks in a much more succinct fashion than valgrind can. I have added a new samba option --leak-check that applies to all Samba tools. When enabled it prints a leak report summarising all top level contexts that are present when the program exits. A typical report looks like this: talloc report on 'null_context' (total 1071 bytes in 52 blocks) iconv(CP850,UTF8) contains 43 bytes in 3 blocks UNNAMED contains 24 bytes in 1 blocks UNNAMED contains 24 bytes in 1 blocks dcesrv_init contains 604 bytes in 26 blocks server_service contains 120 bytes in 6 blocks UNNAMED contains 24 bytes in 1 blocks UNNAMED contains 24 bytes in 1 blocks server_service contains 104 bytes in 4 blocks server_context contains 12 bytes in 2 blocks iconv(UTF8,UTF-16LE) contains 46 bytes in 3 blocks iconv(UTF-16LE,UTF8) contains 46 bytes in 3 blocks the numbers are recursive summaries for all the memory hanging off each context. this option is not thread safe when used, but the code is thread safe if the option is not given, so I don't think thats a problem. (This used to be commit 96d33d36a5639e7fc46b14a470ccac674d87c62a) --- source4/lib/cmdline/popt_common.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index e2deb5db96..f98c460642 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -34,7 +34,7 @@ */ -enum {OPT_OPTION=1}; +enum {OPT_OPTION=1,OPT_LEAK_CHECK=2}; static struct cmdline_auth_info cmdline_auth_info; @@ -116,6 +116,10 @@ static void popt_common_callback(poptContext con, exit(1); } break; + + case OPT_LEAK_CHECK: + talloc_enable_leak_check(); + break; } } @@ -132,10 +136,11 @@ struct poptOption popt_common_connection[] = { struct poptOption popt_common_samba[] = { { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_callback }, - { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, - { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, - { "option", 0, POPT_ARG_STRING, NULL, OPT_OPTION, "Set smb.conf option from command line", "name=value" }, + { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, + { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, + { "option", 0, POPT_ARG_STRING, NULL, OPT_OPTION, "Set smb.conf option from command line", "name=value" }, { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" }, + { "leak-check", 0, POPT_ARG_NONE, NULL, OPT_LEAK_CHECK, "enable talloc leak checking", NULL }, POPT_TABLEEND }; -- cgit From 351ca44e8b3ea8336abba8215dfc1ccb42458384 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Sep 2004 04:20:18 +0000 Subject: r2674: I have realised that talloc() should have its context marked const, as a const pointer really means that "the data pointed to by this pointer won't change", and that is certainly true of talloc(). The fact that some behind-the-scenes meta-data can change doesn't matter from the point of view of const. this fixes a number of const warnings caused by const data structures being passed as talloc contexts. That will no longer generate a warning. also changed the talloc leak reporting option from --leak-check to --leak-report, as all it does is generate a report on exit. A new --leak-report-full option has been added that shows the complete tree of memory allocations, which is is quite useful in tracking things down. NOTE: I find it quite useful to insert talloc_report_full(ptr, stderr) calls at strategic points in the code while debugging memory allocation problems, particularly before freeing a major context (such as the connection context). This allows you to see if that context has been accumulating too much data, such as per-request data, which should have been freed when the request finished. (This used to be commit c60ff99c3129c26a9204bac1c6e5fb386114a923) --- source4/lib/cmdline/popt_common.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index f98c460642..725a5060c0 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -34,7 +34,7 @@ */ -enum {OPT_OPTION=1,OPT_LEAK_CHECK=2}; +enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL}; static struct cmdline_auth_info cmdline_auth_info; @@ -117,8 +117,12 @@ static void popt_common_callback(poptContext con, } break; - case OPT_LEAK_CHECK: - talloc_enable_leak_check(); + case OPT_LEAK_REPORT: + talloc_enable_leak_report(); + break; + + case OPT_LEAK_REPORT_FULL: + talloc_enable_leak_report_full(); break; } } @@ -140,7 +144,8 @@ struct poptOption popt_common_samba[] = { { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, { "option", 0, POPT_ARG_STRING, NULL, OPT_OPTION, "Set smb.conf option from command line", "name=value" }, { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" }, - { "leak-check", 0, POPT_ARG_NONE, NULL, OPT_LEAK_CHECK, "enable talloc leak checking", NULL }, + { "leak-report", 0, POPT_ARG_NONE, NULL, OPT_LEAK_REPORT, "enable talloc leak reporting on exit", NULL }, + { "leak-report-full",0, POPT_ARG_NONE, NULL, OPT_LEAK_REPORT_FULL, "enable full talloc leak reporting on exit", NULL }, POPT_TABLEEND }; -- cgit From 7d32679e9683c81aca538f0267684332a28a286f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 8 Oct 2004 08:13:00 +0000 Subject: r2857: this commit gets rid of smb_ucs2_t, wpstring and fpstring, plus lots of associated functions. The motivation for this change was to avoid having to convert to/from ucs2 strings for so many operations. Doing that was slow, used many static buffers, and was also incorrect as it didn't cope properly with unicode codepoints above 65536 (which could not be represented correctly as smb_ucs2_t chars) The two core functions that allowed this change are next_codepoint() and push_codepoint(). These functions allow you to correctly walk a arbitrary multi-byte string a character at a time without converting the whole string to ucs2. While doing this cleanup I also fixed several ucs2 string handling bugs. See the commit for details. The following code (which counts the number of occuraces of 'c' in a string) shows how to use the new interface: size_t count_chars(const char *s, char c) { size_t count = 0; while (*s) { size_t size; codepoint_t c2 = next_codepoint(s, &size); if (c2 == c) count++; s += size; } return count; } (This used to be commit 814881f0e50019196b3aa9fbe4aeadbb98172040) --- source4/lib/cmdline/popt_common.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 725a5060c0..554b46a940 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -391,8 +391,8 @@ static void popt_common_credentials_callback(poptContext con, d_printf("ERROR: Unable to fetch machine password\n"); exit(1); } - pstr_sprintf(cmdline_auth_info.username, "%s$", - lp_netbios_name()); + snprintf(cmdline_auth_info.username, sizeof(cmdline_auth_info.username), + "%s$", lp_netbios_name()); pstrcpy(cmdline_auth_info.password,opt_password); SAFE_FREE(opt_password); @@ -451,17 +451,21 @@ const char *cmdline_get_userdomain(void) const char *cmdline_get_userpassword(void) { - pstring prompt; + char *prompt; + char *ret; if (cmdline_auth_info.got_pass) { return cmdline_auth_info.password; } - pstr_sprintf(prompt, "Password for [%s\\%s]:", - cmdline_get_userdomain(), - cmdline_get_username()); + prompt = talloc_asprintf(NULL, "Password for [%s\\%s]:", + cmdline_get_userdomain(), + cmdline_get_username()); - return getpass(prompt); + ret = getpass(prompt); + + talloc_free(prompt); + return ret; } void cmdline_set_userpassword(const char *pass) -- cgit From 95ddbe5ad29df57b3d5ad5b9f5be95f6e194d0e0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Oct 2004 00:26:43 +0000 Subject: r3100: support 'bin/smbclient //w2k3-101/c$ -U \\administrator@w2k3.vmnet1.vm.base' we need to send an empty string as userdomain in this case. fix bug #1317 in the client side metze (This used to be commit 958aa8de630b2a88f29ccdf80ac0fc44a8205401) --- source4/lib/cmdline/popt_common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 554b46a940..0cf57bb2e0 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -304,6 +304,7 @@ static void popt_common_credentials_callback(poptContext con, if ((p = strchr_m(tmp,'\\'))) { *p = 0; pstrcpy(cmdline_auth_info.domain,tmp); + cmdline_auth_info.got_domain = True; pstrcpy(cmdline_auth_info.username,p+1); } @@ -317,6 +318,7 @@ static void popt_common_credentials_callback(poptContext con, if (getenv("DOMAIN")) { pstrcpy(cmdline_auth_info.domain,getenv("DOMAIN")); + cmdline_auth_info.got_domain = True; } if (getenv("PASSWD")) { @@ -344,6 +346,7 @@ static void popt_common_credentials_callback(poptContext con, if ((p = strchr_m(tmp,'\\'))) { *p = 0; pstrcpy(cmdline_auth_info.domain,tmp); + cmdline_auth_info.got_domain = True; pstrcpy(cmdline_auth_info.username,p+1); } @@ -431,12 +434,13 @@ const char *cmdline_get_username(void) void cmdline_set_userdomain(const char *domain) { + cmdline_auth_info.got_domain = True; pstrcpy(cmdline_auth_info.domain, domain); } const char *cmdline_get_userdomain(void) { - if (cmdline_auth_info.domain[0]) { + if (cmdline_auth_info.got_domain) { return cmdline_auth_info.domain; } -- cgit From a1063840e7b316eba02fe6112fc09ad84fc96be5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Oct 2004 00:47:05 +0000 Subject: r3101: some minor fixes metze (This used to be commit 61de2229e27c55041cb4e1aac32bc1d8ed68a05c) --- source4/lib/cmdline/popt_common.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 0cf57bb2e0..266c99ae9e 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -257,15 +257,15 @@ static void get_credentials_file(const char *file, struct cmdline_auth_info *inf while ((*val!='\0') && ((*val==' ') || (*val=='\t'))) val++; - if (strwicmp("password", param) == 0) - { + if (strwicmp("password", param) == 0) { pstrcpy(info->password, val); info->got_pass = True; - } - else if (strwicmp("username", param) == 0) + } else if (strwicmp("username", param) == 0) { pstrcpy(info->username, val); - else if (strwicmp("domain", param) == 0) + } else if (strwicmp("domain", param) == 0) { pstrcpy(info->domain,val); + info->got_domain = True; + } memset(buf, 0, sizeof(buf)); } x_fclose(auth); @@ -398,12 +398,13 @@ static void popt_common_credentials_callback(poptContext con, "%s$", lp_netbios_name()); pstrcpy(cmdline_auth_info.password,opt_password); SAFE_FREE(opt_password); + cmdline_auth_info.got_pass = True; - pstrcpy(cmdline_auth_info.password, lp_workgroup()); - + pstrcpy(cmdline_auth_info.domain, lp_workgroup()); + cmdline_auth_info.domain = True; + /* machine accounts only work with kerberos */ cmdline_auth_info.use_kerberos = True; - cmdline_auth_info.got_pass = True; } break; } -- cgit From 5b09d503fffc36de224bdbffb17a84316da0459a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Oct 2004 00:49:39 +0000 Subject: r3102: typo metze (This used to be commit 3bbda7475a63f939019a41a0b7da8d179c533d79) --- source4/lib/cmdline/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 266c99ae9e..05e92866b2 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -401,7 +401,7 @@ static void popt_common_credentials_callback(poptContext con, cmdline_auth_info.got_pass = True; pstrcpy(cmdline_auth_info.domain, lp_workgroup()); - cmdline_auth_info.domain = True; + cmdline_auth_info.got_domain = True; /* machine accounts only work with kerberos */ cmdline_auth_info.use_kerberos = True; -- cgit From 652b8b34f8b326f79771b03e039cfa3c6ba3427e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Nov 2004 20:21:54 +0000 Subject: r3441: some include file cleanups and general housekeeping (This used to be commit 73ea8ee6c268371d05cf74160f2ad451dd2ae699) --- source4/lib/cmdline/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 05e92866b2..bd46373d58 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -175,7 +175,7 @@ static void get_password_file(struct cmdline_auth_info *a) sscanf(p, "%d", &fd); close_it = False; } else if ((p = getenv("PASSWD_FILE")) != NULL) { - fd = sys_open(p, O_RDONLY, 0); + fd = open(p, O_RDONLY, 0); pstrcpy(spec, p); if (fd < 0) { fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n", -- cgit From edbfc0f6e70150e321822365bf0eead2821551bd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 02:57:18 +0000 Subject: r3453: - split out the auth and popt includes - tidied up some of the system includes - moved a few more structures back from misc.idl to netlogon.idl and samr.idl now that pidl knows about inter-IDL dependencies (This used to be commit 7b7477ac42d96faac1b0ff361525d2c63cedfc64) --- source4/lib/cmdline/popt_common.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index bd46373d58..80be23d364 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "lib/cmdline/popt_common.h" /* Handle command line options: * -d,--debuglevel -- cgit From 6148deca663f7b6504b044120b166d6c9ae28750 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 03:13:06 +0000 Subject: r3454: moved a few more things out if includes.h into the include/system/ include files. this brings us down to about 11k lines of headers included with includes.h, while still retaining the speed of building with pch (This used to be commit 10188869ef072309ca580b8b933e172571fcdda7) --- source4/lib/cmdline/popt_common.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 80be23d364..7d4dead4de 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "system/passwd.h" #include "lib/cmdline/popt_common.h" /* Handle command line options: -- cgit From 6f214cc510a59b7a65ee9d4486baf14a3e579f73 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 3 Nov 2004 00:17:12 +0000 Subject: r3494: got rid of include/rewrite.h, and split out the dynconfig.h header (This used to be commit 558de54ec6432a4ae90aa14a585f32c6cd03ced2) --- source4/lib/cmdline/popt_common.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 7d4dead4de..6422b84b44 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "dynconfig.h" #include "system/passwd.h" #include "lib/cmdline/popt_common.h" -- cgit From 64b516b10546619d3b1adef7fcc4cfef3ad610f9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 2 Dec 2004 18:27:08 +0000 Subject: r4045: readd krb5 support defaulted to disable use: gensec:krb5=yes gensec:ms_krb5=yes to enable it or -k on the client tools on the command line metze (This used to be commit 0ae5794cf44933d2554e0356baaca24c7a784f71) --- source4/lib/cmdline/popt_common.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 6422b84b44..c7bd35cbab 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -373,6 +373,8 @@ static void popt_common_credentials_callback(poptContext con, #else cmdline_auth_info.use_kerberos = True; cmdline_auth_info.got_pass = True; + lp_set_cmdline("gensec:krb5", "True"); + lp_set_cmdline("gensec:ms_krb5", "True"); #endif break; -- cgit From 8451b2658ca0f44f2683bf8045a9232a4a8c9660 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 18 Jan 2005 09:30:43 +0000 Subject: r4817: ccache was being made ineffective on all the build farm machines because the version number was being auto-updated and included in all C files. With this change it is only included where needed. (This used to be commit 520cff73c6dc62ba1050cf7ca5145d50b5f2bb4e) --- source4/lib/cmdline/popt_common.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index c7bd35cbab..e440611ee4 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "version.h" #include "dynconfig.h" #include "system/passwd.h" #include "lib/cmdline/popt_common.h" -- cgit From 2cb711f39f80adbe7375c809c57106ac8e71d5d8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 31 Jan 2005 16:01:22 +0000 Subject: r5135: I prepare a clean up in includes.h metze (This used to be commit 670e088e94468a5311353dbbaa7e34d200999313) --- source4/lib/cmdline/popt_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index e440611ee4..0445877e7a 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -23,6 +23,7 @@ #include "includes.h" #include "version.h" #include "dynconfig.h" +#include "system/filesys.h" #include "system/passwd.h" #include "lib/cmdline/popt_common.h" @@ -403,7 +404,7 @@ static void popt_common_credentials_callback(poptContext con, snprintf(cmdline_auth_info.username, sizeof(cmdline_auth_info.username), "%s$", lp_netbios_name()); pstrcpy(cmdline_auth_info.password,opt_password); - SAFE_FREE(opt_password); + free(opt_password); cmdline_auth_info.got_pass = True; pstrcpy(cmdline_auth_info.domain, lp_workgroup()); -- cgit From 02075be0bbc2095073f8898350fded64a7c97c79 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 02:08:38 +0000 Subject: r5917: First step in using the new cli_credentials structure. This patch puts support for it into popt_common, adds a few utility functions (in lib/credentials.c) and the callback functions for the command-line (lib/cmdline/credentials.c). Comments are welcome :-) (This used to be commit 1d49b57c50fe8c2683ea23e9df41ce8ad774db98) --- source4/lib/cmdline/popt_common.c | 303 +++++--------------------------------- 1 file changed, 36 insertions(+), 267 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 0445877e7a..0792a16b3d 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -38,10 +38,9 @@ * -i,--scope */ - enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL}; -static struct cmdline_auth_info cmdline_auth_info; +struct cli_credentials *cmdline_credentials = NULL; static void popt_common_callback(poptContext con, enum poptCallbackReason reason, @@ -160,182 +159,34 @@ struct poptOption popt_common_version[] = { POPT_TABLEEND }; - - -/**************************************************************************** - * get a password from a a file or file descriptor - * exit on failure - * ****************************************************************************/ -static void get_password_file(struct cmdline_auth_info *a) -{ - int fd = -1; - char *p; - BOOL close_it = False; - pstring spec; - char pass[128]; - - if ((p = getenv("PASSWD_FD")) != NULL) { - pstrcpy(spec, "descriptor "); - pstrcat(spec, p); - sscanf(p, "%d", &fd); - close_it = False; - } else if ((p = getenv("PASSWD_FILE")) != NULL) { - fd = open(p, O_RDONLY, 0); - pstrcpy(spec, p); - if (fd < 0) { - fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n", - spec, strerror(errno)); - exit(1); - } - close_it = True; - } - - for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */ - p && p - pass < sizeof(pass);) { - switch (read(fd, p, 1)) { - case 1: - if (*p != '\n' && *p != '\0') { - *++p = '\0'; /* advance p, and null-terminate pass */ - break; - } - case 0: - if (p - pass) { - *p = '\0'; /* null-terminate it, just in case... */ - p = NULL; /* then force the loop condition to become false */ - break; - } else { - fprintf(stderr, "Error reading password from file %s: %s\n", - spec, "empty password\n"); - exit(1); - } - - default: - fprintf(stderr, "Error reading password from file %s: %s\n", - spec, strerror(errno)); - exit(1); - } - } - pstrcpy(a->password, pass); - if (close_it) - close(fd); -} - -static void get_credentials_file(const char *file, struct cmdline_auth_info *info) -{ - XFILE *auth; - fstring buf; - uint16_t len = 0; - char *ptr, *val, *param; - - if ((auth=x_fopen(file, O_RDONLY, 0)) == NULL) - { - /* fail if we can't open the credentials file */ - d_printf("ERROR: Unable to open credentials file!\n"); - exit(-1); - } - - while (!x_feof(auth)) - { - /* get a line from the file */ - if (!x_fgets(buf, sizeof(buf), auth)) - continue; - len = strlen(buf); - - if ((len) && (buf[len-1]=='\n')) - { - buf[len-1] = '\0'; - len--; - } - if (len == 0) - continue; - - /* break up the line into parameter & value. - * will need to eat a little whitespace possibly */ - param = buf; - if (!(ptr = strchr_m (buf, '='))) - continue; - - val = ptr+1; - *ptr = '\0'; - - /* eat leading white space */ - while ((*val!='\0') && ((*val==' ') || (*val=='\t'))) - val++; - - if (strwicmp("password", param) == 0) { - pstrcpy(info->password, val); - info->got_pass = True; - } else if (strwicmp("username", param) == 0) { - pstrcpy(info->username, val); - } else if (strwicmp("domain", param) == 0) { - pstrcpy(info->domain,val); - info->got_domain = True; - } - memset(buf, 0, sizeof(buf)); - } - x_fclose(auth); -} - /* Handle command line options: * -U,--user * -A,--authentication-file * -k,--use-kerberos * -N,--no-pass * -S,--signing - * -P --machine-pass + * -P --machine-pass */ +static BOOL dont_ask = False; + static void popt_common_credentials_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data) { - char *p; - if (reason == POPT_CALLBACK_REASON_PRE) { - cmdline_auth_info.use_kerberos = False; - cmdline_auth_info.got_pass = False; - pstrcpy(cmdline_auth_info.username, "GUEST"); - - if (getenv("LOGNAME"))pstrcpy(cmdline_auth_info.username,getenv("LOGNAME")); - - if (getenv("USER")) { - pstring tmp; - - pstrcpy(cmdline_auth_info.username,getenv("USER")); + cmdline_credentials = talloc_zero(talloc_autofree_context(), struct cli_credentials); + cli_credentials_guess(cmdline_credentials); - pstrcpy(tmp,cmdline_auth_info.username); - if ((p = strchr_m(tmp,'\\'))) { - *p = 0; - pstrcpy(cmdline_auth_info.domain,tmp); - cmdline_auth_info.got_domain = True; - pstrcpy(cmdline_auth_info.username,p+1); - } - - if ((p = strchr_m(cmdline_auth_info.username,'%'))) { - *p = 0; - pstrcpy(cmdline_auth_info.password,p+1); - cmdline_auth_info.got_pass = True; - memset(strchr_m(getenv("USER"),'%')+1,'X',strlen(cmdline_auth_info.password)); - } - } - - if (getenv("DOMAIN")) { - pstrcpy(cmdline_auth_info.domain,getenv("DOMAIN")); - cmdline_auth_info.got_domain = True; - } - - if (getenv("PASSWD")) { - pstrcpy(cmdline_auth_info.password,getenv("PASSWD")); - cmdline_auth_info.got_pass = True; - } - - if (getenv("PASSWD_FD") || getenv("PASSWD_FILE")) { - get_password_file(&cmdline_auth_info); - cmdline_auth_info.got_pass = True; + return; + } + + if (reason == POPT_CALLBACK_REASON_POST) { + if (!dont_ask) { + cli_credentials_set_cmdline_callbacks(cmdline_credentials); } - return; } @@ -343,41 +194,18 @@ static void popt_common_credentials_callback(poptContext con, case 'U': { char *lp; - pstring tmp; - - pstrcpy(cmdline_auth_info.username,arg); - pstrcpy(tmp,cmdline_auth_info.username); - if ((p = strchr_m(tmp,'\\'))) { - *p = 0; - pstrcpy(cmdline_auth_info.domain,tmp); - cmdline_auth_info.got_domain = True; - pstrcpy(cmdline_auth_info.username,p+1); - } + cli_credentials_parse_string(cmdline_credentials,arg, CRED_SPECIFIED); - if ((lp=strchr_m(cmdline_auth_info.username,'%'))) { + if ((lp=strchr_m(arg,'%'))) { *lp = 0; - pstrcpy(cmdline_auth_info.password,lp+1); - cmdline_auth_info.got_pass = True; - memset(strchr_m(arg,'%')+1,'X',strlen(cmdline_auth_info.password)); + memset(strchr_m(arg,'%')+1,'X',strlen(cmdline_credentials->password)); } } break; case 'A': - get_credentials_file(arg, &cmdline_auth_info); - break; - - case 'k': -#ifndef HAVE_KRB5 - d_printf("No kerberos support compiled in\n"); - exit(1); -#else - cmdline_auth_info.use_kerberos = True; - cmdline_auth_info.got_pass = True; - lp_set_cmdline("gensec:krb5", "True"); - lp_set_cmdline("gensec:ms_krb5", "True"); -#endif + cli_credentials_parse_file(cmdline_credentials, arg, CRED_SPECIFIED); break; case 'S': @@ -401,97 +229,38 @@ static void popt_common_credentials_callback(poptContext con, d_printf("ERROR: Unable to fetch machine password\n"); exit(1); } - snprintf(cmdline_auth_info.username, sizeof(cmdline_auth_info.username), - "%s$", lp_netbios_name()); - pstrcpy(cmdline_auth_info.password,opt_password); + cmdline_credentials->username = talloc_asprintf(cmdline_credentials, "%s$", lp_netbios_name()); + cmdline_credentials->username_obtained = CRED_SPECIFIED; + cli_credentials_set_password(cmdline_credentials, opt_password, CRED_SPECIFIED); free(opt_password); - cmdline_auth_info.got_pass = True; - pstrcpy(cmdline_auth_info.domain, lp_workgroup()); - cmdline_auth_info.got_domain = True; - - /* machine accounts only work with kerberos */ - cmdline_auth_info.use_kerberos = True; + cli_credentials_set_domain(cmdline_credentials, lp_workgroup(), CRED_SPECIFIED); } + /* machine accounts only work with kerberos */ + + case 'k': +#ifndef HAVE_KRB5 + d_printf("No kerberos support compiled in\n"); + exit(1); +#else + lp_set_cmdline("gensec:krb5", "True"); + lp_set_cmdline("gensec:ms_krb5", "True"); +#endif break; + + } } struct poptOption popt_common_credentials[] = { - { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_credentials_callback }, + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, popt_common_credentials_callback }, { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "USERNAME" }, - { "no-pass", 'N', POPT_ARG_NONE, &cmdline_auth_info.got_pass, 0, "Don't ask for a password" }, - { "kerberos", 'k', POPT_ARG_NONE, &cmdline_auth_info.use_kerberos, 'k', "Use kerberos (active directory) authentication" }, + { "no-pass", 'N', POPT_ARG_NONE, &dont_ask, True, "Don't ask for a password" }, + { "kerberos", 'k', POPT_ARG_NONE, NULL, 'k', "Use kerberos (active directory) authentication" }, { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, { "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" }, - { "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password" }, + { "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password (implies -k)" }, POPT_TABLEEND }; - -void cmdline_set_username(const char *name) -{ - pstrcpy(cmdline_auth_info.username, name); -} - -const char *cmdline_get_username(void) -{ - return cmdline_auth_info.username; -} - -void cmdline_set_userdomain(const char *domain) -{ - cmdline_auth_info.got_domain = True; - pstrcpy(cmdline_auth_info.domain, domain); -} - -const char *cmdline_get_userdomain(void) -{ - if (cmdline_auth_info.got_domain) { - return cmdline_auth_info.domain; - } - - /* I think this should be lp_netbios_name() - * instead of lp_workgroup(), because if you're logged in - * as domain user the getenv("USER") contains the domain - * and this code path isn't used - * --metze - */ - return lp_netbios_name(); -} - -const char *cmdline_get_userpassword(void) -{ - char *prompt; - char *ret; - - if (cmdline_auth_info.got_pass) { - return cmdline_auth_info.password; - } - - prompt = talloc_asprintf(NULL, "Password for [%s\\%s]:", - cmdline_get_userdomain(), - cmdline_get_username()); - - ret = getpass(prompt); - - talloc_free(prompt); - return ret; -} - -void cmdline_set_userpassword(const char *pass) -{ - cmdline_auth_info.got_pass = True; - pstrcpy(cmdline_auth_info.password, pass); -} - -void cmdline_set_use_kerberos(BOOL use_kerberos) -{ - cmdline_auth_info.use_kerberos = use_kerberos; -} - -BOOL cmdline_get_use_kerberos(void) -{ - return cmdline_auth_info.use_kerberos; -} -- cgit From 13b0776f60f6a0f35a4afc2b3d3c6b5ec9c1ca6a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 23:35:58 +0000 Subject: r5929: Use cli_credentials for the SMB functions as well. Fix a couple of bugs in the new cli_credentials code (This used to be commit 4ad481cfe5cde514d2ef9646147239f3faaa6173) --- source4/lib/cmdline/popt_common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 0792a16b3d..b0b5073e62 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -195,11 +195,10 @@ static void popt_common_credentials_callback(poptContext con, { char *lp; - cli_credentials_parse_string(cmdline_credentials,arg, CRED_SPECIFIED); + cli_credentials_parse_string(cmdline_credentials, arg, CRED_SPECIFIED); if ((lp=strchr_m(arg,'%'))) { - *lp = 0; - memset(strchr_m(arg,'%')+1,'X',strlen(cmdline_credentials->password)); + memset(lp,0,strlen(cmdline_credentials->password)); } } break; -- cgit From 455be8fb8271bd97058390dca5a76db81ea2928b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 22 Mar 2005 01:35:12 +0000 Subject: r5932: Use cli_credentials somewhat more in the Gtk+ code Support ncacn_spx in DCE/RPC bindings. (This used to be commit a0233a3a9a83176ae46873d3a25ed601758a1511) --- source4/lib/cmdline/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index b0b5073e62..c65c311af1 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -255,7 +255,7 @@ static void popt_common_credentials_callback(poptContext con, struct poptOption popt_common_credentials[] = { { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, popt_common_credentials_callback }, - { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "USERNAME" }, + { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN\\]USERNAME[%PASSWORD]" }, { "no-pass", 'N', POPT_ARG_NONE, &dont_ask, True, "Don't ask for a password" }, { "kerberos", 'k', POPT_ARG_NONE, NULL, 'k', "Use kerberos (active directory) authentication" }, { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, -- cgit From 645711c602313940dcf80ec786557920ecfbf884 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 22 Mar 2005 08:00:45 +0000 Subject: r5941: Commit this patch much earlier than I would normally prefer, but metze needs a working tree... The main volume of this patch was what I started working on today: - Cleans up memory handling around DCE/RPC pipes, to have a parent talloc context. - Uses sepereate inner loops for some of the DCE/RPC tests The other and more important part of this patch fixes issues surrounding the new credentials framwork: This makes the struct cli_credentials always a talloc() structure, rather than on the stack. Parts of the cli_credentials code already assumed this. There were other issues, particularly in the DCERPC over SMB handling, as well as little things that had to be tidied up before test_w2k3.sh would start to pass. Andrew Bartlett (This used to be commit 0453f9d05d2e336fba1f85dbf2718d01fa2bf778) --- source4/lib/cmdline/popt_common.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index c65c311af1..d364f4d3bf 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -177,13 +177,13 @@ static void popt_common_credentials_callback(poptContext con, const char *arg, const void *data) { if (reason == POPT_CALLBACK_REASON_PRE) { - cmdline_credentials = talloc_zero(talloc_autofree_context(), struct cli_credentials); - cli_credentials_guess(cmdline_credentials); - + cmdline_credentials = cli_credentials_init(talloc_autofree_context()); return; } if (reason == POPT_CALLBACK_REASON_POST) { + cli_credentials_guess(cmdline_credentials); + if (!dont_ask) { cli_credentials_set_cmdline_callbacks(cmdline_credentials); } @@ -232,8 +232,7 @@ static void popt_common_credentials_callback(poptContext con, cmdline_credentials->username_obtained = CRED_SPECIFIED; cli_credentials_set_password(cmdline_credentials, opt_password, CRED_SPECIFIED); free(opt_password); - - cli_credentials_set_domain(cmdline_credentials, lp_workgroup(), CRED_SPECIFIED); + } /* machine accounts only work with kerberos */ -- cgit From 7c55d0ffa5af6d372ce63ba369a20d9a46fa6454 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 22 Mar 2005 22:11:50 +0000 Subject: r5976: SIDs can't have more then 5 subauths (caught by [validate] and range()) (This used to be commit ec1eaa274b997197ca6996457229c802f1b76d56) --- source4/lib/cmdline/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index d364f4d3bf..7049ce65df 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -3,7 +3,7 @@ Common popt routines Copyright (C) Tim Potter 2001,2002 - Copyright (C) Jelmer Vernooij 2002,2003 + Copyright (C) Jelmer Vernooij 2002,2003,2005 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 -- cgit From 79f6bcd5ae1711075ce0e75392ce83a72766698e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 23 Mar 2005 01:30:43 +0000 Subject: r5988: Fix the -P option (use machine account credentials) to use the Samba4 secrets system, and not the old system from Samba3. This allowed the code from auth_domain to be shared - we now only lookup the secrets.ldb in lib/credentials.c. In order to link the resultant binary, samdb_search() has been moved from deep inside rpc_server into lib/gendb.c, along with the existing gendb_search_v(). The vast majority of this patch is the simple rename that followed, (Depending on the whole SAMDB for just this function seemed pointless, and brought in futher dependencies, such as smbencrypt.c). Andrew Bartlett (This used to be commit e13c671619bd290a8b3cae8555cb281a9a185ee0) --- source4/lib/cmdline/popt_common.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 7049ce65df..50e07d95e9 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -213,26 +213,7 @@ static void popt_common_credentials_callback(poptContext con, case 'P': { - char *opt_password = NULL; - /* it is very useful to be able to make ads queries as the - machine account for testing purposes and for domain leave */ - - if (!secrets_init()) { - d_printf("ERROR: Unable to open secrets database\n"); - exit(1); - } - - opt_password = secrets_fetch_machine_password(lp_workgroup()); - - if (!opt_password) { - d_printf("ERROR: Unable to fetch machine password\n"); - exit(1); - } - cmdline_credentials->username = talloc_asprintf(cmdline_credentials, "%s$", lp_netbios_name()); - cmdline_credentials->username_obtained = CRED_SPECIFIED; - cli_credentials_set_password(cmdline_credentials, opt_password, CRED_SPECIFIED); - free(opt_password); - + cli_credentials_set_machine_account(cmdline_credentials); } /* machine accounts only work with kerberos */ -- cgit From 038c4c4c6a4f6039e0436134de1d9c1e14c444d8 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 24 Mar 2005 03:32:25 +0000 Subject: r6024: Some of the ordering constraints on the popt callbacks were getting painful, so don't call lp_*() functions until the post stage (rather than in the cli_credentails_init(), which is called in the pre stage), and don't open the secrets.ldb looking for the machine account details until we actually need them (well after popt is done, and we know we have the other things right). Set the domain and realm, as well as the account and password for -P (fetch machine password) operation. Allow NETLOGON credentials to be stored in this structure - will allow SCHANNEL to be made more generic. Clarify why we don't do special checks for NULL pointers, particularly in the anonymous check (it indicates a programmer error, not a run-time condition). Also make lib/credentials.c a little more consistant. Andrew Bartlett (This used to be commit 730e6056b730c15008772c30cd6f7c03fb6b7e5f) --- source4/lib/cmdline/popt_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 50e07d95e9..68f491a188 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -212,10 +212,10 @@ static void popt_common_credentials_callback(poptContext con, break; case 'P': - { - cli_credentials_set_machine_account(cmdline_credentials); - } - /* machine accounts only work with kerberos */ + /* Later, after this is all over, get the machine account details from the secrets.ldb */ + cli_credentials_set_machine_account_pending(cmdline_credentials); + + /* machine accounts only work with kerberos (fall though)*/ case 'k': #ifndef HAVE_KRB5 -- cgit From 39b2178fc998c9811636a67546d0818df6ca14c7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 26 Apr 2005 07:10:43 +0000 Subject: r6483: fix anonymous connections, '-U %' or '-U ""%""' can be used for this metze (This used to be commit d31b4d7df375c0d4ea962a0df1693778d56f03ec) --- source4/lib/cmdline/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 68f491a188..94b72c520d 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -197,7 +197,7 @@ static void popt_common_credentials_callback(poptContext con, cli_credentials_parse_string(cmdline_credentials, arg, CRED_SPECIFIED); - if ((lp=strchr_m(arg,'%'))) { + if (cmdline_credentials->password && (lp=strchr_m(arg,'%'))) { memset(lp,0,strlen(cmdline_credentials->password)); } } -- cgit From 2b4791ae733488845b2c36bca64db695203de571 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 13 Jun 2005 08:12:39 +0000 Subject: r7525: Unify lp_load(), load_interfaces and logging setup into popt(). There is now a new --debug-stderr option to enable debug to STDERR. popt isn't perfect, but the callbacks are used in all the main Samba binaries, and should be used in the rest. This avoids duplicated code, and ensures every binary is setup correctly. This also ensures the setup happens early enough to have -s function, and have a correct impact on the credentials code. (Fixing a bug that frustrated tridge earlier today). The only 'subtle' aspect of all this is that I'm pretty sure that the SAMBA_COMMON popt code must be above the CREDENTIALS code, in the popt tables. Andrew Bartlett (This used to be commit 50f3c2b3a22971f40e0d3a88127b5120bfc47591) --- source4/lib/cmdline/popt_common.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 94b72c520d..fec85281ef 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -38,7 +38,7 @@ * -i,--scope */ -enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL}; +enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL, OPT_DEBUG_STDERR}; struct cli_credentials *cmdline_credentials = NULL; @@ -49,6 +49,14 @@ static void popt_common_callback(poptContext con, { const char *pname; + if (reason == POPT_CALLBACK_REASON_POST) { + /* Hook any 'every Samba program must do this, after + * the smb.conf is setup' functions here */ + lp_load(dyn_CONFIGFILE,True,False,False); + load_interfaces(); + return; + } + /* Find out basename of current program */ pname = strrchr_m(poptGetInvocationName(con),'/'); @@ -58,9 +66,7 @@ static void popt_common_callback(poptContext con, pname++; if (reason == POPT_CALLBACK_REASON_PRE) { - char *logfile = talloc_asprintf(NULL, "%s/log.%s", dyn_LOGFILEBASE, pname); - lp_set_cmdline("log file", logfile); - talloc_free(logfile); + setup_logging(pname, DEBUG_STDOUT); return; } @@ -69,6 +75,10 @@ static void popt_common_callback(poptContext con, lp_set_cmdline("log level", arg); break; + case OPT_DEBUG_STDERR: + setup_logging(pname, DEBUG_STDERR); + break; + case 'V': printf( "Version %s\n", SAMBA_VERSION_STRING ); exit(0); @@ -128,6 +138,7 @@ static void popt_common_callback(poptContext con, case OPT_LEAK_REPORT_FULL: talloc_enable_leak_report_full(); break; + } } @@ -143,8 +154,9 @@ struct poptOption popt_common_connection[] = { }; struct poptOption popt_common_samba[] = { - { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_callback }, + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, popt_common_callback }, { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, + { "debug-stderr", 0, POPT_ARG_NONE, NULL, OPT_DEBUG_STDERR, "Send debug output to STDERR", NULL }, { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, { "option", 0, POPT_ARG_STRING, NULL, OPT_OPTION, "Set smb.conf option from command line", "name=value" }, { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" }, -- cgit From 00e2b7c1b49b128488cf977b40b086b935fb605a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 13 Jun 2005 10:01:11 +0000 Subject: r7530: Simply calling convention of lp_load(). This always loads all the services, as we now don't have an easy way to split out smbd. Andrew Bartlett (This used to be commit 990e061939c76b559c4f5914c5fc6ca1b13e19dd) --- source4/lib/cmdline/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index fec85281ef..fb7356dc0e 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -52,7 +52,7 @@ static void popt_common_callback(poptContext con, if (reason == POPT_CALLBACK_REASON_POST) { /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ - lp_load(dyn_CONFIGFILE,True,False,False); + lp_load(dyn_CONFIGFILE); load_interfaces(); return; } -- cgit From 3433a464c2e46301a2ef51642577ef731a3ae1ce Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 28 Jun 2005 00:52:10 +0000 Subject: r7967: We don't have the ms_krb5 stuff any more. Andrew Bartlett (This used to be commit 56a5ccd7d924343609698b034b91b4891fb3f08a) --- source4/lib/cmdline/popt_common.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index fb7356dc0e..b8f8a675eb 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -235,7 +235,6 @@ static void popt_common_credentials_callback(poptContext con, exit(1); #else lp_set_cmdline("gensec:krb5", "True"); - lp_set_cmdline("gensec:ms_krb5", "True"); #endif break; -- cgit From 8139838acf6a211a3984dac71babe7778148aa8b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 2 Jul 2005 05:18:01 +0000 Subject: r8067: added a method for disabling the password prompt in programs that want cmdline credentials, but don't want a prompt if none are supplied (This used to be commit d7d7f7292b7032dcad6d6245510af229f12f7085) --- source4/lib/cmdline/popt_common.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index b8f8a675eb..b7b7bdc286 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -181,7 +181,15 @@ struct poptOption popt_common_version[] = { */ -static BOOL dont_ask = False; +static BOOL dont_ask; + +/* + disable asking for a password +*/ +void popt_common_dont_ask(void) +{ + dont_ask = True; +} static void popt_common_credentials_callback(poptContext con, enum poptCallbackReason reason, -- cgit From 2f5f01567b4c30cd764843a1ca0c7ab6d9bc0882 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 20 Jul 2005 10:07:48 +0000 Subject: r8643: - make lp_configfile() work again - get rid of redundeny dyn_CONFIGFILE argument to lp_load() - fixed provisioning to work with completely pristine install, creating an initial smb.conf is none is present - added lp.set() and lp.reload() to loadparm ejs object interface (This used to be commit c2691ef7126ddcee5f95970b78759b40a049d0a7) --- source4/lib/cmdline/popt_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index b7b7bdc286..e39c8e964d 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -52,7 +52,7 @@ static void popt_common_callback(poptContext con, if (reason == POPT_CALLBACK_REASON_POST) { /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ - lp_load(dyn_CONFIGFILE); + lp_load(); load_interfaces(); return; } @@ -92,7 +92,7 @@ static void popt_common_callback(poptContext con, case 's': if (arg) { - pstrcpy(dyn_CONFIGFILE, arg); + lp_set_cmdline("config file", arg); } break; -- cgit From a369f0ecaf35fb49652873c4c1ddcaf28629c26e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 21 Jul 2005 12:11:52 +0000 Subject: r8678: setup for gdb backtrace in 'make test' (This used to be commit acf8c8fd4995acef47390df5a7d4e611c597367d) --- source4/lib/cmdline/popt_common.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index e39c8e964d..53bb7b5a8c 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -48,6 +48,9 @@ static void popt_common_callback(poptContext con, const char *arg, const void *data) { const char *pname; + + /* setup for panics */ + fault_setup(poptGetInvocationName(con)); if (reason == POPT_CALLBACK_REASON_POST) { /* Hook any 'every Samba program must do this, after -- cgit From 87e2396be99a1560d3f083e77e5fc6c583d3b9c1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 21 Jul 2005 12:20:18 +0000 Subject: r8679: only call fault setup once (thanks to andrew for pointing this out) (This used to be commit f8a2b032a70dd63f4454b982d00168dcf6793202) --- source4/lib/cmdline/popt_common.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 53bb7b5a8c..4e808652f7 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -49,9 +49,6 @@ static void popt_common_callback(poptContext con, { const char *pname; - /* setup for panics */ - fault_setup(poptGetInvocationName(con)); - if (reason == POPT_CALLBACK_REASON_POST) { /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ @@ -69,6 +66,10 @@ static void popt_common_callback(poptContext con, pname++; if (reason == POPT_CALLBACK_REASON_PRE) { + /* setup for panics */ + fault_setup(poptGetInvocationName(con)); + + /* and logging */ setup_logging(pname, DEBUG_STDOUT); return; } -- cgit From 24186a80eb4887b5fb3e72e4b877b456cbe8e35f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 29 Aug 2005 04:30:22 +0000 Subject: r9728: A *major* update to the credentials system, to incorporate the Kerberos CCACHE into the system. This again allows the use of the system ccache when no username is specified, and brings more code in common between gensec_krb5 and gensec_gssapi. It also has a side-effect that may (or may not) be expected: If there is a ccache, even if it is not used (perhaps the remote server didn't want kerberos), it will change the default username. Andrew Bartlett (This used to be commit 6202267f6ec1446d6bd11d1d37d05a977bc8d315) --- source4/lib/cmdline/popt_common.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 4e808652f7..d3bd0a35a4 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -220,9 +220,11 @@ static void popt_common_credentials_callback(poptContext con, char *lp; cli_credentials_parse_string(cmdline_credentials, arg, CRED_SPECIFIED); - - if (cmdline_credentials->password && (lp=strchr_m(arg,'%'))) { - memset(lp,0,strlen(cmdline_credentials->password)); + /* This breaks the abstraction, including the const above */ + if (lp=strchr_m(arg,'%')) { + lp[0]='\0'; + lp++; + memset(lp,0,strlen(lp)); } } break; -- cgit From 7f66d5ce255b07d5ae0c35a95340d2401c6409bb Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 3 Sep 2005 12:37:44 +0000 Subject: r9993: Gcc is fussy about the lack of parentheses around assignment statements. (This used to be commit 908ba892598af83ae2fbe661d40e9f10ff3e34a0) --- source4/lib/cmdline/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index d3bd0a35a4..333004e965 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -221,7 +221,7 @@ static void popt_common_credentials_callback(poptContext con, cli_credentials_parse_string(cmdline_credentials, arg, CRED_SPECIFIED); /* This breaks the abstraction, including the const above */ - if (lp=strchr_m(arg,'%')) { + if ((lp=strchr_m(arg,'%'))) { lp[0]='\0'; lp++; memset(lp,0,strlen(lp)); -- cgit From d2a666acbe04f741387ff4351e3971b24f1c3b14 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 19 Sep 2005 13:26:07 +0000 Subject: r10316: More dynconfig fixes (This used to be commit 0963ab9c148772b961f17ec779213b0eb861e1dd) --- source4/lib/cmdline/popt_common.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 333004e965..fe76292acb 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -22,7 +22,6 @@ #include "includes.h" #include "version.h" -#include "dynconfig.h" #include "system/filesys.h" #include "system/passwd.h" #include "lib/cmdline/popt_common.h" -- cgit From 65d4da0ff330740788c4386a71526b6ed3e10162 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 20 Sep 2005 21:29:29 +0000 Subject: r10364: Turn gensec:gssapi on by default, except for a login of the form -Udomain\\user. This will probably break in a few configurations, so please let me know. I'll also work to have a way to inhibit kerberos/ntlmssp, as this removes -k. Andrew Bartlett (This used to be commit 3c0dc570b86e79aea5446d7c3bb9750a11bf8ca4) --- source4/lib/cmdline/popt_common.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index fe76292acb..43ea203b78 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -241,17 +241,7 @@ static void popt_common_credentials_callback(poptContext con, cli_credentials_set_machine_account_pending(cmdline_credentials); /* machine accounts only work with kerberos (fall though)*/ - - case 'k': -#ifndef HAVE_KRB5 - d_printf("No kerberos support compiled in\n"); - exit(1); -#else - lp_set_cmdline("gensec:krb5", "True"); -#endif break; - - } } @@ -261,7 +251,6 @@ struct poptOption popt_common_credentials[] = { { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, popt_common_credentials_callback }, { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN\\]USERNAME[%PASSWORD]" }, { "no-pass", 'N', POPT_ARG_NONE, &dont_ask, True, "Don't ask for a password" }, - { "kerberos", 'k', POPT_ARG_NONE, NULL, 'k', "Use kerberos (active directory) authentication" }, { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, { "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" }, { "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password (implies -k)" }, -- cgit From f801ad359290c51d3216c755fb2a8344babb484f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Sep 2005 15:59:43 +0000 Subject: r10510: Decrease the amount of data included by includes.h a bit (This used to be commit 03647e1321cf6c9bd6ced3945265f635e9468973) --- source4/lib/cmdline/popt_common.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 43ea203b78..76c8a537e3 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -25,6 +25,7 @@ #include "system/filesys.h" #include "system/passwd.h" #include "lib/cmdline/popt_common.h" +#include "credentials.h" /* Handle command line options: * -d,--debuglevel -- cgit From 42b81d7c3e8ac9ad4c35d5377decbdd5ab18ffbb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Sep 2005 10:00:27 +0000 Subject: r10528: Add credentials.h back into includes.h as some compilers don't seem to be able to handle incomplete enum types. (This used to be commit 540155fad3c8e3d79fb631bb3f14273f82130a73) --- source4/lib/cmdline/popt_common.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 76c8a537e3..43ea203b78 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -25,7 +25,6 @@ #include "system/filesys.h" #include "system/passwd.h" #include "lib/cmdline/popt_common.h" -#include "credentials.h" /* Handle command line options: * -d,--debuglevel -- cgit From 46de306f13ec894c967a93121ac1b0847659cf01 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 18 Dec 2005 21:44:43 +0000 Subject: r12320: Add command-line processing hooks for simple bind DN, and password callback. We may change this in future. Andrew Bartlett (This used to be commit 5fec784d4795af0cf82d36766586ded134f62165) --- source4/lib/cmdline/popt_common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 43ea203b78..0aa4a634fc 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -37,7 +37,7 @@ * -i,--scope */ -enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL, OPT_DEBUG_STDERR}; +enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL, OPT_DEBUG_STDERR, OPT_SIMPLE_BIND_DN}; struct cli_credentials *cmdline_credentials = NULL; @@ -242,6 +242,9 @@ static void popt_common_credentials_callback(poptContext con, /* machine accounts only work with kerberos (fall though)*/ break; + case OPT_SIMPLE_BIND_DN: + cli_credentials_set_bind_dn(cmdline_credentials, arg); + break; } } @@ -254,5 +257,6 @@ struct poptOption popt_common_credentials[] = { { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, { "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" }, { "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password (implies -k)" }, + { "simple-bind-dn", 0, POPT_ARG_STRING, NULL, OPT_SIMPLE_BIND_DN, "DN to use for a simple bind" }, POPT_TABLEEND }; -- cgit From e4dbcc0d5d6c9c68a7f3c437611b726f9f0211cf Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 28 Dec 2005 03:04:40 +0000 Subject: r12531: 'make quicktest' was taking 15 minutes on my system due to failing DNS lookups in load_interfaces(). The reason was my eth0 interface was down, and it was being interpreted as a DNS name. This patch changes load_interfaces() to happening automatically when interfaces are first needed instead of on the startup of every samba binary. This means that (for example) ldbadd doesn't call load_interfaces(), which means no slow DNS lookups. I also reduced the number of static globals in interface.c to 1, and changed from malloc to talloc When you want to force a reload of the interfaces list, you now call unload_interfaces(), which means the next call that needs the interfaces list will reload it (This used to be commit f79d90bd1364b970adb2981b2572e77066431f1e) --- source4/lib/cmdline/popt_common.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 0aa4a634fc..b1f4563fb1 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -52,7 +52,6 @@ static void popt_common_callback(poptContext con, /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ lp_load(); - load_interfaces(); return; } -- cgit From 46aa296cc94933082dbb4b9b2b1ed210a600ad2d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Dec 2005 23:14:33 +0000 Subject: r12592: Remove some useless dependencies (This used to be commit ca8db1a0cd77682ac2c6dc4718f5d753a4fcc4db) --- source4/lib/cmdline/popt_common.c | 88 +-------------------------------------- 1 file changed, 1 insertion(+), 87 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index b1f4563fb1..b8c5b5b9d3 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -37,7 +37,7 @@ * -i,--scope */ -enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL, OPT_DEBUG_STDERR, OPT_SIMPLE_BIND_DN}; +enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL,OPT_DEBUG_STDERR}; struct cli_credentials *cmdline_credentials = NULL; @@ -173,89 +173,3 @@ struct poptOption popt_common_version[] = { POPT_TABLEEND }; -/* Handle command line options: - * -U,--user - * -A,--authentication-file - * -k,--use-kerberos - * -N,--no-pass - * -S,--signing - * -P --machine-pass - */ - - -static BOOL dont_ask; - -/* - disable asking for a password -*/ -void popt_common_dont_ask(void) -{ - dont_ask = True; -} - -static void popt_common_credentials_callback(poptContext con, - enum poptCallbackReason reason, - const struct poptOption *opt, - const char *arg, const void *data) -{ - if (reason == POPT_CALLBACK_REASON_PRE) { - cmdline_credentials = cli_credentials_init(talloc_autofree_context()); - return; - } - - if (reason == POPT_CALLBACK_REASON_POST) { - cli_credentials_guess(cmdline_credentials); - - if (!dont_ask) { - cli_credentials_set_cmdline_callbacks(cmdline_credentials); - } - return; - } - - switch(opt->val) { - case 'U': - { - char *lp; - - cli_credentials_parse_string(cmdline_credentials, arg, CRED_SPECIFIED); - /* This breaks the abstraction, including the const above */ - if ((lp=strchr_m(arg,'%'))) { - lp[0]='\0'; - lp++; - memset(lp,0,strlen(lp)); - } - } - break; - - case 'A': - cli_credentials_parse_file(cmdline_credentials, arg, CRED_SPECIFIED); - break; - - case 'S': - lp_set_cmdline("client signing", arg); - break; - - case 'P': - /* Later, after this is all over, get the machine account details from the secrets.ldb */ - cli_credentials_set_machine_account_pending(cmdline_credentials); - - /* machine accounts only work with kerberos (fall though)*/ - break; - case OPT_SIMPLE_BIND_DN: - cli_credentials_set_bind_dn(cmdline_credentials, arg); - break; - } -} - - - -struct poptOption popt_common_credentials[] = { - { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, popt_common_credentials_callback }, - { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN\\]USERNAME[%PASSWORD]" }, - { "no-pass", 'N', POPT_ARG_NONE, &dont_ask, True, "Don't ask for a password" }, - { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, - { "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" }, - { "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password (implies -k)" }, - { "simple-bind-dn", 0, POPT_ARG_STRING, NULL, OPT_SIMPLE_BIND_DN, "DN to use for a simple bind" }, - POPT_TABLEEND -}; -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/lib/cmdline/popt_common.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index b8c5b5b9d3..f31408b5ad 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -22,8 +22,6 @@ #include "includes.h" #include "version.h" -#include "system/filesys.h" -#include "system/passwd.h" #include "lib/cmdline/popt_common.h" /* Handle command line options: -- cgit From 210d3c1dc760af8e21fbfd5b23e87a1c937051d4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 28 Jan 2006 12:01:39 +0000 Subject: r13205: Add another useful comment. Andrew Bartlett (This used to be commit 78d634047f41466e4bf169e727f730d776949b33) --- source4/lib/cmdline/popt_common.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index f31408b5ad..0ede432424 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -62,6 +62,7 @@ static void popt_common_callback(poptContext con, pname++; if (reason == POPT_CALLBACK_REASON_PRE) { + /* Hook for 'almost the first thing to do in a samba program' here */ /* setup for panics */ fault_setup(poptGetInvocationName(con)); -- cgit From cc23a9ba6247fd1c648bffdf29c17358d941ef69 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 4 Feb 2006 09:50:02 +0000 Subject: r13341: Trivial. (This used to be commit b986278b367a6693f69a06e07ca90f8b5a23a0c0) --- source4/lib/cmdline/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 0ede432424..33959874b7 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -47,9 +47,9 @@ static void popt_common_callback(poptContext con, const char *pname; if (reason == POPT_CALLBACK_REASON_POST) { + lp_load(); /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ - lp_load(); return; } -- cgit From b556df32a849eefa2f2f34868eee02f05451878d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 21 Mar 2006 00:04:41 +0000 Subject: r14598: 'logfile' may be a poor choice for a global variable name, but for now don't shadow it. Andrew Bartlett (This used to be commit ace171f94c57da7b13c147c6e286e9e183df0745) --- source4/lib/cmdline/popt_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 33959874b7..fb6ba722de 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -99,9 +99,9 @@ static void popt_common_callback(poptContext con, case 'l': if (arg) { - char *logfile = talloc_asprintf(NULL, "%s/log.%s", arg, pname); - lp_set_cmdline("log file", logfile); - talloc_free(logfile); + char *new_logfile = talloc_asprintf(NULL, "%s/log.%s", arg, pname); + lp_set_cmdline("log file", new_logfile); + talloc_free(new_logfile); } break; -- cgit From e5cbee330e5b38d525ac8ca5b0e8714216781233 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 27 Jul 2006 18:08:12 +0000 Subject: r17281: we now have client/server max protol metze (This used to be commit 1d74291626399d283c180e136a3f7a8c27ecdb37) --- source4/lib/cmdline/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index fb6ba722de..2d12e29b85 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -118,7 +118,7 @@ static void popt_common_callback(poptContext con, break; case 'm': - lp_set_cmdline("max protocol", arg); + lp_set_cmdline("client max protocol", arg); break; case 'R': -- cgit From 873749f2189ecf1fbfdc681df4dd304a17716279 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 12:28:01 +0000 Subject: r18168: Use {NULL} rather than POPT_TABLEEND, which is not always available. (This used to be commit 8b622c5ded0732df0eaf9f6226f52a27b6eacd73) --- source4/lib/cmdline/popt_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 2d12e29b85..1457873399 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -151,7 +151,7 @@ struct poptOption popt_common_connection[] = { { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" }, { "maxprotocol", 'm', POPT_ARG_STRING, NULL, 'm', "Set max protocol level", "MAXPROTOCOL" }, - POPT_TABLEEND + { NULL } }; struct poptOption popt_common_samba[] = { @@ -163,12 +163,12 @@ struct poptOption popt_common_samba[] = { { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" }, { "leak-report", 0, POPT_ARG_NONE, NULL, OPT_LEAK_REPORT, "enable talloc leak reporting on exit", NULL }, { "leak-report-full",0, POPT_ARG_NONE, NULL, OPT_LEAK_REPORT_FULL, "enable full talloc leak reporting on exit", NULL }, - POPT_TABLEEND + { NULL } }; struct poptOption popt_common_version[] = { { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, - POPT_TABLEEND + { NULL } }; -- cgit From e6a5fd44d01abdcaa082e5afc168a38848f35ccc Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Tue, 7 Nov 2006 23:48:02 +0000 Subject: r19630: Support specifying the realm name from command line. Useful when testing calls against windows servers with krb auth. rafal (This used to be commit 0725e2ddebde9c170340d0284a1573222caa2159) --- source4/lib/cmdline/popt_common.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 1457873399..25d1cd6546 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -32,6 +32,7 @@ * -l,--log-base * -n,--netbios-name * -W,--workgroup + * -r,--realm * -i,--scope */ @@ -108,6 +109,10 @@ static void popt_common_callback(poptContext con, case 'W': lp_set_cmdline("workgroup", arg); break; + + case 'r': + lp_set_cmdline("realm", arg); + break; case 'n': lp_set_cmdline("netbios name", arg); @@ -149,6 +154,7 @@ struct poptOption popt_common_connection[] = { { "socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use", "SOCKETOPTIONS" }, { "netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name", "NETBIOSNAME" }, { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, + { "realm", 'r', POPT_ARG_STRING, NULL, 'r', "Set the realm name", "REALM" }, { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" }, { "maxprotocol", 'm', POPT_ARG_STRING, NULL, 'm', "Set max protocol level", "MAXPROTOCOL" }, { NULL } -- cgit From bf16e43328f4e025a21c4ee2dc1d82f8e522362d Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Wed, 8 Nov 2006 21:11:25 +0000 Subject: r19637: Leave --realm option only, as abartlet suggested. rafal (This used to be commit 73e3f7efa71ca07a42215b044cd9a20762cf2694) --- source4/lib/cmdline/popt_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 25d1cd6546..be46582d0b 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -32,7 +32,7 @@ * -l,--log-base * -n,--netbios-name * -W,--workgroup - * -r,--realm + * --realm * -i,--scope */ @@ -154,7 +154,7 @@ struct poptOption popt_common_connection[] = { { "socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use", "SOCKETOPTIONS" }, { "netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name", "NETBIOSNAME" }, { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, - { "realm", 'r', POPT_ARG_STRING, NULL, 'r', "Set the realm name", "REALM" }, + { "realm", 0, POPT_ARG_STRING, NULL, 'r', "Set the realm name", "REALM" }, { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" }, { "maxprotocol", 'm', POPT_ARG_STRING, NULL, 'm', "Set max protocol level", "MAXPROTOCOL" }, { NULL } -- cgit From 57dd182915c3e81291a3aa48bd6c6795fd00a96f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 17 Apr 2007 13:14:33 +0000 Subject: r22306: try to make the aix compiler happy metze (This used to be commit 44e1459373821adf4ed41a814a1be238442e37fb) --- source4/lib/cmdline/popt_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index be46582d0b..1eeb797e6e 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -149,7 +149,7 @@ static void popt_common_callback(poptContext con, } struct poptOption popt_common_connection[] = { - { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, + { NULL, 0, POPT_ARG_CALLBACK, (void *)popt_common_callback }, { "name-resolve", 'R', POPT_ARG_STRING, NULL, 'R', "Use these name resolution services only", "NAME-RESOLVE-ORDER" }, { "socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use", "SOCKETOPTIONS" }, { "netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name", "NETBIOSNAME" }, @@ -161,7 +161,7 @@ struct poptOption popt_common_connection[] = { }; struct poptOption popt_common_samba[] = { - { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, popt_common_callback }, + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, (void *)popt_common_callback }, { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, { "debug-stderr", 0, POPT_ARG_NONE, NULL, OPT_DEBUG_STDERR, "Send debug output to STDERR", NULL }, { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, @@ -173,7 +173,7 @@ struct poptOption popt_common_samba[] = { }; struct poptOption popt_common_version[] = { - { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, + { NULL, 0, POPT_ARG_CALLBACK, (void *)popt_common_callback }, { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, { NULL } }; -- cgit From f7e093572797e09d7bd78db2d452914092b68c5a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 May 2007 03:25:17 +0000 Subject: r22622: make it possible to pass the config file via 'SMB_CONF_PATH' envvar very usefull for make testenv! this makes it also possible to pass a config file to smbscript metze (This used to be commit f65fcd764b656ba9953d88dc7b002e4977af5011) --- source4/lib/cmdline/popt_common.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 1eeb797e6e..1752f43a84 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -69,6 +69,10 @@ static void popt_common_callback(poptContext con, /* and logging */ setup_logging(pname, DEBUG_STDOUT); + + if (getenv("SMB_CONF_PATH")) { + lp_set_cmdline("config file", getenv("SMB_CONF_PATH")); + } return; } -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/lib/cmdline/popt_common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 1752f43a84..904a873892 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -7,7 +7,7 @@ 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 - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 35b16479a59510a35fc38ff7c0e8ad91c2def141 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 22 Aug 2007 12:04:42 +0000 Subject: r24620: move printing out the version string and exit() into the popt _POST processing. Now 'smbd -V --bla' complains about an unknown option metze (This used to be commit 69bf7f1874c8e89b61c4baa03ff9ad191e71b804) --- source4/lib/cmdline/popt_common.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 904a873892..413c8e7cc3 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -39,6 +39,8 @@ enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL,OPT_DEBUG_STDERR}; struct cli_credentials *cmdline_credentials = NULL; +static bool PrintSambaVersionString; + static void popt_common_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, @@ -47,6 +49,11 @@ static void popt_common_callback(poptContext con, const char *pname; if (reason == POPT_CALLBACK_REASON_POST) { + if (PrintSambaVersionString) { + printf( "Version %s\n", SAMBA_VERSION_STRING ); + exit(0); + } + lp_load(); /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ @@ -85,8 +92,7 @@ static void popt_common_callback(poptContext con, break; case 'V': - printf( "Version %s\n", SAMBA_VERSION_STRING ); - exit(0); + PrintSambaVersionString = true; break; case 'O': @@ -176,7 +182,7 @@ struct poptOption popt_common_samba[] = { }; struct poptOption popt_common_version[] = { - { NULL, 0, POPT_ARG_CALLBACK, (void *)popt_common_callback }, + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_POST, (void *)popt_common_callback }, { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, { NULL } }; -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/lib/cmdline/popt_common.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 413c8e7cc3..6f91c3a26a 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -22,6 +22,7 @@ #include "includes.h" #include "version.h" #include "lib/cmdline/popt_common.h" +#include "param/param.h" /* Handle command line options: * -d,--debuglevel -- cgit From 3048e9ad654506219b169a934edded388d10fcad Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 27 Sep 2007 23:31:28 +0000 Subject: r25392: Add loadparm context as argument in a couple more places. (This used to be commit c62f51cc28a37959128e78a1f34cfd4c6d3ba069) --- source4/lib/cmdline/popt_common.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 6f91c3a26a..6e0573e7ef 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -78,14 +78,14 @@ static void popt_common_callback(poptContext con, setup_logging(pname, DEBUG_STDOUT); if (getenv("SMB_CONF_PATH")) { - lp_set_cmdline("config file", getenv("SMB_CONF_PATH")); + lp_set_cmdline(global_loadparm, "config file", getenv("SMB_CONF_PATH")); } return; } switch(opt->val) { case 'd': - lp_set_cmdline("log level", arg); + lp_set_cmdline(global_loadparm, "log level", arg); break; case OPT_DEBUG_STDERR: @@ -98,50 +98,50 @@ static void popt_common_callback(poptContext con, case 'O': if (arg) { - lp_set_cmdline("socket options", arg); + lp_set_cmdline(global_loadparm, "socket options", arg); } break; case 's': if (arg) { - lp_set_cmdline("config file", arg); + lp_set_cmdline(global_loadparm, "config file", arg); } break; case 'l': if (arg) { char *new_logfile = talloc_asprintf(NULL, "%s/log.%s", arg, pname); - lp_set_cmdline("log file", new_logfile); + lp_set_cmdline(global_loadparm, "log file", new_logfile); talloc_free(new_logfile); } break; case 'W': - lp_set_cmdline("workgroup", arg); + lp_set_cmdline(global_loadparm, "workgroup", arg); break; case 'r': - lp_set_cmdline("realm", arg); + lp_set_cmdline(global_loadparm, "realm", arg); break; case 'n': - lp_set_cmdline("netbios name", arg); + lp_set_cmdline(global_loadparm, "netbios name", arg); break; case 'i': - lp_set_cmdline("netbios scope", arg); + lp_set_cmdline(global_loadparm, "netbios scope", arg); break; case 'm': - lp_set_cmdline("client max protocol", arg); + lp_set_cmdline(global_loadparm, "client max protocol", arg); break; case 'R': - lp_set_cmdline("name resolve order", arg); + lp_set_cmdline(global_loadparm, "name resolve order", arg); break; case OPT_OPTION: - if (!lp_set_option(arg)) { + if (!lp_set_option(global_loadparm, arg)) { fprintf(stderr, "Error setting option '%s'\n", arg); exit(1); } -- cgit From 37d53832a4623653f706e77985a79d84bd7c6694 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Sep 2007 01:17:46 +0000 Subject: r25398: Parse loadparm context to all lp_*() functions. (This used to be commit 3fcc960839c6e5ca4de2c3c042f12f369ac5f238) --- source4/lib/cmdline/popt_common.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 6e0573e7ef..41eb70094e 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -23,6 +23,7 @@ #include "version.h" #include "lib/cmdline/popt_common.h" #include "param/param.h" +#include "dynconfig.h" /* Handle command line options: * -d,--debuglevel @@ -40,8 +41,6 @@ enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL,OPT_DEBUG_STDERR}; struct cli_credentials *cmdline_credentials = NULL; -static bool PrintSambaVersionString; - static void popt_common_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, @@ -50,12 +49,12 @@ static void popt_common_callback(poptContext con, const char *pname; if (reason == POPT_CALLBACK_REASON_POST) { - if (PrintSambaVersionString) { - printf( "Version %s\n", SAMBA_VERSION_STRING ); - exit(0); + if (!lp_loaded()) { + if (getenv("SMB_CONF_PATH")) + lp_load(getenv("SMB_CONF_PATH")); + else + lp_load(dyn_CONFIGFILE); } - - lp_load(); /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ return; @@ -77,9 +76,6 @@ static void popt_common_callback(poptContext con, /* and logging */ setup_logging(pname, DEBUG_STDOUT); - if (getenv("SMB_CONF_PATH")) { - lp_set_cmdline(global_loadparm, "config file", getenv("SMB_CONF_PATH")); - } return; } @@ -93,8 +89,8 @@ static void popt_common_callback(poptContext con, break; case 'V': - PrintSambaVersionString = true; - break; + printf("Version %s\n", SAMBA_VERSION_STRING ); + exit(0); case 'O': if (arg) { @@ -104,7 +100,7 @@ static void popt_common_callback(poptContext con, case 's': if (arg) { - lp_set_cmdline(global_loadparm, "config file", arg); + lp_load(arg); } break; -- cgit From 6c999cd12344f2bb8b1d2941210b4c205b3e0aad Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 2 Dec 2007 22:32:11 +0100 Subject: r26236: Remove more uses of global_loadparm or specify loadparm_context explicitly. (This used to be commit 5b29ef7c03d9ae76b0ca909e9f03a58e1bad3521) --- source4/lib/cmdline/popt_common.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 41eb70094e..1c96bf64cf 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -47,6 +47,7 @@ static void popt_common_callback(poptContext con, const char *arg, const void *data) { const char *pname; + struct loadparm_context *lp_ctx = global_loadparm; /* FIXME: allow overriding */ if (reason == POPT_CALLBACK_REASON_POST) { if (!lp_loaded()) { @@ -81,7 +82,7 @@ static void popt_common_callback(poptContext con, switch(opt->val) { case 'd': - lp_set_cmdline(global_loadparm, "log level", arg); + lp_set_cmdline(lp_ctx, "log level", arg); break; case OPT_DEBUG_STDERR: @@ -94,7 +95,7 @@ static void popt_common_callback(poptContext con, case 'O': if (arg) { - lp_set_cmdline(global_loadparm, "socket options", arg); + lp_set_cmdline(lp_ctx, "socket options", arg); } break; @@ -107,37 +108,37 @@ static void popt_common_callback(poptContext con, case 'l': if (arg) { char *new_logfile = talloc_asprintf(NULL, "%s/log.%s", arg, pname); - lp_set_cmdline(global_loadparm, "log file", new_logfile); + lp_set_cmdline(lp_ctx, "log file", new_logfile); talloc_free(new_logfile); } break; case 'W': - lp_set_cmdline(global_loadparm, "workgroup", arg); + lp_set_cmdline(lp_ctx, "workgroup", arg); break; case 'r': - lp_set_cmdline(global_loadparm, "realm", arg); + lp_set_cmdline(lp_ctx, "realm", arg); break; case 'n': - lp_set_cmdline(global_loadparm, "netbios name", arg); + lp_set_cmdline(lp_ctx, "netbios name", arg); break; case 'i': - lp_set_cmdline(global_loadparm, "netbios scope", arg); + lp_set_cmdline(lp_ctx, "netbios scope", arg); break; case 'm': - lp_set_cmdline(global_loadparm, "client max protocol", arg); + lp_set_cmdline(lp_ctx, "client max protocol", arg); break; case 'R': - lp_set_cmdline(global_loadparm, "name resolve order", arg); + lp_set_cmdline(lp_ctx, "name resolve order", arg); break; case OPT_OPTION: - if (!lp_set_option(global_loadparm, arg)) { + if (!lp_set_option(lp_ctx, arg)) { fprintf(stderr, "Error setting option '%s'\n", arg); exit(1); } -- cgit From b038240ac72fa34a132eb52bda28bbb80f82c29e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 4 Dec 2007 00:12:13 +0100 Subject: r26275: return loadparm context in lp_load. (This used to be commit d01f0f4c2037b531b3fd088060717f90e60471e9) --- source4/lib/cmdline/popt_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 1c96bf64cf..1eeb611256 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -52,9 +52,9 @@ static void popt_common_callback(poptContext con, if (reason == POPT_CALLBACK_REASON_POST) { if (!lp_loaded()) { if (getenv("SMB_CONF_PATH")) - lp_load(getenv("SMB_CONF_PATH")); + lp_load(getenv("SMB_CONF_PATH"), NULL); else - lp_load(dyn_CONFIGFILE); + lp_load(dyn_CONFIGFILE, NULL); } /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ @@ -101,7 +101,7 @@ static void popt_common_callback(poptContext con, case 's': if (arg) { - lp_load(arg); + lp_load(arg, NULL); } break; -- cgit From fd1870e4f7370a184850e35a3d83157c664a79de Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 6 Dec 2007 16:01:15 +0100 Subject: r26308: Split up big popt common callback function. (This used to be commit bd2d6e0595c7ef897bbc6fdea50b96a7c1b94031) --- source4/lib/cmdline/popt_common.c | 83 ++++++++++++++++++++++++++------------- 1 file changed, 56 insertions(+), 27 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 1eeb611256..b95dfdebc4 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -41,7 +41,19 @@ enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL,OPT_DEBUG_STDERR}; struct cli_credentials *cmdline_credentials = NULL; -static void popt_common_callback(poptContext con, +static void popt_version_callback(poptContext con, + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, const void *data) +{ + switch(opt->val) { + case 'V': + printf("Version %s\n", SAMBA_VERSION_STRING ); + exit(0); + } +} + +static void popt_samba_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data) @@ -70,6 +82,7 @@ static void popt_common_callback(poptContext con, pname++; if (reason == POPT_CALLBACK_REASON_PRE) { + /* Hook for 'almost the first thing to do in a samba program' here */ /* setup for panics */ fault_setup(poptGetInvocationName(con)); @@ -81,6 +94,22 @@ static void popt_common_callback(poptContext con, } switch(opt->val) { + + case OPT_LEAK_REPORT: + talloc_enable_leak_report(); + break; + + case OPT_LEAK_REPORT_FULL: + talloc_enable_leak_report_full(); + break; + + case OPT_OPTION: + if (!lp_set_option(lp_ctx, arg)) { + fprintf(stderr, "Error setting option '%s'\n", arg); + exit(1); + } + break; + case 'd': lp_set_cmdline(lp_ctx, "log level", arg); break; @@ -89,16 +118,6 @@ static void popt_common_callback(poptContext con, setup_logging(pname, DEBUG_STDERR); break; - case 'V': - printf("Version %s\n", SAMBA_VERSION_STRING ); - exit(0); - - case 'O': - if (arg) { - lp_set_cmdline(lp_ctx, "socket options", arg); - } - break; - case 's': if (arg) { lp_load(arg, NULL); @@ -112,7 +131,27 @@ static void popt_common_callback(poptContext con, talloc_free(new_logfile); } break; - + + + } + +} + + +static void popt_common_callback(poptContext con, + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, const void *data) +{ + struct loadparm_context *lp_ctx = global_loadparm; /* FIXME: allow overriding */ + + switch(opt->val) { + case 'O': + if (arg) { + lp_set_cmdline(lp_ctx, "socket options", arg); + } + break; + case 'W': lp_set_cmdline(lp_ctx, "workgroup", arg); break; @@ -137,19 +176,8 @@ static void popt_common_callback(poptContext con, lp_set_cmdline(lp_ctx, "name resolve order", arg); break; - case OPT_OPTION: - if (!lp_set_option(lp_ctx, arg)) { - fprintf(stderr, "Error setting option '%s'\n", arg); - exit(1); - } - break; - - case OPT_LEAK_REPORT: - talloc_enable_leak_report(); - break; - - case OPT_LEAK_REPORT_FULL: - talloc_enable_leak_report_full(); + case 'S': + lp_set_cmdline(lp_ctx, "client signing", arg); break; } @@ -160,6 +188,7 @@ struct poptOption popt_common_connection[] = { { "name-resolve", 'R', POPT_ARG_STRING, NULL, 'R', "Use these name resolution services only", "NAME-RESOLVE-ORDER" }, { "socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use", "SOCKETOPTIONS" }, { "netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name", "NETBIOSNAME" }, + { "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" }, { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, { "realm", 0, POPT_ARG_STRING, NULL, 'r', "Set the realm name", "REALM" }, { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" }, @@ -168,7 +197,7 @@ struct poptOption popt_common_connection[] = { }; struct poptOption popt_common_samba[] = { - { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, (void *)popt_common_callback }, + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, (void *)popt_samba_callback }, { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, { "debug-stderr", 0, POPT_ARG_NONE, NULL, OPT_DEBUG_STDERR, "Send debug output to STDERR", NULL }, { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, @@ -180,7 +209,7 @@ struct poptOption popt_common_samba[] = { }; struct poptOption popt_common_version[] = { - { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_POST, (void *)popt_common_callback }, + { NULL, 0, POPT_ARG_CALLBACK, (void *)popt_version_callback }, { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, { NULL } }; -- cgit From a48fdda5fec99649e29760c7a9c91246438c9579 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Dec 2007 23:31:41 +0100 Subject: r26339: Make loadparm talloc-allocated. (This used to be commit 1e02cd8db1d65ff72b747833904a10b47749b1fb) --- source4/lib/cmdline/popt_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index b95dfdebc4..aae22e00c3 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -64,9 +64,9 @@ static void popt_samba_callback(poptContext con, if (reason == POPT_CALLBACK_REASON_POST) { if (!lp_loaded()) { if (getenv("SMB_CONF_PATH")) - lp_load(getenv("SMB_CONF_PATH"), NULL); + lp_load(talloc_autofree_context(), getenv("SMB_CONF_PATH"), NULL); else - lp_load(dyn_CONFIGFILE, NULL); + lp_load(talloc_autofree_context(), dyn_CONFIGFILE, NULL); } /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ @@ -120,7 +120,7 @@ static void popt_samba_callback(poptContext con, case 's': if (arg) { - lp_load(arg, NULL); + lp_load(talloc_autofree_context(), arg, NULL); } break; -- cgit From 5c6eacdb04cd18d96dc6313c2a6f934925967e79 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Dec 2007 23:32:27 +0100 Subject: r26350: More tests. (This used to be commit 87799f55d5d85bf9a15a9637143faa32183b181b) --- source4/lib/cmdline/popt_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index aae22e00c3..2bbb59dbda 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -62,11 +62,11 @@ static void popt_samba_callback(poptContext con, struct loadparm_context *lp_ctx = global_loadparm; /* FIXME: allow overriding */ if (reason == POPT_CALLBACK_REASON_POST) { - if (!lp_loaded()) { + if (lp_ctx == NULL) { if (getenv("SMB_CONF_PATH")) - lp_load(talloc_autofree_context(), getenv("SMB_CONF_PATH"), NULL); + lp_load(talloc_autofree_context(), getenv("SMB_CONF_PATH"), &lp_ctx); else - lp_load(talloc_autofree_context(), dyn_CONFIGFILE, NULL); + lp_load(talloc_autofree_context(), dyn_CONFIGFILE, &lp_ctx); } /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ -- cgit From dd7e5ed88c48f4ee39e53be07c8839791e914e45 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Dec 2007 23:32:37 +0100 Subject: r26352: Don't make lp_load create a new context. (This used to be commit d0d5c1a823a6601292c061dba2b6f4bde2b9e3dd) --- source4/lib/cmdline/popt_common.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 2bbb59dbda..73b3eecfbf 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -40,6 +40,7 @@ enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL,OPT_DEBUG_STDERR}; struct cli_credentials *cmdline_credentials = NULL; +struct loadparm_context *cmdline_lp_ctx = NULL; static void popt_version_callback(poptContext con, enum poptCallbackReason reason, @@ -59,14 +60,13 @@ static void popt_samba_callback(poptContext con, const char *arg, const void *data) { const char *pname; - struct loadparm_context *lp_ctx = global_loadparm; /* FIXME: allow overriding */ if (reason == POPT_CALLBACK_REASON_POST) { - if (lp_ctx == NULL) { + if (lp_configfile(cmdline_lp_ctx) == NULL) { if (getenv("SMB_CONF_PATH")) - lp_load(talloc_autofree_context(), getenv("SMB_CONF_PATH"), &lp_ctx); + lp_load(cmdline_lp_ctx, getenv("SMB_CONF_PATH")); else - lp_load(talloc_autofree_context(), dyn_CONFIGFILE, &lp_ctx); + lp_load(cmdline_lp_ctx, dyn_CONFIGFILE); } /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ @@ -82,6 +82,11 @@ static void popt_samba_callback(poptContext con, pname++; if (reason == POPT_CALLBACK_REASON_PRE) { + if (global_loadparm != NULL) { + cmdline_lp_ctx = global_loadparm; + } else { + cmdline_lp_ctx = global_loadparm = loadparm_init(talloc_autofree_context()); + } /* Hook for 'almost the first thing to do in a samba program' here */ /* setup for panics */ @@ -104,14 +109,14 @@ static void popt_samba_callback(poptContext con, break; case OPT_OPTION: - if (!lp_set_option(lp_ctx, arg)) { + if (!lp_set_option(cmdline_lp_ctx, arg)) { fprintf(stderr, "Error setting option '%s'\n", arg); exit(1); } break; case 'd': - lp_set_cmdline(lp_ctx, "log level", arg); + lp_set_cmdline(cmdline_lp_ctx, "log level", arg); break; case OPT_DEBUG_STDERR: @@ -120,14 +125,14 @@ static void popt_samba_callback(poptContext con, case 's': if (arg) { - lp_load(talloc_autofree_context(), arg, NULL); + lp_load(cmdline_lp_ctx, arg); } break; case 'l': if (arg) { char *new_logfile = talloc_asprintf(NULL, "%s/log.%s", arg, pname); - lp_set_cmdline(lp_ctx, "log file", new_logfile); + lp_set_cmdline(cmdline_lp_ctx, "log file", new_logfile); talloc_free(new_logfile); } break; @@ -143,7 +148,7 @@ static void popt_common_callback(poptContext con, const struct poptOption *opt, const char *arg, const void *data) { - struct loadparm_context *lp_ctx = global_loadparm; /* FIXME: allow overriding */ + struct loadparm_context *lp_ctx = cmdline_lp_ctx; switch(opt->val) { case 'O': -- cgit From 936b973acbc756cc3b6cb0d9df85ebc28ba76ae7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 May 2008 14:36:28 +0200 Subject: Use new dynconfig.h location. (This used to be commit c3f556915f09d078253e4c5539910a1cf420eeca) --- source4/lib/cmdline/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/cmdline/popt_common.c') diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 73b3eecfbf..96d8b8b40a 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -23,7 +23,7 @@ #include "version.h" #include "lib/cmdline/popt_common.h" #include "param/param.h" -#include "dynconfig.h" +#include "dynconfig/dynconfig.h" /* Handle command line options: * -d,--debuglevel -- cgit