mirror of
https://github.com/samba-team/samba.git
synced 2025-02-23 09:57:40 +03:00
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)
This commit is contained in:
parent
238a7e2f4c
commit
2f5f01567b
@ -894,9 +894,9 @@ static void parse_mount_smb(int argc, char **argv)
|
||||
pstrcpy(username,getenv("LOGNAME"));
|
||||
}
|
||||
|
||||
if (!lp_load(dyn_CONFIGFILE)) {
|
||||
if (!lp_load()) {
|
||||
fprintf(stderr, "Can't load %s - run testparm to debug it\n",
|
||||
dyn_CONFIGFILE);
|
||||
lp_config_file());
|
||||
}
|
||||
|
||||
parse_mount_smb(argc, argv);
|
||||
|
@ -177,10 +177,9 @@ static int smb_print(struct smbcli_state *, char *, FILE *);
|
||||
|
||||
setup_logging("smbspool", DEBUG_STDOUT);
|
||||
|
||||
if (!lp_load(dyn_CONFIGFILE))
|
||||
{
|
||||
fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE);
|
||||
return (1);
|
||||
if (!lp_load()) {
|
||||
fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", lp_config_file());
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (workgroup == NULL)
|
||||
|
@ -463,7 +463,7 @@ static GtkWidget* create_mainwindow (void)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
gepdump_init_subsystems;
|
||||
lp_load(dyn_CONFIGFILE);
|
||||
lp_load();
|
||||
load_interfaces();
|
||||
setup_logging(argv[0], DEBUG_STDERR);
|
||||
|
||||
|
@ -977,7 +977,7 @@ int main(int argc, char *argv[])
|
||||
int ret;
|
||||
|
||||
gregedit_init_subsystems;
|
||||
lp_load(dyn_CONFIGFILE);
|
||||
lp_load();
|
||||
load_interfaces();
|
||||
setup_logging(argv[0], DEBUG_STDERR);
|
||||
|
||||
|
@ -495,7 +495,7 @@ static GtkWidget*create_new_job_dialog (void)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
gwcrontab_init_subsystems;
|
||||
lp_load(dyn_CONFIGFILE);
|
||||
lp_load();
|
||||
load_interfaces();
|
||||
setup_logging(argv[0], DEBUG_STDERR);
|
||||
|
||||
|
@ -403,7 +403,7 @@ static GtkWidget* create_mainwindow (void)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
gwsam_init_subsystems;
|
||||
lp_load(dyn_CONFIGFILE);
|
||||
lp_load();
|
||||
load_interfaces();
|
||||
setup_logging(argv[0], DEBUG_STDERR);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -910,6 +910,8 @@ static void init_globals(void)
|
||||
}
|
||||
}
|
||||
|
||||
do_parameter("config file", dyn_CONFIGFILE);
|
||||
|
||||
/* options that can be set on the command line must be initialised via
|
||||
the slower do_parameter() to ensure that FLAG_CMDLINE is obeyed */
|
||||
#ifdef TCP_NODELAY
|
||||
@ -2985,21 +2987,14 @@ static void set_server_role(void)
|
||||
False on failure.
|
||||
***************************************************************************/
|
||||
|
||||
BOOL lp_load(const char *pszFname)
|
||||
BOOL lp_load(void)
|
||||
{
|
||||
pstring n2;
|
||||
BOOL bRetval;
|
||||
struct param_opt *data;
|
||||
|
||||
pstrcpy(n2, pszFname);
|
||||
standard_sub_basic(n2,sizeof(n2));
|
||||
|
||||
add_to_file_list(pszFname, n2);
|
||||
|
||||
bRetval = False;
|
||||
|
||||
DEBUG(2, ("lp_load: refreshing parameters from %s\n", pszFname));
|
||||
|
||||
bInGlobalSection = True;
|
||||
|
||||
if (Globals.param_opt != NULL) {
|
||||
@ -3016,6 +3011,12 @@ BOOL lp_load(const char *pszFname)
|
||||
|
||||
init_globals();
|
||||
|
||||
pstrcpy(n2, lp_configfile());
|
||||
standard_sub_basic(n2,sizeof(n2));
|
||||
DEBUG(2, ("lp_load: refreshing parameters from %s\n", n2));
|
||||
|
||||
add_to_file_list(lp_configfile(), n2);
|
||||
|
||||
/* We get sections first, so have to start 'behind' to make up */
|
||||
iServiceIndex = -1;
|
||||
bRetval = pm_process(n2, do_section, do_parameter);
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "scripting/ejs/smbcalls.h"
|
||||
#include "lib/appweb/ejs/ejs.h"
|
||||
#include "param/loadparm.h"
|
||||
#include "dynconfig.h"
|
||||
|
||||
/*
|
||||
return a list of defined services
|
||||
@ -48,10 +49,10 @@ static int ejs_lpServices(MprVarHandle eid, int argc, char **argv)
|
||||
|
||||
can be called in 4 ways:
|
||||
|
||||
v = lpGet("type:parm"); gets a parametric variable
|
||||
v = lpGet("share", "type:parm"); gets a parametric variable on a share
|
||||
v = lpGet("parm"); gets a global variable
|
||||
v = lpGet("share", "parm"); gets a share variable
|
||||
v = lp.get("type:parm"); gets a parametric variable
|
||||
v = lp.get("share", "type:parm"); gets a parametric variable on a share
|
||||
v = lp.get("parm"); gets a global variable
|
||||
v = lp.get("share", "parm"); gets a share variable
|
||||
|
||||
the returned variable is a ejs object. It is an array object for lists.
|
||||
*/
|
||||
@ -139,6 +140,40 @@ static int ejs_lpGet(MprVarHandle eid, int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
set a smb.conf parameter. Only sets in memory, not permanent
|
||||
|
||||
can be called in 4 ways:
|
||||
|
||||
ok = lp.set("parm", "value");
|
||||
*/
|
||||
static int ejs_lpSet(MprVarHandle eid, int argc, char **argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
ejsSetErrorMsg(eid, "lp.set invalid arguments");
|
||||
return -1;
|
||||
}
|
||||
|
||||
mpr_Return(eid, mprCreateBoolVar(lp_set_cmdline(argv[0], argv[1])));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
reload smb.conf
|
||||
|
||||
ok = lp.reload();
|
||||
*/
|
||||
static int ejs_lpReload(MprVarHandle eid, int argc, char **argv)
|
||||
{
|
||||
BOOL ret = lp_load();
|
||||
if (ret) {
|
||||
load_interfaces();
|
||||
}
|
||||
mpr_Return(eid, mprCreateBoolVar(ret));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
initialise loadparm ejs subsystem
|
||||
*/
|
||||
@ -147,6 +182,8 @@ static int ejs_loadparm_init(MprVarHandle eid, int argc, struct MprVar **argv)
|
||||
struct MprVar *obj = mprInitObject(eid, "loadparm", argc, argv);
|
||||
|
||||
mprSetStringCFunction(obj, "get", ejs_lpGet);
|
||||
mprSetStringCFunction(obj, "set", ejs_lpSet);
|
||||
mprSetStringCFunction(obj, "reload", ejs_lpReload);
|
||||
mprSetStringCFunction(obj, "services", ejs_lpServices);
|
||||
return 0;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ void ejs_exception(const char *reason)
|
||||
smbscript_init_subsystems;
|
||||
mprSetCtx(mem_ctx);
|
||||
|
||||
lp_load(dyn_CONFIGFILE);
|
||||
lp_load();
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "You must supply a script name\n");
|
||||
|
@ -169,7 +169,7 @@ function setup_ldb(ldif, dbname, subobj)
|
||||
function setup_file(template, fname, subobj)
|
||||
{
|
||||
var lp = loadparm_init();
|
||||
var f = lp.get("private dir") + "/" + fname;
|
||||
var f = fname;
|
||||
var src = lp.get("setup directory") + "/" + template;
|
||||
|
||||
sys.unlink(f);
|
||||
@ -187,6 +187,9 @@ function setup_file(template, fname, subobj)
|
||||
function provision(subobj, message)
|
||||
{
|
||||
var data = "";
|
||||
var lp = loadparm_init();
|
||||
var sys = sys_init();
|
||||
var smbconf = lp.get("config file");
|
||||
|
||||
/*
|
||||
some options need to be upper/lower case
|
||||
@ -204,6 +207,13 @@ function provision(subobj, message)
|
||||
|
||||
provision_next_usn = 1;
|
||||
|
||||
/* only install a new smb.conf if there isn't one there already */
|
||||
var st = sys.stat(smbconf);
|
||||
if (st == undefined) {
|
||||
message("Setting up smb.conf\n");
|
||||
setup_file("provision.smb.conf", smbconf, subobj);
|
||||
lp.reload();
|
||||
}
|
||||
message("Setting up hklm.ldb\n");
|
||||
setup_ldb("hklm.ldif", "hklm.ldb", subobj);
|
||||
message("Setting up sam.ldb\n");
|
||||
@ -213,7 +223,9 @@ function provision(subobj, message)
|
||||
message("Setting up secrets.ldb\n");
|
||||
setup_ldb("secrets.ldif", "secrets.ldb", subobj);
|
||||
message("Setting up DNS zone file\n");
|
||||
setup_file("provision.zone", subobj.DNSDOMAIN + ".zone", subobj);
|
||||
setup_file("provision.zone",
|
||||
lp.get("private dir") + "/" + subobj.DNSDOMAIN + ".zone",
|
||||
subobj);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -229,6 +241,11 @@ function provision_guess()
|
||||
subobj.REALM = lp.get("realm");
|
||||
subobj.DOMAIN = lp.get("workgroup");
|
||||
subobj.HOSTNAME = hostname();
|
||||
|
||||
assert(subobj.REALM);
|
||||
assert(subobj.DOMAIN);
|
||||
assert(subobj.HOSTNAME);
|
||||
|
||||
subobj.HOSTIP = hostip();
|
||||
subobj.DOMAINGUID = randguid();
|
||||
subobj.DOMAINSID = randsid();
|
||||
|
@ -92,6 +92,12 @@ if (options["realm"] == undefined ||
|
||||
ShowHelp();
|
||||
}
|
||||
|
||||
/* cope with an initially blank smb.conf */
|
||||
var lp = loadparm_init();
|
||||
lp.set("realm", options.realm);
|
||||
lp.set("workgroup", options.domain);
|
||||
lp.reload();
|
||||
|
||||
var subobj = provision_guess();
|
||||
for (r in options) {
|
||||
var key = strupper(join("", split("-", r)));
|
||||
|
@ -2127,7 +2127,7 @@ static void usage(void)
|
||||
argc -= NSERVERS;
|
||||
argv += NSERVERS;
|
||||
|
||||
lp_load(dyn_CONFIGFILE);
|
||||
lp_load();
|
||||
load_interfaces();
|
||||
|
||||
servers[0].credentials = cli_credentials_init(talloc_autofree_context());
|
||||
|
@ -476,7 +476,7 @@ static void usage(void)
|
||||
argc -= NSERVERS;
|
||||
argv += NSERVERS;
|
||||
|
||||
lp_load(dyn_CONFIGFILE);
|
||||
lp_load();
|
||||
load_interfaces();
|
||||
|
||||
servers[0] = cli_credentials_init(talloc_autofree_context());
|
||||
|
@ -484,7 +484,7 @@ static void usage(void)
|
||||
argc -= 4;
|
||||
argv += 4;
|
||||
|
||||
lp_load(dyn_CONFIGFILE);
|
||||
lp_load();
|
||||
load_interfaces();
|
||||
|
||||
if (getenv("USER")) {
|
||||
|
@ -296,7 +296,7 @@ static void usage(void)
|
||||
argc -= 1;
|
||||
argv += 1;
|
||||
|
||||
lp_load(dyn_CONFIGFILE);
|
||||
lp_load();
|
||||
load_interfaces();
|
||||
|
||||
credentials = cli_credentials_init(talloc_autofree_context());
|
||||
|
@ -41,7 +41,7 @@ void pong_message(int msg_type, pid_t src, void *buf, size_t len)
|
||||
|
||||
setup_logging(argv[0], DEBUG_STDOUT);
|
||||
|
||||
lp_load(dyn_CONFIGFILE);
|
||||
lp_load();
|
||||
|
||||
message_init();
|
||||
|
||||
|
@ -8,7 +8,15 @@
|
||||
|
||||
<%
|
||||
var f = FormObj("Provisioning", 9, 2);
|
||||
var i, subobj = provision_guess();
|
||||
var i;
|
||||
var lp = loadparm_init();
|
||||
|
||||
if (lp.get("realm") == "") {
|
||||
lp.set("realm", lp.get("workgroup") + ".example.com");
|
||||
}
|
||||
|
||||
|
||||
var subobj = provision_guess();
|
||||
|
||||
f.element[0].label = "Realm";
|
||||
f.element[0].name = "REALM";
|
||||
@ -44,6 +52,9 @@ if (form['submit'] == "Provision") {
|
||||
for (i=0;i<f.element.length;i++) {
|
||||
f.element[i].value = subobj[f.element[i].name];
|
||||
}
|
||||
|
||||
lp.set("realm", subobj.REALM);
|
||||
|
||||
if (form['submit'] == "Provision") {
|
||||
provision(subobj, writefln);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user