summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-12-10 00:39:01 +0000
committerAndrew Tridgell <tridge@samba.org>2001-12-10 00:39:01 +0000
commit4a6d29768665f71b72cf48ee34ee9a9c451232f6 (patch)
tree7982cd628ed6e0c27321ebbdb0d3c43e2bb33a04
parent77c1376456765a7afe90afad96fab819fdcf8af3 (diff)
downloadsamba-4a6d29768665f71b72cf48ee34ee9a9c451232f6.tar.gz
make sid_binstring available without HAVE_ADS
-rw-r--r--source/lib/util_sid.c17
-rw-r--r--source/lib/util_str.c23
-rw-r--r--source/libads/ldap.c39
-rw-r--r--source/nsswitch/winbindd_ads.c8
-rw-r--r--source/nsswitch/winbindd_cache.c3
-rw-r--r--source/nsswitch/winbindd_proto.h49
6 files changed, 48 insertions, 91 deletions
diff --git a/source/lib/util_sid.c b/source/lib/util_sid.c
index 923037f479a..72365f5e46d 100644
--- a/source/lib/util_sid.c
+++ b/source/lib/util_sid.c
@@ -663,3 +663,20 @@ BOOL non_mappable_sid(DOM_SID *sid)
return False;
}
+
+/*
+ return the binary string representation of a DOM_SID
+ caller must free
+*/
+char *sid_binstring(DOM_SID *sid)
+{
+ char *buf, *s;
+ int len = sid_size(sid);
+ buf = malloc(len);
+ if (!buf) return NULL;
+ sid_linearize(buf, len, sid);
+ s = binary_string(buf, len);
+ free(buf);
+ return s;
+}
+
diff --git a/source/lib/util_str.c b/source/lib/util_str.c
index d7e6fa0781d..2205f5cf0d0 100644
--- a/source/lib/util_str.c
+++ b/source/lib/util_str.c
@@ -914,3 +914,26 @@ void strupper_m(char *s)
* as source string even in multibyte encoding. (VIV) */
unix_strupper(s,strlen(s)+1,s,strlen(s)+1);
}
+
+/*
+ return a RFC2254 binary string representation of a buffer
+ used in LDAP filters
+ caller must free
+*/
+char *binary_string(char *buf, int len)
+{
+ char *s;
+ int i, j;
+ const char *hex = "0123456789ABCDEF";
+ s = malloc(len * 3 + 1);
+ if (!s) return NULL;
+ for (j=i=0;i<len;i++) {
+ s[j] = '\\';
+ s[j+1] = hex[((unsigned char)buf[i]) >> 4];
+ s[j+2] = hex[((unsigned char)buf[i]) & 0xF];
+ j += 3;
+ }
+ s[j] = 0;
+ return s;
+}
+
diff --git a/source/libads/ldap.c b/source/libads/ldap.c
index c81f2474aef..2fe97ebb1a1 100644
--- a/source/libads/ldap.c
+++ b/source/libads/ldap.c
@@ -386,45 +386,6 @@ NTSTATUS ads_set_machine_password(ADS_STRUCT *ads,
return ret;
}
-
-/*
- return a RFC2254 binary string representation of a buffer
- used in filters
- caller must free
-*/
-char *ads_binary_string(char *buf, int len)
-{
- char *s;
- int i, j;
- const char *hex = "0123456789ABCDEF";
- s = malloc(len * 3 + 1);
- if (!s) return NULL;
- for (j=i=0;i<len;i++) {
- s[j] = '\\';
- s[j+1] = hex[((unsigned char)buf[i]) >> 4];
- s[j+2] = hex[((unsigned char)buf[i]) & 0xF];
- j += 3;
- }
- s[j] = 0;
- return s;
-}
-
-/*
- return the binary string representation of a DOM_SID
- caller must free
-*/
-char *ads_sid_binstring(DOM_SID *sid)
-{
- char *buf, *s;
- int len = sid_size(sid);
- buf = malloc(len);
- if (!buf) return NULL;
- sid_linearize(buf, len, sid);
- s = ads_binary_string(buf, len);
- free(buf);
- return s;
-}
-
/*
pull the first entry from a ADS result
*/
diff --git a/source/nsswitch/winbindd_ads.c b/source/nsswitch/winbindd_ads.c
index cabb482f7d4..e009f9a9aba 100644
--- a/source/nsswitch/winbindd_ads.c
+++ b/source/nsswitch/winbindd_ads.c
@@ -400,7 +400,7 @@ static NTSTATUS sid_to_name(struct winbindd_domain *domain,
ads = ads_cached_connection(domain);
if (!ads) goto done;
- sidstr = ads_sid_binstring(sid);
+ sidstr = sid_binstring(sid);
asprintf(&exp, "(objectSid=%s)", sidstr);
rc = ads_search_retry(ads, &msg, exp, attrs);
free(exp);
@@ -452,7 +452,7 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
ads = ads_cached_connection(domain);
if (!ads) goto done;
- sidstr = ads_sid_binstring(&sid);
+ sidstr = sid_binstring(&sid);
asprintf(&exp, "(objectSid=%s)", sidstr);
rc = ads_search_retry(ads, &msg, exp, attrs);
free(exp);
@@ -523,7 +523,7 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
ads = ads_cached_connection(domain);
if (!ads) goto done;
- sidstr = ads_sid_binstring(&sid);
+ sidstr = sid_binstring(&sid);
asprintf(&exp, "(objectSid=%s)", sidstr);
rc = ads_search_retry(ads, &msg, exp, attrs);
free(exp);
@@ -589,7 +589,7 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
if (!ads) goto done;
sid_from_rid(domain, group_rid, &group_sid);
- sidstr = ads_sid_binstring(&group_sid);
+ sidstr = sid_binstring(&group_sid);
/* search for all users who have that group sid as primary group or as member */
asprintf(&exp, "(&(objectclass=user)(|(primaryGroupID=%d)(memberOf=%s)))",
group_rid, sidstr);
diff --git a/source/nsswitch/winbindd_cache.c b/source/nsswitch/winbindd_cache.c
index e78410e3a50..912ac162b57 100644
--- a/source/nsswitch/winbindd_cache.c
+++ b/source/nsswitch/winbindd_cache.c
@@ -36,6 +36,7 @@ struct cache_entry {
static struct winbind_cache *wcache;
+/* flush the cache */
void wcache_flush_cache(void)
{
extern BOOL opt_nocache;
@@ -500,7 +501,7 @@ static NTSTATUS sid_to_name(struct winbindd_domain *domain,
if (!cache->tdb) goto do_query;
- sidstr = ads_sid_binstring(sid);
+ sidstr = sid_binstring(sid);
centry = wcache_fetch(cache, domain, "SIDTONAME/%s/%s", domain->name, sidstr);
if (!centry) goto do_query;
diff --git a/source/nsswitch/winbindd_proto.h b/source/nsswitch/winbindd_proto.h
index fbb5c731d1d..4abc10c63b5 100644
--- a/source/nsswitch/winbindd_proto.h
+++ b/source/nsswitch/winbindd_proto.h
@@ -3,10 +3,6 @@
/* This file is automatically generated with "make proto". DO NOT EDIT */
-/* The following definitions come from nsswitch/wcache.c */
-
-struct cache_entry *centry_start(struct winbindd_domain *domain, NTSTATUS status);
-
/* The following definitions come from nsswitch/winbindd.c */
int main(int argc, char **argv);
@@ -25,49 +21,8 @@ int ads_search_retry_dn(ADS_STRUCT *ads, void **res,
/* The following definitions come from nsswitch/winbindd_cache.c */
-void winbindd_cache_init(void);
-void winbindd_store_user_cache(struct winbindd_domain *domain,
- struct getpwent_user *sam_entries,
- int num_sam_entries);
-void winbindd_store_group_cache(struct winbindd_domain *domain,
- struct acct_info *sam_entries,
- int num_sam_entries);
-void winbindd_store_name_cache_entry(struct winbindd_domain *domain,
- char *sid, struct winbindd_name *name);
-void winbindd_store_sid_cache_entry(struct winbindd_domain *domain,
- const char *name, struct winbindd_sid *sid);
-void winbindd_store_user_cache_entry(struct winbindd_domain *domain,
- char *user_name, struct winbindd_pw *pw);
-void winbindd_store_uid_cache_entry(struct winbindd_domain *domain, uid_t uid,
- struct winbindd_pw *pw);
-void winbindd_store_group_cache_entry(struct winbindd_domain *domain,
- char *group_name, struct winbindd_gr *gr,
- void *extra_data, int extra_data_len);
-void winbindd_store_gid_cache_entry(struct winbindd_domain *domain, gid_t gid,
- struct winbindd_gr *gr, void *extra_data,
- int extra_data_len);
-BOOL winbindd_fetch_user_cache(struct winbindd_domain *domain,
- struct getpwent_user **sam_entries,
- int *num_entries);
-BOOL winbindd_fetch_group_cache(struct winbindd_domain *domain,
- struct acct_info **sam_entries,
- int *num_entries);
-BOOL winbindd_fetch_sid_cache_entry(struct winbindd_domain *domain,
- const char *name, struct winbindd_sid *sid);
-BOOL winbindd_fetch_name_cache_entry(struct winbindd_domain *domain,
- char *sid, struct winbindd_name *name);
-BOOL winbindd_fetch_user_cache_entry(struct winbindd_domain *domain,
- char *user, struct winbindd_pw *pw);
-BOOL winbindd_fetch_uid_cache_entry(struct winbindd_domain *domain, uid_t uid,
- struct winbindd_pw *pw);
-BOOL winbindd_fetch_group_cache_entry(struct winbindd_domain *domain,
- char *group, struct winbindd_gr *gr,
- void **extra_data, int *extra_data_len);
-BOOL winbindd_fetch_gid_cache_entry(struct winbindd_domain *domain, gid_t gid,
- struct winbindd_gr *gr,
- void **extra_data, int *extra_data_len);
-void winbindd_flush_cache(void);
-void winbindd_cache_status(void);
+void wcache_flush_cache(void);
+struct cache_entry *centry_start(struct winbindd_domain *domain, NTSTATUS status);
/* The following definitions come from nsswitch/winbindd_cm.c */