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

Stefan Metzmacher metze at samba.org
Sun Aug 28 20:03:06 UTC 2016


The branch, v4-5-test has been updated
       via  6c6fb45 s3-util: Fix asking for username and password in smbget.
       via  372fb30 s3: vfs: Fix compilation error on Solaris.
       via  3157af9 vfs_shadow_copy: handle non-existant files and wildcards
       via  8f535d5 selftest: test listing directories inside snapshots
       via  bbc351a selftest: check file readability in shadow_copy2 test
       via  44616ab selftest: add content to files created during shadow_copy2 test
       via  9bbc84a s2-selftest: run shadow_copy2 test both in NT1 and SMB3 modes
       via  8328861 s3: libsmb: Add the capability to find a @GMT- path in an SMB2 create and transform to a timewarp token.
       via  a22c296 s3: libsmb: Plumb new SMB2 shadow copy call into cli_shadow_copy_data().
       via  4dba637 s3: libsmb: Add cli_smb2_shadow_copy_data() function that gets shadow copy info over SMB2.
       via  8c0b554 s3: libsmb: Add return args to clistr_is_previous_version_path().
       via  b755e66 s3: libsmb: Correctly align create contexts in a create call.
       via  38baf4b s3: smbclient. Ensure we don't crash by freeing uninitialized *snapshots.
       via  b5bb91a s3: smbclient: In order to get shadow copy data over SMB1 we must call cli_shadow_copy_data() twice.
       via  bab467d s3: libsmb: Do some hardening in the receive processing of cli_shadow_copy_data_recv().
       via  8d7f69d s3: libsmb: Correctly set max_setup_size in FSCTL_GET_SHADOW_COPY_DATA nttrans ioctl.
       via  1d59274 s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_list_trans_send().
       via  8256656 s3: libsmb: Make a comment note that cli_set_ea() needs some internal changes before cli_set_ea_path() can use previous path versions.
       via  48550cc s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_ctemp_send().
       via  4200c31 s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_chkpath_send().
       via  bff4980 s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_setatr_send().
       via  4276ffb s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_getatr_send().
       via  ce5acbf s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_openx_create().
       via  c98a801 s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_nttrans_create_send().
       via  e702d6a s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_ntcreate1_send().
       via  30c97b3 s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_rmdir_send()
       via  028f181 s3: libsmb: s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_mkdir_send().
       via  a271db6 s3: libsmb: s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_unlink_send().
       via  663c35d s3: libsmb: s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_ntrename_internal_send().
       via  fe2f658 s3: libsmb: s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_rename_send().
       via  87a1a1a s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_qpathinfo_send()
       via  f570cda s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_setpathinfo_send().
       via  6f1ae6a s3: libsmb: Add clistr_is_previous_version_path()
       via  c74aa87 s3: libsmb: Add uint16_t addtional_flags2 to cli_smb_req_create().
       via  050673d s3: libsmb: Add uint16_t addtional_flags2 to cli_trans_send().
       via  ac64b26 s3: libsmb: Add uint16_t additional_flags2 arg to cli_smb_send().
       via  cccf74e s3: SMB1: Add missing FLAGS2 definitions from MS-SMB.
       via  598327a s3: vfs: snapper: Fix snapper_gmt_strip_snapshot() function to strip @GMT token identically to shadow_copy2.c:shadow_copy2_strip_snapshot()
       via  b4a05b1 s3: vfs: snapper: Add and use len_before_gmt, calculated as (p-name).
       via  e5baf88 s3: vfs: shadow_copy2: Replace all uses of (p-name) with len_before_gmt.
       via  4b26677 s3: vfs: shadow_copy2. Remove any trailing slash when stripping @GMT-YYYY... from the end of a path.
       via  1901c9e s3: vfs: shadow_copy2: Re-use an existing variable already set to the right value (p - name).
       via  ad835cf smbd: Fix snapshot query on shares with DFS enabled
       via  74fa37a KCC: Fix misnamed variable in DSA object
      from  eb55718 ctdb-tests: Reimplement daemons_stop() using ctdbd_wrapper

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


- Log -----------------------------------------------------------------
commit 6c6fb451e35f9bdd928fd6c605d84bc9ccaab679
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Aug 25 14:24:08 2016 +0200

    s3-util: Fix asking for username and password in smbget.
    
    If the user specified the username in the URI with with:
    
      smb://DOMAIN;user:secret@server/share
    
    the tool should not prompt for the username nor the password.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12175
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    (cherry picked from commit f5401ff3146aabc5fb2dac25e4856c6c3756c8f7)
    
    Autobuild-User(v4-5-test): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(v4-5-test): Sun Aug 28 22:02:12 CEST 2016 on sn-devel-144

commit 372fb30da71fd80a3f7bfb0f3fe3a4f151ceb30d
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 24 10:32:32 2016 -0700

    s3: vfs: Fix compilation error on Solaris.
    
    BUG:https://bugzilla.samba.org/show_bug.cgi?id=12174
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit d37545538ca0274feb18f04ba120ed013ac2321a)

