summaryrefslogtreecommitdiff
path: root/nsswitch
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-06-05 16:39:36 +0200
committerVolker Lendecke <vl@samba.org>2011-06-12 17:07:47 +0200
commiteb16915e283879aaf0797896fc9bd96b095ff550 (patch)
tree040e3e9132743729c954d506667ec9ebfdb81e01 /nsswitch
parentd5661467e17cc233fe8605e8138991b4a459e78f (diff)
downloadsamba-eb16915e283879aaf0797896fc9bd96b095ff550.tar.gz
nsswitch: Remove some refs to the global winbindd_fd
Diffstat (limited to 'nsswitch')
-rw-r--r--nsswitch/wb_common.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/nsswitch/wb_common.c b/nsswitch/wb_common.c
index dcfc8a51568..80c729a3b6b 100644
--- a/nsswitch/wb_common.c
+++ b/nsswitch/wb_common.c
@@ -369,13 +369,14 @@ static int winbind_open_pipe_sock(int recursing, int need_priv)
static int winbind_write_sock(void *buffer, int count, int recursing,
int need_priv)
{
- int result, nwritten;
+ int fd, result, nwritten;
/* Open connection to winbind daemon */
restart:
- if (winbind_open_pipe_sock(recursing, need_priv) == -1) {
+ fd = winbind_open_pipe_sock(recursing, need_priv);
+ if (fd == -1) {
errno = ENOENT;
return -1;
}
@@ -391,7 +392,7 @@ static int winbind_write_sock(void *buffer, int count, int recursing,
/* Catch pipe close on other end by checking if a read()
call would not block by calling poll(). */
- pfd.fd = winbindd_fd;
+ pfd.fd = fd;
pfd.events = POLLIN|POLLHUP;
ret = poll(&pfd, 1, 0);
@@ -412,8 +413,7 @@ static int winbind_write_sock(void *buffer, int count, int recursing,
/* Do the write */
- result = write(winbindd_fd,
- (char *)buffer + nwritten,
+ result = write(fd, (char *)buffer + nwritten,
count - nwritten);
if ((result == -1) || (result == 0)) {
@@ -434,10 +434,12 @@ static int winbind_write_sock(void *buffer, int count, int recursing,
static int winbind_read_sock(void *buffer, int count)
{
+ int fd;
int nread = 0;
int total_time = 0;
- if (winbindd_fd == -1) {
+ fd = winbind_open_pipe_sock(false, false);
+ if (fd == -1) {
return -1;
}
@@ -449,7 +451,7 @@ static int winbind_read_sock(void *buffer, int count)
/* Catch pipe close on other end by checking if a read()
call would not block by calling poll(). */
- pfd.fd = winbindd_fd;
+ pfd.fd = fd;
pfd.events = POLLIN|POLLHUP;
/* Wait for 5 seconds for a reply. May need to parameterise this... */
@@ -475,7 +477,7 @@ static int winbind_read_sock(void *buffer, int count)
/* Do the Read */
- int result = read(winbindd_fd, (char *)buffer + nread,
+ int result = read(fd, (char *)buffer + nread,
count - nread);
if ((result == -1) || (result == 0)) {