The branch, master has been updated
       via  96a64fb3333 smbd: smbd_dirptr_lanman2_match_fn(): Remove 
"exact_match" handling
       via  079aad50ef4 smbd: Remove a smb1-only optimization findfirst/findnext
       via  cf4e55421bb smbd: Remove "a heuristic to avoid seeking the dirptr"
       via  880eb2bd56d libsmb: Test smb1 mknod
       via  41b094dd2ff pylibsmb: Add smb1_stat()
       via  efeb540602c pylibsmb: Add mknod()
       via  ca99d6a6ff4 libsmb: Add SMB1 posix cli_mknod
       via  c64699aeb0b rpc_server: Fix talloc hierarchy in 
_srvsvc_NetSrvGetInfo()
       via  1cd2f38b54b profiling: Factor out functions to read smbprofile.tdb
       via  18070a2d657 WHATSNEW: Mention removed "directory name cache size" 
parameter
       via  a4972336f12 lib: Add a few required #includes
       via  2c610804fe3 winbind: Fix a typo
       via  1b7fb13654f lib: Simplify two if-expressions
       via  1d6f6f9529b smbd: Remove references to get_Protocol()
       via  c86fef84ef1 smbd: Modernize a DEBUG statement in 
smbd_dirptr_get_entry()
       via  8a864e3f522 docs: Remove seekdir/telldir reference
       via  007b5825de9 smbd: Fix a typo
       via  12cbb043d10 libcli: Simplify security_token_is_sid()
       via  9e2723988ef libcli: Simplify dom_sid_dup()
      from  32fdc764efb s4:auth: Remove unneeded ‘sam_ctx’ parameter

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 96a64fb3333eb62f87e4b55e2c51fd501a13fd7f
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Jun 16 13:53:25 2023 +0200

    smbd: smbd_dirptr_lanman2_match_fn(): Remove "exact_match" handling
    
    No caller uses this anymore. The only downside here now is that we
    always go directly to mask_match instead of a trying strcasecmp_m
    first. I very much doubt this makes a measurable difference because
    this would have been called for non-wildcard
    readdirs (a.k.a. qpathinfo), and there we do this only once per
    complete directory read. Also I don't believe mask_match() is
    measurably more expensive than strcasecmp_m() for the usually short
    filenames we're looking at here.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Fri Jun 16 17:07:46 UTC 2023 on atb-devel-224

commit 079aad50ef47f34453eee9911655872397635c88
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Jun 16 13:45:57 2023 +0200

    smbd: Remove a smb1-only optimization findfirst/findnext
    
    I don't think this is an effective optimization at all anymore. It was
    intended to speed up non-wildcard readdirs after we found the correct
    entry. Nowadays we do the non-wildcard readdirs by a direct fstatat,
    and after we successfully found the entry dptr_ReadDirName()
    immediately returns without any further action. So my very strong
    guess is that this never really kicked in anymore. Not using this flag
    can't be *that* bad, smb2 never used it.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit cf4e55421bbe809bd869781432f4c2385dbf41bc
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Jun 16 13:32:24 2023 +0200

    smbd: Remove "a heuristic to avoid seeking the dirptr"
    
    -- we don't seek the dirptr anymore
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 880eb2bd56d6044e7407f98cc0af45df616267ae
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Mar 9 16:16:50 2023 +0100

    libsmb: Test smb1 mknod
    
    Requires O_PATH to work correctly
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 41b094dd2ff313c37981755c606d4f1d6500def6
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Feb 16 17:20:55 2023 +0100

    pylibsmb: Add smb1_stat()
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit efeb540602c76566ee646d204f4eedbd775d573b
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Feb 16 16:43:46 2023 +0100

    pylibsmb: Add mknod()
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit ca99d6a6ff4b39bfa73e2b2efd1e8140424bb4e8
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Feb 16 13:41:44 2023 +0100

    libsmb: Add SMB1 posix cli_mknod
    
    This is a dead horse, but in the future it will make it easier to test
    the smb311 unix extension code.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit c64699aeb0bb67caddb830004f4db237b3dcfda8
