return (cli->rap_error == 0);
}
-/****************************************************************************
- Send a qpathinfo call.
-****************************************************************************/
-
-struct cli_qpathinfo1_state {
- struct cli_state *cli;
- uint32_t num_data;
- uint8_t *data;
-};
-
-static void cli_qpathinfo1_done(struct tevent_req *subreq);
-
-struct tevent_req *cli_qpathinfo1_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli,
- const char *fname)
-{
- struct tevent_req *req = NULL, *subreq = NULL;
- struct cli_qpathinfo1_state *state = NULL;
-
- req = tevent_req_create(mem_ctx, &state, struct cli_qpathinfo1_state);
- if (req == NULL) {
- return NULL;
- }
- state->cli = cli;
- subreq = cli_qpathinfo_send(state, ev, cli, fname, SMB_INFO_STANDARD,
- 22, CLI_BUFFER_SIZE);
- if (tevent_req_nomem(subreq, req)) {
- return tevent_req_post(req, ev);
- }
- tevent_req_set_callback(subreq, cli_qpathinfo1_done, req);
- return req;
-}
-
-static void cli_qpathinfo1_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(
- subreq, struct tevent_req);
- struct cli_qpathinfo1_state *state = tevent_req_data(
- req, struct cli_qpathinfo1_state);
- NTSTATUS status;
-
- status = cli_qpathinfo_recv(subreq, state, &state->data,
- &state->num_data);
- TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
- return;
- }
- tevent_req_done(req);
-}
-
-NTSTATUS cli_qpathinfo1_recv(struct tevent_req *req,
- time_t *change_time,
- time_t *access_time,
- time_t *write_time,
- off_t *size,
- uint32_t *pattr)
-{
- struct cli_qpathinfo1_state *state = tevent_req_data(
- req, struct cli_qpathinfo1_state);
- NTSTATUS status;
-
- time_t (*date_fn)(const void *buf, int serverzone);
-
- if (tevent_req_is_nterror(req, &status)) {
- return status;
- }
-
- if (state->cli->win95) {
- date_fn = make_unix_date;
- } else {
- date_fn = make_unix_date2;
- }
-
- if (change_time) {
- *change_time = date_fn(state->data+0, smb1cli_conn_server_time_zone(state->cli->conn));
- }
- if (access_time) {
- *access_time = date_fn(state->data+4, smb1cli_conn_server_time_zone(state->cli->conn));
- }
- if (write_time) {
- *write_time = date_fn(state->data+8, smb1cli_conn_server_time_zone(state->cli->conn));
- }
- if (size) {
- *size = IVAL(state->data, 12);
- }
- if (pattr) {
- *pattr = SVAL(state->data, l1_attrFile);
- }
- return NT_STATUS_OK;
-}
-
-NTSTATUS cli_qpathinfo1(struct cli_state *cli,
- const char *fname,
- time_t *change_time,
- time_t *access_time,
- time_t *write_time,
- off_t *size,
- uint32_t *pattr)
-{
- 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_qpathinfo1_send(frame, ev, cli, fname);
- if (req == NULL) {
- goto fail;
- }
- if (!tevent_req_poll_ntstatus(req, ev, &status)) {
- goto fail;
- }
- status = cli_qpathinfo1_recv(req, change_time, access_time,
- write_time, size, pattr);
- fail:
- TALLOC_FREE(frame);
- return status;
-}
-
static void prep_basic_information_buf(
uint8_t buf[40],
struct timespec create_time,
void *state);
bool cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password,
const char *old_password);
-struct tevent_req *cli_qpathinfo1_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli,
- const char *fname);
-NTSTATUS cli_qpathinfo1_recv(struct tevent_req *req,
- time_t *change_time,
- time_t *access_time,
- time_t *write_time,
- off_t *size,
- uint32_t *pattr);
-NTSTATUS cli_qpathinfo1(struct cli_state *cli,
- const char *fname,
- time_t *change_time,
- time_t *access_time,
- time_t *write_time,
- off_t *size,
- uint32_t *pattr);
NTSTATUS cli_setpathinfo_ext(struct cli_state *cli, const char *fname,
struct timespec create_time,
struct timespec access_time,
return True;
}
+NTSTATUS cli_qpathinfo1(struct cli_state *cli,
+ const char *fname,
+ time_t *change_time,
+ time_t *access_time,
+ time_t *write_time,
+ off_t *size,
+ uint32_t *pattr)
+{
+ int timezone = smb1cli_conn_server_time_zone(cli->conn);
+ time_t (*date_fn)(const void *buf, int serverzone) = NULL;
+ uint8_t *rdata = NULL;
+ uint32_t num_rdata;
+ NTSTATUS status;
+
+ status = cli_qpathinfo(talloc_tos(),
+ cli,
+ fname,
+ SMB_INFO_STANDARD,
+ 22,
+ CLI_BUFFER_SIZE,
+ &rdata,
+ &num_rdata);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ if (cli->win95) {
+ date_fn = make_unix_date;
+ } else {
+ date_fn = make_unix_date2;
+ }
+
+ if (change_time) {
+ *change_time = date_fn(rdata + 0, timezone);
+ }
+ if (access_time) {
+ *access_time = date_fn(rdata + 4, timezone);
+ }
+ if (write_time) {
+ *write_time = date_fn(rdata + 8, timezone);
+ }
+ if (size) {
+ *size = PULL_LE_U32(rdata, 12);
+ }
+ if (pattr) {
+ *pattr = PULL_LE_U16(rdata, l1_attrFile);
+ }
+ return NT_STATUS_OK;
+}
static bool wait_lock(struct cli_state *c, int fnum, uint32_t offset, uint32_t len)
{