#include "lib/util/server_id.h"
#include "smbd/globals.h"
#include "system/filesys.h"
-#include "popt_common.h"
+#include "lib/cmdline/cmdline.h"
#include "dbwrap/dbwrap.h"
#include "dbwrap/dbwrap_open.h"
#include "../libcli/security/security.h"
.descrip = "Try to resolve UIDs to usernames"
},
POPT_COMMON_SAMBA
+ POPT_COMMON_VERSION
POPT_TABLEEND
};
TALLOC_CTX *frame = talloc_stackframe();
char *db_path;
bool ok;
- sec_init();
smb_init_locale();
- setup_logging(argv[0], DEBUG_STDERR);
- lp_set_cmdline("log level", "0");
-
- if (getuid() != geteuid()) {
- d_printf("smbstatus should not be run setuid\n");
- ret = 1;
- goto done;
+ ok = samba_cmdline_init(frame,
+ SAMBA_CMDLINE_CONFIG_CLIENT,
+ false /* require_smbconf */);
+ if (!ok) {
+ DBG_ERR("Failed to init cmdline parser!\n");
+ TALLOC_FREE(frame);
+ exit(1);
}
+ lp_set_cmdline("log level", "0");
- if (getuid() != 0) {
- d_printf("smbstatus only works as root!\n");
- ret = 1;
- goto done;
+ pc = samba_popt_get_context(getprogname(),
+ argc,
+ argv,
+ long_options,
+ POPT_CONTEXT_KEEP_FIRST);
+ if (pc == NULL) {
+ DBG_ERR("Failed to setup popt context!\n");
+ TALLOC_FREE(frame);
+ exit(1);
}
-
- pc = poptGetContext(NULL, argc, argv, long_options,
- POPT_CONTEXT_KEEP_FIRST);
-
while ((c = poptGetNextOpt(pc)) != -1) {
switch (c) {
case 'p':
}
}
+ sec_init();
+
+ if (getuid() != geteuid()) {
+ d_printf("smbstatus should not be run setuid\n");
+ ret = 1;
+ goto done;
+ }
+
+ if (getuid() != 0) {
+ d_printf("smbstatus only works as root!\n");
+ ret = 1;
+ goto done;
+ }
+
/* setup the flags based on the possible combincations */
show_processes = !(shares_only || locks_only || profile_only) || processes_only;
goto done;
}
- if (!lp_load_global(get_dyn_CONFIGFILE())) {
- fprintf(stderr, "Can't load %s - run testparm to debug it\n",
- get_dyn_CONFIGFILE());
- ret = -1;
- goto done;
- }
-
switch (profile_only) {
case 'P':
/* Dump profile data */