Author: Volker Lendecke <v...@samba.org>
Date:   Mon Apr 24 16:46:17 2023 +0200

    rpc_server: Fix talloc hierarchy in _srvsvc_NetSrvGetInfo()
    
    Make ->comment a proper talloc child of the right structure.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 1cd2f38b54b7a79ae21a328075fae07cfdc5e9aa
Author: Volker Lendecke <v...@samba.org>
Date:   Wed May 31 09:48:58 2023 +0200

    profiling: Factor out functions to read smbprofile.tdb
    
    We don't need all of Samba just to dump contents of this tdb, make
    exporting profile information cheaper.
    
    No direct use yet, but it's a good cleanup IMHO
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 18070a2d657c3daf80cb1387bcb721275b6c3946
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jun 14 07:23:52 2023 +0200

    WHATSNEW: Mention removed "directory name cache size" parameter
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit a4972336f129efc2d7df802cef4d3a75d4761e21
Author: Volker Lendecke <v...@samba.org>
Date:   Tue May 30 13:27:00 2023 +0200

    lib: Add a few required #includes
    
    You find them if you try to #include these files directly
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 2c610804fe35c683ef395f4e00b96012a5616877
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Apr 26 15:58:51 2023 +0200

    winbind: Fix a typo
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 1b7fb13654fba3f3a06189e86dafb0c5e483b0ca
Author: Volker Lendecke <v...@samba.org>
Date:   Tue May 23 10:44:40 2023 +0200

    lib: Simplify two if-expressions
    
    This version looks easier to read to me.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 1d6f6f9529b137fac89688cd2a63887caeb579f8
Author: Volker Lendecke <v...@samba.org>
Date:   Thu May 25 07:50:43 2023 +0200

    smbd: Remove references to get_Protocol()
    
    We have that available in smbXsrv_connection that is available almost
    everywhere.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit c86fef84ef16630839b0e4ce98e03c28a95ded28
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Jun 15 15:41:35 2023 +0200

    smbd: Modernize a DEBUG statement in smbd_dirptr_get_entry()
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 8a864e3f5222723f869c973c00bd3c850c76b4f2
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jun 14 07:20:34 2023 +0200

    docs: Remove seekdir/telldir reference
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 007b5825de98589a39735906413066d8bc89d811
Author: Volker Lendecke <v...@samba.org>
Date:   Thu May 25 07:31:02 2023 +0200

    smbd: Fix a typo
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 12cbb043d10b773ac292f61f33a81bd61b3c3aa5
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Apr 18 11:30:26 2023 +0200

    libcli: Simplify security_token_is_sid()
    
    Avoid an explicit if-statement.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 9e2723988ef3d8e3c84f812a48475e095f3dcaee
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Apr 18 13:39:09 2023 +0200

    libcli: Simplify dom_sid_dup()
    
    We have sid_copy() for this.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 WHATSNEW.txt                              |   1 +
 docs-xml/manpages/vfs_full_audit.8.xml    |   2 -
 lib/crypto/gnutls_helpers.h               |   1 +
 libcli/security/dom_sid.c                 |  15 +--
 libcli/security/security_token.c          |   8 +-
 python/samba/tests/smb1posix.py           |  20 +++
 selftest/skip.opath-required              |   7 ++
 source3/include/smbprofile.h              |   8 ++
 source3/lib/util.c                        |  18 +--
 source3/libsmb/clifile.c                  | 134 ++++++++++++++++++++
 source3/libsmb/proto.h                    |   8 ++
 source3/libsmb/pylibsmb.c                 | 120 ++++++++++++++++++
 source3/profile/profile.c                 | 144 +--------------------
 source3/profile/profile_read.c            | 202 ++++++++++++++++++++++++++++++
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c |  10 +-
 source3/smbd/dir.c                        |   6 +-
 source3/smbd/globals.h                    |   1 -
 source3/smbd/smb1_nttrans.c               |   4 +-
 source3/smbd/smb1_reply.c                 |  22 ++--
 source3/smbd/smb1_sesssetup.c             |   4 +-
 source3/smbd/smb1_trans2.c                | 145 +++++++++------------
 source3/smbd/smb2_query_directory.c       |   2 -
 source3/smbd/smb2_trans2.c                |  56 +--------
 source3/utils/conn_tdb.h                  |   2 +
 source3/winbindd/wb_query_user_list.c     |   2 +-
 source3/wscript_build                     |   5 +-
 source4/lib/messaging/irpc.h              |   1 +
 source4/lib/messaging/messaging.h         |   2 +
 28 files changed, 616 insertions(+), 334 deletions(-)
 create mode 100644 source3/profile/profile_read.c


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 8fbf1b59dbd..f760b24ef22 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -55,6 +55,7 @@ smb.conf changes
   Parameter Name                          Description     Default
   --------------                          -----------     -------
   winbind debug traceid                   Add traceid     No
