#include "libsmb/clirap.h"
#include "trans2.h"
#include "../libcli/smb/smbXcli_base.h"
+#include "cli_smb2_fnum.h"
#define PIPE_LANMAN "\\PIPE\\LANMAN"
* talloc
*/
- *rparam = (char *)memdup(my_rparam, num_my_rparam);
+ *rparam = (char *)smb_memdup(my_rparam, num_my_rparam);
if (*rparam == NULL) {
goto fail;
}
*rprcnt = num_my_rparam;
TALLOC_FREE(my_rparam);
- *rdata = (char *)memdup(my_rdata, num_my_rdata);
+ *rdata = (char *)smb_memdup(my_rdata, num_my_rdata);
if (*rdata == NULL) {
goto fail;
}
Call a NetShareEnum - try and browse available connections on a host.
****************************************************************************/
-int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state)
+int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32_t, const char *, void *), void *state)
{
char *rparam = NULL;
char *rdata = NULL;
the comment and a state pointer.
****************************************************************************/
-bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
- void (*fn)(const char *, uint32, const char *, void *),
+bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32_t stype,
+ void (*fn)(const char *, uint32_t, const char *, void *),
void *state)
{
char *rparam = NULL;
char param[1024];
int uLevel = 1;
size_t len;
- uint32 func = RAP_NetServerEnum2;
+ uint32_t func = RAP_NetServerEnum2;
char *last_entry = NULL;
int total_cnt = 0;
int return_cnt = 0;
sizeof(param) - PTR_DIFF(p,param) - 1,
STR_TERMINATE|STR_UPPER);
- if (len == (size_t)-1) {
+ if (len == 0) {
SAFE_FREE(last_entry);
return false;
}
sizeof(param) - PTR_DIFF(p,param) - 1,
STR_TERMINATE);
- if (len == (size_t)-1) {
+ if (len == 0) {
SAFE_FREE(last_entry);
return false;
}
time_t *access_time,
time_t *write_time,
off_t *size,
- uint16 *mode)
+ uint16_t *mode)
{
struct cli_qpathinfo1_state *state = tevent_req_data(
req, struct cli_qpathinfo1_state);
time_t *access_time,
time_t *write_time,
off_t *size,
- uint16 *mode)
+ uint16_t *mode)
{
TALLOC_CTX *frame = talloc_stackframe();
struct tevent_context *ev;
time_t access_time,
time_t write_time,
time_t change_time,
- uint16 mode)
+ uint16_t mode)
{
unsigned int data_len = 0;
char data[40];
put_long_date(p, change_time);
p += 8;
- /* Add attributes */
- SIVAL(p, 0, mode);
+ if (mode == (uint16_t)-1 || mode == FILE_ATTRIBUTE_NORMAL) {
+ /* No change. */
+ mode = 0;
+ } else if (mode == 0) {
+ /* Clear all existing attributes. */
+ mode = FILE_ATTRIBUTE_NORMAL;
+ }
+
+ /* Add attributes */
+ SIVAL(p, 0, mode);
+
p += 4;
/* Add padding */
data_len = PTR_DIFF(p, data);
+ if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+ DATA_BLOB in_data = data_blob_const(data, data_len);
+ /*
+ * Split out SMB2 here as we need to select
+ * the correct info type and level.
+ */
+ return cli_smb2_setpathinfo(cli,
+ fname,
+ 1, /* SMB2_SETINFO_FILE */
+ SMB_FILE_BASIC_INFORMATION - 1000,
+ &in_data);
+ }
+
return cli_setpathinfo(cli, SMB_FILE_BASIC_INFORMATION, fname,
(uint8_t *)data, data_len);
}
struct timespec *access_time,
struct timespec *write_time,
struct timespec *change_time,
- off_t *size, uint16 *mode,
+ off_t *size, uint16_t *mode,
SMB_INO_T *ino)
{
struct cli_qpathinfo2_state *state = tevent_req_data(
struct timespec *access_time,
struct timespec *write_time,
struct timespec *change_time,
- off_t *size, uint16 *mode,
+ off_t *size, uint16_t *mode,
SMB_INO_T *ino)
{
TALLOC_CTX *frame = NULL;
****************************************************************************/
NTSTATUS cli_qfileinfo_basic(struct cli_state *cli, uint16_t fnum,
- uint16 *mode, off_t *size,
+ uint16_t *mode, off_t *size,
struct timespec *create_time,
struct timespec *access_time,
struct timespec *write_time,
}
NTSTATUS cli_qpathinfo_basic_recv(struct tevent_req *req,
- SMB_STRUCT_STAT *sbuf, uint32 *attributes)
+ SMB_STRUCT_STAT *sbuf, uint32_t *attributes)
{
struct cli_qpathinfo_basic_state *state = tevent_req_data(
req, struct cli_qpathinfo_basic_state);
}
NTSTATUS cli_qpathinfo_basic(struct cli_state *cli, const char *name,
- SMB_STRUCT_STAT *sbuf, uint32 *attributes)
+ SMB_STRUCT_STAT *sbuf, uint32_t *attributes)
{
TALLOC_CTX *frame = NULL;
struct tevent_context *ev;
struct timespec *access_time,
struct timespec *write_time,
struct timespec *change_time,
- off_t *size, uint16 *mode,
+ off_t *size, uint16_t *mode,
SMB_INO_T *ino)
{
NTSTATUS status = NT_STATUS_OK;
- SMB_STRUCT_STAT st;
+ SMB_STRUCT_STAT st = { 0 };
uint32_t attr;
uint64_t pos;