libsmbclient: Put it back to a known, well-working state
authorVolker Lendecke <vl@samba.org>
Tue, 10 Mar 2020 18:51:09 +0000 (11:51 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 10 Mar 2020 21:25:33 +0000 (21:25 +0000)
For adapting unix extensions in our client libraries, we need a fresh start
with additional APIs. We can't change existing application behaviour.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 files changed:
selftest/knownfail
selftest/knownfail.d/libsmbclient [deleted file]
selftest/selftesthelpers.py
source3/include/client.h
source3/include/libsmb_internal.h
source3/libsmb/clifile.c
source3/libsmb/clilist.c
source3/libsmb/libsmb_dir.c
source3/libsmb/libsmb_file.c
source3/libsmb/libsmb_misc.c
source3/libsmb/libsmb_server.c
source3/libsmb/libsmb_stat.c
source3/libsmb/proto.h
source3/script/tests/test_smbtorture_s3_no_unix_ext.sh [deleted file]
source3/selftest/tests.py
source4/selftest/tests.py
source4/torture/libsmbclient/libsmbclient.c

index d4381b39a84c403cef98f6ccf29abb390c5c708e..4dc434aca7ec58f27f851761e170cc75077d640d 100644 (file)
@@ -19,6 +19,7 @@
 ^samba3.nbt.dgram.*netlogon2\(nt4_dc\)
 ^samba3.*rap.sam.*.useradd # Not provided by Samba 3
 ^samba3.*rap.sam.*.userdelete # Not provided by Samba 3
+^samba3.libsmbclient.opendir # This requires a workgroup called 'WORKGROUP' and for netbios browse lists to have been registered
 # see bug 8412
 ^samba3.smb2.rename.*.simple_nodelete
 ^samba3.smb2.rename.*.no_share_delete_no_delete_access
 ^samba4.smb2.acls.*.ACCESSBASED
 ^samba4.ldap.dirsync.python.ad_dc_ntvfs..__main__.ExtendedDirsyncTests.test_dirsync_deleted_items
 #^samba4.ldap.dirsync.python.ad_dc_ntvfs..__main__.ExtendedDirsyncTests.*
-^samba4.*libsmbclient.opendir.(NT1|SMB3).opendir # This requires netbios browsing
+^samba4.libsmbclient.opendir.(NT1|SMB3).opendir # This requires netbios browsing
 ^samba4.rpc.drsuapi.*.drsuapi.DsGetDomainControllerInfo\(.*\)$
 ^samba4.smb2.oplock.exclusive2\(.*\)$ # samba 4 oplocks are a mess
 ^samba4.smb2.oplock.exclusive5\(.*\)$ # samba 4 oplocks are a mess
diff --git a/selftest/knownfail.d/libsmbclient b/selftest/knownfail.d/libsmbclient
deleted file mode 100644 (file)
index 43c3fb6..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-# We don't have SMB3 unix extensions yet
-samba4.unix_ext.libsmbclient.readdirplus2.SMB3.readdirplus2.*
index 1fdb2e461e1b5da536b98da2e29eded210475fdc..1afabf3cdcad2de15abe4440ac6c583728e691d6 100644 (file)
@@ -172,21 +172,14 @@ smbtorture4_options = [
     "--format=subunit"
 ] + get_env_torture_options()
 
-def smbtorture4testsuite_cmdarray(name, env, options, target):
-    cmdarray = [ valgrindify(smbtorture4), "$LISTOPT", "$LOADLIST" ]
-    cmdarray += smbtorture4_options
-    cmdarray += [ "--target=%s" % target ]
-    cmdarray += options
-    cmdarray += [ name ]
-    return cmdarray
 
 def plansmbtorture4testsuite(name, env, options, target, modname=None):
     if modname is None:
         modname = "samba4.%s" % name
-    if isinstance(options, str):
-        options = options.split()
-    cmdarray = smbtorture4testsuite_cmdarray(name, env, options, target)
-    cmdline = " ".join(cmdarray)
+    if isinstance(options, list):
+        options = " ".join(options)
+    options = " ".join(smbtorture4_options + ["--target=%s" % target]) + " " + options
+    cmdline = "%s $LISTOPT $LOADLIST %s %s" % (valgrindify(smbtorture4), options, name)
     plantestsuite_loadlist(modname, env, cmdline)
 
 
index 34b6a9fc383dc7c786b76ead097389bed3852050..23ba86d2a2c4ab33bf5955623892c8667f79807e 100644 (file)
@@ -114,12 +114,6 @@ struct file_info {
        struct timespec mtime_ts;
        struct timespec atime_ts;
        struct timespec ctime_ts;
-
-       /*
-        * Native sbuf from posix extensions. Valid if st_ex_nlink!=0.
-        */
-       SMB_STRUCT_STAT posix_sbuf;
-
        char *name;
        char *short_name;
 };
index 78c2cb555e0422e84d200cb41b0a9be08e994043..21a11c1a0242cc54762c85f0e76f944140fd6772 100644 (file)
@@ -98,7 +98,6 @@ struct smbc_dir_list {
 struct smbc_dirplus_list {
        struct smbc_dirplus_list *next;
        struct libsmb_file_info *smb_finfo;
-       SMB_STRUCT_STAT *posix_sbuf;
        uint64_t ino;
 };
 
@@ -432,7 +431,8 @@ SMBC_ftruncate_ctx(SMBCCTX *context,
 
 
 /* Functions in libsmb_misc.c */
-bool SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p);
+int
+SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p);
 
 int
 SMBC_errno(SMBCCTX *context,
index 164be11386c4583a0bc79debd04ff2ea3d016df0..dd08b0e30f35fa3fe8347c4f7d0ce026a51ac900 100644 (file)
@@ -736,65 +736,12 @@ NTSTATUS cli_posix_setacl(struct cli_state *cli,
        return status;
 }
 
-static void fetch_file_unix_basic_info(
-       const uint8_t data[100], SMB_STRUCT_STAT *sbuf)
-{
-       ZERO_STRUCTP(sbuf);
-
-       /* total size, in bytes */
-       sbuf->st_ex_size = IVAL2_TO_SMB_BIG_UINT(data, 0);
-
-       /* number of blocks allocated */
-       sbuf->st_ex_blocks = IVAL2_TO_SMB_BIG_UINT(data,8);
-#if defined (HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
-       sbuf->st_ex_blocks /= STAT_ST_BLOCKSIZE;
-#else
-       /* assume 512 byte blocks */
-       sbuf->st_ex_blocks /= 512;
-#endif
-       /* time of last change */
-       sbuf->st_ex_ctime = interpret_long_date((const char *)(data + 16));
-
-       /* time of last access */
-       sbuf->st_ex_atime = interpret_long_date((const char *)(data + 24));
-
-       /* time of last modification */
-       sbuf->st_ex_mtime = interpret_long_date((const char *)(data + 32));
-
-       sbuf->st_ex_uid = (uid_t) IVAL(data, 40); /* user ID of owner */
-       sbuf->st_ex_gid = (gid_t) IVAL(data, 48); /* group ID of owner */
-       sbuf->st_ex_mode = unix_filetype_from_wire(IVAL(data, 56));
-
-#if defined(HAVE_MAKEDEV)
-       {
-               uint32_t dev_major = IVAL(data,60);
-               uint32_t dev_minor = IVAL(data,68);
-               sbuf->st_ex_rdev = makedev(dev_major, dev_minor);
-       }
-#endif
-       /* inode */
-       sbuf->st_ex_ino = (SMB_INO_T)IVAL2_TO_SMB_BIG_UINT(data, 76);
-
-       /* protection */
-       sbuf->st_ex_mode |= wire_perms_to_unix(IVAL(data, 84));
-
-       /* number of hard links */
-       sbuf->st_ex_nlink = BIG_UINT(data, 92);
-}
-
-void fetch_file_unix_basic_info2(
-       const uint8_t data[116], SMB_STRUCT_STAT *sbuf)
-{
-       fetch_file_unix_basic_info(data, sbuf);
-       sbuf->st_ex_btime = interpret_long_date((const char *)(data + 100));
-}
-
 /****************************************************************************
  Stat a file (UNIX extensions).
 ****************************************************************************/
 
 struct stat_state {
-       SMB_STRUCT_STAT sbuf;
+       SMB_STRUCT_STAT *sbuf;
 };
 
 static void cli_posix_stat_done(struct tevent_req *subreq);
@@ -802,7 +749,8 @@ static void cli_posix_stat_done(struct tevent_req *subreq);
 struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx,
                                       struct tevent_context *ev,
                                       struct cli_state *cli,
-                                      const char *fname)
+                                      const char *fname,
+                                      SMB_STRUCT_STAT *sbuf)
 {
        struct tevent_req *req = NULL, *subreq = NULL;
        struct stat_state *state = NULL;
@@ -811,6 +759,7 @@ struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx,
        if (req == NULL) {
                return NULL;
        }
+       state->sbuf = sbuf;
 
        subreq = cli_qpathinfo_send(state, ev, cli, fname,
                                    SMB_QUERY_FILE_UNIX_BASIC, 100, 100);
@@ -826,7 +775,7 @@ static void cli_posix_stat_done(struct tevent_req *subreq)
        struct tevent_req *req = tevent_req_callback_data(
                                subreq, struct tevent_req);
        struct stat_state *state = tevent_req_data(req, struct stat_state);
-       SMB_STRUCT_STAT *sbuf = &state->sbuf;
+       SMB_STRUCT_STAT *sbuf = state->sbuf;
        uint8_t *data;
        uint32_t num_data = 0;
        NTSTATUS status;
@@ -846,25 +795,54 @@ static void cli_posix_stat_done(struct tevent_req *subreq)
                return;
        }
 
