summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-05-26 05:12:31 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-05-26 05:12:31 +0200
commit575f1243856f52f87ccb09f1235f1263b7c54b9b (patch)
treef0470a71393c3a3416de934f3e3daa6fd48a94f6
parent4b3641695ba42d0348e8eceadb02430342c1513c (diff)
downloadsamba-575f1243856f52f87ccb09f1235f1263b7c54b9b.tar.gz
samba-575f1243856f52f87ccb09f1235f1263b7c54b9b.tar.bz2
samba-575f1243856f52f87ccb09f1235f1263b7c54b9b.zip
Cope with no server being active.
(This used to be commit 893119bb4c9c297966d43d37fe73faa747b7c86e)
-rwxr-xr-xsource4/scripting/bin/smbstatus12
-rw-r--r--source4/smb_server/smb_server.c4
2 files changed, 11 insertions, 5 deletions
diff --git a/source4/scripting/bin/smbstatus b/source4/scripting/bin/smbstatus
index 7e58ee1269..bbd0e84826 100755
--- a/source4/scripting/bin/smbstatus
+++ b/source4/scripting/bin/smbstatus
@@ -19,7 +19,7 @@ from samba import irpc, messaging
def show_sessions(conn):
"""show open sessions"""
- conn = open_connection("smb_server")
+
sessions = conn.smbsrv_information(irpc.SMBSRV_INFO_SESSIONS).next()
print "User Client Connected at"
print "-------------------------------------------------------------------------------"
@@ -73,5 +73,11 @@ def open_connection(name):
if opts.nbt:
show_nbt(open_connection)
else:
- show_sessions(open_connection)
- show_tcons(open_connection)
+ try:
+ conn = open_connection("smb_server")
+ except RuntimeError, (num, msg):
+ if msg == 'NT_STATUS_OBJECT_NAME_NOT_FOUND':
+ print "No active connections"
+ else:
+ show_sessions(conn)
+ show_tcons(conn)
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index 367557dbb7..6eccb836d6 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -150,12 +150,12 @@ static void smbsrv_accept(struct stream_connection *conn)
smb_conn->connection = conn;
conn->private = smb_conn;
- irpc_add_name(conn->msg_ctx, "smb_server");
-
smb_conn->statistics.connect_time = timeval_current();
smbsrv_management_init(smb_conn);
+ irpc_add_name(conn->msg_ctx, "smb_server");
+
if (!NT_STATUS_IS_OK(share_get_context_by_name(smb_conn, lp_share_backend(smb_conn->lp_ctx),
smb_conn->connection->event.ctx,
smb_conn->lp_ctx, &(smb_conn->share_context)))) {