After a discussion with Volker, sdd a backup_intent state to the client struct.
authorJeremy Allison <jra@samba.org>
Thu, 1 Dec 2011 21:24:22 +0000 (13:24 -0800)
committerJeremy Allison <jra@samba.org>
Thu, 1 Dec 2011 21:24:22 +0000 (13:24 -0800)
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.

source3/include/client.h
source3/libsmb/clientgen.c
source3/libsmb/clifile.c
source3/libsmb/clilist.c
source3/libsmb/proto.h

index 0fc9f43e621e8a3b22937d50f3918767a7a38403..18bf26eed344204cdc776e1df3ec1ea3202f4138 100644 (file)
@@ -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 */
index fbce64f200e88c94fbcc5c2188d08d9ab3485c3a..29a26d2f76c5a33b456731e7e4e67a4a0deffd55 100644 (file)
@@ -52,6 +52,17 @@ unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout)
        return old_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
 ****************************************************************************/
index b418049d32b54432da30acd27cb0f21281ef08b4..ec8395626be08f480583c6b040d433858c9a50a7 100644 (file)
@@ -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);
index 5118f9f377c3137ec9c465b407e607974ccb5fee..ce36a4b2e78a01f1858771f85502ca1512852871 100644 (file)
@@ -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,
index e03d721ef25b4652d2a14f099cbccea8a25a4bee..182e8c8e4d25a0b2851dca1c6e9346687a8054ef 100644 (file)
@@ -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);