-       fetch_file_unix_basic_info(data, sbuf);
+       *sbuf = (SMB_STRUCT_STAT) { 0 };
+
+       /* total size, in bytes */
+       sbuf->st_ex_size = IVAL2_TO_SMB_BIG_UINT(data, 0);
+
+       /* number of blocks allocated */
+       sbuf->st_ex_blocks = IVAL2_TO_SMB_BIG_UINT(data,8);
+#if defined (HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
+       sbuf->st_ex_blocks /= STAT_ST_BLOCKSIZE;
+#else
+       /* assume 512 byte blocks */
+       sbuf->st_ex_blocks /= 512;
+#endif
+       /* time of last change */
+       sbuf->st_ex_ctime = interpret_long_date((char *)(data + 16));
+
+       /* time of last access */
+       sbuf->st_ex_atime = interpret_long_date((char *)(data + 24));
+
+       /* time of last modification */
+       sbuf->st_ex_mtime = interpret_long_date((char *)(data + 32));
+
+       sbuf->st_ex_uid = (uid_t) IVAL(data, 40); /* user ID of owner */
+       sbuf->st_ex_gid = (gid_t) IVAL(data, 48); /* group ID of owner */
+       sbuf->st_ex_mode = unix_filetype_from_wire(IVAL(data, 56));
+
+#if defined(HAVE_MAKEDEV)
+       {
+               uint32_t dev_major = IVAL(data,60);
+               uint32_t dev_minor = IVAL(data,68);
+               sbuf->st_ex_rdev = makedev(dev_major, dev_minor);
+       }
+#endif
+       /* inode */
+       sbuf->st_ex_ino = (SMB_INO_T)IVAL2_TO_SMB_BIG_UINT(data, 76);
+
+       /* protection */
+       sbuf->st_ex_mode |= wire_perms_to_unix(IVAL(data, 84));
+
+       /* number of hard links */
+       sbuf->st_ex_nlink = BIG_UINT(data, 92);
 
        tevent_req_done(req);
 }
 