commit 3157af9bfdfa2d5e476f86ff930758b0b0180a98
Author: Uri Simchoni <uri at samba.org>
Date:   Wed Aug 24 14:42:23 2016 +0300

    vfs_shadow_copy: handle non-existant files and wildcards
    
    During path checking, the vfs connectpath_fn is called to
    determine the share's root, relative to the file being
    queried (for example, in snapshot file this may be other
    than the share's "usual" root directory). connectpath_fn
    must be able to answer this question even if the path does
    not exist and its parent does exist. The convention in this
    case is that this refers to a yet-uncreated file under the parent
    and all queries are relative to the parent.
    
    This also serves as a workaround for the case where connectpath_fn
    has to handle wildcards, as with the case of SMB1 trans2 findfirst.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12172
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Aug 25 05:35:29 CEST 2016 on sn-devel-144
    
    (cherry picked from commit f41f439335efb352d03a842c370212a0af77262a)

commit 8f535d5055f95de71437c90c276cab083e611020
Author: Uri Simchoni <uri at samba.org>
Date:   Tue Aug 23 14:29:39 2016 +0300

    selftest: test listing directories inside snapshots
    
    Verify that directories are also listable.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12172
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 22c3982100a1d6bf67979a0659604942ef6f11f0)

commit bbc351a83ca9c5c27c059d3a90824648f413a377
Author: Uri Simchoni <uri at samba.org>
Date:   Tue Aug 23 14:03:30 2016 +0300

    selftest: check file readability in shadow_copy2 test
    
    Add tests which verify that a snapshot file is readable
    if and only if it its metadata can be retrieved. Also
    verify (in most tests) that file is retrieved from the
    correct snapshot.
    
    Together with the existing test for number of previous
    versions we can stat, this test checks that we can read
    those files, and also that we cannot break out of a snapshot
    if wide links are not allowed.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12172
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 495b8177363bf1930f3afb373ad73caac022f353)

commit 44616abeff03d0add2c8a0619a61da217931e054
Author: Uri Simchoni <uri at samba.org>
Date:   Tue Aug 23 11:33:52 2016 +0300

    selftest: add content to files created during shadow_copy2 test
    
    This will allow reading them and verifying we got the right version
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12172
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 523046080dd65607eacb901d58ee3b6e54de865e)

commit 9bbc84ac294815dd995e5552ddfbd3c4b4ef2eeb
Author: Uri Simchoni <uri at samba.org>
Date:   Tue Aug 16 07:19:04 2016 +0300

    s2-selftest: run shadow_copy2 test both in NT1 and SMB3 modes
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12172
    
    Signed-off-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit c695faa7f94feb8c0a02a9e2f0472af20047bf65)

commit 832886164cedf572053d2406a37576f849dd739c
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Aug 19 17:00:25 2016 -0700

    s3: libsmb: Add the capability to find a @GMT- path in an SMB2 create and transform to a timewarp token.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12166
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Mon Aug 22 22:59:22 CEST 2016 on sn-devel-144
    
    (cherry picked from commit 272f5c95cfb3d8035939dada7bd473058c7b6517)

commit a22c296837e4d0b770a7146b1ae82a069ebb3e95
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 16 15:27:55 2016 -0700

    s3: libsmb: Plumb new SMB2 shadow copy call into cli_shadow_copy_data().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12166
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 03bf1f858d1c474f9522cb0f5b264c4f6c2ca5b9)

commit 4dba637ae8d4e41d56cc0ded8742bb16a89f7ce0
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 16 15:26:53 2016 -0700

    s3: libsmb: Add cli_smb2_shadow_copy_data() function that gets shadow copy info over SMB2.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12166
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 0c6329bc152fcf08fcef385d2f7ee829485eb1a6)

commit 8c0b55439c167bf499cb3741cb08b14000167626
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 17:15:01 2016 -0700

    s3: libsmb: Add return args to clistr_is_previous_version_path().
    
    Not yet used - we will use these to construct the SMB2 TWrp blob.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12166
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 14fd6dca4ef33ee85a2f8578f1ad608d6056da1f)

commit b755e66ee54f1d8ffd554b1c170bb663fa2e8883
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Aug 19 16:58:39 2016 -0700

    s3: libsmb: Correctly align create contexts in a create call.
    
    SMB2 shadow copy requests are the first time we've used
    create contexts in anger in this codepath. This took me
    longer than I'd like to admit to find :-).
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12166
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit f8caadfc78a15fa3aefc9ef6249195767c47aa8f)

commit 38baf4b59406ef903b3f015cb2ef893b939b5dcd
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Aug 19 16:57:27 2016 -0700

    s3: smbclient. Ensure we don't crash by freeing uninitialized *snapshots.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit cb687a6af0a498676268874ab25b19a6b0764915)

commit b5bb91aa97e90a939a3501d0eb52df9f7743b7cc
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 14:36:50 2016 -0700

    s3: smbclient: In order to get shadow copy data over SMB1 we must call cli_shadow_copy_data() twice.
    
    Once with 'get_names = false' to get the size, then again with 'get_names = true'
    to get the data or a Windows server fails to return valid info. Samba doesn't have this bug.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    
    Autobuild-User(master): Uri Simchoni <uri at samba.org>
    Autobuild-Date(master): Fri Aug 19 23:59:35 CEST 2016 on sn-devel-144
    
    (cherry picked from commit 57a54af66f414708d5c02f346f08bc4bfd55349d)

