s3:libsmb: Plumb cli_smb2_qpathinfo2() inside cli_qpathinfo2().
[bbaumbach/samba-autobuild/.git] / source3 / libsmb / clirap.c
index 6685fbd1d8b8c5a3e306c5bbcf1abea8e7c0af07..41608dd73284d2d8eb268c98a505992516082d7f 100644 (file)
@@ -117,13 +117,17 @@ bool cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation)
        SSVAL(p,0,1);
        p += 2;
        strlcpy(p,user,sizeof(param)-PTR_DIFF(p,param));
-       strupper_m(p);
+       if (!strupper_m(p)) {
+               return false;
+       }
        p += 21;
        p++;
        p += 15;
        p++;
        strlcpy(p, workstation,sizeof(param)-PTR_DIFF(p,param));
-       strupper_m(p);
+       if (!strupper_m(p)) {
+               return false;
+       }
        p += 16;
        SSVAL(p, 0, CLI_BUFFER_SIZE);
        p += 2;
@@ -578,7 +582,7 @@ struct cli_qpathinfo1_state {
 static void cli_qpathinfo1_done(struct tevent_req *subreq);
 
 struct tevent_req *cli_qpathinfo1_send(TALLOC_CTX *mem_ctx,
-                                      struct event_context *ev,
+                                      struct tevent_context *ev,
                                       struct cli_state *cli,
                                       const char *fname)
 {
@@ -667,7 +671,7 @@ NTSTATUS cli_qpathinfo1(struct cli_state *cli,
                        uint16 *mode)
 {
        TALLOC_CTX *frame = talloc_stackframe();
-       struct event_context *ev;
+       struct tevent_context *ev;
        struct tevent_req *req;
        NTSTATUS status = NT_STATUS_NO_MEMORY;
 
@@ -678,7 +682,7 @@ NTSTATUS cli_qpathinfo1(struct cli_state *cli,
                status = NT_STATUS_INVALID_PARAMETER;
                goto fail;
        }
-       ev = event_context_init(frame);
+       ev = samba_tevent_context_init(frame);
        if (ev == NULL) {
                goto fail;
        }
@@ -754,7 +758,7 @@ struct cli_qpathinfo2_state {
 static void cli_qpathinfo2_done(struct tevent_req *subreq);
 
 struct tevent_req *cli_qpathinfo2_send(TALLOC_CTX *mem_ctx,
-                                      struct event_context *ev,
+                                      struct tevent_context *ev,
                                       struct cli_state *cli,
                                       const char *fname)
 {
@@ -841,11 +845,25 @@ NTSTATUS cli_qpathinfo2(struct cli_state *cli, const char *fname,
                        off_t *size, uint16 *mode,
                        SMB_INO_T *ino)
 {
-       TALLOC_CTX *frame = talloc_stackframe();
-       struct event_context *ev;
+       TALLOC_CTX *frame = NULL;
+       struct tevent_context *ev;
        struct tevent_req *req;
        NTSTATUS status = NT_STATUS_NO_MEMORY;
 
+       if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+               return cli_smb2_qpathinfo2(cli,
+                                       fname,
+                                       create_time,
+                                       access_time,
+                                       write_time,
+                                       change_time,
+                                       size,
+                                       mode,
+                                       ino);
+       }
+
+       frame = talloc_stackframe();
+
        if (smbXcli_conn_has_async_calls(cli->conn)) {
                /*
                 * Can't use sync call while an async call is in flight
@@ -853,7 +871,7 @@ NTSTATUS cli_qpathinfo2(struct cli_state *cli, const char *fname,
                status = NT_STATUS_INVALID_PARAMETER;
                goto fail;
        }
-       ev = event_context_init(frame);
+       ev = samba_tevent_context_init(frame);
        if (ev == NULL) {
                goto fail;
        }
@@ -875,11 +893,6 @@ NTSTATUS cli_qpathinfo2(struct cli_state *cli, const char *fname,
  Get the stream info
 ****************************************************************************/
 
-static bool parse_streams_blob(TALLOC_CTX *mem_ctx, const uint8_t *data,
-                              size_t data_len,
-                              unsigned int *pnum_streams,
-                              struct stream_struct **pstreams);
-
 struct cli_qpathinfo_streams_state {
        uint32_t num_data;
        uint8_t *data;
@@ -953,7 +966,7 @@ NTSTATUS cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
                               struct stream_struct **pstreams)
 {
        TALLOC_CTX *frame = talloc_stackframe();
-       struct event_context *ev;
+       struct tevent_context *ev;
        struct tevent_req *req;
        NTSTATUS status = NT_STATUS_NO_MEMORY;
 
@@ -964,7 +977,7 @@ NTSTATUS cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
                status = NT_STATUS_INVALID_PARAMETER;
                goto fail;
        }
-       ev = event_context_init(frame);
+       ev = samba_tevent_context_init(frame);
        if (ev == NULL) {
                goto fail;
        }
@@ -982,7 +995,7 @@ NTSTATUS cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
        return status;
 }
 
-static bool parse_streams_blob(TALLOC_CTX *mem_ctx, const uint8_t *rdata,
+bool parse_streams_blob(TALLOC_CTX *mem_ctx, const uint8_t *rdata,
                               size_t data_len,
                               unsigned int *pnum_streams,
                               struct stream_struct **pstreams)
@@ -1179,7 +1192,7 @@ struct cli_qpathinfo_basic_state {
 static void cli_qpathinfo_basic_done(struct tevent_req *subreq);
 
 struct tevent_req *cli_qpathinfo_basic_send(TALLOC_CTX *mem_ctx,
-                                           struct event_context *ev,
+                                           struct tevent_context *ev,
                                            struct cli_state *cli,
                                            const char *fname)
 {
@@ -1241,7 +1254,7 @@ NTSTATUS cli_qpathinfo_basic(struct cli_state *cli, const char *name,
                             SMB_STRUCT_STAT *sbuf, uint32 *attributes)
 {
        TALLOC_CTX *frame = talloc_stackframe();
-       struct event_context *ev;
+       struct tevent_context *ev;
        struct tevent_req *req;
        NTSTATUS status = NT_STATUS_NO_MEMORY;
 
@@ -1252,7 +1265,7 @@ NTSTATUS cli_qpathinfo_basic(struct cli_state *cli, const char *name,
                status = NT_STATUS_INVALID_PARAMETER;
                goto fail;
        }
-       ev = event_context_init(frame);
+       ev = samba_tevent_context_init(frame);
        if (ev == NULL) {
                goto fail;
        }