[PATCH] A few cleanups
Volker Lendecke
Volker.Lendecke at SerNet.DE
Sun Nov 8 19:34:01 UTC 2015
Hi!
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 f097d25c42a74c8ea2a545dd545b632d9990b5d8 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 8 Nov 2015 10:16:04 +0100
Subject: [PATCH 1/6] vfs_fruit: Fix a typo
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/vfs_fruit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index a09e288..bd71ff1 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1839,7 +1839,7 @@ static NTSTATUS check_aapl(vfs_handle_struct *handle,
}
if (aapl->data.length != 24) {
- DEBUG(1, ("unexpected AAPL ctxt legnth: %ju\n",
+ DEBUG(1, ("unexpected AAPL ctxt length: %ju\n",
(uintmax_t)aapl->data.length));
return NT_STATUS_INVALID_PARAMETER;
}
--
1.9.1
From ad681d3aeabd210b32f1477f17c06c4e1b41b491 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 6 Nov 2015 15:39:45 +0100
Subject: [PATCH 2/6] lib: Increase a debuglevel
We do this every time when a process exits. If that process has
properly cleaned up after itself, we spit out this message.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 3a8bc67..2b28ff2 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1967,8 +1967,8 @@ struct server_id pid_to_procid(pid_t pid)
ret = messaging_dgm_get_unique(pid, &unique);
if (ret != 0) {
- DBG_WARNING("messaging_dgm_get_unique failed: %s\n",
- strerror(ret));
+ DBG_NOTICE("messaging_dgm_get_unique failed: %s\n",
+ strerror(ret));
}
return (struct server_id) {
--
1.9.1
From 2b645defccaa10874f64e203c1cba4fdc0965c0a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 6 Nov 2015 16:59:44 +0100
Subject: [PATCH 3/6] lib: Move some procid functions out of util.c
Including proto.h just for pid_to_procid() is a pain...
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/proto.h | 9 +++----
source3/lib/util.c | 43 -----------------------------
source3/lib/util_procid.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++
source3/lib/util_procid.h | 37 +++++++++++++++++++++++++
source3/wscript_build | 1 +
5 files changed, 110 insertions(+), 49 deletions(-)
create mode 100644 source3/lib/util_procid.c
create mode 100644 source3/lib/util_procid.h
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c2d9166..9dd08fb 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -433,14 +433,11 @@ bool unix_wild_match(const char *pattern, const char *string);
bool name_to_fqdn(fstring fqdn, const char *name);
void *talloc_append_blob(TALLOC_CTX *mem_ctx, void *buf, DATA_BLOB blob);
uint32_t map_share_mode_to_deny_mode(uint32_t share_access, uint32_t private_options);
-pid_t procid_to_pid(const struct server_id *proc);
-void set_my_vnn(uint32_t vnn);
-uint32_t get_my_vnn(void);
-struct server_id pid_to_procid(pid_t pid);
+
+#include "lib/util_procid.h"
+
#define serverid_equal(p1, p2) server_id_equal(p1,p2)
struct server_id interpret_pid(const char *pid_string);
-bool procid_valid(const struct server_id *pid);
-bool procid_is_local(const struct server_id *pid);
bool is_offset_safe(const char *buf_base, size_t buf_len, char *ptr, size_t off);
char *get_safe_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
char *get_safe_str_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 2b28ff2..420fe91 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1942,54 +1942,11 @@ uint32_t map_share_mode_to_deny_mode(uint32_t share_access, uint32_t private_opt
return (uint32_t)-1;
}
-pid_t procid_to_pid(const struct server_id *proc)
-{
- return proc->pid;
-}
-
-static uint32_t my_vnn = NONCLUSTER_VNN;
-
-void set_my_vnn(uint32_t vnn)
-{
- DEBUG(10, ("vnn pid %d = %u\n", (int)getpid(), (unsigned int)vnn));
- my_vnn = vnn;
-}
-
-uint32_t get_my_vnn(void)
-{
- return my_vnn;
-}
-
-struct server_id pid_to_procid(pid_t pid)
-{
- uint64_t unique = 0;
- int ret;
-
- ret = messaging_dgm_get_unique(pid, &unique);
- if (ret != 0) {
- DBG_NOTICE("messaging_dgm_get_unique failed: %s\n",
- strerror(ret));
- }
-
- return (struct server_id) {
- .pid = pid, .unique_id = unique, .vnn = my_vnn };
-}
-
struct server_id interpret_pid(const char *pid_string)
{
return server_id_from_string(get_my_vnn(), pid_string);
}
-bool procid_valid(const struct server_id *pid)
-{
- return (pid->pid != (uint64_t)-1);
-}
-
-bool procid_is_local(const struct server_id *pid)
-{
- return pid->vnn == my_vnn;
-}
-
/****************************************************************
Check if an offset into a buffer is safe.
If this returns True it's safe to indirect into the byte at
diff --git a/source3/lib/util_procid.c b/source3/lib/util_procid.c
new file mode 100644
index 0000000..0ae99cc
--- /dev/null
+++ b/source3/lib/util_procid.c
@@ -0,0 +1,69 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Samba utility functions
+ * Copyright (C) Andrew Tridgell 1992-1998
+ * Copyright (C) Jeremy Allison 2001-2007
+ * Copyright (C) Simo Sorce 2001
+ * Copyright (C) Jim McDonough <jmcd at us.ibm.com> 2003
+ * Copyright (C) James Peach 2006
+ *
+ * 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 "util_procid.h"
+#include "lib/util/debug.h"
+#include "lib/messages_dgm.h"
+
+pid_t procid_to_pid(const struct server_id *proc)
+{
+ return proc->pid;
+}
+
+static uint32_t my_vnn = NONCLUSTER_VNN;
+
+void set_my_vnn(uint32_t vnn)
+{
+ DEBUG(10, ("vnn pid %d = %u\n", (int)getpid(), (unsigned int)vnn));
+ my_vnn = vnn;
+}
+
+uint32_t get_my_vnn(void)
+{
+ return my_vnn;
+}
+
+struct server_id pid_to_procid(pid_t pid)
+{
+ uint64_t unique = 0;
+ int ret;
+
+ ret = messaging_dgm_get_unique(pid, &unique);
+ if (ret != 0) {
+ DBG_NOTICE("messaging_dgm_get_unique failed: %s\n",
+ strerror(ret));
+ }
+
+ return (struct server_id) {
+ .pid = pid, .unique_id = unique, .vnn = my_vnn };
+}
+
+bool procid_valid(const struct server_id *pid)
+{
+ return (pid->pid != (uint64_t)-1);
+}
+
+bool procid_is_local(const struct server_id *pid)
+{
+ return pid->vnn == my_vnn;
+}
diff --git a/source3/lib/util_procid.h b/source3/lib/util_procid.h
new file mode 100644
index 0000000..9637363
--- /dev/null
+++ b/source3/lib/util_procid.h
@@ -0,0 +1,37 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Samba utility functions
+ * Copyright (C) Andrew Tridgell 1992-1998
+ * Copyright (C) Jeremy Allison 2001-2007
+ * Copyright (C) Simo Sorce 2001
+ * Copyright (C) Jim McDonough <jmcd at us.ibm.com> 2003
+ * Copyright (C) James Peach 2006
+ *
+ * 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/>.
+ */
+
+#ifndef __LIB_UTIL_PROCID_H__
+#define __LIB_UTIL_PROCID_H__
+
+#include "replace.h"
+#include "librpc/gen_ndr/server_id.h"
+
+pid_t procid_to_pid(const struct server_id *proc);
+void set_my_vnn(uint32_t vnn);
+uint32_t get_my_vnn(void);
+struct server_id pid_to_procid(pid_t pid);
+bool procid_valid(const struct server_id *pid);
+bool procid_is_local(const struct server_id *pid);
+
+#endif
diff --git a/source3/wscript_build b/source3/wscript_build
index 1f9f757..be749ef 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -255,6 +255,7 @@ bld.SAMBA3_SUBSYSTEM('samba3util',
lib/util_sid.c
lib/util_file.c
lib/util.c
+ lib/util_procid.c
lib/util_sock.c
lib/util_tsock.c
lib/util_transfer_file.c
--
1.9.1
From 8b06aa674604558bf815652bce8a43af1ea6ddd1 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 2 Nov 2015 12:46:35 +0100
Subject: [PATCH 4/6] lib: messages.h references struct iovec
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/messages.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/source3/include/messages.h b/source3/include/messages.h
index 35f5ea7..8bbe026 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -60,6 +60,7 @@
#include "librpc/gen_ndr/server_id.h"
#include "lib/util/data_blob.h"
+#include "system/network.h"
#define MSG_BROADCAST_PID_STR "0:0"
--
1.9.1
From 63fa5942a8665e510aa3c00de9d0c06d7e99932f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 8 Nov 2015 10:43:59 +0100
Subject: [PATCH 5/6] vfs_cap: Fix a warning
clang warns about increased alignment cast. talloc_size does align properly.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/vfs_cap.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c
index b5a1906..ab17376 100644
--- a/source3/modules/vfs_cap.c
+++ b/source3/modules/vfs_cap.c
@@ -73,13 +73,12 @@ static struct dirent *cap_readdir(vfs_handle_struct *handle,
}
DEBUG(3,("cap: cap_readdir: %s\n", newname));
newnamelen = strlen(newname)+1;
- newdirent = (struct dirent *)talloc_array(talloc_tos(),
- char,
- sizeof(struct dirent)+
- newnamelen);
+ newdirent = talloc_size(
+ talloc_tos(), sizeof(struct dirent) + newnamelen);
if (!newdirent) {
return NULL;
}
+ talloc_set_name_const(newdirent, "struct dirent");
memcpy(newdirent, result, sizeof(struct dirent));
memcpy(&newdirent->d_name, newname, newnamelen);
return newdirent;
--
1.9.1
From 6c04f71f3d35122a81da47c6400c02b1d117e3ac Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 8 Nov 2015 11:34:40 +0100
Subject: [PATCH 6/6] vfs_acl_*: Only sha256 needed
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/vfs_acl_tdb.c | 2 +-
source3/modules/vfs_acl_xattr.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/modules/vfs_acl_tdb.c b/source3/modules/vfs_acl_tdb.c
index c7acf43..62559a2 100644
--- a/source3/modules/vfs_acl_tdb.c
+++ b/source3/modules/vfs_acl_tdb.c
@@ -23,7 +23,7 @@
#include "system/filesys.h"
#include "librpc/gen_ndr/xattr.h"
#include "librpc/gen_ndr/ndr_xattr.h"
-#include "../lib/crypto/crypto.h"
+#include "../lib/crypto/sha256.h"
#include "dbwrap/dbwrap.h"
#include "dbwrap/dbwrap_open.h"
#include "auth.h"
diff --git a/source3/modules/vfs_acl_xattr.c b/source3/modules/vfs_acl_xattr.c
index 710fbf3..2338798 100644
--- a/source3/modules/vfs_acl_xattr.c
+++ b/source3/modules/vfs_acl_xattr.c
@@ -22,7 +22,7 @@
#include "smbd/smbd.h"
#include "librpc/gen_ndr/xattr.h"
#include "librpc/gen_ndr/ndr_xattr.h"
-#include "../lib/crypto/crypto.h"
+#include "../lib/crypto/sha256.h"
#include "auth.h"
#undef DBGC_CLASS
--
1.9.1
More information about the samba-technical
mailing list