[SCM] Samba Shared Repository - branch master updated
Martin Schwenke
martins at samba.org
Sun Sep 22 10:45:02 UTC 2024
The branch, master has been updated
via 25a222225db ctdb: Use str_list_add_printf() in lock_helper_args()
via 83716809a8f ctdb: Change the ctdb_vfork_exec prototype to const char*const*
via cc76e2c7d7d smbd: We can expect the file to exist in is_visible_fsp()
from 81ecdb125bf auth: Fix CID 1615191 Uninitialized scalar variable
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 25a222225db1779d09d8c97aee6b5d9be1c6dbe8
Author: Volker Lendecke <vl at samba.org>
Date: Thu Sep 19 17:32:42 2024 +0200
ctdb: Use str_list_add_printf() in lock_helper_args()
Saves lines, str_list_add_printf takes care of NULL checks
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Martin Schwenke <martin at meltin.net>
Autobuild-User(master): Martin Schwenke <martins at samba.org>
Autobuild-Date(master): Sun Sep 22 10:44:59 UTC 2024 on atb-devel-224
commit 83716809a8ff0057aa5ef58b6f951b8d5197c67f
Author: Volker Lendecke <vl at samba.org>
Date: Fri Sep 20 02:54:57 2024 +0200
ctdb: Change the ctdb_vfork_exec prototype to const char*const*
I could not find out how to cast a char ** to const char ** without
warning. This transfers fine to the execv call as well.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit cc76e2c7d7d2535a736420283a38a89f17f5c21e
Author: Volker Lendecke <vl at samba.org>
Date: Thu Sep 19 16:09:43 2024 +0200
smbd: We can expect the file to exist in is_visible_fsp()
Another leftover from symlinks in posix context to not open an fsp
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
ctdb/include/ctdb_private.h | 8 ++--
ctdb/server/ctdb_fork.c | 8 ++--
ctdb/server/ctdb_lock.c | 92 ++++++++++++++++-----------------------------
source3/smbd/dir.c | 9 -----
4 files changed, 43 insertions(+), 74 deletions(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 88f775ce126..b36eaa08a08 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -609,9 +609,11 @@ int switch_from_server_to_client(struct ctdb_context *ctdb);
void ctdb_track_child(struct ctdb_context *ctdb, pid_t pid);
pid_t ctdb_fork(struct ctdb_context *ctdb);
-pid_t ctdb_vfork_exec(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
- const char *helper, int helper_argc,
- const char **helper_argv);
+pid_t ctdb_vfork_exec(TALLOC_CTX *mem_ctx,
+ struct ctdb_context *ctdb,
+ const char *helper,
+ int helper_argc,
+ const char *const *helper_argv);
struct tevent_signal *ctdb_init_sigchld(struct ctdb_context *ctdb);
diff --git a/ctdb/server/ctdb_fork.c b/ctdb/server/ctdb_fork.c
index 1065423199d..8f3e0896b32 100644
--- a/ctdb/server/ctdb_fork.c
+++ b/ctdb/server/ctdb_fork.c
@@ -105,9 +105,11 @@ pid_t ctdb_fork(struct ctdb_context *ctdb)
/*
* vfork + exec
*/
-pid_t ctdb_vfork_exec(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
- const char *helper, int helper_argc,
- const char **helper_argv)
+pid_t ctdb_vfork_exec(TALLOC_CTX *mem_ctx,
+ struct ctdb_context *ctdb,
+ const char *helper,
+ int helper_argc,
+ const char *const *helper_argv)
{
pid_t pid;
struct timeval before;
diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c
index d526413454e..4231313b654 100644
--- a/ctdb/server/ctdb_lock.c
+++ b/ctdb/server/ctdb_lock.c
@@ -606,68 +606,39 @@ skip_lock_debug:
(void *)lock_ctx);
}
-static bool lock_helper_args(TALLOC_CTX *mem_ctx,
- struct lock_context *lock_ctx, int fd,
- int *argc, const char ***argv)
+static char **lock_helper_args(TALLOC_CTX *mem_ctx,
+ struct lock_context *lock_ctx,
+ int fd)
{
- const char **args = NULL;
- int nargs = 0, i;
-
- switch (lock_ctx->type) {
- case LOCK_RECORD:
- nargs = 6;
- break;
-
- case LOCK_DB:
- nargs = 5;
- break;
- }
-
- /* Add extra argument for null termination */
- nargs++;
+ int tdb_flags = tdb_get_flags(lock_ctx->ctdb_db->ltdb->tdb);
+ char **args = str_list_make_empty(mem_ctx);
- args = talloc_array(mem_ctx, const char *, nargs);
- if (args == NULL) {
- return false;
- }
+ str_list_add_printf(&args, "%d", getpid());
+ str_list_add_printf(&args, "%d", fd);
+ str_list_add_printf(&args,
+ "%s",
+ (lock_ctx->type == LOCK_RECORD) ? "RECORD" : "DB");
- args[0] = talloc_asprintf(args, "%d", getpid());
- args[1] = talloc_asprintf(args, "%d", fd);
+ str_list_add_printf(&args, "%s", lock_ctx->ctdb_db->db_path);
+ str_list_add_printf(&args, "0x%x", tdb_flags);
- switch (lock_ctx->type) {
- case LOCK_RECORD:
- args[2] = talloc_strdup(args, "RECORD");
- args[3] = talloc_strdup(args, lock_ctx->ctdb_db->db_path);
- args[4] = talloc_asprintf(args, "0x%x",
- tdb_get_flags(lock_ctx->ctdb_db->ltdb->tdb));
+ if (lock_ctx->type == LOCK_RECORD) {
if (lock_ctx->key.dsize == 0) {
- args[5] = talloc_strdup(args, "NULL");
+ str_list_add_printf(&args, "NULL");
} else {
- args[5] = hex_encode_talloc(args, lock_ctx->key.dptr, lock_ctx->key.dsize);
- }
- break;
-
- case LOCK_DB:
- args[2] = talloc_strdup(args, "DB");
- args[3] = talloc_strdup(args, lock_ctx->ctdb_db->db_path);
- args[4] = talloc_asprintf(args, "0x%x",
- tdb_get_flags(lock_ctx->ctdb_db->ltdb->tdb));
- break;
- }
-
- /* Make sure last argument is NULL */
- args[nargs-1] = NULL;
-
- for (i=0; i<nargs-1; i++) {
- if (args[i] == NULL) {
- talloc_free(args);
- return false;
+ char *hex = hex_encode_talloc(mem_ctx,
+ lock_ctx->key.dptr,
+ lock_ctx->key.dsize);
+ if (hex == NULL) {
+ TALLOC_FREE(args);
+ return NULL;
+ }
+ str_list_add_printf(&args, "%s", hex);
+ TALLOC_FREE(hex);
}
}
- *argc = nargs;
- *argv = args;
- return true;
+ return args;
}
/*
@@ -733,10 +704,10 @@ static struct lock_context *ctdb_find_lock_context(struct ctdb_context *ctdb)
static void ctdb_lock_schedule(struct ctdb_context *ctdb)
{
struct lock_context *lock_ctx;
- int ret, argc;
+ int ret;
TALLOC_CTX *tmp_ctx;
static char prog[PATH_MAX+1] = "";
- const char **args;
+ char **args = NULL;
if (!ctdb_set_helper("lock helper",
prog, sizeof(prog),
@@ -779,8 +750,8 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb)
}
/* Create arguments for lock helper */
- if (!lock_helper_args(tmp_ctx, lock_ctx, lock_ctx->fd[1],
- &argc, &args)) {
+ args = lock_helper_args(tmp_ctx, lock_ctx, lock_ctx->fd[1]);
+ if (args == NULL) {
DEBUG(DEBUG_ERR, ("Failed to create lock helper args\n"));
close(lock_ctx->fd[0]);
close(lock_ctx->fd[1]);
@@ -788,8 +759,11 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb)
return;
}
- lock_ctx->child = ctdb_vfork_exec(lock_ctx, ctdb, prog, argc,
- (const char **)args);
+ lock_ctx->child = ctdb_vfork_exec(lock_ctx,
+ ctdb,
+ prog,
+ talloc_array_length(args),
+ (const char *const *)args);
if (lock_ctx->child == -1) {
DEBUG(DEBUG_ERR, ("Failed to create a child in ctdb_lock_schedule\n"));
close(lock_ctx->fd[0]);
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 147515fe2f5..406db604f8e 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -921,15 +921,6 @@ bool is_visible_fsp(struct files_struct *fsp)
int hide_new_files_timeout = 0;
const char *last_component = NULL;
- /*
- * If the file does not exist, there's no point checking
- * the configuration options. We succeed, on the basis that the
- * checks *might* have passed if the file was present.
- */
- if (fsp == NULL) {
- return true;
- }
-
hide_unreadable = lp_hide_unreadable(SNUM(fsp->conn));
hide_unwriteable = lp_hide_unwriteable_files(SNUM(fsp->conn));
hide_special = lp_hide_special_files(SNUM(fsp->conn));
--
Samba Shared Repository
More information about the samba-cvs
mailing list