summaryrefslogtreecommitdiff
path: root/source3/nsswitch/winbind_nss.c
diff options
context:
space:
mode:
authorHerb Lewis <herb@samba.org>2002-03-29 15:37:39 +0000
committerHerb Lewis <herb@samba.org>2002-03-29 15:37:39 +0000
commit93af72fe45a92148af3e3e3197cd7c481894cfa8 (patch)
tree3ea3356c70b0c86f53eb14d43910be5f24d31223 /source3/nsswitch/winbind_nss.c
parent14f0beb21cebe319c34e25dbb685c6b30fe10561 (diff)
downloadsamba-93af72fe45a92148af3e3e3197cd7c481894cfa8.tar.gz
samba-93af72fe45a92148af3e3e3197cd7c481894cfa8.tar.bz2
samba-93af72fe45a92148af3e3e3197cd7c481894cfa8.zip
merge winbindd WINS changes from 2.2
(This used to be commit 205399dc17e464360b0152538329b9e111b0e7f4)
Diffstat (limited to 'source3/nsswitch/winbind_nss.c')
-rw-r--r--source3/nsswitch/winbind_nss.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/source3/nsswitch/winbind_nss.c b/source3/nsswitch/winbind_nss.c
index 8d33cd9b2f..0a49f5ec96 100644
--- a/source3/nsswitch/winbind_nss.c
+++ b/source3/nsswitch/winbind_nss.c
@@ -107,7 +107,7 @@ winbind_xid_lookup(int xid, struct winbindd_request **requestp)
*last = dx->next;
result = dx->rq;
*requestp = dx->request;
- free(dx);
+ SAFE_FREE(dx);
}
nsd_logprintf(NSD_LOG_LOW,
"entering winbind_xid_lookup xid = %d rq = 0x%x, request = 0x%x\n",
@@ -178,9 +178,9 @@ winbind_callback(nsd_file_t **rqp, int fd)
struct winbindd_gr *gr = &response.data.gr;
nsd_file_t *rq;
NSS_STATUS status;
- char result[1024];
+ fstring result;
char *members;
- int i;
+ int i, maxlen;
dequeue_request();
@@ -204,10 +204,17 @@ winbind_callback(nsd_file_t **rqp, int fd)
rq->f_status = NS_NOTFOUND;
return NSD_NEXT;
}
+
+ maxlen = sizeof(result) - 1;
+
switch ((int)rq->f_cmd_data) {
+ case WINBINDD_WINS_BYNAME:
+ case WINBINDD_WINS_BYIP:
+ snprintf(result,maxlen,"%s\n",response.data.winsresp);
+ break;
case WINBINDD_GETPWUID:
case WINBINDD_GETPWNAM:
- snprintf(result,1023,"%s:%s:%d:%d:%s:%s:%s\n",
+ snprintf(result,maxlen,"%s:%s:%d:%d:%s:%s:%s\n",
pw->pw_name,
pw->pw_passwd,
pw->pw_uid,
@@ -222,7 +229,7 @@ winbind_callback(nsd_file_t **rqp, int fd)
members = response.extra_data;
else
members = "";
- snprintf(result,1023,"%s:%s:%d:%s\n",
+ snprintf(result,maxlen,"%s:%s:%d:%s\n",
gr->gr_name, gr->gr_passwd, gr->gr_gid, members);
break;
case WINBINDD_SETGRENT:
@@ -244,7 +251,7 @@ winbind_callback(nsd_file_t **rqp, int fd)
members = (char *)response.extra_data +
(response.data.num_entries * sizeof(struct winbindd_gr));
for (i = 0; i < response.data.num_entries; i++) {
- snprintf(result,1023,"%s:%s:%d:%s\n",
+ snprintf(result,maxlen,"%s:%s:%d:%s\n",
gr->gr_name, gr->gr_passwd, gr->gr_gid,
&members[gr->gr_mem_ofs]);
nsd_logprintf(NSD_LOG_MIN, " GETGRENT %s\n",result);
@@ -270,7 +277,7 @@ winbind_callback(nsd_file_t **rqp, int fd)
return NSD_ERROR;
}
for (i = 0; i < response.data.num_entries; i++) {
- snprintf(result,1023,"%s:%s:%d:%d:%s:%s:%s",
+ snprintf(result,maxlen,"%s:%s:%d:%d:%s:%s:%s",
pw->pw_name,
pw->pw_passwd,
pw->pw_uid,
@@ -338,7 +345,7 @@ send_next_request(nsd_file_t *rq, struct winbindd_request *request)
nsd_logprintf(NSD_LOG_MIN, "send_next_request (winbind) %d to = %d\n",
rq->f_cmd_data, timeout);
status = winbindd_send_request((int)rq->f_cmd_data,request);
- free(request);
+ SAFE_FREE(request);
if (status != NSS_STATUS_SUCCESS) {
nsd_logprintf(NSD_LOG_MIN,
@@ -407,12 +414,20 @@ int lookup(nsd_file_t *rq)
} else if (strcasecmp(map,"group.bygid") == 0) {
request->data.gid = atoi(key);
rq->f_cmd_data = (void *)WINBINDD_GETGRGID;
+ } else if (strcasecmp(map,"hosts.byname") == 0) {
+ strncpy(request->data.winsreq, key, sizeof(request->data.winsreq) - 1);
+ request->data.winsreq[sizeof(request->data.winsreq) - 1] = '\0';
+ rq->f_cmd_data = (void *)WINBINDD_WINS_BYNAME;
+ } else if (strcasecmp(map,"hosts.byaddr") == 0) {
+ strncpy(request->data.winsreq, key, sizeof(request->data.winsreq) - 1);
+ request->data.winsreq[sizeof(request->data.winsreq) - 1] = '\0';
+ rq->f_cmd_data = (void *)WINBINDD_WINS_BYIP;
} else {
/*
* Don't understand this map - just return not found
*/
nsd_logprintf(NSD_LOG_MIN, "lookup (winbind) unknown table\n");
- free(request);
+ SAFE_FREE(request);
rq->f_status = NS_NOTFOUND;
return NSD_NEXT;
}
@@ -470,7 +485,7 @@ do_list(int state, nsd_file_t *rq)
break;
default:
nsd_logprintf(NSD_LOG_MIN, "do_list (winbind) unknown state\n");
- free(request);
+ SAFE_FREE(request);
rq->f_status = NS_NOTFOUND;
return NSD_NEXT;
}
@@ -488,7 +503,7 @@ do_list(int state, nsd_file_t *rq)
break;
default:
nsd_logprintf(NSD_LOG_MIN, "do_list (winbind) unknown state\n");
- free(request);
+ SAFE_FREE(request);
rq->f_status = NS_NOTFOUND;
return NSD_NEXT;
}
@@ -497,7 +512,7 @@ do_list(int state, nsd_file_t *rq)
* Don't understand this map - just return not found
*/
nsd_logprintf(NSD_LOG_MIN, "do_list (winbind) unknown table\n");
- free(request);
+ SAFE_FREE(request);
rq->f_status = NS_NOTFOUND;
return NSD_NEXT;
}