commit bab467dc4850e434154d74b584904ae97513e7c4
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 12:06:23 2016 -0700

    s3: libsmb: Do some hardening in the receive processing of cli_shadow_copy_data_recv().
    
    Protect against malicious servers.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 336da637541fba13586af6fc2cb9d143d656e87e)

commit 8d7f69db40d5e12e80234c951ea2f79ebc8210cb
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 14:33:01 2016 -0700

    s3: libsmb: Correctly set max_setup_size in FSCTL_GET_SHADOW_COPY_DATA nttrans ioctl.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit a9fe27e17ce55461946037bb25a432da340095ab)

commit 1d59274f9803520557e7a6ae388fbb5f4e187984
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 14:26:20 2016 -0700

    s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_list_trans_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 0b252d7c6fdd963308fff8938a8be185892afbbe)

commit 82566562b226c91f93fca876b6057033e6295cf9
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 14:20:11 2016 -0700

    s3: libsmb: Make a comment note that cli_set_ea() needs some internal changes before cli_set_ea_path() can use previous path versions.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit e4a261c6c826a2be75bcd9d6af8232f043acc5f1)

commit 48550cc8ad72ec4bca5b5da3fb2951c6b7af83f3
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 14:07:17 2016 -0700

    s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_ctemp_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 97cde5dc92185f188868ddd71287d43ddae30516)

commit 4200c31778f971070728fe82269849b6e23992ce
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 14:05:33 2016 -0700

    s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_chkpath_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit e2d70551e1ba13119d53afaa00f05e70897484f0)

commit bff49802ad6db1ad9e24df6ebd45c6e97ce5d26b
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 14:04:05 2016 -0700

    s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_setatr_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 00551d73063b46d3dd2740951a2a8f1b2e351f79)

commit 4276ffbab4efdece293b8ce78fe333316045a68a
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 14:02:24 2016 -0700

    s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_getatr_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 461000c8812a99a81a9f3fc87f93c1b7c67f42bd)

commit ce5acbf39086ad2fd201419d719a0a3e0a789b26
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 13:59:52 2016 -0700

    s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_openx_create().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 47c1314429cdf516358d5e00ca24c313ddab67b0)

commit c98a801e8f840ffb71447e07d29c6bfdb3beb683
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 13:40:23 2016 -0700

    s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_nttrans_create_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit d7ee917b165da2695433b7b115363223f2bd214f)

commit e702d6af8cbfb2b4e445ba9fab0e1b3c65f8797c
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 13:37:22 2016 -0700

    s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_ntcreate1_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit cd4a60bb1f84891763617f96de148068e0492773)

commit 30c97b308409de0ba92e2d8b1d8bd1c89de9889c
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 13:34:44 2016 -0700

    s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_rmdir_send()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 17d1f19eda2c735fcb10a389c3681ccd385bb9c7)

commit 028f1810357ae957bed2ebf332977d768eff89d8
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 13:33:30 2016 -0700

    s3: libsmb: s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_mkdir_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 3081604734a9531cefa71d0417a6fbfee9a6a8b6)

commit a271db6064d1f0650160c19c5c2c1cb1be20c9be
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 13:32:03 2016 -0700

    s3: libsmb: s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_unlink_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 3242a0b9f0ae0d51110dc6542195af1be91aeece)

commit 663c35ddbebc20ed5aec73c9135f87d36eec95c3
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 13:29:01 2016 -0700

    s3: libsmb: s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_ntrename_internal_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit c2a1905abd5d8756dd4afdd3116d311b1dec1246)

commit fe2f658e4e643fe7f693c9f5ccb2bf5007d60b21
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 13:26:59 2016 -0700

    s3: libsmb: s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_rename_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit ae7047923e756d7ee1d760b7495560c25c71b523)

commit 87a1a1acb6f3c7bf702f61ed6aba3d097c7a0399
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 13:17:49 2016 -0700

    s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_qpathinfo_send()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 21a7bf428bb8ed5b5634b87896bf0aa6c095d7f6)

commit f570cda95a5f2afc1de30dc6782e01832dac45d9
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 13:12:22 2016 -0700

    s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to cli_setpathinfo_send().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 75e4290b6055cf95fc4730c4fa431bcc91eed203)

commit 6f1ae6a3dc08e2226f9e33e817c4ba32c9cc6aea
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 13:06:54 2016 -0700

    s3: libsmb: Add clistr_is_previous_version_path()
    
    Looks for @GMT- token in pathname.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 19696f3494bd944ac9226aeebebb7a00df6f53b4)

commit c74aa8752326b6064e477559f49af78cf0709479
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 13:45:35 2016 -0700

    s3: libsmb: Add uint16_t addtional_flags2 to cli_smb_req_create().
    
    Not yet used.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 79c8b756715d021f12474a12eca1efb596f92a84)

commit 050673dc89fbb6d67b62a31a56b2c79e818bd312
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 12:45:32 2016 -0700

    s3: libsmb: Add uint16_t addtional_flags2 to cli_trans_send().
    
    Not yet used.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 76bbc4c0c338a021e10f3d2de2f6c58b4ee81169)