-NTSTATUS cli_posix_stat_recv(struct tevent_req *req,
-                            SMB_STRUCT_STAT *sbuf)
+NTSTATUS cli_posix_stat_recv(struct tevent_req *req)
 {
-       struct stat_state *state = tevent_req_data(req, struct stat_state);
-       NTSTATUS status;
-
-       if (tevent_req_is_nterror(req, &status)) {
-               return status;
-       }
-       if (sbuf != NULL) {
-               *sbuf = state->sbuf;
-       }
-       tevent_req_received(req);
-       return NT_STATUS_OK;
+       return tevent_req_simple_recv_ntstatus(req);
 }
 
 NTSTATUS cli_posix_stat(struct cli_state *cli,
@@ -890,7 +868,7 @@ NTSTATUS cli_posix_stat(struct cli_state *cli,
                goto fail;
        }
 
-       req = cli_posix_stat_send(frame, ev, cli, fname);
+       req = cli_posix_stat_send(frame, ev, cli, fname, sbuf);
        if (req == NULL) {
                status = NT_STATUS_NO_MEMORY;
                goto fail;
@@ -900,7 +878,7 @@ NTSTATUS cli_posix_stat(struct cli_state *cli,
                goto fail;
        }
 
-       status = cli_posix_stat_recv(req, sbuf);
+       status = cli_posix_stat_recv(req);
 
  fail:
        TALLOC_FREE(frame);
index ca6d8b531297afe8614ab06f80c0b27cf9d12b07..f868e72a239e4b2aa2ba230fa08b80c834899d37 100644 (file)
@@ -305,63 +305,6 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
                        }
                        return calc_next_entry_offset(base, pdata_end);
                }