+  directory name cache size               Removed
 
 
 KNOWN ISSUES
diff --git a/docs-xml/manpages/vfs_full_audit.8.xml 
b/docs-xml/manpages/vfs_full_audit.8.xml
index 401ac5a0d8f..9a9f1efc33b 100644
--- a/docs-xml/manpages/vfs_full_audit.8.xml
+++ b/docs-xml/manpages/vfs_full_audit.8.xml
@@ -126,7 +126,6 @@
        <member>removexattr</member>
        <member>renameat</member>
        <member>rewinddir</member>
-       <member>seekdir</member>
        <member>sendfile</member>
        <member>set_compression</member>
        <member>set_offline</member>
@@ -142,7 +141,6 @@
        <member>sys_acl_delete_def_fd</member>
        <member>sys_acl_get_fd</member>
        <member>sys_acl_set_fd</member>
-       <member>telldir</member>
        <member>translate_name</member>
        <member>unlinkat</member>
        <member>write</member>
diff --git a/lib/crypto/gnutls_helpers.h b/lib/crypto/gnutls_helpers.h
index 6719a599604..4e6f4f3f8b1 100644
--- a/lib/crypto/gnutls_helpers.h
+++ b/lib/crypto/gnutls_helpers.h
@@ -22,6 +22,7 @@
 
 #include "libcli/util/ntstatus.h"
 #include "libcli/util/werror.h"
+#include "lib/util/data_blob.h"
 
 /* Those macros are only available in GnuTLS >= 3.6.4 */
 #ifndef GNUTLS_FIPS140_SET_LAX_MODE
