[SCM] Samba Shared Repository - branch v4-7-test updated

Stefan Metzmacher metze at samba.org
Thu Jul 13 10:09:03 UTC 2017


The branch, v4-7-test has been updated
       via  7cf9a52 unittests: Add missing stdint.h include
       via  a235bb4 WHATSNEW: CTDB changes for 4.7
       via  dc35068 Add code to run the tests for 'samba-tool user edit'
       via  a1874cd Add test for 'samba-tool user edit'
       via  ec0545f Easily edit a users object in AD, as if using ldbedit.
       via  21f9477 waf: Only build unit tests with selftest enabled
       via  fdd1dc7 s3:smbd: consistently use talloc_tos() memory for rpc_pipe_open_interface()
       via  c6d2d56 selftest: add a test for accessing previous version of directories with snapdirseverywhere
       via  b1916bf s3/smbd: let non_widelink_open() chdir() to directories directly
       via  08f8402 unittests: Do not install the test_dummy rpc module
       via  e1b217c waf: Do not install _ldb_text.py if we have system libldb
      from  3d9dddb VERSION: Bump version up to 4.6.0rc3...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-7-test


- Log -----------------------------------------------------------------
commit 7cf9a52487a9f8fc4778da2f7313222ada873846
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jul 5 08:59:23 2017 +0200

    unittests: Add missing stdint.h include
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12878
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    (cherry picked from commit 5d18c5e5ec52a185991f9de6883171f85f7d4fa7)
    
    Autobuild-User(v4-7-test): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(v4-7-test): Thu Jul 13 12:08:53 CEST 2017 on sn-devel-144

commit a235bb4bcb80a01c6b6566320d624ce975cd8105
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 5 16:31:48 2017 +1000

    WHATSNEW: CTDB changes for 4.7
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit dc3506874da888c0ff53f2df5cd2ffc4d7fac1fc
Author: Rowland Penny <rpenny at samba.org>
Date:   Tue Jul 4 15:07:53 2017 +0100

    Add code to run the tests for 'samba-tool user edit'
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12884
    
    Signed-off-by: Rowland Penny <rpenny at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    
    Autobuild-User(master): Alexander Bokovoy <ab at samba.org>
    Autobuild-Date(master): Wed Jul  5 17:53:24 CEST 2017 on sn-devel-144
    
    (cherry picked from commit e3707c1b19a27d431722e1b355dc39a39f7f8f1c)

commit a1874cd86a2f2c12ce2b40c7c3a115f0e50a238e
Author: Rowland Penny <rpenny at samba.org>
Date:   Tue Jul 4 15:04:36 2017 +0100

    Add test for 'samba-tool user edit'
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12884
    
    Signed-off-by: Rowland Penny <rpenny at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    (cherry picked from commit 3c03ac750f4dea00da21f21302beeaf5b12a35b8)

commit ec0545f5efeb9ff3e87c03a45e6484b8ba4d92c6
Author: Rowland Penny <rpenny at samba.org>
Date:   Tue Jul 4 15:00:58 2017 +0100

    Easily edit a users object in AD, as if using ldbedit.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12884
    
    Signed-off-by: Rowland Penny <rpenny at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    (cherry picked from commit 2ab239be0d69389b451816ec72d548d1156e495b)

commit 21f94775f0d33c1fee4702af43c684261f5c1c16
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jul 5 10:08:49 2017 +0200

    waf: Only build unit tests with selftest enabled
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12877
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    (cherry picked from commit 25ef27b2e6d80f0afa271e73a195caa2105be648)

commit fdd1dc7b71404c5a84352d8611edd6ab18d773c1
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Jul 10 11:29:58 2017 +0200

    s3:smbd: consistently use talloc_tos() memory for rpc_pipe_open_interface()
    
    The result is only used temporary and should not be leaked on a long term
    memory context as 'conn'.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12890
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 77cbced5d2f8bf65c8d02f5edfaba8cbad519d08)

commit c6d2d56e500d8d66e4b8e81be37814a0b5d7704f
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Jul 7 13:12:19 2017 +0200

    selftest: add a test for accessing previous version of directories with snapdirseverywhere
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12885
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Sat Jul  8 00:33:51 CEST 2017 on sn-devel-144
    
    (cherry picked from commit cc9ba98c08665e0ed6927fd81fa43a7bb7842e45)