commit ac64b26f83f5e5bab678fd1ce16e44ffecb0fb4e
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Aug 18 12:20:25 2016 -0700

    s3: libsmb: Add uint16_t additional_flags2 arg to cli_smb_send().
    
    Not yet used.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit a876f915fd2cddc96e6044c0a73c87153445baf6)

commit cccf74e608ff44a7567b3931f4c0b783f8a53666
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 17 14:33:00 2016 -0700

    s3: SMB1: Add missing FLAGS2 definitions from MS-SMB.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    (cherry picked from commit 66650e67698ed2ed2c1e604343d4209e84f58032)

commit 598327abcfe08f7449622657019a8e1fa8cccc34
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 17 10:57:10 2016 -0700

    s3: vfs: snapper: Fix snapper_gmt_strip_snapshot() function to strip @GMT token identically to shadow_copy2.c:shadow_copy2_strip_snapshot()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    
    Autobuild-User(master): David Disseldorp <ddiss at samba.org>
    Autobuild-Date(master): Thu Aug 18 06:43:02 CEST 2016 on sn-devel-144
    
    (cherry picked from commit b21308252eb409bad6089cc0f09fada0229d33e8)

commit b4a05b1f881cfe80570c2848321cebaa9a755558
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 17 10:53:08 2016 -0700

    s3: vfs: snapper: Add and use len_before_gmt, calculated as (p-name).
    
    Make the code closer to the same functionality in shadow_copy2.c:shadow_copy2_strip_snapshot().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    (cherry picked from commit 3e3b9be948d873696a1ab9c0cb859bd8911165f0)

commit e5baf884efeb443575857066c3b5c0d4d14548dd
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 17 10:49:50 2016 -0700

    s3: vfs: shadow_copy2: Replace all uses of (p-name) with len_before_gmt.
    
    p and name don't change, and we've already calculated this length.
    Part of the effort to make the code inside vfs_snapper.c that does
    the same thing more similar (we can't make these functions identical
    due to the 'snapdir' use case).
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    (cherry picked from commit abf18f42dc398f5f17088de87fd0e681fd44ebeb)

commit 4b266772a33653cc79c7dd88d9c6012da3cd62da
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 16 09:43:37 2016 -0700

    s3: vfs: shadow_copy2. Remove any trailing slash when stripping @GMT-YYYY... from the end of a path.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Aug 17 05:25:30 CEST 2016 on sn-devel-144
    
    (cherry picked from commit 639063da8c5077170bfe2dc4d3a69c3219a4f6a1)

commit 1901c9e7da28e96b6668df6f0faceedb675ab443
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Aug 16 09:41:43 2016 -0700

    s3: vfs: shadow_copy2: Re-use an existing variable already set to the right value (p - name).
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    (cherry picked from commit 6245f2c042da55c71086e1d40186b11964ddeba8)

commit ad835cff55d0cdf97c162ccf41cd46e77c6a9911
Author: Christof Schmitt <cs at samba.org>
Date:   Fri Aug 12 14:59:07 2016 -0700

    smbd: Fix snapshot query on shares with DFS enabled
    
    When DFS is enabled (host msdfs = yes and msdfs root = yes), then SMB
    clients send create requests in the format \hostname\service\path.
    Putting the GMT tag as first element breaks the DFS parsing and results
    in OBJECT_NOT_FOUND for snapshotted files.  Fix this by appending the
    GMT tag to the end of the path.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sat Aug 13 05:44:39 CEST 2016 on sn-devel-144
    
    (cherry picked from commit f1b42ec778e08875e076df7fdf67dd69bf9b2757)

commit 74fa37acf0285ca4f54331be84214e31952cd96d
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Fri Aug 12 11:50:07 2016 +1200

    KCC: Fix misnamed variable in DSA object
    
    Found by Garming. Unlikely to affect anyone.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12143
    
    Pair-programmed-with: Garming Sam <garming at catalyst.net.nz>
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Signed-off-by: Garming Sam <garming at catalyst.net.nz>
    
    Autobuild-User(master): Douglas Bagnall <dbagnall at samba.org>
    Autobuild-Date(master): Fri Aug 12 08:20:31 CEST 2016 on sn-devel-144
    
    (cherry picked from commit e7ad8727be6d947f31ca2ca9bfee81b2a34f25a5)

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

Summary of changes:
 libcli/smb/smb2cli_create.c              |   1 +
 libcli/smb/smb_constants.h               |   2 +
 python/samba/kcc/kcc_utils.py            |   2 +-
 source3/client/client.c                  |  16 +-
 source3/include/async_smb.h              |   5 +-
 source3/libsmb/async_smb.c               |   4 +-
 source3/libsmb/cli_smb2_fnum.c           | 274 ++++++++++++++++++++++++++++++-
 source3/libsmb/cli_smb2_fnum.h           |   6 +
 source3/libsmb/cliconnect.c              |  20 +--
 source3/libsmb/clientgen.c               |   2 +-
 source3/libsmb/clifile.c                 | 194 ++++++++++++++++++----
 source3/libsmb/clifsinfo.c               |   7 +-
 source3/libsmb/clilist.c                 |  21 ++-
 source3/libsmb/climessage.c              |   6 +-
 source3/libsmb/clioplock.c               |   2 +-
 source3/libsmb/clireadwrite.c            |   4 +-
 source3/libsmb/clistr.c                  |  43 +++++
 source3/libsmb/clisymlink.c              |   4 +-
 source3/libsmb/clitrans.c                |   3 +-
 source3/libsmb/proto.h                   |   6 +-
 source3/modules/vfs_shadow_copy2.c       |  47 +++++-
 source3/modules/vfs_snapper.c            |  30 +++-
 source3/modules/vfs_solarisacl.c         |   2 +-
 source3/script/tests/test_shadow_copy.sh | 102 +++++++++---
 source3/selftest/tests.py                |   3 +-
 source3/smbd/smb2_create.c               |   6 +-
 source3/utils/smbget.c                   |  26 ++-
 27 files changed, 723 insertions(+), 115 deletions(-)