diff --git a/libcli/security/dom_sid.c b/libcli/security/dom_sid.c
index 52d4454e4e5..9a91760ff62 100644
--- a/libcli/security/dom_sid.c
+++ b/libcli/security/dom_sid.c
@@ -290,7 +290,6 @@ struct dom_sid *dom_sid_parse_length(TALLOC_CTX *mem_ctx, 
const DATA_BLOB *sid)
 struct dom_sid *dom_sid_dup(TALLOC_CTX *mem_ctx, const struct dom_sid *dom_sid)
 {
        struct dom_sid *ret;
-       int i;
 
        if (!dom_sid) {
                return NULL;
@@ -300,19 +299,7 @@ struct dom_sid *dom_sid_dup(TALLOC_CTX *mem_ctx, const 
struct dom_sid *dom_sid)
        if (!ret) {
                return NULL;
        }
-
-       ret->sid_rev_num = dom_sid->sid_rev_num;
-       ret->id_auth[0] = dom_sid->id_auth[0];
-       ret->id_auth[1] = dom_sid->id_auth[1];
-       ret->id_auth[2] = dom_sid->id_auth[2];
-       ret->id_auth[3] = dom_sid->id_auth[3];
-       ret->id_auth[4] = dom_sid->id_auth[4];
-       ret->id_auth[5] = dom_sid->id_auth[5];
-       ret->num_auths = dom_sid->num_auths;
-
-       for (i=0;i<dom_sid->num_auths;i++) {
-               ret->sub_auths[i] = dom_sid->sub_auths[i];
-       }
+       sid_copy(ret, dom_sid);
 
        return ret;
 }
diff --git a/libcli/security/security_token.c b/libcli/security/security_token.c
index 31be678941e..a80637f0ce1 100644
--- a/libcli/security/security_token.c
+++ b/libcli/security/security_token.c
@@ -67,13 +67,13 @@ void security_token_debug(int dbg_class, int dbg_lev, const 
struct security_toke
 
 bool security_token_is_sid(const struct security_token *token, const struct 
dom_sid *sid)
 {
+       bool ret;
+
        if (token->sids == NULL) {
                return false;
        }
-       if (dom_sid_equal(&token->sids[PRIMARY_USER_SID_INDEX], sid)) {
-               return true;
-       }
-       return false;
+       ret = dom_sid_equal(&token->sids[PRIMARY_USER_SID_INDEX], sid);
+       return ret;
 }
 
 bool security_token_is_system(const struct security_token *token)
diff --git a/python/samba/tests/smb1posix.py b/python/samba/tests/smb1posix.py
index 52b0312ac8b..d77c49d0664 100644
--- a/python/samba/tests/smb1posix.py
+++ b/python/samba/tests/smb1posix.py
@@ -19,6 +19,7 @@ from samba.samba3 import libsmb_samba_internal as libsmb
 from samba import (ntstatus,NTSTATUSError)
 from samba.dcerpc import security as sec
 import samba.tests.libsmb
+import stat
 
 class Smb1PosixTests(samba.tests.libsmb.LibsmbTests):
 
@@ -47,6 +48,25 @@ class Smb1PosixTests(samba.tests.libsmb.LibsmbTests):
         conn.rmdir("lower/second")
         conn.rmdir("lower")
 
+    def test_mknod(self):
+        """Test SMB1 posix mknod"""
+        conn = libsmb.Conn(
+            self.server_ip,
+            "posix_share",
+            self.lp,
+            self.creds,
+            force_smb1=True)
+        conn.smb1_posix()
+
+        def do_test(name, filetype):
+            conn.mknod(name, filetype | 0o755)
+            st = conn.smb1_stat(name)
+            self.assertEqual(st["mode"], filetype | 0o755)
+            conn.unlink(name)
+
+        do_test("fifo", stat.S_IFIFO)
+        do_test("sock", stat.S_IFSOCK)
+
 if __name__ == '__main__':
     import unittest
     unittest.main()
diff --git a/selftest/skip.opath-required b/selftest/skip.opath-required
index 0faf0c4bd6c..c3a13f5ec6e 100644
--- a/selftest/skip.opath-required
+++ b/selftest/skip.opath-required
@@ -7,3 +7,10 @@
 # These fail because become_root() doesn't work in make test
 ^samba3.blackbox.dropbox.*
 ^samba3.raw.samba3hide.*
+
+# samba.tests.smb1posix.samba.tests.smb1posix.Smb1PosixTests.test_mknod
+# creates a socket and posix stat() gives an error because opening the
+# socket from filename_covert_dirfsp() returns ENXIO. With O_PATH
+# available this works fine. So for now restrict testing posix
+# extensions to environments where we have O_PATH around
+^samba.tests.smb1posix
diff --git a/source3/include/smbprofile.h b/source3/include/smbprofile.h
index 62873a5532b..91af220051d 100644
--- a/source3/include/smbprofile.h
+++ b/source3/include/smbprofile.h
@@ -21,6 +21,10 @@
 
 */
 
+#include "replace.h"
+#include <tdb.h>
+#include "lib/util/time.h"
+
 struct tevent_context;
 
 #ifdef WITH_PROFILE
@@ -514,6 +518,10 @@ void smbprofile_dump(void);
 void smbprofile_cleanup(pid_t pid, pid_t dst);
 void smbprofile_stats_accumulate(struct profile_stats *acc,
                                 const struct profile_stats *add);
+int smbprofile_magic(const struct profile_stats *stats, uint64_t *_magic);
+void smbprofile_collect_tdb(struct tdb_context *tdb,
+                           uint64_t magic,
+                           struct profile_stats *stats);
 void smbprofile_collect(struct profile_stats *stats);
 
 static inline uint64_t profile_timestamp(void)
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 9fd913ba729..922b7ad83d9 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -119,11 +119,8 @@ uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf)
 bool check_same_dev_ino(const SMB_STRUCT_STAT *sbuf1,
                         const SMB_STRUCT_STAT *sbuf2)
 {
-       if (sbuf1->st_ex_dev != sbuf2->st_ex_dev ||
-                       sbuf1->st_ex_ino != sbuf2->st_ex_ino) {
-               return false;
-       }
-       return true;
+       return ((sbuf1->st_ex_dev == sbuf2->st_ex_dev) &&
+               (sbuf1->st_ex_ino == sbuf2->st_ex_ino));
 }
 
 /****************************************************************************
@@ -131,14 +128,11 @@ bool check_same_dev_ino(const SMB_STRUCT_STAT *sbuf1,
 ****************************************************************************/
 
 bool check_same_stat(const SMB_STRUCT_STAT *sbuf1,
-                       const SMB_STRUCT_STAT *sbuf2)
+                    const SMB_STRUCT_STAT *sbuf2)
 {
-       if (sbuf1->st_ex_uid != sbuf2->st_ex_uid ||
-                       sbuf1->st_ex_gid != sbuf2->st_ex_gid ||
-                       !check_same_dev_ino(sbuf1, sbuf2)) {
-               return false;
-       }
-       return true;
+       return ((sbuf1->st_ex_uid == sbuf2->st_ex_uid) &&
+               (sbuf1->st_ex_gid == sbuf2->st_ex_gid) &&
+               check_same_dev_ino(sbuf1, sbuf2));
 }
 
 /*******************************************************************
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index ecc652c81e6..6acca11211e 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -1178,6 +1178,140 @@ NTSTATUS cli_posix_chown(struct cli_state *cli,
        return status;
 }
 
+struct cli_smb1_posix_mknod_state {
+       uint8_t data[100];
+};
+
+static void cli_smb1_posix_mknod_done(struct tevent_req *subreq);
+
+static struct tevent_req *cli_smb1_posix_mknod_send(
+       TALLOC_CTX *mem_ctx,
+       struct tevent_context *ev,
+       struct cli_state *cli,
+       const char *fname,
+       mode_t mode,
+       dev_t dev)
+{
+       struct tevent_req *req = NULL, *subreq = NULL;
+       struct cli_smb1_posix_mknod_state *state = NULL;
+       mode_t type = mode & S_IFMT;
+       uint32_t smb_unix_type = 0xFFFFFFFF;
+
+       req = tevent_req_create(
+               mem_ctx, &state, struct cli_smb1_posix_mknod_state);
+       if (req == NULL) {
+               return NULL;
+       }
+       /*
+        * Set all sizes/times/ids to no change.
+        */
+       memset(state->data, 0xff, 56);
+
+       switch (type) {
+       case S_IFREG:
+               smb_unix_type = UNIX_TYPE_FILE;
+               break;
+       case S_IFDIR:
+               smb_unix_type = UNIX_TYPE_DIR;
+               break;
+       case S_IFLNK:
+               smb_unix_type = UNIX_TYPE_SYMLINK;
+               break;
+       case S_IFCHR:
+               smb_unix_type = UNIX_TYPE_CHARDEV;
+               break;
+       case S_IFBLK:
+               smb_unix_type = UNIX_TYPE_BLKDEV;
+               break;
+       case S_IFIFO:
+               smb_unix_type = UNIX_TYPE_FIFO;
+               break;
+       case S_IFSOCK:
+               smb_unix_type = UNIX_TYPE_SOCKET;
+               break;
+       }
+       PUSH_LE_U32(state->data, 56, smb_unix_type);
+
+       if ((type == S_IFCHR) || (type == S_IFBLK)) {
+               PUSH_LE_U64(state->data, 60, unix_dev_major(dev));
+               PUSH_LE_U64(state->data, 68, unix_dev_minor(dev));
+       }
+
+       PUSH_LE_U32(state->data, 84, unix_perms_to_wire(mode));
+
+       subreq = cli_setpathinfo_send(
+               state,
+               ev,
+               cli,
+               SMB_SET_FILE_UNIX_BASIC,
+               fname,
+               state->data,
+               sizeof(state->data));
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, cli_smb1_posix_mknod_done, req);
+       return req;
+}
+
+static void cli_smb1_posix_mknod_done(struct tevent_req *subreq)
+{
+       NTSTATUS status = cli_setpathinfo_recv(subreq);
+       tevent_req_simple_finish_ntstatus(subreq, status);
+}
+
+static NTSTATUS cli_smb1_posix_mknod_recv(struct tevent_req *req)
+{
+       return tevent_req_simple_recv_ntstatus(req);
+}
+
+struct cli_mknod_state {
+       uint8_t dummy;
+};
+
+static void cli_mknod_done1(struct tevent_req *subreq);
+
+struct tevent_req *cli_mknod_send(
+       TALLOC_CTX *mem_ctx,
+       struct tevent_context *ev,
+       struct cli_state *cli,
+       const char *fname,
+       mode_t mode,
+       dev_t dev)
+{
+       struct tevent_req *req = NULL, *subreq = NULL;
+       struct cli_mknod_state *state = NULL;
+
+       req = tevent_req_create(mem_ctx, &state, struct cli_mknod_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+       if (cli->requested_posix_capabilities != 0) {
+               subreq = cli_smb1_posix_mknod_send(
+                       state, ev, cli, fname, mode, dev);
+               if (tevent_req_nomem(subreq, req)) {
+                       return tevent_req_post(req, ev);
+               }
+               tevent_req_set_callback(subreq, cli_mknod_done1, req);
+               return req;
+       }
+
+       tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
+       return tevent_req_post(req, ev);
+}
+
+static void cli_mknod_done1(struct tevent_req *subreq)
+{
+       NTSTATUS status = cli_smb1_posix_mknod_recv(subreq);
+       tevent_req_simple_finish_ntstatus(subreq, status);
+}
+
+NTSTATUS cli_mknod_recv(struct tevent_req *req)
+{
+       return tevent_req_simple_recv_ntstatus(req);
+}
+
 /****************************************************************************
  Rename a file.
 ****************************************************************************/
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 3bac88c2ee4..4905702c0dc 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -327,6 +327,14 @@ NTSTATUS cli_posix_chown(struct cli_state *cli,
                        const char *fname,
                        uid_t uid,
                        gid_t gid);
+struct tevent_req *cli_mknod_send(
+       TALLOC_CTX *mem_ctx,
+       struct tevent_context *ev,
+       struct cli_state *cli,
+       const char *fname,
+       mode_t mode,
+       dev_t dev);
+NTSTATUS cli_mknod_recv(struct tevent_req *req);
 struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
                                   struct tevent_context *ev,
                                   struct cli_state *cli,
diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c
index bace98ddd3a..6199f7b32dc 100644
--- a/source3/libsmb/pylibsmb.c
+++ b/source3/libsmb/pylibsmb.c
@@ -2508,6 +2508,116 @@ static PyObject *py_smb_smb1_symlink(
        Py_RETURN_NONE;
 }
 
+static PyObject *py_smb_smb1_stat(
+       struct py_cli_state *self, PyObject *args)
+{
+       NTSTATUS status;
+       const char *fname = NULL;
+       struct tevent_req *req = NULL;
+       struct stat_ex sbuf = { .st_ex_nlink = 0, };
+
+       if (!PyArg_ParseTuple(args, "s:smb1_stat", &fname)) {
+               return NULL;
+       }
+
+       req = cli_posix_stat_send(NULL, self->ev, self->cli, fname);
+       if (!py_tevent_req_wait_exc(self, req)) {
+               return NULL;
+       }
+       status = cli_posix_stat_recv(req, &sbuf);
+       TALLOC_FREE(req);
+       if (!NT_STATUS_IS_OK(status)) {
+               PyErr_SetNTSTATUS(status);
+               return NULL;
+       }
+
+       return Py_BuildValue(
+               "{sLsLsLsLsLsLsLsLsLsLsLsLsLsLsLsLsLsLsLsL}",
+               "dev",
+               (unsigned long long)sbuf.st_ex_dev,
+               "ino",
+               (unsigned long long)sbuf.st_ex_ino,
+               "mode",
+               (unsigned long long)sbuf.st_ex_mode,
+               "nlink",
+               (unsigned long long)sbuf.st_ex_nlink,
+               "uid",
+               (unsigned long long)sbuf.st_ex_uid,
+               "gid",
+               (unsigned long long)sbuf.st_ex_gid,
+               "rdev",
+               (unsigned long long)sbuf.st_ex_size,
+               "atime_sec",
+               (unsigned long long)sbuf.st_ex_atime.tv_sec,
+               "atime_nsec",
+               (unsigned long long)sbuf.st_ex_atime.tv_nsec,
+               "mtime_sec",
+               (unsigned long long)sbuf.st_ex_mtime.tv_sec,
+               "mtime_nsec",
+               (unsigned long long)sbuf.st_ex_mtime.tv_nsec,
+               "ctime_sec",
+               (unsigned long long)sbuf.st_ex_ctime.tv_sec,
+               "ctime_nsec",
+               (unsigned long long)sbuf.st_ex_ctime.tv_nsec,
+               "btime_sec",
+               (unsigned long long)sbuf.st_ex_btime.tv_sec,
+               "btime_nsec",
+               (unsigned long long)sbuf.st_ex_btime.tv_nsec,
+               "cached_dos_attributes",
+               (unsigned long long)sbuf.cached_dos_attributes,
+               "blksize",
+               (unsigned long long)sbuf.st_ex_blksize,
+               "blocks",
+               (unsigned long long)sbuf.st_ex_blocks,
+               "flags",
+               (unsigned long long)sbuf.st_ex_flags,
+               "iflags",
+               (unsigned long long)sbuf.st_ex_iflags);
+}
+
+static PyObject *py_cli_mknod(
+       struct py_cli_state *self, PyObject *args, PyObject *kwds)
+{
+       char *fname = NULL;
+       int mode = 0, major = 0, minor = 0, dev = 0;
+       struct tevent_req *req = NULL;
+       static const char *kwlist[] = {
+               "fname", "mode", "major", "minor", NULL,
+       };
+       NTSTATUS status;
+       bool ok;
+
+       ok = ParseTupleAndKeywords(
+               args,
+               kwds,
+               "sI|II:mknod",
+               kwlist,
+               &fname,
+               &mode,
+               &major,
+               &minor);
+       if (!ok) {
+               return NULL;
+       }
+
+#if defined(HAVE_MAKEDEV)
+       dev = makedev(major, minor);
+#endif
+
+       req = cli_mknod_send(
+               NULL, self->ev, self->cli, fname, mode, dev);
+       if (!py_tevent_req_wait_exc(self, req)) {
+               return NULL;
+       }
+       status = cli_mknod_recv(req);
+       TALLOC_FREE(req);
+       if (!NT_STATUS_IS_OK(status)) {
+               PyErr_SetNTSTATUS(status);
+               return NULL;
+       }
+       Py_RETURN_NONE;
+}
+
 static PyObject *py_cli_fsctl(
        struct py_cli_state *self, PyObject *args, PyObject *kwds)
 {


-- 
Samba Shared Repository

Reply via email to