[PATCH] Random patches
Volker Lendecke
Volker.Lendecke at SerNet.DE
Wed Feb 25 13:56:52 MST 2015
Hi!
Just a bit of stuff I collected over time.
Review&push 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 11f5e13766265b1892499dbc0f0521fb1ee88c2c Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 21 Jan 2015 11:44:58 +0100
Subject: [PATCH 01/13] registry: Fix an aligment increase warning
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/registry/reg_objects.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/registry/reg_objects.c b/source3/registry/reg_objects.c
index baa3000..1c9e79d 100644
--- a/source3/registry/reg_objects.c
+++ b/source3/registry/reg_objects.c
@@ -188,7 +188,7 @@ static WERROR regsubkey_ctr_index_for_keyname(struct regsubkey_ctr *ctr,
}
if (idx != NULL) {
- *idx = *(uint32_t *)data.dptr;
+ memcpy(idx, data.dptr, sizeof(*idx));
}
talloc_free(data.dptr);
--
1.7.9.5
From d666bb963e0cdde552cfd6915f275c45dea8d9ea Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 14 Jan 2015 17:11:12 +0100
Subject: [PATCH 02/13] Fix whitespace
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/util/pidfile.c | 22 +++++++++++-----------
libcli/security/display_sec.c | 14 +++++++-------
librpc/idl/smb_acl.idl | 20 ++++++++++----------
3 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/lib/util/pidfile.c b/lib/util/pidfile.c
index 1b382d1..4960be6 100644
--- a/lib/util/pidfile.c
+++ b/lib/util/pidfile.c
@@ -1,20 +1,20 @@
/* this code is broken - there is a race condition with the unlink (tridge) */
-/*
+/*
Unix SMB/CIFS implementation.
pidfile handling
Copyright (C) Andrew Tridgell 1998
-
+
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/>.
*/
@@ -30,7 +30,7 @@
/**
* return the pid in a pidfile. return 0 if the process (or pidfile)
- * does not exist
+ * does not exist
*/
pid_t pidfile_pid(const char *piddir, const char *name)
{
@@ -62,7 +62,7 @@ pid_t pidfile_pid(const char *piddir, const char *name)
pidFile));
goto noproc;
}
-
+
if (!process_exists_by_pid(ret)) {
DEBUG(10, ("Process with PID=%d does not exist.\n", (int)ret));
goto noproc;
@@ -90,7 +90,7 @@ pid_t pidfile_pid(const char *piddir, const char *name)
}
/**
- * create a pid file in the pid directory. open it and leave it locked
+ * create a pid file in the pid directory. open it and leave it locked
*/
void pidfile_create(const char *piddir, const char *name)
{
@@ -106,14 +106,14 @@ void pidfile_create(const char *piddir, const char *name)
pid = pidfile_pid(piddir, name);
if (pid != 0) {
- DEBUG(0,("ERROR: %s is already running. File %s exists and process id %d is running.\n",
+ DEBUG(0,("ERROR: %s is already running. File %s exists and process id %d is running.\n",
name, pidFile, (int)pid));
exit(1);
}
fd = open(pidFile, O_NONBLOCK | O_CREAT | O_WRONLY | O_EXCL, 0644);
if (fd == -1) {
- DEBUG(0,("ERROR: can't open %s: Error was %s\n", pidFile,
+ DEBUG(0,("ERROR: can't open %s: Error was %s\n", pidFile,
strerror(errno)));
exit(1);
}
@@ -121,7 +121,7 @@ void pidfile_create(const char *piddir, const char *name)
smb_set_close_on_exec(fd);
if (fcntl_lock(fd,F_SETLK,0,1,F_WRLCK)==false) {
- DEBUG(0,("ERROR: %s : fcntl lock of file %s failed. Error was %s\n",
+ DEBUG(0,("ERROR: %s : fcntl lock of file %s failed. Error was %s\n",
name, pidFile, strerror(errno)));
exit(1);
}
@@ -129,7 +129,7 @@ void pidfile_create(const char *piddir, const char *name)
memset(buf, 0, sizeof(buf));
slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int) getpid());
if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) {
- DEBUG(0,("ERROR: can't write to file %s: %s\n",
+ DEBUG(0,("ERROR: can't write to file %s: %s\n",
pidFile, strerror(errno)));
exit(1);
}
diff --git a/libcli/security/display_sec.c b/libcli/security/display_sec.c
index de8bb8b..a8d173c 100644
--- a/libcli/security/display_sec.c
+++ b/libcli/security/display_sec.c
@@ -1,19 +1,19 @@
-/*
+/*
Unix SMB/CIFS implementation.
Samba utility functions
Copyright (C) Andrew Tridgell 1992-1999
Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
-
+
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,
+
+ 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/>.
*/
@@ -237,7 +237,7 @@ void display_sec_acl(struct security_acl *sec_acl)
uint32_t i;
printf("\tACL\tNum ACEs:\t%u\trevision:\t%x\n",
- sec_acl->num_aces, sec_acl->revision);
+ sec_acl->num_aces, sec_acl->revision);
printf("\t---\n");
if (sec_acl->size != 0 && sec_acl->num_aces != 0) {
@@ -283,7 +283,7 @@ void display_acl_type(uint16_t type)
printf("SEC_DESC_RM_CONTROL_VALID ");
if (type & SEC_DESC_SELF_RELATIVE) /* 0x8000 */
printf("SEC_DESC_SELF_RELATIVE ");
-
+
printf("\n");
}
diff --git a/librpc/idl/smb_acl.idl b/librpc/idl/smb_acl.idl
index ffd1ee2..a7a76c9 100644
--- a/librpc/idl/smb_acl.idl
+++ b/librpc/idl/smb_acl.idl
@@ -1,28 +1,28 @@
-/*
+/*
Unix SMB/CIFS implementation.
Portable SMB ACL interface
Copyright (C) Jeremy Allison 2000
Copyright (C) Andrew Bartlett 2012
-
+
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/>.
*/
-/*
+/*
* Allow the smb_acl interface to be pushed into an NDR blob and
* read/written in python.
- *
+ *
* The exact layout of these stuctures is CRITICAL, as a SHA-256 hash is
* taken over these after they are pushed as NDR blobs, and stored in an
* xattr for ACL verification.
@@ -62,7 +62,7 @@ interface smb_acl
[case (SMB_ACL_GROUP)] smb_acl_group group;
[case (SMB_ACL_GROUP_OBJ)];
[case (SMB_ACL_OTHER)];
- [case (SMB_ACL_MASK)];
+ [case (SMB_ACL_MASK)];
} smb_acl_entry_info;
typedef struct {
@@ -70,16 +70,16 @@ interface smb_acl
[switch_is(a_type)] smb_acl_entry_info info;
mode_t a_perm;
} smb_acl_entry;
-
+
[public] typedef struct {
int count;
[value(0)] int next;
[size_is(count)] smb_acl_entry acl[*];
} smb_acl_t;
-
+
const int SMB_ACL_FIRST_ENTRY = 0;
const int SMB_ACL_NEXT_ENTRY = 1;
-
+
const int SMB_ACL_TYPE_ACCESS = 0;
const int SMB_ACL_TYPE_DEFAULT = 1;
--
1.7.9.5
From bdc1e25193817f54fd5ae165b4a69aa1a4a176b8 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 19 Jan 2015 10:52:11 +0100
Subject: [PATCH 03/13] lib: Simplify pidfile.c
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/util/pidfile.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/lib/util/pidfile.c b/lib/util/pidfile.c
index 4960be6..5590780 100644
--- a/lib/util/pidfile.c
+++ b/lib/util/pidfile.c
@@ -34,19 +34,17 @@
*/
pid_t pidfile_pid(const char *piddir, const char *name)
{
+ size_t len = strlen(piddir) + strlen(name) + 6;
+ char pidFile[len];
int fd;
char pidstr[20];
pid_t ret = -1;
- char *pidFile;
- if (asprintf(&pidFile, "%s/%s.pid", piddir, name) < 0) {
- return 0;
- }
+ snprintf(pidFile, sizeof(pidFile), "%s/%s.pid", piddir, name);
fd = open(pidFile, O_NONBLOCK | O_RDONLY, 0644);
if (fd == -1) {
- SAFE_FREE(pidFile);
return 0;
}
@@ -76,7 +74,6 @@ pid_t pidfile_pid(const char *piddir, const char *name)
}
close(fd);
- SAFE_FREE(pidFile);
DEBUG(10, ("Process with PID=%d is running.\n", (int)ret));
return ret;
@@ -85,7 +82,6 @@ pid_t pidfile_pid(const char *piddir, const char *name)
DEBUG(10, ("Deleting %s, since %d is not a Samba process.\n", pidFile,
(int)ret));
unlink(pidFile);
- SAFE_FREE(pidFile);
return 0;
}
@@ -94,15 +90,13 @@ pid_t pidfile_pid(const char *piddir, const char *name)
*/
void pidfile_create(const char *piddir, const char *name)
{
+ size_t len = strlen(piddir) + strlen(name) + 6;
+ char pidFile[len];
int fd;
char buf[20];
- char *pidFile;
pid_t pid;
- if (asprintf(&pidFile, "%s/%s.pid", piddir, name) < 0) {
- DEBUG(0,("ERROR: Out of memory\n"));
- exit(1);
- }
+ snprintf(pidFile, sizeof(pidFile), "%s/%s.pid", piddir, name);
pid = pidfile_pid(piddir, name);
if (pid != 0) {
@@ -135,7 +129,6 @@ void pidfile_create(const char *piddir, const char *name)
}
/* Leave pid file open & locked for the duration... */
- SAFE_FREE(pidFile);
}
void pidfile_unlink(const char *piddir, const char *name)
--
1.7.9.5
From 82f13ee35031fa780d938e5caf15b2327cfd9df1 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 25 Feb 2015 20:42:33 +0000
Subject: [PATCH 04/13] libsmb: Use tevent_req_poll_ntstatus
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/smb/smb1cli_trans.c | 3 +--
libcli/smb/smbXcli_base.c | 6 ++----
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/libcli/smb/smb1cli_trans.c b/libcli/smb/smb1cli_trans.c
index 38d4e2e..59888ba 100644
--- a/libcli/smb/smb1cli_trans.c
+++ b/libcli/smb/smb1cli_trans.c
@@ -894,8 +894,7 @@ NTSTATUS smb1cli_trans(TALLOC_CTX *mem_ctx, struct smbXcli_conn *conn,
goto fail;
}
- if (!tevent_req_poll(req, ev)) {
- status = map_nt_error_from_unix_common(errno);
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
goto fail;
}
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index 2b34980..5773ab3 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -590,9 +590,8 @@ NTSTATUS smbXcli_conn_samba_suicide(struct smbXcli_conn *conn,
if (req == NULL) {
goto fail;
}
- ok = tevent_req_poll(req, ev);
+ ok = tevent_req_poll_ntstatus(req, ev, &status);
if (!ok) {
- status = map_nt_error_from_unix_common(errno);
goto fail;
}
status = smbXcli_conn_samba_suicide_recv(req);
@@ -4876,9 +4875,8 @@ NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
if (req == NULL) {
goto fail;
}
- ok = tevent_req_poll(req, ev);
+ ok = tevent_req_poll_ntstatus(req, ev, &status);
if (!ok) {
- status = map_nt_error_from_unix_common(errno);
goto fail;
}
status = smbXcli_negprot_recv(req);
--
1.7.9.5
From c40db4c6c084d5e807c725fa233d17328ab86d76 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 23 Jan 2015 13:32:45 +0000
Subject: [PATCH 05/13] winbind: Slightly simplify wb_sids2xids
We only needs "names" and "domains" wb_sids2xids_lookupsids_done. It confused
me when reading this code that these variables are stored in "state".
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/wb_sids2xids.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/source3/winbindd/wb_sids2xids.c b/source3/winbindd/wb_sids2xids.c
index 3e6f235..7614974 100644
--- a/source3/winbindd/wb_sids2xids.c
+++ b/source3/winbindd/wb_sids2xids.c
@@ -36,9 +36,6 @@ struct wb_sids2xids_state {
struct dom_sid *non_cached;
uint32_t num_non_cached;
- struct lsa_RefDomainList *domains;
- struct lsa_TransNameArray *names;
-
/*
* Domain array to use for the idmap call. The output from
* lookupsids cannot be used directly since for migrated
@@ -158,12 +155,13 @@ static void wb_sids2xids_lookupsids_done(struct tevent_req *subreq)
subreq, struct tevent_req);
struct wb_sids2xids_state *state = tevent_req_data(
req, struct wb_sids2xids_state);
+ struct lsa_RefDomainList *domains = NULL;
+ struct lsa_TransNameArray *names = NULL;
struct winbindd_child *child;
NTSTATUS status;
int i;
- status = wb_lookupsids_recv(subreq, state, &state->domains,
- &state->names);
+ status = wb_lookupsids_recv(subreq, state, &domains, &names);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
@@ -184,13 +182,13 @@ static void wb_sids2xids_lookupsids_done(struct tevent_req *subreq)
for (i=0; i<state->num_non_cached; i++) {
struct dom_sid dom_sid;
struct lsa_DomainInfo *info;
- struct lsa_TranslatedName *n = &state->names->names[i];
+ struct lsa_TranslatedName *n = &names->names[i];
struct wbint_TransID *t = &state->ids.ids[i];
sid_copy(&dom_sid, &state->non_cached[i]);
sid_split_rid(&dom_sid, &t->rid);
- info = &state->domains->domains[n->sid_index];
+ 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,
@@ -200,6 +198,9 @@ static void wb_sids2xids_lookupsids_done(struct tevent_req *subreq)
t->xid.type = t->type;
}
+ TALLOC_FREE(names);
+ TALLOC_FREE(domains);
+
child = idmap_child();
subreq = dcerpc_wbint_Sids2UnixIDs_send(
--
1.7.9.5
From a8fe39c218118595dc37e0d21686025269becfed Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Jan 2015 11:46:28 +0100
Subject: [PATCH 06/13] param: Remove lib/param/generic.c
This seems completely unused.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/param/generic.c | 276 -----------------------------------------------
lib/param/param.h | 21 ----
lib/param/wscript_build | 2 +-
3 files changed, 1 insertion(+), 298 deletions(-)
delete mode 100644 lib/param/generic.c
diff --git a/lib/param/generic.c b/lib/param/generic.c
deleted file mode 100644
index 8becffb..0000000
--- a/lib/param/generic.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * Copyright (C) Jelmer Vernooij 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/>.
- */
-
-#include "includes.h"
-#include "../lib/util/dlinklist.h"
-#include "../lib/util/parmlist.h"
-#include "param/param.h"
-#include "param/loadparm.h"
-#include "system/filesys.h"
-
-struct param_section *param_get_section(struct param_context *ctx, const char *name)
-{
- struct param_section *sect;
-
- if (name == NULL)
- name = GLOBAL_NAME;
-
- for (sect = ctx->sections; sect; sect = sect->next) {
- if (!strcasecmp_m(sect->name, name))
- return sect;
- }
-
- return NULL;
-}
-
-struct parmlist_entry *param_section_get(struct param_section *section, const char *name)
-{
- return parmlist_get(section->parameters, name);
-}
-
-struct param_section *param_add_section(struct param_context *ctx, const char *section_name)
-{
- struct param_section *section;
- section = talloc_zero(ctx, struct param_section);
- if (section == NULL)
- return NULL;
-
- section->name = talloc_strdup(section, section_name);
- DLIST_ADD_END(ctx->sections, section, struct param_section *);
- return section;
-}
-
-/* Look up parameter. If it is not found, add it */
-struct parmlist_entry *param_get_add(struct param_context *ctx, const char *name, const char *section_name)
-{
- struct param_section *section;
- struct parmlist_entry *p;
-
- SMB_ASSERT(section_name != NULL);
- SMB_ASSERT(name != NULL);
-
- section = param_get_section(ctx, section_name);
-
- if (section == NULL) {
- section = param_add_section(ctx, section_name);
- }
-
- p = param_section_get(section, name);
- if (p == NULL) {
- p = talloc_zero(section, struct parmlist_entry);
- if (p == NULL)
- return NULL;
-
- p->key = talloc_strdup(p, name);
- DLIST_ADD_END(section->parameters->entries, p, struct parmlist_entry *);
- }
-
- return p;
-}
-
-const char *param_get_string(struct param_context *ctx, const char *param, const char *section_name)
-{
- struct param_section *section = param_get_section(ctx, section_name);
-
- if (section == NULL)
- return NULL;
-
- return parmlist_get_string(section->parameters, param, NULL);
-}
-
-int param_set_string(struct param_context *ctx, const char *param, const char *value, const char *section_name)
-{
- struct param_section *section = param_get_section(ctx, section_name);
-
- if (section == NULL)
- return -1;
-
- return parmlist_set_string(section->parameters, param, value);
-}
-
-const char **param_get_string_list(struct param_context *ctx, const char *param, const char *separator, const char *section_name)
-{
- struct param_section *section = param_get_section(ctx, section_name);
-
- if (section == NULL)
- return NULL;
-
- return parmlist_get_string_list(section->parameters, param, separator);
-}
-
-int param_set_string_list(struct param_context *ctx, const char *param, const char **list, const char *section)
-{
- struct parmlist_entry *p = param_get_add(ctx, param, section);
-
- p->value = str_list_join(p, list, ' ');
-
- return 0;
-}
-
-int param_get_int(struct param_context *ctx, const char *param, int default_v, const char *section_name)
-{
- struct param_section *section = param_get_section(ctx, section_name);
-
- if (section == NULL)
- return default_v;
-
- return parmlist_get_int(section->parameters, param, default_v);
-}
-
-void param_set_int(struct param_context *ctx, const char *param, int value, const char *section)
-{
- struct parmlist_entry *p = param_get_add(ctx, section, param);
-
- if (!p)
- return;
-
- p->value = talloc_asprintf(p, "%d", value);
-}
-
-unsigned long param_get_ulong(struct param_context *ctx, const char *param, unsigned long default_v, const char *section)
-{
- const char *value = param_get_string(ctx, param, section);
-
- if (value)
- return strtoul(value, NULL, 0);
-
- return default_v;
-}
-
-void param_set_ulong(struct param_context *ctx, const char *name, unsigned long value, const char *section)
-{
- struct parmlist_entry *p = param_get_add(ctx, name, section);
-
- if (!p)
- return;
-
- p->value = talloc_asprintf(p, "%lu", value);
-}
-
-static bool param_sfunc (const char *name, void *_ctx)
-{
- struct param_context *ctx = (struct param_context *)_ctx;
- struct param_section *section = param_get_section(ctx, name);
-
- if (section == NULL) {
- section = talloc_zero(ctx, struct param_section);
- if (section == NULL)
- return false;
-
- section->name = talloc_strdup(section, name);
-
- DLIST_ADD_END(ctx->sections, section, struct param_section *);
- }
-
- /* Make sure this section is on top of the list for param_pfunc */
- DLIST_PROMOTE(ctx->sections, section);
-
- return true;
-}
-
-static bool param_pfunc (const char *name, const char *value, void *_ctx)
-{
- struct param_context *ctx = (struct param_context *)_ctx;
- struct parmlist_entry *p = param_section_get(ctx->sections, name);
-
- if (!p) {
- p = talloc_zero(ctx->sections, struct parmlist_entry);
- if (p == NULL)
- return false;
-
- p->key = talloc_strdup(p, name);
- p->value = talloc_strdup(p, value);
- DLIST_ADD(ctx->sections->parameters->entries, p);
- } else { /* Replace current value */
- talloc_free(p->value);
- p->value = talloc_strdup(p, value);
- }
-
- return true;
-}
-
-struct param_context *param_init(TALLOC_CTX *mem_ctx)
-{
- return talloc_zero(mem_ctx, struct param_context);
-}
-
-
-int param_read(struct param_context *ctx, const char *fn)
-{
- ctx->sections = talloc_zero(ctx, struct param_section);
- if (ctx->sections == NULL)
- return -1;
-
- ctx->sections->name = talloc_strdup(ctx->sections, "global");
- if (!pm_process( fn, param_sfunc, param_pfunc, ctx)) {
- return -1;
- }
-
- return 0;
-}
-
-int param_use(struct loadparm_context *lp_ctx, struct param_context *ctx)
-{
- struct param_section *section;
-
- for (section = ctx->sections; section; section = section->next) {
- struct parmlist_entry *param;
- bool isglobal = strcmp(section->name, "global") == 0;
- for (param = section->parameters->entries; param; param = param->next) {
- if (isglobal)
- lpcfg_do_global_parameter(lp_ctx, param->key,
- param->value);
- else {
- struct loadparm_service *service =
- lpcfg_service(lp_ctx, section->name);
- if (service == NULL)
- service = lpcfg_add_service(lp_ctx, lpcfg_default_service(lp_ctx), section->name);
- lpcfg_do_service_parameter(lp_ctx, service, param->key, param->value);
- }
- }
- }
- return 0;
-}
-
-int param_write(struct param_context *ctx, const char *fn)
-{
- int file;
- struct param_section *section;
-
- if (fn == NULL || ctx == NULL)
- return -1;
-
- file = open(fn, O_WRONLY|O_CREAT, 0755);
-
- if (file == -1)
- return -1;
-
- for (section = ctx->sections; section; section = section->next) {
- struct parmlist_entry *param;
-
- fdprintf(file, "[%s]\n", section->name);
- for (param = section->parameters->entries; param; param = param->next) {
- fdprintf(file, "\t%s = %s\n", param->key, param->value);
- }
- fdprintf(file, "\n");
- }
-
- close(file);
-
- return 0;
-}
diff --git a/lib/param/param.h b/lib/param/param.h
index 2fb6d4b..5e8d2bd 100644
--- a/lib/param/param.h
+++ b/lib/param/param.h
@@ -213,27 +213,6 @@ struct dcerpc_server_info *lpcfg_dcerpc_server_info(TALLOC_CTX *mem_ctx, struct
struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *, struct loadparm_context *);
-/* The following definitions come from param/generic.c */
-
-struct param_section *param_get_section(struct param_context *ctx, const char *name);
-struct parmlist_entry *param_section_get(struct param_section *section,
- const char *name);
-struct parmlist_entry *param_get (struct param_context *ctx, const char *name, const char *section_name);
-struct param_section *param_add_section(struct param_context *ctx, const char *section_name);
-struct parmlist_entry *param_get_add(struct param_context *ctx, const char *name, const char *section_name);
-const char *param_get_string(struct param_context *ctx, const char *param, const char *section);
-int param_set_string(struct param_context *ctx, const char *param, const char *value, const char *section);
-const char **param_get_string_list(struct param_context *ctx, const char *param, const char *separator, const char *section);
-int param_set_string_list(struct param_context *ctx, const char *param, const char **list, const char *section);
-int param_get_int(struct param_context *ctx, const char *param, int default_v, const char *section);
-void param_set_int(struct param_context *ctx, const char *param, int value, const char *section);
-unsigned long param_get_ulong(struct param_context *ctx, const char *param, unsigned long default_v, const char *section);
-void param_set_ulong(struct param_context *ctx, const char *name, unsigned long value, const char *section);
-struct param_context *param_init(TALLOC_CTX *mem_ctx);
-int param_read(struct param_context *ctx, const char *fn);
-int param_use(struct loadparm_context *lp_ctx, struct param_context *ctx);
-int param_write(struct param_context *ctx, const char *fn);
-
/* The following definitions come from param/util.c */
diff --git a/lib/param/wscript_build b/lib/param/wscript_build
index 69746bc..66003e9 100644
--- a/lib/param/wscript_build
+++ b/lib/param/wscript_build
@@ -30,7 +30,7 @@ bld.SAMBA_LIBRARY('server-role',
private_library=True)
bld.SAMBA_LIBRARY('samba-hostconfig',
- source='loadparm.c generic.c util.c param_table.c',
+ source='loadparm.c util.c param_table.c',
pc_files='samba-hostconfig.pc',
vnum='0.0.1',
deps='DYNCONFIG server-role tdb',
--
1.7.9.5
From ea68e3676a8cf85a7e0dc2cdd4f50dd58ebad92e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 12 Dec 2014 23:00:41 +0100
Subject: [PATCH 07/13] winbind: Simplify winbindd_dsgetdcname_recv
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/winbindd_dsgetdcname.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/source3/winbindd/winbindd_dsgetdcname.c b/source3/winbindd/winbindd_dsgetdcname.c
index c447b3a..8eb1de7 100644
--- a/source3/winbindd/winbindd_dsgetdcname.c
+++ b/source3/winbindd/winbindd_dsgetdcname.c
@@ -101,6 +101,7 @@ NTSTATUS winbindd_dsgetdcname_recv(struct tevent_req *req,
{
struct winbindd_dsgetdcname_state *state = tevent_req_data(
req, struct winbindd_dsgetdcname_state);
+ struct GUID_txt_buf guid_str_buf;
char *guid_str;
NTSTATUS status;
@@ -109,10 +110,6 @@ NTSTATUS winbindd_dsgetdcname_recv(struct tevent_req *req,
return status;
}
- guid_str = GUID_string(talloc_tos(), &state->dc_info->domain_guid);
- if (guid_str == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
fstrcpy(response->data.dsgetdcname.dc_unc,
state->dc_info->dc_unc);
@@ -120,8 +117,11 @@ NTSTATUS winbindd_dsgetdcname_recv(struct tevent_req *req,
state->dc_info->dc_address);
response->data.dsgetdcname.dc_address_type =
state->dc_info->dc_address_type;
+
+ guid_str = GUID_buf_string(&state->dc_info->domain_guid,
+ &guid_str_buf);
fstrcpy(response->data.dsgetdcname.domain_guid, guid_str);
- TALLOC_FREE(guid_str);
+
fstrcpy(response->data.dsgetdcname.domain_name,
state->dc_info->domain_name);
fstrcpy(response->data.dsgetdcname.forest_name,
--
1.7.9.5
From 320776cbb1e63e0aa0d8e9ce4b6c61bcacb85892 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 23 Feb 2015 11:04:58 +0000
Subject: [PATCH 08/13] smbd: ZERO_STRUCTP -> talloc_zero()
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/smbd/dir.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 36d95d5..4883916 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -522,15 +522,13 @@ NTSTATUS dptr_create(connection_struct *conn,
dptr_idleoldest(sconn);
}
- dptr = talloc(NULL, struct dptr_struct);
+ dptr = talloc_zero(NULL, struct dptr_struct);
if(!dptr) {
DEBUG(0,("talloc fail in dptr_create.\n"));
TALLOC_FREE(dir_hnd);
return NT_STATUS_NO_MEMORY;
}
- ZERO_STRUCTP(dptr);
-
dptr->path = talloc_strdup(dptr, path);
if (!dptr->path) {
TALLOC_FREE(dptr);
--
1.7.9.5
From a969083fa2e20eb6cf0681591d64e5651091d1c6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 23 Feb 2015 11:07:32 +0000
Subject: [PATCH 09/13] smbd: ZERO_STRUCT -> struct assignment
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/smbd/dir.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 4883916..16ce0490 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -771,8 +771,7 @@ static char *dptr_ReadDirName(TALLOC_CTX *ctx,
return NULL;
/* Create an smb_filename with stream_name == NULL. */
- ZERO_STRUCT(smb_fname_base);
- smb_fname_base.base_name = pathreal;
+ smb_fname_base = (struct smb_filename) { .base_name = pathreal };
if (SMB_VFS_STAT(dptr->conn, &smb_fname_base) == 0) {
*pst = smb_fname_base.st;
--
1.7.9.5
From 3087bff4fcb7982e522d4f45316ac94066c14b6e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 23 Feb 2015 11:08:30 +0000
Subject: [PATCH 10/13] smbd: ZERO_STRUCT -> struct assignment
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/smbd/dir.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 16ce0490..aa81a38 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -1138,9 +1138,9 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
talloc_get_size(dname));
/* Create smb_fname with NULL stream_name. */
- ZERO_STRUCT(smb_fname);
- smb_fname.base_name = pathreal;
- smb_fname.st = sbuf;
+ smb_fname = (struct smb_filename) {
+ .base_name = pathreal, .st = sbuf
+ };
ok = mode_fn(ctx, private_data, &smb_fname, &mode);
if (!ok) {
--
1.7.9.5
From 5a6b7e35325c8db3e165240d509c2f411b20be44 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 23 Feb 2015 11:17:59 +0000
Subject: [PATCH 11/13] smbd: ZERO_STRUCT -> struct init
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/smbd/trans2.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index bdad126..a732bac 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -1620,7 +1620,10 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
uint64_t allocation_size = 0;
uint64_t file_index = 0;
size_t len = 0;
- struct timespec mdate_ts, adate_ts, cdate_ts, create_date_ts;
+ struct timespec mdate_ts = {0};
+ struct timespec adate_ts = {0};
+ struct timespec cdate_ts = {0};
+ struct timespec create_date_ts = {0};
time_t mdate = (time_t)0, adate = (time_t)0, create_date = (time_t)0;
char *nameptr;
char *last_entry_ptr;
@@ -1630,11 +1633,6 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
NTSTATUS status;
struct readdir_attr_data *readdir_attr_data = NULL;
- ZERO_STRUCT(mdate_ts);
- ZERO_STRUCT(adate_ts);
- ZERO_STRUCT(create_date_ts);
- ZERO_STRUCT(cdate_ts);
-
if (!(mode & FILE_ATTRIBUTE_DIRECTORY)) {
file_size = get_file_size_stat(&smb_fname->st);
}
--
1.7.9.5
From d7211f117f96ceff509588e232ac7b52bb081b48 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 24 Feb 2015 13:46:09 +0000
Subject: [PATCH 12/13] smbd: Simplify ReadDirName
In the if-branches we return, so no "else" necessary
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/smbd/dir.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index aa81a38..073ac2f 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -1652,14 +1652,16 @@ const char *ReadDirName(struct smb_Dir *dirp, long *poffset,
dirp->file_number++;
*ptalloced = NULL;
return n;
- } else if (*poffset == END_OF_DIRECTORY_OFFSET) {
+ }
+
+ if (*poffset == END_OF_DIRECTORY_OFFSET) {
*poffset = dirp->offset = END_OF_DIRECTORY_OFFSET;
return NULL;
- } else {
- /* A real offset, seek to it. */
- SeekDir(dirp, *poffset);
}
+ /* A real offset, seek to it. */
+ SeekDir(dirp, *poffset);
+
while ((n = vfs_readdirname(conn, dirp->dir, sbuf, &talloced))) {
/* Ignore . and .. - we've already returned them. */
if (*n == '.') {
--
1.7.9.5
From 4ea09d1bd248cffaaec70751de231073c55f448e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 24 Feb 2015 14:03:11 +0000
Subject: [PATCH 13/13] vfs_catia: Simplify init_mappings()
No else required after return
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/vfs_catia.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index 6743dfe..35cae1e 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -210,7 +210,8 @@ static bool init_mappings(connection_struct *conn,
if (share_level->mappings) {
(*selected_out) = share_level;
return True;
- } else if (global->mappings) {
+ }
+ if (global->mappings) {
share_level->mappings = global->mappings;
(*selected_out) = share_level;
return True;
--
1.7.9.5
More information about the samba-technical
mailing list