Changeset truncated at 500 lines:

diff --git a/libcli/smb/smb2cli_create.c b/libcli/smb/smb2cli_create.c
index 0db546c..778b501 100644
--- a/libcli/smb/smb2cli_create.c
+++ b/libcli/smb/smb2cli_create.c
@@ -113,6 +113,7 @@ struct tevent_req *smb2cli_create_send(
 	blobs_offset = ((blobs_offset + 3) & ~3);
 
 	if (blob.length > 0) {
+		blobs_offset = ((blobs_offset + 7) & ~7);
 		SIVAL(fixed, 48, blobs_offset + SMB2_HDR_BODY + 56);
 		SIVAL(fixed, 52, blob.length);
 	}
diff --git a/libcli/smb/smb_constants.h b/libcli/smb/smb_constants.h
index e03e843..2fcb590 100644
--- a/libcli/smb/smb_constants.h
+++ b/libcli/smb/smb_constants.h
@@ -309,8 +309,10 @@ enum csc_policy {
 #define FLAGS2_LONG_PATH_COMPONENTS    0x0001
 #define FLAGS2_EXTENDED_ATTRIBUTES     0x0002
 #define FLAGS2_SMB_SECURITY_SIGNATURES 0x0004
+#define FLAGS2_COMPRESSED              0x0008 /* MS-SMB */
 #define FLAGS2_SMB_SECURITY_SIGNATURES_REQUIRED 0x0010
 #define FLAGS2_IS_LONG_NAME            0x0040
+#define FLAGS2_REPARSE_PATH            0x0400 /* MS-SMB @GMT- path. */
 #define FLAGS2_EXTENDED_SECURITY       0x0800
 #define FLAGS2_DFS_PATHNAMES           0x1000
 #define FLAGS2_READ_PERMIT_EXECUTE     0x2000
diff --git a/python/samba/kcc/kcc_utils.py b/python/samba/kcc/kcc_utils.py
index 190b93f..2c3e322 100644
--- a/python/samba/kcc/kcc_utils.py
+++ b/python/samba/kcc/kcc_utils.py
@@ -564,7 +564,7 @@ class DirectoryServiceAgent(object):
         self.dsa_ivid = None
         self.dsa_is_ro = False
         self.dsa_is_istg = False
-        self.dsa_options = 0
+        self.options = 0
         self.dsa_behavior = 0
         self.default_dnstr = None  # default domain dn string for dsa
 
diff --git a/source3/client/client.c b/source3/client/client.c
index 45dc11c..e7531d3 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1696,7 +1696,7 @@ static int do_allinfo(const char *name)
 	unsigned int num_streams;
 	struct stream_struct *streams;
 	int num_snapshots;
-	char **snapshots;
+	char **snapshots = NULL;
 	unsigned int i;
 	NTSTATUS status;
 
@@ -1782,6 +1782,20 @@ static int do_allinfo(const char *name)
 		 */
 		return 0;
 	}
+	/*
+	 * In order to get shadow copy data over SMB1 we
+	 * must call twice, once with 'get_names = false'
+	 * to get the size, then again with 'get_names = true'
+	 * to get the data or a Windows server fails to return
+	 * valid info. Samba doesn't have this bug. JRA.
+	 */
+
+	status = cli_shadow_copy_data(talloc_tos(), cli, fnum,
+				      false, &snapshots, &num_snapshots);
+	if (!NT_STATUS_IS_OK(status)) {
+		cli_close(cli, fnum);
+		return 0;
+	}
 	status = cli_shadow_copy_data(talloc_tos(), cli, fnum,
 				      true, &snapshots, &num_snapshots);
 	if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/include/async_smb.h b/source3/include/async_smb.h
index 00c2313..3c64d08 100644
--- a/source3/include/async_smb.h
+++ b/source3/include/async_smb.h
@@ -27,12 +27,15 @@ struct tevent_req *cli_smb_req_create(TALLOC_CTX *mem_ctx,
 				      struct cli_state *cli,
 				      uint8_t smb_command,
 				      uint8_t additional_flags,
+				      uint16_t additional_flags2,
 				      uint8_t wct, uint16_t *vwv,
 				      int iov_count,
 				      struct iovec *bytes_iov);
 struct tevent_req *cli_smb_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 				struct cli_state *cli,
-				uint8_t smb_command, uint8_t additional_flags,
+				uint8_t smb_command,
+				uint8_t additional_flags,
+				uint16_t additional_flags2,
 				uint8_t wct, uint16_t *vwv,
 				uint32_t num_bytes,
 				const uint8_t *bytes);
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 8d5c3d4..bcb24a4 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -54,13 +54,13 @@ struct tevent_req *cli_smb_req_create(TALLOC_CTX *mem_ctx,
 				      struct cli_state *cli,
 				      uint8_t smb_command,
 				      uint8_t additional_flags,
+				      uint16_t additional_flags2,
 				      uint8_t wct, uint16_t *vwv,
 				      int iov_count,
 				      struct iovec *bytes_iov)
 {
 	struct cli_smb_req_state *state;
 	uint8_t clear_flags = 0;
-	uint16_t additional_flags2 = 0;
 	uint16_t clear_flags2 = 0;
 
 	state = talloc_zero(mem_ctx, struct cli_smb_req_state);
@@ -101,13 +101,13 @@ struct tevent_req *cli_smb_send(TALLOC_CTX *mem_ctx,
 				struct cli_state *cli,
 				uint8_t smb_command,
 				uint8_t additional_flags,
+				uint16_t additional_flags2,
 				uint8_t wct, uint16_t *vwv,
 				uint32_t num_bytes,
 				const uint8_t *bytes)
 {
 	struct cli_smb_req_state *state;
 	uint8_t clear_flags = 0;
-	uint16_t additional_flags2 = 0;
 	uint16_t clear_flags2 = 0;
 
 	state = talloc_zero(mem_ctx, struct cli_smb_req_state);
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index c5b1434..ac72090 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -39,6 +39,7 @@
 #include "../libcli/security/security.h"
 #include "lib/util_ea.h"
 #include "librpc/gen_ndr/ndr_ioctl.h"
+#include "ntioctl.h"
 
 struct smb2_hnd {
 	uint64_t fid_persistent;
@@ -177,6 +178,10 @@ struct tevent_req *cli_smb2_create_fnum_send(TALLOC_CTX *mem_ctx,
 	struct tevent_req *req, *subreq;
 	struct cli_smb2_create_fnum_state *state;
 	size_t fname_len = 0;
+	const char *startp = NULL;
+	const char *endp = NULL;
+	time_t tstamp = (time_t)0;
+	struct smb2_create_blobs *cblobs = NULL;
 
 	req = tevent_req_create(mem_ctx, &state,
 				struct cli_smb2_create_fnum_state);
@@ -194,14 +199,51 @@ struct tevent_req *cli_smb2_create_fnum_send(TALLOC_CTX *mem_ctx,
 		create_options |= FILE_OPEN_FOR_BACKUP_INTENT;
 	}
 
+	/* Check for @GMT- paths. Remove the @GMT and turn into TWrp if so. */
+	fname_len = strlen(fname);
+	if (clistr_is_previous_version_path(fname, &startp, &endp, &tstamp)) {
+		size_t len_before_gmt = startp - fname;
+		size_t len_after_gmt = fname + fname_len - endp;
+		DATA_BLOB twrp_blob;
+		NTTIME ntt;
+		NTSTATUS status;
+
+		char *new_fname = talloc_array(state, char,
+				len_before_gmt + len_after_gmt + 1);
+
+		if (tevent_req_nomem(new_fname, req)) {
+			return tevent_req_post(req, ev);
+		}
+
+		memcpy(new_fname, fname, len_before_gmt);
+		memcpy(new_fname + len_before_gmt, endp, len_after_gmt + 1);
+		fname = new_fname;
+		fname_len = len_before_gmt + len_after_gmt;
+
+		unix_to_nt_time(&ntt, tstamp);
+		twrp_blob = data_blob_const((const void *)&ntt, 8);
+
+		cblobs = talloc_zero(state, struct smb2_create_blobs);
+		if (tevent_req_nomem(cblobs, req)) {
+			return tevent_req_post(req, ev);
+		}
+
+		status = smb2_create_blob_add(state, cblobs,
+				SMB2_CREATE_TAG_TWRP, twrp_blob);
+		if (!NT_STATUS_IS_OK(status)) {
+			tevent_req_nterror(req, status);
+			return tevent_req_post(req, ev);
+		}
+	}
+
 	/* SMB2 is pickier about pathnames. Ensure it doesn't
 	   start in a '\' */
 	if (*fname == '\\') {
 		fname++;
+		fname_len--;
 	}
 
 	/* Or end in a '\' */
-	fname_len = strlen(fname);
 	if (fname_len > 0 && fname[fname_len-1] == '\\') {
 		char *new_fname = talloc_strdup(state, fname);
 		if (tevent_req_nomem(new_fname, req)) {
@@ -224,7 +266,7 @@ struct tevent_req *cli_smb2_create_fnum_send(TALLOC_CTX *mem_ctx,
 				     share_access,
 				     create_disposition,
 				     create_options,
-				     NULL);
+				     cblobs);
 	if (tevent_req_nomem(subreq, req)) {
 		return tevent_req_post(req, ev);
 	}
@@ -2873,3 +2915,231 @@ NTSTATUS cli_smb2_splice_recv(struct tevent_req *req, off_t *written)
 	tevent_req_received(req);
 	return NT_STATUS_OK;
 }
+
+/***************************************************************
+ SMB2 enum shadow copy data.
+***************************************************************/
+
+struct cli_smb2_shadow_copy_data_fnum_state {
+	struct cli_state *cli;
+	uint16_t fnum;
+	struct smb2_hnd *ph;
+	DATA_BLOB out_input_buffer;
+	DATA_BLOB out_output_buffer;
+};
+
+static void cli_smb2_shadow_copy_data_fnum_done(struct tevent_req *subreq);
+
+static struct tevent_req *cli_smb2_shadow_copy_data_fnum_send(
+					TALLOC_CTX *mem_ctx,
+					struct tevent_context *ev,
+					struct cli_state *cli,
+					uint16_t fnum,
+					bool get_names)
+{
+	struct tevent_req *req, *subreq;
+	struct cli_smb2_close_fnum_state *state;
+	NTSTATUS status;
+
+	req = tevent_req_create(mem_ctx, &state,
+				struct cli_smb2_shadow_copy_data_fnum_state);
+	if (req == NULL) {
+		return NULL;
+	}
+
+	if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
+		tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+		return tevent_req_post(req, ev);
+	}
+
+	state->cli = cli;
+	state->fnum = fnum;
+
+	status = map_fnum_to_smb2_handle(cli, fnum, &state->ph);
+	if (tevent_req_nterror(req, status)) {
+		return tevent_req_post(req, ev);
+	}
+
+	/*
+	 * TODO. Under SMB2 we should send a zero max_output_length
+	 * ioctl to get the required size, then send another ioctl
+	 * to get the data, but the current SMB1 implementation just
+	 * does one roundtrip with a 64K buffer size. Do the same
+	 * for now. JRA.
+	 */
+
+	subreq = smb2cli_ioctl_send(state, ev, state->cli->conn,
+			state->cli->timeout,
+			state->cli->smb2.session,
+			state->cli->smb2.tcon,
+			state->ph->fid_persistent, /* in_fid_persistent */
+			state->ph->fid_volatile, /* in_fid_volatile */
+			FSCTL_GET_SHADOW_COPY_DATA,
+			0, /* in_max_input_length */
+			NULL, /* in_input_buffer */
+			get_names ?
+				CLI_BUFFER_SIZE : 16, /* in_max_output_length */
+			NULL, /* in_output_buffer */
+			SMB2_IOCTL_FLAG_IS_FSCTL);
+
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
+	}
+	tevent_req_set_callback(subreq,
+				cli_smb2_shadow_copy_data_fnum_done,
+				req);
+
+	return req;
+}
+
+static void cli_smb2_shadow_copy_data_fnum_done(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct cli_smb2_shadow_copy_data_fnum_state *state = tevent_req_data(
+		req, struct cli_smb2_shadow_copy_data_fnum_state);
+	NTSTATUS status;
+
+	status = smb2cli_ioctl_recv(subreq, state,
+				&state->out_input_buffer,
+				&state->out_output_buffer);
+	TALLOC_FREE(subreq);
+	if (tevent_req_nterror(req, status)) {
+		return;
+	}
+	tevent_req_done(req);
+}
+
+static NTSTATUS cli_smb2_shadow_copy_data_fnum_recv(struct tevent_req *req,
+				TALLOC_CTX *mem_ctx,
+				bool get_names,
+				char ***pnames,
+				int *pnum_names)
+{
+	struct cli_smb2_shadow_copy_data_fnum_state *state = tevent_req_data(
+		req, struct cli_smb2_shadow_copy_data_fnum_state);
+	char **names = NULL;
+	uint32_t num_names = 0;
+	uint32_t num_names_returned = 0;
+	uint32_t dlength = 0;
+	uint32_t i;
+	uint8_t *endp = NULL;
+	NTSTATUS status;
+
+	if (tevent_req_is_nterror(req, &status)) {
+		return status;
+	}
+
+	if (state->out_output_buffer.length < 16) {
+		return NT_STATUS_INVALID_NETWORK_RESPONSE;
+	}
+
+	num_names = IVAL(state->out_output_buffer.data, 0);
+	num_names_returned = IVAL(state->out_output_buffer.data, 4);
+	dlength = IVAL(state->out_output_buffer.data, 8);
+
+	if (num_names > 0x7FFFFFFF) {
+		return NT_STATUS_INVALID_NETWORK_RESPONSE;
+	}
+
+	if (get_names == false) {
+		*pnum_names = (int)num_names;
+		return NT_STATUS_OK;
+	}
+	if (num_names != num_names_returned) {
+		return NT_STATUS_INVALID_NETWORK_RESPONSE;
+	}
+	if (dlength + 12 < 12) {
+		return NT_STATUS_INVALID_NETWORK_RESPONSE;
+	}
+	/*
+	 * NB. The below is an allowable return if there are
+	 * more snapshots than the buffer size we told the
+	 * server we can receive. We currently don't support
+	 * this.
+	 */
+	if (dlength + 12 > state->out_output_buffer.length) {
+		return NT_STATUS_INVALID_NETWORK_RESPONSE;
+	}
+	if (state->out_output_buffer.length +
+			(2 * sizeof(SHADOW_COPY_LABEL)) <
+				state->out_output_buffer.length) {
+		return NT_STATUS_INVALID_NETWORK_RESPONSE;
+	}
+
+	names = talloc_array(mem_ctx, char *, num_names_returned);
+	if (names == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	endp = state->out_output_buffer.data +
+			state->out_output_buffer.length;
+
+	for (i=0; i<num_names_returned; i++) {
+		bool ret;
+		uint8_t *src;
+		size_t converted_size;
+
+		src = state->out_output_buffer.data + 12 +
+			(i * 2 * sizeof(SHADOW_COPY_LABEL));
+
+		if (src + (2 * sizeof(SHADOW_COPY_LABEL)) > endp) {
+			return NT_STATUS_INVALID_NETWORK_RESPONSE;
+		}
+		ret = convert_string_talloc(
+			names, CH_UTF16LE, CH_UNIX,
+			src, 2 * sizeof(SHADOW_COPY_LABEL),
+			&names[i], &converted_size);
+		if (!ret) {
+			TALLOC_FREE(names);
+			return NT_STATUS_INVALID_NETWORK_RESPONSE;
+		}
+	}
+	*pnum_names = num_names;
+	*pnames = names;
+	return NT_STATUS_OK;
+}
+
+NTSTATUS cli_smb2_shadow_copy_data(TALLOC_CTX *mem_ctx,
+				struct cli_state *cli,
+				uint16_t fnum,
+				bool get_names,
+				char ***pnames,
+				int *pnum_names)
+{
+	TALLOC_CTX *frame = talloc_stackframe();
+	struct tevent_context *ev;
+	struct tevent_req *req;
+	NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+	if (smbXcli_conn_has_async_calls(cli->conn)) {
+		/*
+		 * Can't use sync call while an async call is in flight
+		 */
+		status = NT_STATUS_INVALID_PARAMETER;
+		goto fail;
+	}
+	ev = samba_tevent_context_init(frame);
+	if (ev == NULL) {
+		goto fail;
+	}
+	req = cli_smb2_shadow_copy_data_fnum_send(frame,
+					ev,
+					cli,
+					fnum,
+					get_names);
+	if (req == NULL) {
+		goto fail;
+	}
+	if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+		goto fail;
+	}
+	status = cli_smb2_shadow_copy_data_fnum_recv(req,
+						mem_ctx,
+						get_names,
+						pnames,
+						pnum_names);
+ fail:
+	TALLOC_FREE(frame);
+	return status;
+}
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index ceb5629..0436c68 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -184,4 +184,10 @@ struct tevent_req *cli_smb2_splice_send(TALLOC_CTX *mem_ctx,
 			off_t size, off_t src_offset, off_t dst_offset,
 			int (*splice_cb)(off_t n, void *priv), void *priv);
 NTSTATUS cli_smb2_splice_recv(struct tevent_req *req, off_t *written);
+NTSTATUS cli_smb2_shadow_copy_data(TALLOC_CTX *mem_ctx,
+			struct cli_state *cli,
+			uint16_t fnum,
+			bool get_names,
+			char ***pnames,
+			int *pnum_names);
 #endif /* __SMB2CLI_FNUM_H__ */
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 33759d9..9c8851f 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -204,7 +204,7 @@ static struct tevent_req *cli_session_setup_lanman2_send(
 		return tevent_req_post(req, ev);
 	}
 
-	subreq = cli_smb_send(state, ev, cli, SMBsesssetupX, 0, 10, vwv,
+	subreq = cli_smb_send(state, ev, cli, SMBsesssetupX, 0, 0, 10, vwv,
 			      talloc_get_size(bytes), bytes);
 	if (tevent_req_nomem(subreq, req)) {
 		return tevent_req_post(req, ev);
@@ -386,8 +386,8 @@ struct tevent_req *cli_session_setup_guest_create(TALLOC_CTX *mem_ctx,
 	state->bytes.iov_base = (void *)bytes;
 	state->bytes.iov_len = talloc_get_size(bytes);
 
-	subreq = cli_smb_req_create(state, ev, cli, SMBsesssetupX, 0, 13, vwv,
-				    1, &state->bytes);
+	subreq = cli_smb_req_create(state, ev, cli, SMBsesssetupX, 0, 0, 13,
+			vwv, 1, &state->bytes);
 	if (subreq == NULL) {
 		TALLOC_FREE(req);
 		return NULL;
@@ -569,7 +569,7 @@ static struct tevent_req *cli_session_setup_plain_send(
 		return tevent_req_post(req, ev);
 	}
 
-	subreq = cli_smb_send(state, ev, cli, SMBsesssetupX, 0, 13, vwv,
+	subreq = cli_smb_send(state, ev, cli, SMBsesssetupX, 0, 0, 13, vwv,
 			      talloc_get_size(bytes), bytes);
 	if (tevent_req_nomem(subreq, req)) {
 		return tevent_req_post(req, ev);
@@ -880,7 +880,7 @@ static struct tevent_req *cli_session_setup_nt1_send(
 		return tevent_req_post(req, ev);
 	}
 
-	subreq = cli_smb_send(state, ev, cli, SMBsesssetupX, 0, 13, vwv,
+	subreq = cli_smb_send(state, ev, cli, SMBsesssetupX, 0, 0, 13, vwv,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list