[SCM] Samba Shared Repository - branch v3-2-test updated -
release-3-2-0pre2-632-g9d0e5a1
Stefan Metzmacher
metze at samba.org
Thu Apr 3 13:50:36 GMT 2008
The branch, v3-2-test has been updated
via 9d0e5a13215d4904084e81fde6098c70ee4d4636 (commit)
via 046b26b763b16362dd662a77b2434641bf583bc2 (commit)
via b917be4986bd55aeffae03b08cf476ea6302fa26 (commit)
via ff4611832a0b498b83590279a7153e606a4720f5 (commit)
from 118cf3813336122a060916848e37d2d5d25bff92 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 9d0e5a13215d4904084e81fde6098c70ee4d4636
Author: Stefan Metzmacher <metze at samba.org>
Date: Wed Apr 2 06:10:04 2008 +0200
wbinfo: use wbcLookupNames()
metze
commit 046b26b763b16362dd662a77b2434641bf583bc2
Author: Stefan Metzmacher <metze at samba.org>
Date: Wed Apr 2 06:03:48 2008 +0200
wbinfo: use wbcLookupRids()
metze
commit b917be4986bd55aeffae03b08cf476ea6302fa26
Author: Stefan Metzmacher <metze at samba.org>
Date: Wed Apr 2 05:26:36 2008 +0200
wbinfo: use wbcLookupSid()
metze
commit ff4611832a0b498b83590279a7153e606a4720f5
Author: Stefan Metzmacher <metze at samba.org>
Date: Wed Apr 2 06:02:45 2008 +0200
wbinfo: catch NULL domain string as in other places
metze
-----------------------------------------------------------------------
Summary of changes:
source/nsswitch/wbinfo.c | 132 ++++++++++++++++++++++++++-------------------
1 files changed, 76 insertions(+), 56 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/nsswitch/wbinfo.c b/source/nsswitch/wbinfo.c
index 6707f9d..d3988ca 100644
--- a/source/nsswitch/wbinfo.c
+++ b/source/nsswitch/wbinfo.c
@@ -508,7 +508,7 @@ static bool wbinfo_domain_info(const char *domain)
struct wbcDomainInfo *dinfo = NULL;
char *sid_str = NULL;
- if (strcmp(domain, ".") == 0 || domain[0] == '\0') {
+ if ((domain == NULL) || (strequal(domain, ".")) || (domain[0] == '\0')) {
domain = get_winbind_domain();
}
@@ -773,73 +773,68 @@ static bool wbinfo_allocate_gid(void)
/* Convert sid to string */
-static bool wbinfo_lookupsid(char *sid)
+static bool wbinfo_lookupsid(const char *sid_str)
{
- struct winbindd_request request;
- struct winbindd_response response;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ struct wbcDomainSid sid;
+ char *domain;
+ char *name;
+ enum wbcSidType type;
/* Send off request */
- fstrcpy(request.data.sid, sid);
+ wbc_status = wbcStringToSid(sid_str, &sid);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ return false;
+ }
- if (winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response) !=
- NSS_STATUS_SUCCESS)
+ wbc_status = wbcLookupSid(&sid, &domain, &name, &type);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
return false;
+ }
/* Display response */
- d_printf("%s%c%s %d\n", response.data.name.dom_name,
- winbind_separator(), response.data.name.name,
- response.data.name.type);
+ d_printf("%s%c%s %d\n",
+ domain, winbind_separator(), name, type);
return true;
}
/* Lookup a list of RIDs */
-static bool wbinfo_lookuprids(char *domain, char *arg)
+static bool wbinfo_lookuprids(const char *domain, const char *arg)
{
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ struct wbcDomainInfo *dinfo = NULL;
+ char *domain_name = NULL;
+ const char **names = NULL;
+ enum wbcSidType *types = NULL;
size_t i;
- DOM_SID sid;
int num_rids;
- uint32 *rids;
+ uint32 *rids = NULL;
const char *p;
char *ridstr;
- const char **names;
- enum lsa_SidType *types;
- const char *domain_name;
TALLOC_CTX *mem_ctx;
- struct winbindd_request request;
- struct winbindd_response response;
-
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
+ bool ret = false;
- if ((domain == NULL) || (strequal(domain, ".")) || (domain[0] == '\0'))
- fstrcpy(request.domain_name, get_winbind_domain());
- else
- fstrcpy(request.domain_name, domain);
+ if ((domain == NULL) || (strequal(domain, ".")) || (domain[0] == '\0')) {
+ domain = get_winbind_domain();
+ }
/* Send request */
- if (winbindd_request_response(WINBINDD_DOMAIN_INFO, &request, &response) !=
- NSS_STATUS_SUCCESS) {
- d_printf("Could not get domain sid for %s\n", request.domain_name);
- return false;
- }
-
- if (!string_to_sid(&sid, response.data.domain_info.sid)) {
- d_printf("Could not convert %s to sid\n", response.data.domain_info.sid);
- return false;
+ wbc_status = wbcDomainInfo(domain, &dinfo);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_printf("wbcDomainInfo(%s) failed: %s\n", domain,
+ wbcErrorString(wbc_status));
+ goto done;
}
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
d_printf("talloc_new failed\n");
- return false;
+ goto done;
}
num_rids = 0;
@@ -852,15 +847,16 @@ static bool wbinfo_lookuprids(char *domain, char *arg)
}
if (rids == NULL) {
- TALLOC_FREE(mem_ctx);
- return false;
+ d_printf("no rids\n");
+ goto done;
}
- if (!winbind_lookup_rids(mem_ctx, &sid, num_rids, rids,
- &domain_name, &names, &types)) {
- d_printf("winbind_lookup_rids failed\n");
- TALLOC_FREE(mem_ctx);
- return false;
+ wbc_status = wbcLookupRids(&dinfo->sid, num_rids, rids,
+ (const char **)&domain_name, &names, &types);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_printf("winbind_lookup_rids failed: %s\n",
+ wbcErrorString(wbc_status));
+ goto done;
}
d_printf("Domain: %s\n", domain_name);
@@ -870,32 +866,56 @@ static bool wbinfo_lookuprids(char *domain, char *arg)
sid_type_lookup(types[i]));
}
+ ret = true;
+done:
+ if (dinfo) {
+ wbcFreeMemory(dinfo);
+ }
+ if (domain_name) {
+ wbcFreeMemory(domain_name);
+ }
+ if (names) {
+ wbcFreeMemory(names);
+ }
+ if (types) {
+ wbcFreeMemory(types);
+ }
TALLOC_FREE(mem_ctx);
- return true;
+ return ret;
}
/* Convert string to sid */
-static bool wbinfo_lookupname(char *name)
+static bool wbinfo_lookupname(const char *full_name)
{
- struct winbindd_request request;
- struct winbindd_response response;
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ struct wbcDomainSid sid;
+ char *sid_str;
+ enum wbcSidType type;
+ fstring domain_name;
+ fstring account_name;
/* Send off request */
- ZERO_STRUCT(request);
- ZERO_STRUCT(response);
+ parse_wbinfo_domain_user(full_name, domain_name,
+ account_name);
- parse_wbinfo_domain_user(name, request.data.name.dom_name,
- request.data.name.name);
+ wbc_status = wbcLookupName(domain_name, account_name,
+ &sid, &type);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ return false;
+ }
- if (winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response) !=
- NSS_STATUS_SUCCESS)
+ wbc_status = wbcSidToString(&sid, &sid_str);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
return false;
+ }
/* Display response */
- d_printf("%s %s (%d)\n", response.data.sid.sid, sid_type_lookup(response.data.sid.type), response.data.sid.type);
+ d_printf("%s %s (%d)\n", sid_str, sid_type_lookup(type), type);
+
+ wbcFreeMemory(sid_str);
return true;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list