[PATCH] A few cleanups
Volker Lendecke
Volker.Lendecke at SerNet.DE
Mon Feb 15 11:31:11 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 4b4a24dc302f3bdf13aa8a9b86df3a7f1c07e079 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 2 Feb 2016 14:21:32 +0100
Subject: [PATCH 1/5] winbind: Add some const
This makes source and destination a bit clearer to me
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/wb_fill_pwent.c | 4 ++--
source3/winbindd/winbindd_proto.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/source3/winbindd/wb_fill_pwent.c b/source3/winbindd/wb_fill_pwent.c
index 4b4484f..2229b05 100644
--- a/source3/winbindd/wb_fill_pwent.c
+++ b/source3/winbindd/wb_fill_pwent.c
@@ -23,7 +23,7 @@
struct wb_fill_pwent_state {
struct tevent_context *ev;
- struct wbint_userinfo *info;
+ const struct wbint_userinfo *info;
struct winbindd_pw *pw;
};
@@ -41,7 +41,7 @@ static void wb_fill_pwent_getgrsid_done(struct tevent_req *subreq);
struct tevent_req *wb_fill_pwent_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
- struct wbint_userinfo *info,
+ const struct wbint_userinfo *info,
struct winbindd_pw *pw)
{
struct tevent_req *req, *subreq;
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 6e50718..1f4f174 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -729,7 +729,7 @@ NTSTATUS wb_query_group_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
struct tevent_req *wb_fill_pwent_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
- struct wbint_userinfo *info,
+ const struct wbint_userinfo *info,
struct winbindd_pw *pw);
NTSTATUS wb_fill_pwent_recv(struct tevent_req *req);
--
1.7.9.5
From 83ae9fca961f792993fb398db0d0ec722787f341 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 2 Feb 2016 14:41:16 +0100
Subject: [PATCH 2/5] winbind: Fix a type error
nss_info_methods has "get_nss_info"'s p_gid parameter as
gid_t *, not uint32_t *. Probably that did not hurt due to
typedefs, but if we find a platform where gid_t is not
uint32_t, this would be VERY hard to debug
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/idmap_ad.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c
index bc9d785..87d4343 100644
--- a/source3/winbindd/idmap_ad.c
+++ b/source3/winbindd/idmap_ad.c
@@ -672,7 +672,7 @@ static NTSTATUS nss_ad_get_info( struct nss_domain_entry *e,
const char **homedir,
const char **shell,
const char **gecos,
- uint32_t *gid )
+ gid_t *p_gid )
{
const char *attrs[] = {NULL, /* attr_homedir */
NULL, /* attr_shell */
@@ -741,9 +741,15 @@ static NTSTATUS nss_ad_get_info( struct nss_domain_entry *e,
*shell = ads_pull_string(ctx->ads, mem_ctx, msg_internal, ctx->ad_schema->posix_shell_attr);
*gecos = ads_pull_string(ctx->ads, mem_ctx, msg_internal, ctx->ad_schema->posix_gecos_attr);
- if (gid) {
- if (!ads_pull_uint32(ctx->ads, msg_internal, ctx->ad_schema->posix_gidnumber_attr, gid))
- *gid = (uint32_t)-1;
+ if (p_gid) {
+ uint32_t gid = UINT32_MAX;
+ if (ads_pull_uint32(ctx->ads, msg_internal,
+ ctx->ad_schema->posix_gidnumber_attr,
+ &gid)) {
+ *p_gid = gid;
+ } else {
+ *p_gid = (gid_t)-1;
+ }
}
nt_status = NT_STATUS_OK;
--
1.7.9.5
From d44f98d4b052c21981daccaf0155046a9a7c6996 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 7 Feb 2016 16:22:05 +0100
Subject: [PATCH 3/5] credentials: Fix whitespace
Signed-off-by: Volker Lendecke <vl at samba.org>
---
auth/credentials/credentials_secrets.c | 57 ++++++++++++++++----------------
1 file changed, 28 insertions(+), 29 deletions(-)
diff --git a/auth/credentials/credentials_secrets.c b/auth/credentials/credentials_secrets.c
index 784e345..8dbbad4 100644
--- a/auth/credentials/credentials_secrets.c
+++ b/auth/credentials/credentials_secrets.c
@@ -1,4 +1,4 @@
-/*
+/*
Unix SMB/CIFS implementation.
User credentials handling (as regards on-disk files)
@@ -6,17 +6,17 @@
Copyright (C) Jelmer Vernooij 2005
Copyright (C) Tim Potter 2001
Copyright (C) Andrew Bartlett <abartlet at samba.org> 2005
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -43,24 +43,24 @@
/**
* Fill in credentials for the machine trust account, from the secrets database.
- *
+ *
* @param cred Credentials structure to fill in
* @retval NTSTATUS error detailing any failure
*/
-static NTSTATUS cli_credentials_set_secrets_lct(struct cli_credentials *cred,
+static NTSTATUS cli_credentials_set_secrets_lct(struct cli_credentials *cred,
struct loadparm_context *lp_ctx,
struct ldb_context *ldb,
const char *base,
- const char *filter,
+ const char *filter,
time_t secrets_tdb_last_change_time,
const char *secrets_tdb_password,
char **error_string)
{
TALLOC_CTX *mem_ctx;
-
+
int ldb_ret;
struct ldb_message *msg;
-
+
const char *machine_account;
const char *password;
const char *domain;
@@ -116,23 +116,23 @@ static NTSTATUS cli_credentials_set_secrets_lct(struct cli_credentials *cred,
talloc_free(mem_ctx);
return NT_STATUS_NOT_FOUND;
}
-
+
if (lct == secrets_tdb_last_change_time && secrets_tdb_password && strcmp(password, secrets_tdb_password) != 0) {
talloc_free(mem_ctx);
return NT_STATUS_NOT_FOUND;
}
-
+
cli_credentials_set_password_last_changed_time(cred, lct);
-
+
machine_account = ldb_msg_find_attr_as_string(msg, "samAccountName", NULL);
if (!machine_account) {
machine_account = ldb_msg_find_attr_as_string(msg, "servicePrincipalName", NULL);
-
+
if (!machine_account) {
const char *ldap_bind_dn = ldb_msg_find_attr_as_string(msg, "ldapBindDn", NULL);
if (!ldap_bind_dn) {
- *error_string = talloc_asprintf(cred,
+ *error_string = talloc_asprintf(cred,
"Could not find 'samAccountName', "
"'servicePrincipalName' or "
"'ldapBindDn' in secrets record: %s",
@@ -148,20 +148,20 @@ static NTSTATUS cli_credentials_set_secrets_lct(struct cli_credentials *cred,
salt_principal = ldb_msg_find_attr_as_string(msg, "saltPrincipal", NULL);
cli_credentials_set_salt_principal(cred, salt_principal);
-
+
sct = ldb_msg_find_attr_as_int(msg, "secureChannelType", 0);
- if (sct) {
+ if (sct) {
cli_credentials_set_secure_channel_type(cred, sct);
}
-
+
if (!password) {
const struct ldb_val *nt_password_hash = ldb_msg_find_ldb_val(msg, "unicodePwd");
struct samr_Password hash;
ZERO_STRUCT(hash);
if (nt_password_hash) {
- memcpy(hash.hash, nt_password_hash->data,
+ memcpy(hash.hash, nt_password_hash->data,
MIN(nt_password_hash->length, sizeof(hash.hash)));
-
+
cli_credentials_set_nt_hash(cred, &hash, CRED_SPECIFIED);
} else {
cli_credentials_set_password(cred, NULL, CRED_SPECIFIED);
@@ -170,7 +170,6 @@ static NTSTATUS cli_credentials_set_secrets_lct(struct cli_credentials *cred,
cli_credentials_set_password(cred, password, CRED_SPECIFIED);
}
-
domain = ldb_msg_find_attr_as_string(msg, "flatname", NULL);
if (domain) {
cli_credentials_set_domain(cred, domain, CRED_SPECIFIED);
@@ -196,22 +195,22 @@ static NTSTATUS cli_credentials_set_secrets_lct(struct cli_credentials *cred,
talloc_free(keytab);
}
talloc_free(mem_ctx);
-
+
return NT_STATUS_OK;
}
/**
* Fill in credentials for the machine trust account, from the secrets database.
- *
+ *
* @param cred Credentials structure to fill in
* @retval NTSTATUS error detailing any failure
*/
-_PUBLIC_ NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred,
+_PUBLIC_ NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred,
struct loadparm_context *lp_ctx,
struct ldb_context *ldb,
const char *base,
- const char *filter,
+ const char *filter,
char **error_string)
{
NTSTATUS status = cli_credentials_set_secrets_lct(cred, lp_ctx, ldb, base, filter, 0, NULL, error_string);
@@ -224,7 +223,7 @@ _PUBLIC_ NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred,
/**
* Fill in credentials for the machine trust account, from the secrets database.
- *
+ *
* @param cred Credentials structure to fill in
* @retval NTSTATUS error detailing any failure
*/
@@ -397,14 +396,14 @@ _PUBLIC_ NTSTATUS cli_credentials_set_machine_account_db_ctx(struct cli_credenti
/* set anonymous as the fallback, if the machine account won't work */
cli_credentials_set_anonymous(cred);
}
-
+
TALLOC_FREE(tmp_ctx);
return status;
}
/**
* Fill in credentials for a particular prinicpal, from the secrets database.
- *
+ *
* @param cred Credentials structure to fill in
* @retval NTSTATUS error detailing any failure
*/
@@ -437,9 +436,9 @@ _PUBLIC_ NTSTATUS cli_credentials_set_stored_principal(struct cli_credentials *c
/**
* Ask that when required, the credentials system will be filled with
* machine trust account, from the secrets database.
- *
+ *
* @param cred Credentials structure to fill in
- * @note This function is used to call the above function after, rather
+ * @note This function is used to call the above function after, rather
* than during, popt processing.
*
*/
--
1.7.9.5
From 0a6cc25e3df00e8d6fbf5258f74a53f260c04cca Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 7 Feb 2016 16:22:59 +0100
Subject: [PATCH 4/5] credentials: Fix a typo
Signed-off-by: Volker Lendecke <vl at samba.org>
---
auth/credentials/credentials_secrets.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/auth/credentials/credentials_secrets.c b/auth/credentials/credentials_secrets.c
index 8dbbad4..d5a37cf 100644
--- a/auth/credentials/credentials_secrets.c
+++ b/auth/credentials/credentials_secrets.c
@@ -402,7 +402,7 @@ _PUBLIC_ NTSTATUS cli_credentials_set_machine_account_db_ctx(struct cli_credenti
}
/**
- * Fill in credentials for a particular prinicpal, from the secrets database.
+ * Fill in credentials for a particular principal, from the secrets database.
*
* @param cred Credentials structure to fill in
* @retval NTSTATUS error detailing any failure
--
1.7.9.5
From d4724efb7a74a2f30e41e724d817867cdfd83bd3 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 8 Feb 2016 10:30:43 +0100
Subject: [PATCH 5/5] idmap_ad: Fix a copy&paste error
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/idmap_ad.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c
index 87d4343..2ba76c5 100644
--- a/source3/winbindd/idmap_ad.c
+++ b/source3/winbindd/idmap_ad.c
@@ -322,7 +322,8 @@ again:
ctx->ad_schema->posix_gidnumber_attr,
&id))
{
- DEBUG(1, ("Could not get SID for unix ID %u\n", (unsigned) id));
+ DEBUG(1, ("Could not get unix ID for SID %s\n",
+ dom_sid_string(talloc_tos(), &sid)));
continue;
}
--
1.7.9.5
More information about the samba-technical
mailing list