commit b1916bf355cea38056e999c093d7ddb05b52d7e6
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Jul 7 12:57:57 2017 +0200

    s3/smbd: let non_widelink_open() chdir() to directories directly
    
    If the caller passes O_DIRECTORY we just try to chdir() to smb_fname
    directly, not to the parent directory.
    
    The security check in check_reduced_name() will continue to work, but
    this fixes the case of an open() for a previous version of a
    subdirectory that contains snapshopt.
    
    Eg:
    
    [share]
        path = /shares/test
        vfs objects = shadow_copy2
        shadow:snapdir = .snapshots
        shadow:snapdirseverywhere = yes
    
    Directory tree with fake snapshots:
    
    $ tree -a /shares/test/
    /shares/test/
    ├── dir
    │   ├── file
    │   └── .snapshots
    │       └── @GMT-2017.07.04-04.30.12
    │           └── file
    ├── dir2
    │   └── file
    ├── file
    ├── .snapshots
    │   └── @GMT-2001.01.01-00.00.00
    │       ├── dir2
    │       │   └── file
    │       └── file
    └── testfsctl.dat
    
    ./bin/smbclient -U slow%x //localhost/share -c 'ls @GMT-2017.07.04-04.30.12/dir/*'
    NT_STATUS_OBJECT_NAME_NOT_FOUND listing \@GMT-2017.07.04-04.30.12\dir\*
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=12885
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit b886a9443d49f6e27fa3863d87c9e24d12e62874)

commit 08f8402169a31fe2c4715d210ec52909449de533
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jul 5 10:30:35 2017 +0200

    unittests: Do not install the test_dummy rpc module
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12879
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Wed Jul  5 22:21:06 CEST 2017 on sn-devel-144
    
    (cherry picked from commit 1de439035308b80a6bedc8110d02a4c29388c975)

commit e1b217ccd0fe1d52fc5f96c99a0033c913797f80
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jul 6 07:44:28 2017 +0200

    waf: Do not install _ldb_text.py if we have system libldb
    
    _ldb_text.py is installed as part of the ldb package and also if you
    compile Samba with the system ldb version. This way we have have the
    file twice in the same location and run into file confilcts.
    
    This has already been fixed some time ago:
        60dc26bfe1573265dcbd87b9dd3439f945e57d97
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12882
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    (cherry picked from commit 98e30cf491c63eb0b69c13ad42b720d22944adda)

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

Summary of changes:
 WHATSNEW.txt                                |  44 +++++++++
 lib/ldb/wscript                             |  13 ++-
 python/samba/netcmd/user.py                 | 139 +++++++++++++++++++++++++++-
 python/samba/tests/samba_tool/edit.sh       |  72 ++++++++++++++
 source3/script/tests/test_shadow_copy.sh    |  23 +++++
 source3/smbd/lanman.c                       |  20 ++--
 source3/smbd/open.c                         |  30 +++++-
 source3/smbd/reply.c                        |   2 +-
 source4/selftest/tests.py                   |   4 +
 testsuite/unittests/test_sambafs_srv_pipe.c |   1 +
 testsuite/unittests/wscript                 |   3 +-
 wscript                                     |   2 +-
 wscript_build                               |   3 +-
 13 files changed, 331 insertions(+), 25 deletions(-)
 create mode 100755 python/samba/tests/samba_tool/edit.sh


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 73daedf..2b66242 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -276,6 +276,50 @@ smb.conf changes
   password hash userPassword schemes New parameter
   ntlm auth                          New values              ntlmv2-only
 
