[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu Dec 1 16:24:02 MST 2011


The branch, master has been updated
       via  30d4484 Add the "backup" toggle command to smbclient. In order for this to be really useful we need to change to using NTCreateX opens by default in cli_open() and fall back to old OpenX calls instead of doing it the other way around.
       via  af76d25 After a discussion with Volker, sdd a backup_intent state to the client struct.
      from  3c4af39 s4-ntvfs: added allow_override check based on use of NT ACL

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


- Log -----------------------------------------------------------------
commit 30d4484bf95eecc0e2c9e94d26ae41ee38bbba97
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 1 13:47:12 2011 -0800

    Add the "backup" toggle command to smbclient. In order for this to be
    really useful we need to change to using NTCreateX opens by default in
    cli_open() and fall back to old OpenX calls instead of doing it the
    other way around.
    
    Autobuild-User: Jeremy Allison <jra at samba.org>
    Autobuild-Date: Fri Dec  2 00:23:13 CET 2011 on sn-devel-104

commit af76d2588c9aab9ed0eb71ab216ea55faaa40cf2
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 1 13:24:22 2011 -0800

    After a discussion with Volker, sdd a backup_intent state to the client struct.
    
    This causes the backup_intent flags to be added to findfirst/findnext
    and ntcreate/nttrans_create calls.
    
    cli_set_backup_intent() sets the flag and returns the old value of
    its state.

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

Summary of changes:
 docs-xml/manpages-3/smbclient.1.xml |   11 +++++++++++
 source3/client/client.c             |   14 ++++++++++++++
 source3/include/client.h            |    1 +
 source3/libsmb/clientgen.c          |   11 +++++++++++
 source3/libsmb/clifile.c            |    6 ++++--
 source3/libsmb/clilist.c            |    6 ++++--
 source3/libsmb/proto.h              |    1 +
 7 files changed, 46 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages-3/smbclient.1.xml b/docs-xml/manpages-3/smbclient.1.xml
index fe1e011..c79d9df 100644
--- a/docs-xml/manpages-3/smbclient.1.xml
+++ b/docs-xml/manpages-3/smbclient.1.xml
@@ -559,6 +559,17 @@
 		</varlistentry>
 
 		<varlistentry>
+		<term>backup</term>
+		<listitem><para>Toggle the state of the "backup intent" flag
+		sent to the server on directory listings and file opens. If
+		the "backup intent" flag is true, the server will try and
+		bypass some file system checks if the user has been granted
+		SE_BACKUP or SE_RESTORE privilages. This state is useful when
+		performing a backup or restore operation.
+		</para></listitem>
+		</varlistentry>
+
+		<varlistentry>
 		<term>blocksize <number></term>
 		<listitem><para>Sets the blocksize parameter for a tar operation. The default is 20.
 		Causes tar file to be written out in blocksize*TBLOCK (normally 512 byte) units.
diff --git a/source3/client/client.c b/source3/client/client.c
index 22f861b..47d4470 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -88,6 +88,7 @@ static bool prompt = true;
 static bool recurse = false;
 static bool showacls = false;
 bool lowercase = false;
+static bool backup_intent = false;
 
 static struct sockaddr_storage dest_ss;
 static char dest_ss_str[INET6_ADDRSTRLEN];
@@ -3923,6 +3924,18 @@ static int cmd_archive(void)
 }
 
 /****************************************************************************
+ Toggle the backup_intent state.
+****************************************************************************/
+
+static int cmd_backup(void)
+{
+	backup_intent = !backup_intent;
+	cli_set_backup_intent(cli, backup_intent);
+	DEBUG(2,("backup intent is now %s\n",backup_intent?"on":"off"));
+	return 1;
+}
+
+/****************************************************************************
  Toggle the lowercaseflag.
 ****************************************************************************/
 
@@ -4519,6 +4532,7 @@ static struct {
    {COMPL_NONE,COMPL_NONE}},
   {"altname",cmd_altname,"<file> show alt name",{COMPL_NONE,COMPL_NONE}},
   {"archive",cmd_archive,"<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit",{COMPL_NONE,COMPL_NONE}},
