[PATCH] A few cleanups
Volker Lendecke
Volker.Lendecke at SerNet.DE
Tue Jan 12 15:05:13 UTC 2016
Hi!
Review appreciated!
Thanks, Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 1717e1ab0c6923db97e8c8678da06e24773fd39e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 15 Dec 2015 21:43:50 +0100
Subject: [PATCH 1/7] libsmb: Convert resolve_hosts to sockaddr_storage
Eventually I want to get rid of struct ip_service.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/libsmb/namequery.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 7eb5dff..38c6648 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -2327,7 +2327,8 @@ static NTSTATUS resolve_lmhosts(const char *name, int name_type,
*********************************************************/
static NTSTATUS resolve_hosts(const char *name, int name_type,
- struct ip_service **return_iplist,
+ TALLOC_CTX *mem_ctx,
+ struct sockaddr_storage **return_iplist,
int *return_count)
{
/*
@@ -2388,16 +2389,15 @@ static NTSTATUS resolve_hosts(const char *name, int name_type,
*return_count += 1;
- *return_iplist = SMB_REALLOC_ARRAY(*return_iplist,
- struct ip_service,
- *return_count);
+ *return_iplist = talloc_realloc(
+ mem_ctx, *return_iplist, struct sockaddr_storage,
+ *return_count);
if (!*return_iplist) {
DEBUG(3,("resolve_hosts: malloc fail !\n"));
freeaddrinfo(ailist);
return NT_STATUS_NO_MEMORY;
}
- (*return_iplist)[i].ss = ss;
- (*return_iplist)[i].port = PORT_NONE;
+ (*return_iplist)[i] = ss;
i++;
}
if (ailist) {
@@ -2715,9 +2715,16 @@ NTSTATUS internal_resolve_name(const char *name,
tok = resolve_order[i];
if((strequal(tok, "host") || strequal(tok, "hosts"))) {
- status = resolve_hosts(name, name_type, return_iplist,
+ struct sockaddr_storage *ss_list;
+ status = resolve_hosts(name, name_type,
+ talloc_tos(), &ss_list,
return_count);
if (NT_STATUS_IS_OK(status)) {
+ if (!convert_ss2service(return_iplist,
+ ss_list,
+ return_count)) {
+ status = NT_STATUS_NO_MEMORY;
+ }
goto done;
}
} else if(strequal( tok, "kdc")) {
--
1.9.1
From 05a1685af8a877d7ab68e14f3b2cb7e0d1100695 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 15 Dec 2015 21:52:38 +0100
Subject: [PATCH 2/7] libsmb: Remove ip_service based resolve_lmhosts
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/libsmb/namequery.c | 59 +++++++---------------------------------------
1 file changed, 9 insertions(+), 50 deletions(-)
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 38c6648..4709c03 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -2275,54 +2275,6 @@ fail:
}
/********************************************************
- Resolve via "lmhosts" method.
-*********************************************************/
-
-static NTSTATUS resolve_lmhosts(const char *name, int name_type,
- struct ip_service **return_iplist,
- int *return_count)
-{
- /*
- * "lmhosts" means parse the local lmhosts file.
- */
- struct sockaddr_storage *ss_list;
- NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
- TALLOC_CTX *ctx = NULL;
-
- *return_iplist = NULL;
- *return_count = 0;
-
- DEBUG(3,("resolve_lmhosts: "
- "Attempting lmhosts lookup for name %s<0x%x>\n",
- name, name_type));
-
- ctx = talloc_init("resolve_lmhosts");
- if (!ctx) {
- return NT_STATUS_NO_MEMORY;
- }
-
- status = resolve_lmhosts_file_as_sockaddr(get_dyn_LMHOSTSFILE(),
- name, name_type,
- ctx,
- &ss_list,
- return_count);
- if (NT_STATUS_IS_OK(status)) {
- if (convert_ss2service(return_iplist,
- ss_list,
- return_count)) {
- talloc_free(ctx);
- return NT_STATUS_OK;
- } else {
- talloc_free(ctx);
- return NT_STATUS_NO_MEMORY;
- }
- }
- talloc_free(ctx);
- return status;
-}
-
-
-/********************************************************
Resolve via "hosts" method.
*********************************************************/
@@ -2747,9 +2699,16 @@ NTSTATUS internal_resolve_name(const char *name,
goto done;
}
} else if (strequal(tok, "lmhosts")) {
- status = resolve_lmhosts(name, name_type,
- return_iplist, return_count);
+ struct sockaddr_storage *ss_list;
+ status = resolve_lmhosts_file_as_sockaddr(
+ get_dyn_LMHOSTSFILE(), name, name_type,
+ talloc_tos(), &ss_list, return_count);
if (NT_STATUS_IS_OK(status)) {
+ if (!convert_ss2service(return_iplist,
+ ss_list,
+ return_count)) {
+ status = NT_STATUS_NO_MEMORY;
+ }
goto done;
}
} else if (strequal(tok, "wins")) {
--
1.9.1
From f5fb329fcb7f267f23596bf35b55b06607b3d868 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 17 Dec 2015 15:42:33 +0100
Subject: [PATCH 3/7] libcli: Fix a typo
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/libcli/ldap/ldap_client.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c
index 94367a1..4b8f951 100644
--- a/source4/libcli/ldap/ldap_client.c
+++ b/source4/libcli/ldap/ldap_client.c
@@ -223,7 +223,7 @@ static void ldap_connection_recv_next(struct ldap_connection *conn)
}
/*
- * The minimun size of a LDAP pdu is 7 bytes
+ * The minimum size of a LDAP pdu is 7 bytes
*
* dumpasn1 -hh ldap-unbind-min.dat
*
--
1.9.1
From 908f3d7387e9a0bb8299306ac7afe3eaaac3a85c Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 27 Dec 2015 19:55:40 +0100
Subject: [PATCH 4/7] idmap: Fix whitespace
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/idmap_nss.c | 8 ++++----
source3/winbindd/idmap_rid.c | 6 +++---
source3/winbindd/idmap_util.c | 4 ++--
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/source3/winbindd/idmap_nss.c b/source3/winbindd/idmap_nss.c
index e65a499..24f8217 100644
--- a/source3/winbindd/idmap_nss.c
+++ b/source3/winbindd/idmap_nss.c
@@ -30,16 +30,16 @@
#define DBGC_CLASS DBGC_IDMAP
/*****************************
- Initialise idmap database.
+ Initialise idmap database.
*****************************/
static NTSTATUS idmap_nss_int_init(struct idmap_domain *dom)
-{
+{
return NT_STATUS_OK;
}
/**********************************
- lookup a set of unix ids.
+ lookup a set of unix ids.
**********************************/
static NTSTATUS idmap_nss_unixids_to_sids(struct idmap_domain *dom, struct id_map **ids)
@@ -120,7 +120,7 @@ static NTSTATUS idmap_nss_unixids_to_sids(struct idmap_domain *dom, struct id_ma
}
/**********************************
- lookup a set of sids.
+ lookup a set of sids.
**********************************/
static NTSTATUS idmap_nss_sids_to_unixids(struct idmap_domain *dom, struct id_map **ids)
diff --git a/source3/winbindd/idmap_rid.c b/source3/winbindd/idmap_rid.c
index d6c649b..d68dbf7 100644
--- a/source3/winbindd/idmap_rid.c
+++ b/source3/winbindd/idmap_rid.c
@@ -94,7 +94,7 @@ static NTSTATUS idmap_rid_id_to_sid(struct idmap_domain *dom, struct id_map *map
}
/**********************************
- Single sid to id lookup function.
+ Single sid to id lookup function.
**********************************/
static NTSTATUS idmap_rid_sid_to_id(struct idmap_domain *dom, struct id_map *map)
@@ -123,7 +123,7 @@ static NTSTATUS idmap_rid_sid_to_id(struct idmap_domain *dom, struct id_map *map
}
/**********************************
- lookup a set of unix ids.
+ lookup a set of unix ids.
**********************************/
static NTSTATUS idmap_rid_unixids_to_sids(struct idmap_domain *dom, struct id_map **ids)
@@ -151,7 +151,7 @@ static NTSTATUS idmap_rid_unixids_to_sids(struct idmap_domain *dom, struct id_ma
}
/**********************************
- lookup a set of sids.
+ lookup a set of sids.
**********************************/
static NTSTATUS idmap_rid_sids_to_unixids(struct idmap_domain *dom, struct id_map **ids)
diff --git a/source3/winbindd/idmap_util.c b/source3/winbindd/idmap_util.c
index dc7d37c..f90565f 100644
--- a/source3/winbindd/idmap_util.c
+++ b/source3/winbindd/idmap_util.c
@@ -32,7 +32,7 @@
/*****************************************************************
Returns the SID mapped to the given UID.
If mapping is not possible returns an error.
-*****************************************************************/
+*****************************************************************/
NTSTATUS idmap_uid_to_sid(struct dom_sid *sid, uid_t uid)
{
@@ -95,7 +95,7 @@ backend:
/*****************************************************************
Returns SID mapped to the given GID.
If mapping is not possible returns an error.
-*****************************************************************/
+*****************************************************************/
NTSTATUS idmap_gid_to_sid(struct dom_sid *sid, gid_t gid)
{
--
1.9.1
From d92b3cbc241fd271e37af25f4795b3650200a2f7 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 28 Dec 2015 17:01:47 +0100
Subject: [PATCH 5/7] winbind: Properly error check init_lsa_ref_domain_list
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/wb_sids2xids.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/source3/winbindd/wb_sids2xids.c b/source3/winbindd/wb_sids2xids.c
index e3962de..940a06b 100644
--- a/source3/winbindd/wb_sids2xids.c
+++ b/source3/winbindd/wb_sids2xids.c
@@ -184,16 +184,22 @@ static void wb_sids2xids_lookupsids_done(struct tevent_req *subreq)
struct lsa_DomainInfo *info;
struct lsa_TranslatedName *n = &names->names[i];
struct wbint_TransID *t = &state->ids.ids[i];
+ int domain_index;
sid_copy(&dom_sid, &state->non_cached[i]);
sid_split_rid(&dom_sid, &t->rid);
info = &domains->domains[n->sid_index];
t->type = lsa_SidType_to_id_type(n->sid_type);
- t->domain_index = init_lsa_ref_domain_list(state,
- state->idmap_doms,
- info->name.string,
- &dom_sid);
+
+ domain_index = init_lsa_ref_domain_list(
+ state, state->idmap_doms, info->name.string, &dom_sid);
+ if (domain_index == -1) {
+ tevent_req_oom(req);
+ return;
+ }
+ t->domain_index = domain_index;
+
t->xid.id = UINT32_MAX;
t->xid.type = t->type;
}
--
1.9.1
From bc0e199684a3c46897e8e2effbdf00f140622246 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 11 Jan 2016 21:38:20 +0100
Subject: [PATCH 6/7] asn1: Fix a typo
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/util/asn1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/util/asn1.c b/lib/util/asn1.c
index 9ce7c23..a1597f0 100644
--- a/lib/util/asn1.c
+++ b/lib/util/asn1.c
@@ -284,7 +284,7 @@ bool ber_write_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *OID)
if (newp[0] != '.') return false;
p = newp + 1;
- /*the ber representation can't use more space then the string one */
+ /*the ber representation can't use more space than the string one */
*blob = data_blob_talloc(mem_ctx, NULL, strlen(OID));
if (!blob->data) return false;
--
1.9.1
From 1e2c35a3dd7687f7ac8c963e37d96f6db14a34dc Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 11 Jan 2016 21:41:22 +0100
Subject: [PATCH 7/7] asn1: Make asn1_peek_tag_needed_size static
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/util/asn1.c | 3 ++-
lib/util/asn1.h | 1 -
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/util/asn1.c b/lib/util/asn1.c
index a1597f0..8f2c516 100644
--- a/lib/util/asn1.c
+++ b/lib/util/asn1.c
@@ -543,7 +543,8 @@ bool asn1_peek_tag(struct asn1_data *data, uint8_t tag)
/*
* just get the needed size the tag would consume
*/
-bool asn1_peek_tag_needed_size(struct asn1_data *data, uint8_t tag, size_t *size)
+static bool asn1_peek_tag_needed_size(struct asn1_data *data, uint8_t tag,
+ size_t *size)
{
off_t start_ofs = data->ofs;
uint8_t b;
diff --git a/lib/util/asn1.h b/lib/util/asn1.h
index 128858f..9ebf453 100644
--- a/lib/util/asn1.h
+++ b/lib/util/asn1.h
@@ -76,7 +76,6 @@ bool asn1_peek(struct asn1_data *data, void *p, int len);
bool asn1_read(struct asn1_data *data, void *p, int len);
bool asn1_read_uint8(struct asn1_data *data, uint8_t *v);
bool asn1_peek_uint8(struct asn1_data *data, uint8_t *v);
-bool asn1_peek_tag_needed_size(struct asn1_data *data, uint8_t tag, size_t *size);
bool asn1_peek_tag(struct asn1_data *data, uint8_t tag);
bool asn1_start_tag(struct asn1_data *data, uint8_t tag);
bool asn1_end_tag(struct asn1_data *data);
--
1.9.1
More information about the samba-technical
mailing list