From 4f4f56d147628c5569f2c2fc6aeb2e0f5eecde8b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 10 May 2002 14:40:55 +0000 Subject: Allow -c to specify the location of the config file, and fix up some handling of non-existant passdb cases. (This used to be commit e56de32f5ce5cb301137497451b0ccd633f09f54) --- source3/utils/pdbedit.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index bf52d08989..6b4cd606d0 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -182,11 +182,9 @@ static int print_users_list (struct pdb_context *in, BOOL verbosity, BOOL smbpwd SAM_ACCOUNT *sam_pwent=NULL; BOOL check, ret; - errno = 0; /* testing --simo */ check = in->pdb_setsampwent(in, False); - if (check && errno == ENOENT) { - fprintf (stderr,"Password database not found!\n"); - exit(1); + if (!check) { + return 1; } check = True; @@ -411,6 +409,7 @@ int main (int argc, char **argv) static char *backend_out = NULL; static char *logon_script = NULL; static char *profile_path = NULL; + static char *config_file = dyn_CONFIGFILE; static int new_debuglevel = -1; struct pdb_context *in; @@ -431,7 +430,8 @@ int main (int argc, char **argv) {"delete", 'x',POPT_ARG_VAL,&delete_user,1,"delete user",NULL}, {"import", 'i',POPT_ARG_STRING,&backend_in,0,"use different passdb backend",NULL}, {"export", 'e',POPT_ARG_STRING,&backend_out,0,"export user accounts to backend", NULL}, - {"debuglevel",'D',POPT_ARG_INT,&new_debuglevel,0,"set debuglevel",NULL}, + {"debuglevel",'D', POPT_ARG_INT, &new_debuglevel,0,"set debuglevel",NULL}, + {"configfile",'c',POPT_ARG_STRING, &config_file,0,"use different configuration file",NULL}, {0,0,0,0} }; @@ -439,14 +439,6 @@ int main (int argc, char **argv) setup_logging("pdbedit", True); AllowDebugChange = False; - if (!lp_load(dyn_CONFIGFILE,True,False,False)) { - fprintf(stderr, "Can't load %s - run testparm to debug it\n", - dyn_CONFIGFILE); - exit(1); - } - - backend_in = lp_passdb_backend(); - pc = poptGetContext(NULL, argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); @@ -456,6 +448,16 @@ int main (int argc, char **argv) DEBUGLEVEL = new_debuglevel; } + if (!lp_load(config_file,True,False,False)) { + fprintf(stderr, "Can't load %s - run testparm to debug it\n", + config_file); + exit(1); + } + + if (!backend_in) { + backend_in = lp_passdb_backend(); + } + setparms = (full_name || home_dir || home_drive || logon_script || profile_path); if (((add_user?1:0) + (delete_user?1:0) + (list_users?1:0) + (import?1:0) + (setparms?1:0)) + (backend_out?1:0) > 1) { -- cgit