-               case SMB_FIND_FILE_UNIX_INFO2:
-               {
-                       SMB_STRUCT_STAT *sbuf = &finfo->posix_sbuf;
-                       size_t namelen;
-
-                       if (pdata_end - base < 128) {
-                               return pdata_end - base;
-                       }
-
-                       p += 4; /* next entry offset */
-
-                       if (p_resume_key) {
-                               *p_resume_key = IVAL(p,0);
-                       }
-                       p += 4; /* fileindex */
-
-                       fetch_file_unix_basic_info2((const uint8_t *)p, sbuf);
-                       p += 116;
-
-                       finfo->mode = S_ISDIR(sbuf->st_ex_mode) ?
-                               FILE_ATTRIBUTE_DIRECTORY :
-                               FILE_ATTRIBUTE_NORMAL;
-                       if (sbuf->st_ex_mode & S_IXUSR) {
-                               finfo->mode |= FILE_ATTRIBUTE_ARCHIVE;
-                       }
-
-                       finfo->size = sbuf->st_ex_size;
-                       finfo->allocated_size =
-                               sbuf->st_ex_blksize * sbuf->st_ex_blocks;
-                       finfo->uid = sbuf->st_ex_uid;
-                       finfo->gid = sbuf->st_ex_gid;
-                       finfo->ino = sbuf->st_ex_ino;
-                       finfo->btime_ts = sbuf->st_ex_btime;
-                       finfo->mtime_ts = sbuf->st_ex_mtime;
-                       finfo->atime_ts = sbuf->st_ex_atime;
-                       finfo->ctime_ts = sbuf->st_ex_ctime;
-
-                       namelen = IVAL(p, 0);
-                       p += 4;
-
-                       if (namelen > (pdata_end - p)) {
-                               return pdata_end - base;
-                       }
-
-                       ret = clistr_pull_talloc(
-                               ctx,
-                               base_ptr,
-                               recv_flags2,
-                               &finfo->name,
-                               p,
-                               namelen,
-                               0);
-                       if (ret == (size_t)-1) {
-                               return pdata_end - base;
-                       }
-                       return calc_next_entry_offset(base, pdata_end);
-               }
        }
 
        DEBUG(1,("Unknown long filename format %d\n",level));
