From f2570b3bdd0285ef8e7eeee935c6001c592cd774 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 15 Nov 2004 21:25:40 +0000 Subject: r3773: more low-risk or critical changes from 3.0 (also started updating release notes): svn merge -r 3559:3561 $SVNURL/branches/SAMBA_3_0 svn merge -r 3559:3561 $SVNURL/branches/SAMBA_3_0 svn merge -r 3685:3688 $SVNURL/branches/SAMBA_3_0 svn merge -r 3688:3693 $SVNURL/branches/SAMBA_3_0 svn merge -r 3693:3697 $SVNURL/branches/SAMBA_3_0 svn merge -r 3708:3709 $SVNURL/branches/SAMBA_3_0 svn merge -r 3709:3710 $SVNURL/branches/SAMBA_3_0 svn merge -r 3710:3711 $SVNURL/branches/SAMBA_3_0 svn merge -r 3758:3761 $SVNURL/branches/SAMBA_3_0 svn merge -r 3761:3764 $SVNURL/branches/SAMBA_3_0 svn merge -r 3771:3772 $SVNURL/branches/SAMBA_3_0 --- source/utils/net.c | 10 ++++++- source/utils/status.c | 81 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 59 insertions(+), 32 deletions(-) (limited to 'source/utils') diff --git a/source/utils/net.c b/source/utils/net.c index 2fe15c2b8ef..784612fc71b 100644 --- a/source/utils/net.c +++ b/source/utils/net.c @@ -479,11 +479,19 @@ static int net_getlocalsid(int argc, const char **argv) "backend knowlege (such as the sid stored in LDAP)\n")); } + /* first check to see if we can even access secrets, so we don't + panic when we can't. */ + + if (!secrets_init()) { + d_printf("Unable to open secrets.tdb. Can't fetch domain SID for name: %s\n", name); + return 1; + } + /* Generate one, if it doesn't exist */ get_global_sam_sid(); if (!secrets_fetch_domain_sid(name, &sid)) { - DEBUG(0, ("Can't fetch domain SID for name: %s\n", name)); + DEBUG(0, ("Can't fetch domain SID for name: %s\n", name)); return 1; } sid_to_string(sid_str, &sid); diff --git a/source/utils/status.c b/source/utils/status.c index 4585b101b28..122c6193f91 100644 --- a/source/utils/status.c +++ b/source/utils/status.c @@ -47,6 +47,8 @@ static int locks_only = 0; /* Added by RJS */ static BOOL processes_only=False; static int show_brl; +const char *username = NULL; + /* added by OH */ static void Ucrit_addUsername(const char *username) { @@ -578,6 +580,7 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo int c; static int profile_only = 0; TDB_CONTEXT *tdb; + BOOL show_processes, show_locks, show_shares; poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP @@ -585,7 +588,7 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo {"verbose", 'v', POPT_ARG_NONE, &verbose, 'v', "Be verbose" }, {"locks", 'L', POPT_ARG_NONE, &locks_only, 'L', "Show locks only" }, {"shares", 'S', POPT_ARG_NONE, &shares_only, 'S', "Show shares only" }, - {"user", 'u', POPT_ARG_STRING, 0, 'u', "Switch to user" }, + {"user", 'u', POPT_ARG_STRING, &username, 'u', "Switch to user" }, {"brief", 'b', POPT_ARG_NONE, &brief, 'b', "Be brief" }, #ifdef WITH_PROFILE {"profile", 'P', POPT_ARG_NONE, &profile_only, 'P', "Do profiling" }, @@ -615,6 +618,15 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo } } + /* setup the flags based on the possible combincations */ + + show_processes = !(shares_only || locks_only || profile_only) || processes_only; + show_locks = !(shares_only || processes_only || profile_only) || locks_only; + show_shares = !(processes_only || locks_only || profile_only) || shares_only; + + if ( username ) + Ucrit_addUsername( username ); + if (verbose) { d_printf("using configfile = %s\n", dyn_CONFIGFILE); } @@ -628,43 +640,50 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo return profile_dump(); } - tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0); - if (!tdb) { - d_printf("sessionid.tdb not initialised\n"); - } else { - if (locks_only) goto locks; - - d_printf("\nSamba version %s\n",SAMBA_VERSION_STRING); - d_printf("PID Username Group Machine \n"); - d_printf("-------------------------------------------------------------------\n"); - - tdb_traverse(tdb, traverse_sessionid, NULL); - tdb_close(tdb); + if ( show_processes ) { + tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0); + if (!tdb) { + d_printf("sessionid.tdb not initialised\n"); + } else { + d_printf("\nSamba version %s\n",SAMBA_VERSION_STRING); + d_printf("PID Username Group Machine \n"); + d_printf("-------------------------------------------------------------------\n"); + + tdb_traverse(tdb, traverse_sessionid, NULL); + tdb_close(tdb); + } + + if (processes_only) + exit(0); } - tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0); - if (!tdb) { - d_printf("%s not initialised\n", lock_path("connections.tdb")); - d_printf("This is normal if an SMB client has never connected to your server.\n"); - } else { - if (verbose) { - d_printf("Opened %s\n", lock_path("connections.tdb")); + if ( show_shares ) { + tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0); + if (!tdb) { + d_printf("%s not initialised\n", lock_path("connections.tdb")); + d_printf("This is normal if an SMB client has never connected to your server.\n"); + } else { + if (verbose) { + d_printf("Opened %s\n", lock_path("connections.tdb")); + } + + if (brief) + exit(0); + + d_printf("\nService pid machine Connected at\n"); + d_printf("-------------------------------------------------------\n"); + + tdb_traverse(tdb, traverse_fn1, NULL); + tdb_close(tdb); + + d_printf("\n"); } - if (brief) + if ( shares_only ) exit(0); - - d_printf("\nService pid machine Connected at\n"); - d_printf("-------------------------------------------------------\n"); - - tdb_traverse(tdb, traverse_fn1, NULL); - tdb_close(tdb); } - locks: - if (processes_only) exit(0); - - if (!shares_only) { + if ( show_locks ) { int ret; if (!locking_init(1)) { -- cgit v1.2.1