+CTDB changes
+------------
+
+* CTDB no longer allows mixed minor versions in a cluster
+
+  See the AllowMixedVersions tunable option in ctdb-tunables(7) and also
+  https://wiki.samba.org/index.php/Upgrading_a_CTDB_cluster#Policy
+
+* CTDB now ignores hints from Samba about TDB flags when attaching to databases
+
+  CTDB will use the correct flags depending on the type of database.
+  For clustered databases, the smb.conf setting
+  dbwrap_tdb_mutexes:*=true will be ignored. Instead, CTDB continues
+  to use the TDBMutexEnabled tunable.
+
+* New configuration variable CTDB_NFS_CHECKS_DIR
+
+  See ctdbd.conf(5) for more details.
+
+* The CTDB_SERVICE_AUTOSTARTSTOP configuration variable has been
+  removed
+
+  To continue to manage/unmanage services while CTDB is running:
+
+  - Start service by hand and then flag it as managed
+
+  - Mark service as unmanaged and shut it down by hand
+
+  - In some cases CTDB does something fancy - e.g. start Samba under
+    "nice", so care is needed. One technique is to disable the
+    eventscript, mark as managed, run the startup event by hand and then
+    re-enable the eventscript.
+
+* The CTDB_SCRIPT_DEBUGLEVEL configuration variable has been removed
+
+* The example NFS Ganesha call-out has been improved
+
+* A new "replicated" database type is available
+
+  Replicated databases are intended for CTDB's internal use to
+  replicate state data across the cluster, but may find other
+  uses. The data in replicated databases is valid for the lifetime of
+  CTDB and cleared on first attach.
+
 
 KNOWN ISSUES
 ============
diff --git a/lib/ldb/wscript b/lib/ldb/wscript
index 6f36965..32647dd 100644
--- a/lib/ldb/wscript
+++ b/lib/ldb/wscript
@@ -177,12 +177,15 @@ def build(bld):
                                      realname='ldb.so',
                                      cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
 
-        for env in bld.gen_python_environments(['PKGCONFIGDIR']):
-                bld.SAMBA_SCRIPT('_ldb_text.py',
-                                 pattern='_ldb_text.py',
-                                 installdir='python')
+        # Do only install this file as part of the Samba build if we do not
+        # use the system libldb!
+        if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
+            for env in bld.gen_python_environments(['PKGCONFIGDIR']):
+                    bld.SAMBA_SCRIPT('_ldb_text.py',
+                                     pattern='_ldb_text.py',
+                                     installdir='python')
 
-                bld.INSTALL_FILES('${PYTHONARCHDIR}', '_ldb_text.py')
+                    bld.INSTALL_FILES('${PYTHONARCHDIR}', '_ldb_text.py')
 
     if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
         if bld.is_install:
diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py
index 53ac39f..3b744a3 100644
--- a/python/samba/netcmd/user.py
+++ b/python/samba/netcmd/user.py
@@ -21,6 +21,9 @@ import samba.getopt as options
 import ldb
 import pwd
 import os
+import re
+import tempfile
+import difflib
 import sys
 import fcntl
 import signal
@@ -28,7 +31,7 @@ import errno
 import time
 import base64
 import binascii
-from subprocess import Popen, PIPE, STDOUT
+from subprocess import Popen, PIPE, STDOUT, check_call, CalledProcessError
 from getpass import getpass
 from samba.auth import system_session
 from samba.samdb import SamDB
@@ -2283,6 +2286,139 @@ samba-tool user syncpasswords --terminate \\
         update_pid(None)
         return
 
