summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2001-10-27 04:48:22 +0000
committerTim Potter <tpot@samba.org>2001-10-27 04:48:22 +0000
commitb267dc04e6b81bd605c4236031ede391400e6cdf (patch)
tree53ce2f59dfb00884e715387c6eab8da978b290d7 /source3/nsswitch
parentd148a15c6cffb25dd880f7d300a9efd8754164b8 (diff)
downloadsamba-b267dc04e6b81bd605c4236031ede391400e6cdf.tar.gz
samba-b267dc04e6b81bd605c4236031ede391400e6cdf.tar.bz2
samba-b267dc04e6b81bd605c4236031ede391400e6cdf.zip
Added some connection checking code. Doesn't work yet though.
(This used to be commit 4f4dace5772780cf4eedc0ebca1c60d04171eb74)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/winbindd_cm.c53
1 files changed, 43 insertions, 10 deletions
diff --git a/source3/nsswitch/winbindd_cm.c b/source3/nsswitch/winbindd_cm.c
index b6c72e8b8e..45a0993551 100644
--- a/source3/nsswitch/winbindd_cm.c
+++ b/source3/nsswitch/winbindd_cm.c
@@ -180,6 +180,19 @@ static BOOL cm_open_connection(char *domain, char *pipe_name,
return result;
}
+/* Return true if a connection is still alive */
+
+static BOOL connection_ok(struct winbindd_cm_conn *conn)
+{
+ if (!conn->cli->initialised)
+ return False;
+
+ if (!conn->cli->fd == -1)
+ return False;
+
+ return True;
+}
+
/* Return a LSA policy handle on a domain */
CLI_POLICY_HND *cm_get_lsa_handle(char *domain)
@@ -193,8 +206,13 @@ CLI_POLICY_HND *cm_get_lsa_handle(char *domain)
for (conn = cm_conns; conn; conn = conn->next) {
if (strequal(conn->domain, domain) &&
- strequal(conn->pipe_name, PIPE_LSARPC))
+ strequal(conn->pipe_name, PIPE_LSARPC)) {
+
+ if (!connection_ok(conn))
+ return NULL;
+
goto ok;
+ }
}
/* Create a new one */
@@ -242,8 +260,13 @@ CLI_POLICY_HND *cm_get_sam_handle(char *domain)
for (conn = cm_conns; conn; conn = conn->next) {
if (strequal(conn->domain, domain) &&
strequal(conn->pipe_name, PIPE_SAMR) &&
- conn->sam_pipe_type == SAM_PIPE_BASIC)
+ conn->sam_pipe_type == SAM_PIPE_BASIC) {
+
+ if (!connection_ok(conn))
+ return NULL;
+
goto ok;
+ }
}
/* Create a new one */
@@ -291,8 +314,13 @@ CLI_POLICY_HND *cm_get_sam_dom_handle(char *domain, DOM_SID *domain_sid)
for (conn = cm_conns; conn; conn = conn->next) {
if (strequal(conn->domain, domain) &&
strequal(conn->pipe_name, PIPE_SAMR) &&
- conn->sam_pipe_type == SAM_PIPE_DOM)
+ conn->sam_pipe_type == SAM_PIPE_DOM) {
+
+ if (!connection_ok(conn))
+ return NULL;
+
goto ok;
+ }
}
/* Create a basic handle to open a domain handle from */
@@ -307,11 +335,6 @@ CLI_POLICY_HND *cm_get_sam_dom_handle(char *domain, DOM_SID *domain_sid)
basic_conn = conn;
}
- if (!basic_conn) {
- DEBUG(0, ("No basic sam handle was created!\n"));
- return NULL;
-
- }
if (!(conn = (struct winbindd_cm_conn *)
malloc(sizeof(struct winbindd_cm_conn))))
return NULL;
@@ -359,8 +382,13 @@ CLI_POLICY_HND *cm_get_sam_user_handle(char *domain, DOM_SID *domain_sid,
if (strequal(conn->domain, domain) &&
strequal(conn->pipe_name, PIPE_SAMR) &&
conn->sam_pipe_type == SAM_PIPE_USER &&
- conn->user_rid == user_rid)
+ conn->user_rid == user_rid) {
+
+ if (!connection_ok(conn))
+ return NULL;
+
goto ok;
+ }
}
/* Create a domain handle to open a user handle from */
@@ -428,8 +456,13 @@ CLI_POLICY_HND *cm_get_sam_group_handle(char *domain, DOM_SID *domain_sid,
if (strequal(conn->domain, domain) &&
strequal(conn->pipe_name, PIPE_SAMR) &&
conn->sam_pipe_type == SAM_PIPE_GROUP &&
- conn->group_rid == group_rid)
+ conn->group_rid == group_rid) {
+
+ if (!connection_ok(conn))
+ return NULL;
+
goto ok;
+ }
}
/* Create a domain handle to open a user handle from */