@@ -1100,7 +1043,6 @@ NTSTATUS cli_list(struct cli_state *cli, const char *mask, uint16_t attribute,
        NTSTATUS status = NT_STATUS_NO_MEMORY;
        struct file_info *finfo;
        size_t i, num_finfo = 0;
-       uint32_t caps;
        uint16_t info_level;
 
        if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
@@ -1121,15 +1063,8 @@ NTSTATUS cli_list(struct cli_state *cli, const char *mask, uint16_t attribute,
                goto fail;
        }
 
-       caps = smb1cli_conn_capabilities(cli->conn);
-
-       if (caps & CAP_UNIX) {
-               info_level = SMB_FIND_FILE_UNIX_INFO2;
-       } else if (caps & CAP_NT_SMBS) {
-               info_level = SMB_FIND_FILE_BOTH_DIRECTORY_INFO;
-       } else {
-               info_level = SMB_FIND_INFO_STANDARD;
-       }
+       info_level = (smb1cli_conn_capabilities(cli->conn) & CAP_NT_SMBS)
+               ? SMB_FIND_FILE_BOTH_DIRECTORY_INFO : SMB_FIND_INFO_STANDARD;
 
        req = cli_list_send(frame, ev, cli, mask, attribute, info_level);
        if (req == NULL) {
index 801d556f53bae3d54f80c5b8d839a18cc2d30de4..00d2a878e8464e37048c25564103a3c815fe8a5b 100644 (file)
@@ -49,7 +49,6 @@ static void remove_dirplus(SMBCFILE *dir)
                struct smbc_dirplus_list *f = d;
                d = d->next;
 
-               SAFE_FREE(f->posix_sbuf);
                SAFE_FREE(f->smb_finfo->short_name);
                SAFE_FREE(f->smb_finfo->name);
                SAFE_FREE(f->smb_finfo);
@@ -213,20 +212,6 @@ static int add_dirplus(SMBCFILE *dir, struct file_info *finfo)
        }
        new_entry->smb_finfo = info;
 
-       if (finfo->posix_sbuf.st_ex_nlink != 0) {
-               new_entry->posix_sbuf = SMB_MALLOC_P(SMB_STRUCT_STAT);
-               if (new_entry->posix_sbuf == NULL) {
-                       SAFE_FREE(info->short_name);
-                       SAFE_FREE(info->name);
-                       SAFE_FREE(info);
-                       SAFE_FREE(new_entry);
-                       dir->dir_error = ENOMEM;
-                       return -1;
-               }
-               *new_entry->posix_sbuf = finfo->posix_sbuf;
-               new_entry->posix_sbuf->st_ex_dev = dir->srv->dev;
-       }
-
        /* Now add to the list. */
        if (dir->dirplus_list == NULL) {
                /* Empty list - point everything at new_entry. */
@@ -561,12 +546,6 @@ SMBC_opendir_ctx(SMBCCTX *context,
 
        dir->cli_fd   = 0;
        dir->fname    = SMB_STRDUP(fname);
-       if (dir->fname == NULL) {
-               SAFE_FREE(dir);
-               TALLOC_FREE(frame);
-               errno = ENOMEM;
-               return NULL;
-       }
        dir->srv      = NULL;
        dir->offset   = 0;
        dir->file     = False;
@@ -1055,7 +1034,7 @@ SMBC_closedir_ctx(SMBCCTX *context,
                return -1;
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, dir)) {
+       if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) {
                errno = EBADF;
                TALLOC_FREE(frame);
                return -1;
@@ -1168,7 +1147,7 @@ SMBC_readdir_ctx(SMBCCTX *context,
 
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, dir)) {
+       if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) {
 
                errno = EBADF;
                 DEBUG(0, ("Invalid dir in SMBC_readdir_ctx()\n"));
@@ -1247,7 +1226,9 @@ SMBC_readdirplus_ctx(SMBCCTX *context,
                return NULL;
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, dir)) {
+       if (dir == NULL ||
+           SMBC_dlist_contains(context->internal->files,
+                               dir) == 0) {
                DBG_ERR("Invalid dir in SMBC_readdirplus_ctx()\n");
                TALLOC_FREE(frame);
                errno = EBADF;
@@ -1326,7 +1307,10 @@ const struct libsmb_file_info *SMBC_readdirplus2_ctx(SMBCCTX *context,
                return NULL;
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, dir)) {
+       if (dir == NULL ||
+           SMBC_dlist_contains(context->internal->files,
+                                       dir) == 0)
+       {
                DBG_ERR("Invalid dir in SMBC_readdirplus2_ctx()\n");
                TALLOC_FREE(frame);
                errno = EBADF;
@@ -1375,20 +1359,15 @@ const struct libsmb_file_info *SMBC_readdirplus2_ctx(SMBCCTX *context,
                return NULL;
        }
 
-       if (dp_list->posix_sbuf != NULL) {
-               setup_stat_from_stat_ex(dp_list->posix_sbuf, path, st);
-       } else {
-               setup_stat(
-                       st,
-                       path,
-                       smb_finfo->size,
-                       smb_finfo->attrs,
-                       ino,
-                       dir->srv->dev,
-                       smb_finfo->atime_ts,
-                       smb_finfo->ctime_ts,
-                       smb_finfo->mtime_ts);
-       }
+       setup_stat(st,
+               path,
+               smb_finfo->size,
+               smb_finfo->attrs,
+               ino,
+               dir->srv->dev,
+               smb_finfo->atime_ts,
+               smb_finfo->ctime_ts,
+               smb_finfo->mtime_ts);
 
        TALLOC_FREE(full_pathname);
 
@@ -1436,7 +1415,7 @@ SMBC_getdents_ctx(SMBCCTX *context,
 
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, dir)) {
+       if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) {
 
                errno = EBADF;
                TALLOC_FREE(frame);
@@ -1803,7 +1782,7 @@ SMBC_telldir_ctx(SMBCCTX *context,
 
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, dir)) {
+       if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) {
 
                errno = EBADF;
                TALLOC_FREE(frame);
@@ -2651,7 +2630,8 @@ SMBC_notify_ctx(SMBCCTX *context, SMBCFILE *dir, smbc_bool recursive,
                errno = EINVAL;
                return -1;
        }
-       if (!SMBC_dlist_contains(context->internal->files, dir)) {
+       if ((dir == NULL) ||
+           !SMBC_dlist_contains(context->internal->files, dir)) {
                TALLOC_FREE(frame);
                errno = EBADF;
                return -1;
index 512827e134d4c7cc365f43b9fc2ea2a79cac69ad..1577010e49018ee290f55eb0cacd92e14472f55b 100644 (file)
@@ -125,21 +125,8 @@ SMBC_open_ctx(SMBCCTX *context,
                }
                /*d_printf(">>>open: resolved %s as %s\n", path, targetpath);*/
 
-               if (srv->try_posixinfo) {
-                       status = cli_posix_open(
-                               targetcli,
-                               targetpath,
-                               flags,
-                               mode,
-                               &fd);
-               } else {
-                       status = cli_open(
-                               targetcli,
-                               targetpath,
-                               flags,
-                               context->internal->share_mode,
-                               &fd);
-               }
+               status = cli_open(targetcli, targetpath, flags,
+                                   context->internal->share_mode, &fd);
                if (!NT_STATUS_IS_OK(status)) {
 
                        /* Handle the error ... */
@@ -269,9 +256,9 @@ SMBC_read_ctx(SMBCCTX *context,
                return -1;
        }
 
-       DEBUG(4, ("smbc_read(%p, %zu)\n", file, count));
+       DEBUG(4, ("smbc_read(%p, %d)\n", file, (int)count));
 
-       if (!SMBC_dlist_contains(context->internal->files, file)) {
+       if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
                errno = EBADF;
                TALLOC_FREE(frame);
                return -1;
@@ -297,7 +284,7 @@ SMBC_read_ctx(SMBCCTX *context,
 
        file->offset += ret;
 
-       DEBUG(4, ("  --> %zu\n", ret));
+       DEBUG(4, ("  --> %ld\n", (unsigned long)ret));
 
        TALLOC_FREE(frame);
        return ret;  /* Success, ret bytes of data ... */
@@ -321,13 +308,17 @@ SMBC_splice_ctx(SMBCCTX *context,
                return -1;
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, srcfile)) {
+       if (!srcfile ||
+           !SMBC_dlist_contains(context->internal->files, srcfile))
+       {
                errno = EBADF;
                TALLOC_FREE(frame);
                return -1;
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, dstfile)) {
+       if (!dstfile ||
+           !SMBC_dlist_contains(context->internal->files, dstfile))
+       {
                errno = EBADF;
                TALLOC_FREE(frame);
                return -1;
@@ -372,7 +363,7 @@ SMBC_write_ctx(SMBCCTX *context,
                return -1;
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, file)) {
+       if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
                errno = EBADF;
                TALLOC_FREE(frame);
                return -1;
@@ -418,7 +409,7 @@ SMBC_close_ctx(SMBCCTX *context,
                return -1;
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, file)) {
+       if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
                errno = EBADF;
                TALLOC_FREE(frame);
                return -1;
@@ -484,7 +475,7 @@ SMBC_getatr(SMBCCTX * context,
        }
 
        /* path fixup for . and .. */
-       if (ISDOT(path) || ISDOTDOT(path)) {
+       if (strequal(path, ".") || strequal(path, "..")) {
                fixedpath = talloc_strdup(frame, "\\");
                if (!fixedpath) {
                        errno = ENOMEM;
@@ -516,9 +507,8 @@ SMBC_getatr(SMBCCTX * context,
        if (srv->try_posixinfo) {
                SMB_STRUCT_STAT sbuf;
 
-               status = cli_posix_stat(targetcli, targetpath, &sbuf);
+               status = cli_posix_stat(targetcli, frame, &sbuf);
                if (NT_STATUS_IS_OK(status)) {
-                       sbuf.st_ex_dev = srv->dev;
                        setup_stat_from_stat_ex(&sbuf, path, sb);
 
                        TALLOC_FREE(frame);
@@ -711,7 +701,7 @@ SMBC_lseek_ctx(SMBCCTX *context,
                return -1;
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, file)) {
+       if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
                errno = EBADF;
                TALLOC_FREE(frame);
                return -1;
@@ -774,7 +764,7 @@ SMBC_ftruncate_ctx(SMBCCTX *context,
                return -1;
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, file)) {
+       if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
                errno = EBADF;
                TALLOC_FREE(frame);
                return -1;
index 28e2ca842cf141e40111d8debb8971634054f21b..1d874c74cd813216fab67500a20a8f7fd7139b49 100644 (file)
 /*
  * check if an element is part of the list.
  */
-bool SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p)
+int
+SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p)
 {
-       if ((p == NULL) || (list == NULL)) {
-               return false;
-       }
+       if (!p || !list) return False;
        do {
-               if (p == list) {
-                       return true;
-               }
+               if (p == list) return True;
                list = list->next;
-       } while (list != NULL);
-       return false;
+       } while (list);
+       return False;
 }
 
 
index 104a04a6fc8ddc90f8c784ce31d8c90a5bdca75e..d4f71d8c8b70fe88655e33d37ca7845934175d28 100644 (file)
@@ -296,6 +296,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
        bool use_ccache = false;
        bool pw_nt_hash = false;
 
+       ZERO_STRUCT(c);
        *in_cache = false;
 
        if (server[0] == 0) {
index a4aaf6c327f484b0b7ed147834977f2e2b75b479..f20f79579e2caa4ec2c761c0397936e58837eb31 100644 (file)
@@ -251,7 +251,7 @@ SMBC_fstat_ctx(SMBCCTX *context,
                return -1;
        }
 
-       if (!SMBC_dlist_contains(context->internal->files, file)) {
+       if (!file || !SMBC_dlist_contains(context->internal->files, file)) {
                errno = EBADF;
                TALLOC_FREE(frame);
                return -1;
index 07c22a696fea6dcbb25f613c531a2f930486e911..0e2c1adb4ae2890185c0bedfdeaa0eaf304900c9 100644 (file)
@@ -283,8 +283,6 @@ NTSTATUS cli_posix_hardlink(struct cli_state *cli,
                        const char *newname);
 uint32_t unix_perms_to_wire(mode_t perms);
 mode_t wire_perms_to_unix(uint32_t perms);
-void fetch_file_unix_basic_info2(
-       const uint8_t data[116], SMB_STRUCT_STAT *sbuf);
 struct tevent_req *cli_posix_getacl_send(TALLOC_CTX *mem_ctx,
                                        struct tevent_context *ev,
                                        struct cli_state *cli,
@@ -312,9 +310,9 @@ NTSTATUS cli_posix_setacl(struct cli_state *cli,
 struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx,
                                       struct tevent_context *ev,
                                       struct cli_state *cli,
-                                      const char *fname);
-NTSTATUS cli_posix_stat_recv(struct tevent_req *req,
-                            SMB_STRUCT_STAT *sbuf);
+                                      const char *fname,
+                                      SMB_STRUCT_STAT *sbuf);
+NTSTATUS cli_posix_stat_recv(struct tevent_req *req);
 NTSTATUS cli_posix_stat(struct cli_state *cli,
                        const char *fname,
                        SMB_STRUCT_STAT *sbuf);
diff --git a/source3/script/tests/test_smbtorture_s3_no_unix_ext.sh b/source3/script/tests/test_smbtorture_s3_no_unix_ext.sh
deleted file mode 100755 (executable)
index 19af4ff..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-# this runs test_smbtorture_s3 with disabled unix extensions
-
-if [ -z "$SERVERCONFFILE" ] ; then
-    echo \$SERVERCONFFILE not defined
-    exit 1
-fi
-inject=${SERVERCONFFILE%/*}/global_inject.conf
-
-echo "unix extensions = no" > ${inject}
-$(dirname $0)/test_smbtorture_s3.sh $*
-ret=$?
-> ${inject}
-exit $ret
index ff6ab1a6b15b3619ec7776bc5b2b0522b9571fcb..fa7b6c3772a7ae7983134b451aff08492bf8fd3b 100755 (executable)
@@ -90,7 +90,7 @@ tests = ["FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", "LOCK5", "LOCK6", "LOCK7"
          "OPEN", "XCOPY", "RENAME", "DELETE", "DELETE-LN", "WILDDELETE", "PROPERTIES", "W2K",
          "TCON2", "IOCTL", "CHKPATH", "FDSESS", "CHAIN1", "CHAIN2", "OWNER-RIGHTS",
          "CHAIN3", "PIDHIGH", "CLI_SPLICE",
-         "UID-REGRESSION-TEST",
+         "UID-REGRESSION-TEST", "SHORTNAME-TEST",
          "CASE-INSENSITIVE-CREATE", "SMB2-BASIC", "NTTRANS-FSCTL", "SMB2-NEGPROT",
          "SMB2-SESSION-REAUTH", "SMB2-SESSION-RECONNECT", "SMB2-FTRUNCATE",
          "SMB2-ANONYMOUS", "SMB2-DIR-FSYNC",
@@ -113,26 +113,6 @@ for t in tests:
         plantestsuite("samba3.smbtorture_s3.plain.%s" % t, "fileserver", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//$SERVER_IP/tmp', '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH", "-mNT1"])
     plantestsuite("samba3.smbtorture_s3.plain.%s" % t, "ad_dc_ntvfs", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//$SERVER_IP/tmp', '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"])
 
-nonunix_tests = [
-    "SHORTNAME-TEST"
-    ]
-
-for t in nonunix_tests:
-    plantestsuite(
-        "samba3.smbtorture_s3.plain.%s" % t,
-        "fileserver",
-        [os.path.join(samba3srcdir,
-                      "script/tests/test_smbtorture_s3_no_unix_ext.sh"),
-         t,
-         '//$SERVER_IP/tmp',
-         '$USERNAME',
-         '$PASSWORD',
-         smbtorture3,
-         "",
-         "-l $LOCAL_PATH"])
-    # Can't run SMB1 encrypted tests without unix extensions. This
-    # will have to be added once we do SMB3 unix extensions.
-
 t = "TLDAP"
 plantestsuite("samba3.smbtorture_s3.plain.%s" % t, "ad_dc", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//$SERVER/tmp', '$DC_USERNAME', '$DC_PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"])
 
@@ -191,7 +171,7 @@ shares = [
 for s in shares:
     plantestsuite("samba3.smbtorture_s3.%s(simpleserver).SMB2-BASIC" % s, "simpleserver", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), 'SMB2-BASIC', '//$SERVER_IP/' + s, '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"])
     t = "smb2.compound_find"
-    plansmbtorture4testsuite(t, "simpleserver", "//%s/%s %s" % ('$SERVER_IP', s, '-U$USERNAME%$PASSWORD'), description=s)
+    plansmbtorture4testsuite(t, "simpleserver", "//%s/%s %s" % ('$SERVER_IP', s, ' -U$USERNAME%$PASSWORD'), description=s)
 
 posix_tests = ["POSIX", "POSIX-APPEND", "POSIX-SYMLINK-ACL", "POSIX-SYMLINK-EA", "POSIX-OFD-LOCK",
                "POSIX-STREAM-DELETE", "WINDOWS-BAD-SYMLINK", "POSIX-MKDIR",
index c55f33c1a2e8dcf70f59eb361a1e5b7888db0985..389a142db7dedf3a64a9c5cb6a3032c558489d4c 100755 (executable)
@@ -365,53 +365,28 @@ netapi = smbtorture4_testsuites("netapi.")
 for t in base + raw + smb2 + netapi:
     plansmbtorture4testsuite(t, "ad_dc_ntvfs", ['//$SERVER/tmp', '-U$USERNAME%$PASSWORD'] + ntvfsargs)
 
-def planlibsmbclienttest(name, testargs, proto):
-    env = "nt4_dc"
-
-    url = "--option=torture:smburl=smb://$USERNAME:$PASSWORD@$SERVER"
-
-    cmdarray = selftesthelpers.smbtorture4testsuite_cmdarray(
-        name,
-        env,
-        testargs + [ "--option=torture:clientprotocol=%s" % proto],
-        'samba4')
-
-    urloption = url
-    if name != "libsmbclient.list_shares":
-        urloption += "/posix_share"
-
-    plantestsuite_loadlist(
-        "samba4.unix_ext.%s.%s" % (t, proto),
-        env,
-        " ".join(cmdarray +
-                 ["--option=torture:unix_extensions=true"] +
-                 [urloption]))
-
-    urloption = url
-    if name != "libsmbclient.list_shares":
-        urloption += "/tmp"
-
-    plantestsuite_loadlist(
-        "samba4.non_unix_ext.%s.%s" % (t, proto),
-        env,
-        "(inject=\"${SERVERCONFFILE%/*}/global_inject.conf\"; " +
-        "echo \"unix extensions = no\" > ${inject} ; " +
-        " ".join(cmdarray + [urloption]) +
-        "; > ${inject})")
-
-
 libsmbclient = smbtorture4_testsuites("libsmbclient.")
 protocols = [ 'NT1', 'SMB3' ]
 for t in libsmbclient:
+    url = "smb://$USERNAME:$PASSWORD@$SERVER/tmp"
+    if t == "libsmbclient.list_shares":
+        url = "smb://$USERNAME:$PASSWORD@$SERVER"
+
     libsmbclient_testargs = [
         '//$SERVER/tmp',
         '-U$USERNAME%$PASSWORD',
+        "--option=torture:smburl=" + url,
         "--option=torture:replace_smbconf="
         "%s/testdata/samba3/smb_new.conf" % srcdir()
         ]
 
     for proto in protocols:
-        planlibsmbclienttest(t, libsmbclient_testargs, proto)
+        plansmbtorture4testsuite(
+            t,
+            "nt4_dc",
+            libsmbclient_testargs +
+            [ "--option=torture:clientprotocol=%s" % proto],
+            "samba4.%s.%s" % (t, proto))
 
 plansmbtorture4testsuite("raw.qfileinfo.ipc", "ad_dc_ntvfs", '//$SERVER/ipc\$ -U$USERNAME%$PASSWORD')
 
index 13bde24e9c0ac7c7172bf040de66f500fc056c39..c1508680d99a87031a1d843916a06d2005dd888c 100644 (file)
@@ -824,9 +824,6 @@ static bool torture_libsmbclient_readdirplus2(struct torture_context *tctx)
        struct stat st = {0};
        int ret;
        const char *smburl = torture_setting_string(tctx, "smburl", NULL);
-       bool unix_extensions = torture_setting_bool(
-               tctx, "unix_extensions", false);
-       mode_t expected_mode = 0;
 
        if (smburl == NULL) {
                torture_fail(tctx,
@@ -903,26 +900,21 @@ static bool torture_libsmbclient_readdirplus2(struct torture_context *tctx)
                                filename));
        }
 
-       if (unix_extensions) {
-               expected_mode = S_IFREG | 0666;
-       } else {
-               /*
-                * New file gets SMBC_FILE_MODE plus
-                * archive bit -> S_IXUSR
-                * !READONLY -> S_IWUSR.
-                */
-               expected_mode = SMBC_FILE_MODE|S_IXUSR|S_IWUSR;
-       }
-
+       /* Ensure mode is as expected. */
+       /*
+        * New file gets SMBC_FILE_MODE plus
+        * archive bit -> S_IXUSR
+        * !READONLY -> S_IWUSR.
+        */
        torture_assert_int_equal_goto(tctx,
                st2.st_mode,
-               expected_mode,
+               SMBC_FILE_MODE|S_IXUSR|S_IWUSR,
                success,
                done,
                talloc_asprintf(tctx,
                        "file %s st_mode should be 0%o, got 0%o'",
                        filename,
-                       expected_mode,
+                       SMBC_FILE_MODE|S_IXUSR|S_IWUSR,
                        (unsigned int)st2.st_mode));
 
        /* Ensure smbc_stat() gets the same data. */