+class cmd_user_edit(Command):
+    """Modify User AD object.
+
+This command will allow editing of a user account in the Active Directory
+domain. You will then be able to add or change attributes and their values.
+
+The username specified on the command is the sAMAccountName.
+
+The command may be run from the root userid or another authorized userid.
+
+The -H or --URL= option can be used to execute the command against a remote
+server.
+
+Example1:
+samba-tool user edit User1 -H ldap://samba.samdom.example.com \
+-U administrator --password=passw1rd
+
+Example1 shows how to edit a users attributes in the domain against a remote
+LDAP server.
+
+The -H parameter is used to specify the remote target server.
+
+Example2:
+samba-tool user edit User2
+
+Example2 shows how to edit a users attributes in the domain against a local
+LDAP server.
+
+Example3:
+samba-tool user edit User3 --editor=nano
+
+Example3 shows how to edit a users attributes in the domain against a local
+LDAP server using the 'nano' editor.
+
+"""
+    synopsis = "%prog <username> [options]"
+
+    takes_options = [
+        Option("-H", "--URL", help="LDB URL for database or target server",
+               type=str, metavar="URL", dest="H"),
+        Option("--editor", help="Editor to use instead of the system default,"
+               " or 'vi' if no system default is set.", type=str),
+    ]
+
+    takes_args = ["username"]
+    takes_optiongroups = {
+        "sambaopts": options.SambaOptions,
+        "credopts": options.CredentialsOptions,
+        "versionopts": options.VersionOptions,
+        }
+
+    def run(self, username, credopts=None, sambaopts=None, versionopts=None,
+            H=None, editor=None):
+
+        lp = sambaopts.get_loadparm()
+        creds = credopts.get_credentials(lp, fallback_machine=True)
+        samdb = SamDB(url=H, session_info=system_session(),
+                      credentials=creds, lp=lp)
+
+        filter = ("(&(sAMAccountType=%d)(sAMAccountName=%s))" %
+                  (dsdb.ATYPE_NORMAL_ACCOUNT, ldb.binary_encode(username)))
+
+        domaindn = samdb.domain_dn()
+
+        try:
+            res = samdb.search(base=domaindn,
+                               expression=filter,
+                               scope=ldb.SCOPE_SUBTREE)
+            user_dn = res[0].dn
+        except IndexError:
+            raise CommandError('Unable to find user "%s"' % (username))
+
+        for msg in res:
+            r_ldif = samdb.write_ldif(msg, 1)
+            # remove 'changetype' line
+            result_ldif = re.sub('changetype: add\n', '', r_ldif)
+
+            if editor is None:
+                editor = os.environ.get('EDITOR')
+                if editor is None:
+                    editor = 'vi'
+
+            with tempfile.NamedTemporaryFile(suffix=".tmp") as t_file:
+                t_file.write(result_ldif)
+                t_file.flush()
+                try:
+                    check_call([editor, t_file.name])
+                except CalledProcessError as e:
+                    raise CalledProcessError("ERROR: ", e)
+                with open(t_file.name) as edited_file:
+                    edited_message = edited_file.read()
+
+        if result_ldif != edited_message:
+            diff = difflib.ndiff(result_ldif.splitlines(),
+                                 edited_message.splitlines())
+            minus_lines = []
+            plus_lines = []
+            for line in diff:
+                if line.startswith('-'):
+                    line = line[2:]
+                    minus_lines.append(line)
+                elif line.startswith('+'):
+                    line = line[2:]
+                    plus_lines.append(line)
+
+            user_ldif="dn: %s\n" % user_dn
+            user_ldif += "changetype: modify\n"
+
+            for line in minus_lines:
+                attr, val = line.split(':', 1)
+                search_attr="%s:" % attr
+                if not re.search(r'^' + search_attr, str(plus_lines)):
+                    user_ldif += "delete: %s\n" % attr
+                    user_ldif += "%s: %s\n" % (attr, val)
+
+            for line in plus_lines:
+                attr, val = line.split(':', 1)
+                search_attr="%s:" % attr
+                if re.search(r'^' + search_attr, str(minus_lines)):
+                    user_ldif += "replace: %s\n" % attr
+                    user_ldif += "%s: %s\n" % (attr, val)
+                if not re.search(r'^' + search_attr, str(minus_lines)):
+                    user_ldif += "add: %s\n" % attr
+                    user_ldif += "%s: %s\n" % (attr, val)
+
+            try:
+                samdb.modify_ldif(user_ldif)
+            except Exception as e:
+                raise CommandError("Failed to modify user '%s': " %
+                                   username, e)
+
+            self.outf.write("Modified User '%s' successfully\n" % username)
+
 class cmd_user(SuperCommand):
     """User management."""
 
@@ -2298,3 +2434,4 @@ class cmd_user(SuperCommand):
     subcommands["setpassword"] = cmd_user_setpassword()
     subcommands["getpassword"] = cmd_user_getpassword()
     subcommands["syncpasswords"] = cmd_user_syncpasswords()
