[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Thu Feb 17 18:12:01 UTC 2022
The branch, master has been updated
via 2649d654cfb smbd: Make strnorm() static to filename.c
via a31ab494cfb vfs: Don't go through strnorm(..., CASE_LOWER)
via 826ae22c1bd vfs: Fix a typo
via 6d7f079029a smbd: Use ISDOT/ISDOTDOT
via 61dd0096c29 smbd: Filter out "::$DATA" for query name information
via 259a716c5ae smbd: Simplify open_file_ntcreate()
via 219dc590f89 smbd: Only open base_fsp for non-"::$DATA" streams
via 7ba970b082c vfs: Use is_named_stream() for checking if we have an ADS
via 6e77185f929 smbd: Use fsp_is_alternate_stream(), we checked for fsp!=NULL above
via 1ef6800ef66 smbd: Slightly simplify openat_pathref_fsp()
via 6f9c20cc66d vfs: Use fsp_get_pathref_fd() in aio_pthread
via ea8198ac29e libsmb: Avoid a call to SMBC_errno()
via e1674e108f2 libsmb: Avoid a call to SMBC_errno()
from 4e464fc96ae vfs_gpfs: use linux oplock specific funcions only when available
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 2649d654cfbc13d6285bcf3aaaf3c177054a2b20
Author: Volker Lendecke <vl at samba.org>
Date: Thu Feb 17 11:24:38 2022 +0100
smbd: Make strnorm() static to filename.c
The caller in vfs_prealloc was a bit unneeded, and strnorm is only
called here.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Thu Feb 17 18:11:18 UTC 2022 on sn-devel-184
commit a31ab494cfb99b42af9e05b53ab464c8514508be
Author: Volker Lendecke <vl at samba.org>
Date: Thu Feb 17 11:19:50 2022 +0100
vfs: Don't go through strnorm(..., CASE_LOWER)
With a fixed CASE_LOWER we should go directly to the lowerlevel call, this
makes it more obvious to me.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 826ae22c1bd923dc0e567d5728eb19278966e43c
Author: Volker Lendecke <vl at samba.org>
Date: Thu Feb 17 11:19:42 2022 +0100
vfs: Fix a typo
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 6d7f079029a33d4f889925d09468099e05a3221b
Author: Volker Lendecke <vl at samba.org>
Date: Thu Feb 17 11:10:00 2022 +0100
smbd: Use ISDOT/ISDOTDOT
This is simpler to read for me
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 61dd0096c295416e2fecb3611d69a5f8c681ef7e
Author: Volker Lendecke <vl at samba.org>
Date: Fri Feb 11 18:09:56 2022 +0100
smbd: Filter out "::$DATA" for query name information
Make this piece of code robust against having "::$DATA" passed in.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 259a716c5ae67109c2008b5c1a11f0873bc2d66b
Author: Volker Lendecke <vl at samba.org>
Date: Fri Feb 11 18:07:42 2022 +0100
smbd: Simplify open_file_ntcreate()
For streams our caller create_file_unixpath() has already taken care
of properly initializing fsp->base_fsp, so we can rely on
fsp_is_alternate_stream() here instead of looking at the file name.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 219dc590f89974bc1c42db287eb1ed280067346e
Author: Volker Lendecke <vl at samba.org>
Date: Fri Feb 11 18:09:00 2022 +0100
smbd: Only open base_fsp for non-"::$DATA" streams
"is_named_stream()" is more what we really mean here. Make this line robust
against callers passing in "::$DATA".
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 7ba970b082cceadfdd86968ad255c3d793164e8f
Author: Volker Lendecke <vl at samba.org>
Date: Fri Feb 11 16:13:07 2022 +0100
vfs: Use is_named_stream() for checking if we have an ADS
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 6e77185f92912a42861b3e2377f0a3b1405c2758
Author: Volker Lendecke <vl at samba.org>
Date: Fri Feb 11 15:59:06 2022 +0100
smbd: Use fsp_is_alternate_stream(), we checked for fsp!=NULL above
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 1ef6800ef6691938e2ce1e182d5a8ff8c116ac29
Author: Volker Lendecke <vl at samba.org>
Date: Thu Dec 30 18:04:55 2021 +0100
smbd: Slightly simplify openat_pathref_fsp()
We don't need to look at the full share-relative path to figure out if
we have a stream name, the original smb_fname is sufficient for this.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 6f9c20cc66d979bdf1e65b1f6f8d0ad49824961e
Author: Volker Lendecke <vl at samba.org>
Date: Mon Feb 14 13:30:43 2022 +0100
vfs: Use fsp_get_pathref_fd() in aio_pthread
We only use the fd as "dirfd" in openat, so we don't need an I/O fd
here.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit ea8198ac29e4238dc8d457b6c33290dc3fb23143
Author: Volker Lendecke <vl at samba.org>
Date: Sun Feb 13 09:25:54 2022 +0100
libsmb: Avoid a call to SMBC_errno()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit e1674e108f2937a00f3cd1ca228b6376638bb8c6
Author: Volker Lendecke <vl at samba.org>
Date: Sun Feb 13 09:21:47 2022 +0100
libsmb: Avoid a call to SMBC_errno()
This involves converting cli_print_queue() to NTSTATUS. No caller
looked at the number of jobs returned.
Review with "git show -b", most of the patch is indentation
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source3/include/proto.h | 1 -
source3/lib/util_str.c | 12 -----
source3/libsmb/cliprint.c | 103 ++++++++++++++++++++++++--------------
source3/libsmb/libsmb_file.c | 7 ++-
source3/libsmb/libsmb_printjob.c | 8 +--
source3/libsmb/proto.h | 4 +-
source3/modules/vfs_aio_pthread.c | 12 ++---
source3/modules/vfs_prealloc.c | 6 ++-
source3/smbd/filename.c | 8 +++
source3/smbd/files.c | 2 +-
source3/smbd/mangle_hash2.c | 6 +--
source3/smbd/open.c | 7 +--
source3/smbd/trans2.c | 4 +-
13 files changed, 102 insertions(+), 78 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 19a9c6b8a01..916032a931d 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -525,7 +525,6 @@ int poll_intr_one_fd(int fd, int events, int timeout, int *revents);
bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize);
bool strnequal(const char *s1,const char *s2,size_t n);
bool strcsequal(const char *s1,const char *s2);
-bool strnorm(char *s, int case_default);
char *skip_string(const char *base, size_t len, char *buf);
size_t str_charnum(const char *s);
bool trim_char(char *s,char cfront,char cback);
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index b1ed43669c0..9362969795e 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -52,18 +52,6 @@ bool strnequal(const char *s1,const char *s2,size_t n)
return(strncasecmp_m(s1,s2,n)==0);
}
-/**
- Convert a string to "normal" form.
-**/
-
-bool strnorm(char *s, int case_default)
-{
- if (case_default == CASE_UPPER)
- return strupper_m(s);
- else
- return strlower_m(s);
-}
-
/**
Skip past a string in a buffer. Buffer may not be
null terminated. end_ptr points to the first byte after
diff --git a/source3/libsmb/cliprint.c b/source3/libsmb/cliprint.c
index 309a108a72c..c4ee3420e73 100644
--- a/source3/libsmb/cliprint.c
+++ b/source3/libsmb/cliprint.c
@@ -52,16 +52,18 @@ static const char *fix_char_ptr(unsigned int datap, unsigned int converter,
call fn() on each entry in a print queue
****************************************************************************/
-int cli_print_queue(struct cli_state *cli,
- void (*fn)(struct print_job_info *))
+NTSTATUS cli_print_queue(struct cli_state *cli,
+ void (*fn)(struct print_job_info *))
{
- char *rparam = NULL;
- char *rdata = NULL;
- char *p;
- unsigned int rdrcnt, rprcnt;
+ uint8_t *rparam = NULL;
+ uint8_t *rdata = NULL;
+ char *p = NULL;
+ uint32_t rdrcnt, rprcnt;
char param[1024];
+ int converter;
int result_code=0;
int i = -1;
+ NTSTATUS status;
memset(param,'\0',sizeof(param));
@@ -82,43 +84,68 @@ int cli_print_queue(struct cli_state *cli,
DEBUG(4,("doing cli_print_queue for %s\n", cli->share));
- if (cli_api(cli,
- param, PTR_DIFF(p,param), 1024, /* Param, length, maxlen */
- NULL, 0, CLI_BUFFER_SIZE, /* data, length, maxlen */
- &rparam, &rprcnt, /* return params, length */
- &rdata, &rdrcnt)) { /* return data, length */
- int converter;
- result_code = SVAL(rparam,0);
- converter = SVAL(rparam,2); /* conversion factor */
-
- if (result_code == 0) {
- struct print_job_info job;
-
- p = rdata;
-
- for (i = 0; i < SVAL(rparam,4); ++i) {
- job.id = SVAL(p,0);
- job.priority = SVAL(p,2);
- fstrcpy(job.user,
- fix_char_ptr(SVAL(p,4), converter,
- rdata, rdrcnt));
- job.t = make_unix_date3(
- p + 12, smb1cli_conn_server_time_zone(cli->conn));
- job.size = IVAL(p,16);
- fstrcpy(job.name,fix_char_ptr(SVAL(p,24),
- converter,
- rdata, rdrcnt));
- fn(&job);
- p += 28;
- }
+ status = cli_trans(
+ talloc_tos(),
+ cli,
+ SMBtrans, /* trans_cmd */
+ "\\PIPE\\LANMAN", /* name */
+ 0, /* fid */
+ 0, /* function */
+ 0, /* flags */
+ NULL, /* setup */
+ 0, /* num_setup */
+ 0, /* max_setup */
+ (uint8_t *)param, /* param */
+ PTR_DIFF(p,param), /* num_param */
+ 1024, /* max_param */
+ NULL, /* data */
+ 0, /* num_data */
+ CLI_BUFFER_SIZE, /* max_data */
+ NULL, /* recv_flags2 */
+ NULL, /* rsetup */
+ 0, /* min_rsetup */
+ NULL, /* num_rsetup */
+ &rparam, /* rparam */
+ 8, /* min_rparam */
+ &rprcnt, /* num_rparam */
+ &rdata, /* rdata */
+ 0, /* min_rdata */
+ &rdrcnt); /* num_rdata */
+ if (!NT_STATUS_IS_OK(status)) {
+ cli->raw_status = status;
+ return status;
+ }
+
+ result_code = SVAL(rparam,0);
+ converter = SVAL(rparam,2); /* conversion factor */
+
+ if (result_code == 0) {
+ struct print_job_info job;
+
+ p = (char *)rdata;
+
+ for (i = 0; i < SVAL(rparam,4); ++i) {
+ job.id = SVAL(p,0);
+ job.priority = SVAL(p,2);
+ fstrcpy(job.user,
+ fix_char_ptr(SVAL(p,4), converter,
+ (char *)rdata, rdrcnt));
+ job.t = make_unix_date3(
+ p + 12, smb1cli_conn_server_time_zone(cli->conn));
+ job.size = IVAL(p,16);
+ fstrcpy(job.name,fix_char_ptr(SVAL(p,24),
+ converter,
+ (char *)rdata, rdrcnt));
+ fn(&job);
+ p += 28;
}
}
/* If any parameters or data were returned, free the storage. */
- SAFE_FREE(rparam);
- SAFE_FREE(rdata);
+ TALLOC_FREE(rparam);
+ TALLOC_FREE(rdata);
- return i;
+ return NT_STATUS_OK;
}
/****************************************************************************
diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index 499be92cb4a..fa301b9fa18 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -197,12 +197,11 @@ SMBC_open_ctx(SMBCCTX *context,
/* Check if opendir needed ... */
if (!NT_STATUS_IS_OK(status)) {
- int eno = 0;
-
- eno = SMBC_errno(context, srv->cli);
file = smbc_getFunctionOpendir(context)(context, fname);
- if (!file) errno = eno;
TALLOC_FREE(frame);
+ if (file == NULL) {
+ errno = cli_status_to_errno(status);
+ }
return file;
}
diff --git a/source3/libsmb/libsmb_printjob.c b/source3/libsmb/libsmb_printjob.c
index 813841a9ca9..cb567231fce 100644
--- a/source3/libsmb/libsmb_printjob.c
+++ b/source3/libsmb/libsmb_printjob.c
@@ -194,6 +194,7 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context,
char *path = NULL;
uint16_t port = 0;
TALLOC_CTX *frame = talloc_stackframe();
+ NTSTATUS status;
if (!context || !context->internal->initialized) {
errno = EINVAL;
@@ -242,10 +243,11 @@ SMBC_list_print_jobs_ctx(SMBCCTX *context,
return -1; /* errno set by SMBC_server */
}
- if (cli_print_queue(srv->cli,
- (void (*)(struct print_job_info *))fn) < 0) {
- errno = SMBC_errno(context, srv->cli);
+ status = cli_print_queue(srv->cli,
+ (void (*)(struct print_job_info *))fn);
+ if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(frame);
+ errno = cli_status_to_errno(status);
return -1;
}
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index bda4058dafe..ec66582e28a 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -801,8 +801,8 @@ NTSTATUS cli_oplock_ack_recv(struct tevent_req *req);
/* The following definitions come from libsmb/cliprint.c */
-int cli_print_queue(struct cli_state *cli,
- void (*fn)(struct print_job_info *));
+NTSTATUS cli_print_queue(struct cli_state *cli,
+ void (*fn)(struct print_job_info *));
int cli_printjob_del(struct cli_state *cli, int job);
/* The following definitions come from libsmb/cliquota.c */
diff --git a/source3/modules/vfs_aio_pthread.c b/source3/modules/vfs_aio_pthread.c
index 685f91d9f2b..d58e990a666 100644
--- a/source3/modules/vfs_aio_pthread.c
+++ b/source3/modules/vfs_aio_pthread.c
@@ -302,8 +302,8 @@ static struct aio_open_private_data *create_private_open_data(
return NULL;
}
- if (fsp_get_io_fd(dirfsp) != AT_FDCWD) {
- opd->dir_fd = fsp_get_io_fd(dirfsp);
+ if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
+ opd->dir_fd = fsp_get_pathref_fd(dirfsp);
} else {
#if defined(O_DIRECTORY)
opd->dir_fd = open(".", O_RDONLY|O_DIRECTORY);
@@ -458,7 +458,7 @@ static int aio_pthread_openat_fn(vfs_handle_struct *handle,
bool aio_allow_open = lp_parm_bool(
SNUM(handle->conn), "aio_pthread", "aio open", false);
- if (smb_fname->stream_name != NULL) {
+ if (is_named_stream(smb_fname)) {
/* Don't handle stream opens. */
errno = ENOENT;
return -1;
@@ -473,7 +473,7 @@ static int aio_pthread_openat_fn(vfs_handle_struct *handle,
if (!aio_allow_open) {
/* aio opens turned off. */
- return openat(fsp_get_io_fd(dirfsp),
+ return openat(fsp_get_pathref_fd(dirfsp),
smb_fname->base_name,
flags,
mode);
@@ -481,7 +481,7 @@ static int aio_pthread_openat_fn(vfs_handle_struct *handle,
if (!(flags & O_CREAT)) {
/* Only creates matter. */
- return openat(fsp_get_io_fd(dirfsp),
+ return openat(fsp_get_pathref_fd(dirfsp),
smb_fname->base_name,
flags,
mode);
@@ -489,7 +489,7 @@ static int aio_pthread_openat_fn(vfs_handle_struct *handle,
if (!(flags & O_EXCL)) {
/* Only creates with O_EXCL matter. */
- return openat(fsp_get_io_fd(dirfsp),
+ return openat(fsp_get_pathref_fd(dirfsp),
smb_fname->base_name,
flags,
mode);
diff --git a/source3/modules/vfs_prealloc.c b/source3/modules/vfs_prealloc.c
index 19b142e877b..467f619b8df 100644
--- a/source3/modules/vfs_prealloc.c
+++ b/source3/modules/vfs_prealloc.c
@@ -129,8 +129,10 @@ static int prealloc_openat(struct vfs_handle_struct* handle,
dot = strrchr(smb_fname->base_name, '.');
if (dot && *++dot) {
if (strlen(dot) < sizeof(fext)) {
+ bool ok;
strncpy(fext, dot, sizeof(fext));
- if (!strnorm(fext, CASE_LOWER)) {
+ ok = strlower_m(fext);
+ if (!ok);
goto normal_open;
}
}
@@ -158,7 +160,7 @@ static int prealloc_openat(struct vfs_handle_struct* handle,
return fd;
}
- /* Prellocate only if the file is being created or replaced. Note that
+ /* Preallocate only if the file is being created or replaced. Note that
* Samba won't ever pass down O_TRUNC, which is why we have to handle
* truncate calls specially.
*/
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index ef382b43bd6..00fc3c7ca68 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -418,6 +418,14 @@ NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
return NT_STATUS_OK;
}
+static bool strnorm(char *s, int case_default)
+{
+ if (case_default == CASE_UPPER)
+ return strupper_m(s);
+ else
+ return strlower_m(s);
+}
+
/*
* Utility function to normalize case on an incoming client filename
* if required on this connection struct.
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 32c9f00547a..da792a41c6e 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -497,7 +497,7 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
}
if ((conn->fs_capabilities & FILE_NAMED_STREAMS)
- && is_ntfs_stream_smb_fname(fsp->fsp_name))
+ && is_ntfs_stream_smb_fname(smb_fname))
{
/*
* We must use smb_fname here, not fsp->fsp_name
diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c
index 53e944ef61b..a8cf3527b57 100644
--- a/source3/smbd/mangle_hash2.c
+++ b/source3/smbd/mangle_hash2.c
@@ -443,10 +443,8 @@ static bool is_8_3(const char *name, bool check_case, bool allow_wildcards, cons
char *dot_p;
/* as a special case, the names '.' and '..' are allowable 8.3 names */
- if (name[0] == '.') {
- if (!name[1] || (name[1] == '.' && !name[2])) {
- return True;
- }
+ if (ISDOT(name) || (ISDOTDOT(name))) {
+ return true;
}
/* the simplest test is on the overall length of the
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index ddc9866605e..d32b7b19368 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -4034,8 +4034,9 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
*/
/* Delete streams if create_disposition requires it */
- if (!new_file_created && clear_ads(create_disposition) &&
- !is_ntfs_stream_smb_fname(smb_fname)) {
+ if (!new_file_created &&
+ clear_ads(create_disposition) &&
+ !fsp_is_alternate_stream(fsp)) {
status = delete_all_streams(conn, smb_fname);
if (!NT_STATUS_IS_OK(status)) {
del_share_mode(lck, fsp);
@@ -5664,7 +5665,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
}
if ((conn->fs_capabilities & FILE_NAMED_STREAMS)
- && is_ntfs_stream_smb_fname(smb_fname))
+ && is_named_stream(smb_fname))
{
uint32_t base_create_disposition;
struct smb_filename *smb_fname_base = NULL;
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index cf5f6fedfdc..ce274d196be 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -5249,7 +5249,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
if (!dos_fname) {
return NT_STATUS_NO_MEMORY;
}
- if (is_ntfs_stream_smb_fname(smb_fname)) {
+ if (is_named_stream(smb_fname)) {
dos_fname = talloc_asprintf(dos_fname, "%s",
smb_fname->stream_name);
if (!dos_fname) {
@@ -5526,7 +5526,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
}
string_replace(nfname, '/', '\\');
- if (smb_fname->stream_name != NULL) {
+ if (fsp_is_alternate_stream(fsp)) {
const char *s = smb_fname->stream_name;
const char *e = NULL;
size_t n;
--
Samba Shared Repository
More information about the samba-cvs
mailing list