+  {"backup",cmd_backup,"toggle backup intent state",{COMPL_NONE,COMPL_NONE}},  
   {"blocksize",cmd_block,"blocksize <number> (default 20)",{COMPL_NONE,COMPL_NONE}},
   {"cancel",cmd_cancel,"<jobid> cancel a print queue entry",{COMPL_NONE,COMPL_NONE}},
   {"case_sensitive",cmd_setcase,"toggle the case sensitive flag to server",{COMPL_NONE,COMPL_NONE}},
diff --git a/source3/include/client.h b/source3/include/client.h
index 0fc9f43..18bf26e 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -75,6 +75,7 @@ struct cli_state {
 	/* What the client requested. */
 	uint32_t requested_posix_capabilities;
 	bool dfsroot;
+	bool backup_intent;
 
 	/* the session key for this CLI, outside
 	   any per-pipe authenticaion */
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index fbce64f..29a26d2 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -53,6 +53,17 @@ unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout)
 }
 
 /****************************************************************************
+ Set the 'backup_intent' flag.
+****************************************************************************/
+
+bool cli_set_backup_intent(struct cli_state *cli, bool flag)
+{
+	bool old_state = cli->backup_intent;
+	cli->backup_intent = flag;
+	return old_state;
+}
+
+/****************************************************************************
  convenience routine to find if we negotiated ucs2
 ****************************************************************************/
 
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index b418049..ec83956 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -1813,7 +1813,8 @@ struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
 	SIVAL(vwv+13, 1, FileAttributes);
 	SIVAL(vwv+15, 1, ShareAccess);
 	SIVAL(vwv+17, 1, CreateDisposition);
-	SIVAL(vwv+19, 1, CreateOptions);
+	SIVAL(vwv+19, 1, CreateOptions |
+		(cli->backup_intent ? FILE_OPEN_FOR_BACKUP_INTENT : 0));
 	SIVAL(vwv+21, 1, 0x02);	/* ImpersonationLevel */
 	SCVAL(vwv+23, 1, SecurityFlags);
 
@@ -2002,7 +2003,8 @@ struct tevent_req *cli_nttrans_create_send(TALLOC_CTX *mem_ctx,
 	SIVAL(param, 20, FileAttributes);
 	SIVAL(param, 24, ShareAccess);
 	SIVAL(param, 28, CreateDisposition);
-	SIVAL(param, 32, CreateOptions);
+	SIVAL(param, 32, CreateOptions |
+		(cli->backup_intent ? FILE_OPEN_FOR_BACKUP_INTENT : 0));
 	SIVAL(param, 36, secdesc_len);
 	SIVAL(param, 40, 0);	 /* EA length*/
 	SIVAL(param, 44, converted_len);
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index 5118f9f..ce36a4b 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -585,7 +585,8 @@ static struct tevent_req *cli_list_trans_send(TALLOC_CTX *mem_ctx,
 	SSVAL(state->param, 2, state->max_matches);
 	SSVAL(state->param, 4,
 	      FLAG_TRANS2_FIND_REQUIRE_RESUME
-	      |FLAG_TRANS2_FIND_CLOSE_IF_END);
+	      |FLAG_TRANS2_FIND_CLOSE_IF_END
+	      |(cli->backup_intent ? FLAG_TRANS2_FIND_BACKUP_INTENT : 0));
 	SSVAL(state->param, 6, state->info_level);
 	SIVAL(state->param, 8, 0);
 
@@ -760,7 +761,8 @@ static void cli_list_trans_done(struct tevent_req *subreq)
 	 * continue instead. JRA
 	 */
 	SSVAL(param, 10, (FLAG_TRANS2_FIND_REQUIRE_RESUME
-			  |FLAG_TRANS2_FIND_CLOSE_IF_END));
+			  |FLAG_TRANS2_FIND_CLOSE_IF_END
+			  |(state->cli->backup_intent ? FLAG_TRANS2_FIND_BACKUP_INTENT : 0)));
 	if (last_name_raw.length) {
 		state->param = trans2_bytes_push_bytes(state->param,
 						       last_name_raw.data,
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index e03d721..182e8c8 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -155,6 +155,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
 
 int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
 unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
+bool cli_set_backup_intent(struct cli_state *cli, bool flag);
 void cli_setup_packet_buf(struct cli_state *cli, char *buf);
 NTSTATUS cli_set_domain(struct cli_state *cli, const char *domain);
 NTSTATUS cli_set_username(struct cli_state *cli, const char *username);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list