+    subcommands["edit"] = cmd_user_edit()
diff --git a/python/samba/tests/samba_tool/edit.sh b/python/samba/tests/samba_tool/edit.sh
new file mode 100755
index 0000000..c1ecfde
--- /dev/null
+++ b/python/samba/tests/samba_tool/edit.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# Test for 'samba-tool user edit'
+
+if [ $# -lt 3 ]; then
+cat <<EOF
+Usage: edit.sh SERVER USERNAME PASSWORD
+EOF
+exit 1;
+fi
+
+SERVER="$1"
+USERNAME="$2"
+PASSWORD="$3"
+
+STpath=$(pwd)
+. $STpath/testprogs/blackbox/subunit.sh
+
+# create editor.sh
+# this has to be hard linked to /tmp or 'samba-tool user edit' cannot find it
+tmpeditor=$(mktemp --suffix .sh -p $STpath/bin samba-tool-editor-XXXXXXXX)
+
+cat >$tmpeditor <<-'EOF'
+#!/usr/bin/env bash
+user_ldif="$1"
+SED=$(which sed)
+$SED -i -e 's/userAccountControl: 512/userAccountControl: 514/' $user_ldif
+EOF
+
+chmod +x $tmpeditor
+
+failed=0
+
+# Create a test user
+subunit_start_test "Create_User"
+output=$(${STpath}/source4/scripting/bin/samba-tool user create sambatool1 --random-password \
+-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD")
+status=$?
+if [ "x$status" = "x0" ]; then
+    subunit_pass_test "Create_User"
+else
+    echo "$output" | subunit_fail_test "Create_User"
+    failed=$((failed + 1))
+fi
+
+# Edit test user
+subunit_start_test "Edit_User"
+output=$(${STpath}/source4/scripting/bin/samba-tool user edit sambatool1 --editor=$tmpeditor \
+-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD")
+status=$?
+if [ "x$status" = "x0" ]; then
+    subunit_pass_test "Edit_User"
+else
+    echo "$output" | subunit_fail_test "Edit_User"
+    failed=$((failed + 1))
+fi
+
+# Delete test user
+subunit_start_test "Delete_User"
+output=$(${STpath}/source4/scripting/bin/samba-tool user delete sambatool1 \
+-H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD")
+status=$?
+if [ "x$status" = "x0" ]; then
+    subunit_pass_test "Delete_User"
+else
+    echo "$output" | subunit_fail_test "Delete_User"
+    failed=$((failed + 1))
+fi
+
+rm -f $tmpeditor
+
+exit $failed
diff --git a/source3/script/tests/test_shadow_copy.sh b/source3/script/tests/test_shadow_copy.sh
index 783e7f32..eba873f 100755
--- a/source3/script/tests/test_shadow_copy.sh
+++ b/source3/script/tests/test_shadow_copy.sh
@@ -221,6 +221,26 @@ test_fetch_snap_file()
         -c "get ${SNAPSHOTS[$snapidx]}/$path $WORKDIR/foo"
 }
 
+# Test fetching a previous version of a file
+test_fetch_snap_dir()
+{
+    local share
+    local path
+    local snapidx
+
+    share=$1
+    path=$2
+    snapidx=$3
+
+    # This first command is not strictly needed, but it causes the snapshots to
+    # appear in a network trace which helps debugging...
+    $SMBCLIENT -U$USERNAME%$PASSWORD "//$SERVER/$share" -I $SERVER_IP \
+        -c "allinfo $path"
+
+    $SMBCLIENT -U$USERNAME%$PASSWORD "//$SERVER/$share" -I $SERVER_IP \
+        -c "ls ${SNAPSHOTS[$snapidx]}/$path/*"
+}
+
 test_shadow_copy_fixed()
 {
     local share     #share to contact
@@ -329,6 +349,9 @@ test_shadow_copy_everywhere()
         test_fetch_snap_file $share "bar/lfoo" 3 || \
         failed=`expr $failed + 1`
 
+    testit "list a previous version directory" \
+        test_fetch_snap_dir $share "bar" 6 || \
+        failed=`expr $failed + 1`
 }
 
 test_shadow_copy_format()
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index c3e540f..6854527 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -831,7 +831,7 @@ static bool api_DosPrintQGetInfo(struct smbd_server_connection *sconn,
 		goto out;
 	}
 
-	status = rpc_pipe_open_interface(conn,
+	status = rpc_pipe_open_interface(mem_ctx,
 					 &ndr_table_spoolss,
 					 conn->session_info,
 					 conn->sconn->remote_address,
@@ -1029,7 +1029,7 @@ static bool api_DosPrintQEnum(struct smbd_server_connection *sconn,
 		return(True);
 	}
 
-	status = rpc_pipe_open_interface(conn,
+	status = rpc_pipe_open_interface(mem_ctx,
 					 &ndr_table_spoolss,
 					 conn->session_info,
 					 conn->sconn->remote_address,
@@ -3144,7 +3144,7 @@ static bool api_RDosPrintJobDel(struct smbd_server_connection *sconn,
 
 	ZERO_STRUCT(handle);
 
-	status = rpc_pipe_open_interface(conn,
+	status = rpc_pipe_open_interface(mem_ctx,
 					 &ndr_table_spoolss,
 					 conn->session_info,
 					 conn->sconn->remote_address,
@@ -3273,7 +3273,7 @@ static bool api_WPrintQueueCtrl(struct smbd_server_connection *sconn,
 
 	ZERO_STRUCT(handle);
 
-	status = rpc_pipe_open_interface(conn,
+	status = rpc_pipe_open_interface(mem_ctx,
 					 &ndr_table_spoolss,
 					 conn->session_info,
 					 conn->sconn->remote_address,
@@ -3456,7 +3456,7 @@ static bool api_PrintJobInfo(struct smbd_server_connection *sconn,
 
 	ZERO_STRUCT(handle);
 
-	status = rpc_pipe_open_interface(conn,
+	status = rpc_pipe_open_interface(mem_ctx,
 					 &ndr_table_spoolss,
 					 conn->session_info,
 					 conn->sconn->remote_address,
@@ -4601,7 +4601,7 @@ static bool api_WPrintJobGetInfo(struct smbd_server_connection *sconn,
 
 	ZERO_STRUCT(handle);
 
-	status = rpc_pipe_open_interface(conn,
+	status = rpc_pipe_open_interface(mem_ctx,
 					 &ndr_table_spoolss,
 					 conn->session_info,
 					 conn->sconn->remote_address,
@@ -4744,7 +4744,7 @@ static bool api_WPrintJobEnumerate(struct smbd_server_connection *sconn,
 
 	ZERO_STRUCT(handle);
 
-	status = rpc_pipe_open_interface(conn,
+	status = rpc_pipe_open_interface(mem_ctx,
 					 &ndr_table_spoolss,
 					 conn->session_info,
 					 conn->sconn->remote_address,
@@ -4945,7 +4945,7 @@ static bool api_WPrintDestGetInfo(struct smbd_server_connection *sconn,
 
 	ZERO_STRUCT(handle);
 
-	status = rpc_pipe_open_interface(conn,
+	status = rpc_pipe_open_interface(mem_ctx,
 					 &ndr_table_spoolss,
 					 conn->session_info,
 					 conn->sconn->remote_address,
@@ -5078,7 +5078,7 @@ static bool api_WPrintDestEnum(struct smbd_server_connection *sconn,
 
 	queuecnt = 0;
 
-	status = rpc_pipe_open_interface(conn,
+	status = rpc_pipe_open_interface(mem_ctx,
 					 &ndr_table_spoolss,
 					 conn->session_info,
 					 conn->sconn->remote_address,
@@ -5390,7 +5390,7 @@ static bool api_RNetSessionEnum(struct smbd_server_connection *sconn,
 		return False;
 	}
 
-	status = rpc_pipe_open_interface(conn,
+	status = rpc_pipe_open_interface(mem_ctx,
 					 &ndr_table_srvsvc,
 					 conn->session_info,
 					 conn->sconn->remote_address,
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 3ccee36..7781a6f 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -550,12 +550,32 @@ static int non_widelink_open(struct connection_struct *conn,
 	char *parent_dir = NULL;
 	struct smb_filename parent_dir_fname = {0};
 	const char *final_component = NULL;
+	bool is_directory = false;
+	bool ok;
 
-	if (!parent_dirname(talloc_tos(),
-			smb_fname->base_name,
-			&parent_dir,
-			&final_component)) {
-		goto out;
+#ifdef O_DIRECTORY
+	if (flags & O_DIRECTORY) {
+		is_directory = true;
+	}
+#endif
+
+	if (is_directory) {
+		parent_dir = talloc_strdup(talloc_tos(), smb_fname->base_name);
+		if (parent_dir == NULL) {
+			saved_errno = errno;
+			goto out;
+		}
+
+		final_component = ".";
+	} else {
+		ok = parent_dirname(talloc_tos(),
+				    smb_fname->base_name,
+				    &parent_dir,
+				    &final_component);
+		if (!ok) {
+			saved_errno = errno;
+			goto out;
+		}


-- 
Samba Shared Repository



More information about the samba-cvs mailing list