[SCM] Samba Shared Repository - branch v4-11-test updated
Karolin Seeger
kseeger at samba.org
Wed Jan 15 10:34:03 UTC 2020
The branch, v4-11-test has been updated
via c5dee3fcee6 libsmbclient: If over SMB1 first try to do a posix stat on the file.
via e82e78b8747 s3:libsmb: Add a setup_stat_from_stat_ex() function
via 8936e2d0274 s3:libsmb: Return a 'struct stat' buffer for SMBC_getatr()
via 2db3606327f s3:libsmb: Add try_posixinfo to SMBSRV struct. Only enable for SMB1 with UNIX for now.
via fa22e5b6133 s3:libsmb: Generate the inode only based on the path component
via 260d66aa0aa s3: libsmb: Move setting all struct stat fields into setup_stat().
via 4eb710e3298 s3: libsmb: Move setting st->st_ino into setup_stat.
via 463a2df2de7 s3: libsmb: Change generate_inode()/setup_stat() to modern coding standards.
from ee215ff101d ctdb-tests: Skip some tests that don't work with IPv6
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-11-test
- Log -----------------------------------------------------------------
commit c5dee3fcee618c471d6bec02340eddef5dd68855
Author: Andreas Schneider <asn at samba.org>
Date: Mon Nov 25 11:11:13 2019 +0100
libsmbclient: If over SMB1 first try to do a posix stat on the file.
Disable in future, if server doesn't support this.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
Autobuild-Date(master): Thu Dec 19 15:44:25 UTC 2019 on sn-devel-184
(cherry picked from commit 8b04590e4d8f817ad6d194bb9d622c18734e3011)
Autobuild-User(v4-11-test): Karolin Seeger <kseeger at samba.org>
Autobuild-Date(v4-11-test): Wed Jan 15 10:33:14 UTC 2020 on sn-devel-184
commit e82e78b8747110b73231fdc83e18a43a06f71404
Author: Andreas Schneider <asn at samba.org>
Date: Mon Nov 25 11:10:49 2019 +0100
s3:libsmb: Add a setup_stat_from_stat_ex() function
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit b3e3cb3bbd86a53b48ee009adf811d48dd50dc8b)
commit 8936e2d0274f5601f97e69aaaf2f92965dd00ddd
Author: Andreas Schneider <asn at samba.org>
Date: Mon Nov 25 11:09:52 2019 +0100
s3:libsmb: Return a 'struct stat' buffer for SMBC_getatr()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit 0fe9dc5219beaf605da9c7922053f7324507b50e)
commit 2db3606327fc4a1a19c294b87e8da6e2eb12e703
Author: Andreas Schneider <asn at samba.org>
Date: Mon Nov 25 11:06:57 2019 +0100
s3:libsmb: Add try_posixinfo to SMBSRV struct. Only enable for SMB1 with UNIX for now.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit bf9a3a7aa1913238ae2c997ce00369d0dbae3a08)
commit fa22e5b613345fb80f8ea47332139c328c550f5b
Author: Andreas Schneider <asn at samba.org>
Date: Wed Dec 18 13:27:26 2019 +0100
s3:libsmb: Generate the inode only based on the path component
Currently we use the full smb url which includes also username and
password.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit ea51a426e506bd6456814ecddcb63441859f9d89)
commit 260d66aa0aa9868a826c9e6e96b937e94da9a3fd
Author: Jeremy Allison <jra at samba.org>
Date: Fri Oct 18 10:48:55 2019 -0700
s3: libsmb: Move setting all struct stat fields into setup_stat().
That way we only have one place where a struct stat is synthesised
for libsmbclient callers.
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
(cherry picked from commit 1f0715c0e5e6ff371e3b393a0b35222c8b6f49bc)
commit 4eb710e329827b4de9365fed8b02055e96d368cf
Author: Jeremy Allison <jra at samba.org>
Date: Fri Oct 18 09:34:02 2019 -0700
s3: libsmb: Move setting st->st_ino into setup_stat.
Signed-off-by: Puran Chand <pchand at vmware.com>
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
(cherry picked from commit 7d3b4f47be0359b496087fc40f89b815c7958dd6)
commit 463a2df2de78f4110cb1b765293a94ebbd111658
Author: Jeremy Allison <jra at samba.org>
Date: Fri Oct 18 09:24:38 2019 -0700
s3: libsmb: Change generate_inode()/setup_stat() to modern coding standards.
Change setup_stat() to be void. It doesn't return anything. Export
so it can be used by upcoming smbc_readdirplus2() call.
Remove unused SMBCCTX *context parameters.
Remove unused talloc_stackframe().
Signed-off-by: Puran Chand <pchand at vmware.com>
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
(cherry picked from commit d44a84295b46cc6c540a9730a615a59c1f22a277)
-----------------------------------------------------------------------
Summary of changes:
source3/include/libsmb_internal.h | 22 +++++--
source3/libsmb/libsmb_dir.c | 31 ++++-----
source3/libsmb/libsmb_file.c | 122 ++++++++++++++++++++++-------------
source3/libsmb/libsmb_server.c | 9 +++
source3/libsmb/libsmb_stat.c | 132 +++++++++++++++++++++++---------------
source3/libsmb/libsmb_xattr.c | 69 ++++++++------------
6 files changed, 216 insertions(+), 169 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h
index f3e44e875d8..af56df58792 100644
--- a/source3/include/libsmb_internal.h
+++ b/source3/include/libsmb_internal.h
@@ -76,6 +76,7 @@ typedef struct DOS_ATTR_DESC {
struct _SMBCSRV {
struct cli_state *cli;
dev_t dev;
+ bool try_posixinfo;
bool no_pathinfo;
bool no_pathinfo2;
bool no_pathinfo3;
@@ -401,13 +402,7 @@ bool
SMBC_getatr(SMBCCTX * context,
SMBCSRV *srv,
const char *path,
- uint16_t *mode,
- off_t *size,
- struct timespec *create_time_ts,
- struct timespec *access_time_ts,
- struct timespec *write_time_ts,
- struct timespec *change_time_ts,
- SMB_INO_T *ino);
+ struct stat *sbuf);
bool
SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
@@ -522,6 +517,19 @@ SMBC_attr_server(TALLOC_CTX *ctx,
/* Functions in libsmb_stat.c */
+void setup_stat(struct stat *st,
+ const char *fname,
+ off_t size,
+ int mode,
+ ino_t ino,
+ dev_t dev,
+ struct timespec access_time_ts,
+ struct timespec change_time_ts,
+ struct timespec write_time_ts);
+void setup_stat_from_stat_ex(const struct stat_ex *stex,
+ const char *fname,
+ struct stat *st);
+
int
SMBC_stat_ctx(SMBCCTX *context,
const char *fname,
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index 14bfcdec6a7..fd42c71b2b8 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -474,7 +474,6 @@ SMBC_opendir_ctx(SMBCCTX *context,
char *workgroup = NULL;
char *path = NULL;
size_t path_len = 0;
- uint16_t mode;
uint16_t port = 0;
SMBCSRV *srv = NULL;
SMBCFILE *dir = NULL;
@@ -961,6 +960,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
saved_errno = SMBC_errno(context, targetcli);
if (saved_errno == EINVAL) {
+ struct stat sb = {0};
/*
* See if they asked to opendir
* something other than a directory.
@@ -970,11 +970,11 @@ SMBC_opendir_ctx(SMBCCTX *context,
*/
path[path_len] = '\0'; /* restore original path */
- if (SMBC_getatr(context, srv, path,
- &mode, NULL,
- NULL, NULL, NULL, NULL,
- NULL) &&
- ! IS_DOS_DIR(mode)) {
+ if (SMBC_getatr(context,
+ srv,
+ path,
+ &sb) &&
+ !S_ISDIR(sb.st_mode)) {
/* It is. Correct the error value */
saved_errno = ENOTDIR;
@@ -2098,20 +2098,11 @@ SMBC_unlink_ctx(SMBCCTX *context,
if (errno == EACCES) { /* Check if the file is a directory */
int saverr = errno;
- off_t size = 0;
- uint16_t mode = 0;
- struct timespec write_time_ts;
- struct timespec access_time_ts;
- struct timespec change_time_ts;
- SMB_INO_T ino = 0;
-
- if (!SMBC_getatr(context, srv, path, &mode, &size,
- NULL,
- &access_time_ts,
- &write_time_ts,
- &change_time_ts,
- &ino)) {
+ struct stat sb = {0};
+ bool ok;
+ ok = SMBC_getatr(context, srv, path, &sb);
+ if (!ok) {
/* Hmmm, bad error ... What? */
errno = SMBC_errno(context, targetcli);
@@ -2121,7 +2112,7 @@ SMBC_unlink_ctx(SMBCCTX *context,
}
else {
- if (IS_DOS_DIR(mode))
+ if (S_ISDIR(sb.st_mode))
errno = EISDIR;
else
errno = saverr; /* Restore this */
diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index be9bcd936b2..1577010e490 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -452,18 +452,19 @@ bool
SMBC_getatr(SMBCCTX * context,
SMBCSRV *srv,
const char *path,
- uint16_t *mode,
- off_t *size,
- struct timespec *create_time_ts,
- struct timespec *access_time_ts,
- struct timespec *write_time_ts,
- struct timespec *change_time_ts,
- SMB_INO_T *ino)
+ struct stat *sb)
{
char *fixedpath = NULL;
char *targetpath = NULL;
struct cli_state *targetcli = NULL;
- time_t write_time;
+ uint16_t mode = 0;
+ off_t size = 0;
+ struct timespec create_time_ts = {0};
+ struct timespec access_time_ts = {0};
+ struct timespec write_time_ts = {0};
+ struct timespec change_time_ts = {0};
+ time_t write_time = 0;
+ SMB_INO_T ino = 0;
TALLOC_CTX *frame = talloc_stackframe();
NTSTATUS status;
@@ -503,28 +504,56 @@ SMBC_getatr(SMBCCTX * context,
return False;
}
- if (!srv->no_pathinfo2 &&
- NT_STATUS_IS_OK(cli_qpathinfo2(targetcli, targetpath,
- create_time_ts,
- access_time_ts,
- write_time_ts,
- change_time_ts,
- size, mode, ino))) {
- TALLOC_FREE(frame);
- return True;
+ if (srv->try_posixinfo) {
+ SMB_STRUCT_STAT sbuf;
+
+ status = cli_posix_stat(targetcli, frame, &sbuf);
+ if (NT_STATUS_IS_OK(status)) {
+ setup_stat_from_stat_ex(&sbuf, path, sb);
+
+ TALLOC_FREE(frame);
+ return true;
+ }
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED) ||
+ NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL)) {
+ /*
+ * Turn this off if the server doesn't
+ * support it.
+ */
+ srv->try_posixinfo = false;
+ }
+ }
+
+ if (!srv->no_pathinfo2) {
+ status = cli_qpathinfo2(targetcli,
+ targetpath,
+ &create_time_ts,
+ &access_time_ts,
+ &write_time_ts,
+ &change_time_ts,
+ &size,
+ &mode,
+ &ino);
+ if (NT_STATUS_IS_OK(status)) {
+ goto setup_stat;
+ }
}
srv->no_pathinfo2 = True;
- if (!srv->no_pathinfo3 &&
- NT_STATUS_IS_OK(cli_qpathinfo3(targetcli, targetpath,
- create_time_ts,
- access_time_ts,
- write_time_ts,
- change_time_ts,
- size, mode, ino))) {
- TALLOC_FREE(frame);
- return True;
+ if (!srv->no_pathinfo3) {
+ status = cli_qpathinfo3(targetcli,
+ targetpath,
+ &create_time_ts,
+ &access_time_ts,
+ &write_time_ts,
+ &change_time_ts,
+ &size,
+ &mode,
+ &ino);
+ if (NT_STATUS_IS_OK(status)) {
+ goto setup_stat;
+ }
}
srv->no_pathinfo3 = True;
@@ -534,29 +563,30 @@ SMBC_getatr(SMBCCTX * context,
goto all_failed;
}
- if (NT_STATUS_IS_OK(cli_getatr(targetcli, targetpath, mode, size, &write_time))) {
- struct timespec w_time_ts;
+ status = cli_getatr(targetcli, targetpath, &mode, &size, &write_time);
+ if (NT_STATUS_IS_OK(status)) {
+ struct timespec w_time_ts =
+ convert_time_t_to_timespec(write_time);
- w_time_ts = convert_time_t_to_timespec(write_time);
- if (write_time_ts != NULL) {
- *write_time_ts = w_time_ts;
- }
- if (create_time_ts != NULL) {
- *create_time_ts = w_time_ts;
- }
- if (access_time_ts != NULL) {
- *access_time_ts = w_time_ts;
- }
- if (change_time_ts != NULL) {
- *change_time_ts = w_time_ts;
- }
- if (ino) {
- *ino = 0;
- }
- TALLOC_FREE(frame);
- return True;
+ access_time_ts = change_time_ts = write_time_ts = w_time_ts;
+
+ goto setup_stat;
}
+setup_stat:
+ setup_stat(sb,
+ path,
+ size,
+ mode,
+ ino,
+ srv->dev,
+ access_time_ts,
+ change_time_ts,
+ write_time_ts);
+
+ TALLOC_FREE(frame);
+ return true;
+
all_failed:
srv->no_pathinfo2 = False;
srv->no_pathinfo3 = False;
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index 0067df48cac..d4f71d8c8b7 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -657,6 +657,15 @@ SMBC_server_internal(TALLOC_CTX *ctx,
ZERO_STRUCTP(srv);
DLIST_ADD(srv->cli, c);
srv->dev = (dev_t)(str_checksum(server) ^ str_checksum(share));
+ srv->try_posixinfo = false;
+ /*
+ * Until SMB2 POSIX is done, only
+ * try POSIX stat on SMB1 with POSIX capabilities.
+ */
+ if ((smbXcli_conn_protocol(c->conn) < PROTOCOL_SMB2_02) &&
+ (smb1cli_conn_capabilities(c->conn) & CAP_UNIX)) {
+ srv->try_posixinfo = true;
+ }
srv->no_pathinfo = False;
srv->no_pathinfo2 = False;
srv->no_pathinfo3 = False;
diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c
index 2f6e66c08e5..f20f79579e2 100644
--- a/source3/libsmb/libsmb_stat.c
+++ b/source3/libsmb/libsmb_stat.c
@@ -32,16 +32,11 @@
* Generate an inode number from file name for those things that need it
*/
-static ino_t
-generate_inode(SMBCCTX *context,
- const char *name)
+static ino_t generate_inode(const char *name)
{
- if (!context || !context->internal->initialized) {
- errno = EINVAL;
- return -1;
+ if (name == NULL) {
+ return (ino_t)-1;
}
-
- if (!*name) return 2; /* FIXME, why 2 ??? */
return (ino_t)str_checksum(name);
}
@@ -50,15 +45,16 @@ generate_inode(SMBCCTX *context,
* fstat below.
*/
-static int
-setup_stat(SMBCCTX *context,
- struct stat *st,
- const char *fname,
- off_t size,
- int mode)
+void setup_stat(struct stat *st,
+ const char *fname,
+ off_t size,
+ int mode,
+ ino_t ino,
+ dev_t dev,
+ struct timespec access_time_ts,
+ struct timespec change_time_ts,
+ struct timespec write_time_ts)
{
- TALLOC_CTX *frame = talloc_stackframe();
-
st->st_mode = 0;
if (IS_DOS_DIR(mode)) {
@@ -67,10 +63,18 @@ setup_stat(SMBCCTX *context,
st->st_mode = SMBC_FILE_MODE;
}
- if (IS_DOS_ARCHIVE(mode)) st->st_mode |= S_IXUSR;
- if (IS_DOS_SYSTEM(mode)) st->st_mode |= S_IXGRP;
- if (IS_DOS_HIDDEN(mode)) st->st_mode |= S_IXOTH;
- if (!IS_DOS_READONLY(mode)) st->st_mode |= S_IWUSR;
+ if (IS_DOS_ARCHIVE(mode)) {
+ st->st_mode |= S_IXUSR;
+ }
+ if (IS_DOS_SYSTEM(mode)) {
+ st->st_mode |= S_IXGRP;
+ }
+ if (IS_DOS_HIDDEN(mode)) {
+ st->st_mode |= S_IXOTH;
+ }
+ if (!IS_DOS_READONLY(mode)) {
+ st->st_mode |= S_IWUSR;
+ }
st->st_size = size;
#ifdef HAVE_STAT_ST_BLKSIZE
@@ -91,12 +95,53 @@ setup_stat(SMBCCTX *context,
st->st_nlink = 1;
}
- if (st->st_ino == 0) {
- st->st_ino = generate_inode(context, fname);
+ if (ino != 0) {
+ st->st_ino = ino;
+ } else {
+ st->st_ino = generate_inode(fname);
}
- TALLOC_FREE(frame);
- return True; /* FIXME: Is this needed ? */
+ st->st_dev = dev;
+ st->st_atime = convert_timespec_to_time_t(access_time_ts);
+ st->st_ctime = convert_timespec_to_time_t(change_time_ts);
+ st->st_mtime = convert_timespec_to_time_t(write_time_ts);
+}
+
+void setup_stat_from_stat_ex(const struct stat_ex *stex,
+ const char *fname,
+ struct stat *st)
+{
+ st->st_atime = convert_timespec_to_time_t(stex->st_ex_atime);
+ st->st_ctime = convert_timespec_to_time_t(stex->st_ex_ctime);
+ st->st_mtime = convert_timespec_to_time_t(stex->st_ex_mtime);
+
+ st->st_mode = stex->st_ex_mode;
+ st->st_size = stex->st_ex_size;
+#ifdef HAVE_STAT_ST_BLKSIZE
+ st->st_blksize = 512;
+#endif
+#ifdef HAVE_STAT_ST_BLOCKS
+ st->st_blocks = (st->st_size + 511) / 512;
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
+ st->st_rdev = 0;
+#endif
+ st->st_uid = stex->st_ex_uid;
+ st->st_gid = stex->st_ex_gid;
+
+ st->st_nlink = stex->st_ex_nlink;
+
+ if (stex->st_ex_ino == 0) {
+ st->st_ino = 0;
+ if (fname != NULL) {
+ st->st_ino = generate_inode(fname);
+ }
+ } else {
+ st->st_ino = stex->st_ex_ino;
+ }
+
+ st->st_dev = stex->st_ex_dev;
+
}
/*
@@ -115,13 +160,7 @@ SMBC_stat_ctx(SMBCCTX *context,
char *password = NULL;
char *workgroup = NULL;
char *path = NULL;
- struct timespec write_time_ts;
- struct timespec access_time_ts;
- struct timespec change_time_ts;
- off_t size = 0;
- uint16_t mode = 0;
uint16_t port = 0;
- SMB_INO_T ino = 0;
TALLOC_CTX *frame = talloc_stackframe();
if (!context || !context->internal->initialized) {
@@ -170,26 +209,12 @@ SMBC_stat_ctx(SMBCCTX *context,
return -1; /* errno set by SMBC_server */
}
- if (!SMBC_getatr(context, srv, path, &mode, &size,
- NULL,
- &access_time_ts,
- &write_time_ts,
- &change_time_ts,
- &ino)) {
+ if (!SMBC_getatr(context, srv, path, st)) {
errno = SMBC_errno(context, srv->cli);
TALLOC_FREE(frame);
return -1;
}
- st->st_ino = ino;
-
- setup_stat(context, st, fname, size, mode);
-
- st->st_atime = convert_timespec_to_time_t(access_time_ts);
- st->st_ctime = convert_timespec_to_time_t(change_time_ts);
- st->st_mtime = convert_timespec_to_time_t(write_time_ts);
- st->st_dev = srv->dev;
-
TALLOC_FREE(frame);
return 0;
}
@@ -286,14 +311,15 @@ SMBC_fstat_ctx(SMBCCTX *context,
write_time_ts = convert_time_t_to_timespec(write_time);
}
- st->st_ino = ino;
-
- setup_stat(context, st, file->fname, size, mode);
-
- st->st_atime = convert_timespec_to_time_t(access_time_ts);
- st->st_ctime = convert_timespec_to_time_t(change_time_ts);
- st->st_mtime = convert_timespec_to_time_t(write_time_ts);
- st->st_dev = file->srv->dev;
+ setup_stat(st,
+ path,
+ size,
+ mode,
+ ino,
+ file->srv->dev,
+ access_time_ts,
+ change_time_ts,
+ write_time_ts);
TALLOC_FREE(frame);
return 0;
diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c
index 442b45f2435..06a1d0c601d 100644
--- a/source3/libsmb/libsmb_xattr.c
+++ b/source3/libsmb/libsmb_xattr.c
@@ -552,13 +552,7 @@ dos_attr_query(SMBCCTX *context,
const char *filename,
SMBCSRV *srv)
{
--
Samba Shared Repository
More information about the samba-cvs
mailing list