#include "libsmb/nmblib.h"
#include "include/ntioctl.h"
#include "../libcli/smb/smbXcli_base.h"
+#include "lib/util/time_basic.h"
#ifndef REGISTER
#define REGISTER 0
static int process_tok(char *tok);
static int cmd_help(void);
-#define CREATE_ACCESS_READ READ_CONTROL_ACCESS
-
/* value for unused fid field in trans2 secondary request */
#define FID_UNUSED (0xFFFF)
return false;
}
- if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
+ if (finfo->attr & FILE_ATTRIBUTE_DIRECTORY) {
return true;
}
return false;
}
- if ((archive_level==1 || archive_level==2) && !(finfo->mode & FILE_ATTRIBUTE_ARCHIVE)) {
+ if ((archive_level==1 || archive_level==2) && !(finfo->attr & FILE_ATTRIBUTE_ARCHIVE)) {
DEBUG(3,("archive %s failed\n", finfo->name));
return false;
}
if (!showacls) {
d_printf(" %-30s%7.7s %8.0f %s",
finfo->name,
- attrib_string(talloc_tos(), finfo->mode),
+ attrib_string(talloc_tos(), finfo->attr),
(double)finfo->size,
time_to_asc(t));
dir_total += finfo->size;
}
/* print file meta date header */
d_printf( "FILENAME:%s\n", finfo->name);
- d_printf( "MODE:%s\n", attrib_string(talloc_tos(), finfo->mode));
+ d_printf( "MODE:%s\n", attrib_string(talloc_tos(), finfo->attr));
d_printf( "SIZE:%.0f\n", (double)finfo->size);
d_printf( "MTIME:%s", time_to_asc(t));
- status = cli_ntcreate(cli_state, afname, 0,
- CREATE_ACCESS_READ, 0,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OPEN, 0x0, 0x0, &fnum, NULL);
+ status = cli_ntcreate(
+ cli_state, /* cli */
+ afname, /* fname */
+ 0, /* CreatFlags */
+ READ_CONTROL_ACCESS, /* DesiredAccess */
+ 0, /* FileAttributes */
+ FILE_SHARE_READ|
+ FILE_SHARE_WRITE, /* ShareAccess */
+ FILE_OPEN, /* CreateDisposition */
+ 0x0, /* CreateOptions */
+ 0x0, /* SecurityFlags */
+ &fnum, /* pfid */
+ NULL); /* cr */
if (!NT_STATUS_IS_OK(status)) {
DEBUG( 0, ("display_finfo() Failed to open %s: %s\n",
afname, nt_errstr(status)));
*dir_end = '\0';
}
- if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
+ if (f->attr & FILE_ATTRIBUTE_DIRECTORY) {
if (do_list_dirs && do_this_one(f)) {
status = do_list_fn(cli_state, f, dir);
if (!NT_STATUS_IS_OK(status)) {
return NT_STATUS_UNSUCCESSFUL;
}
- if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
+ if (finfo->attr & FILE_ATTRIBUTE_DIRECTORY) {
if (asprintf(&quest,
"Get directory %s? ",finfo->name) < 0) {
return NT_STATUS_NO_MEMORY;
}
SAFE_FREE(quest);
- if (!(finfo->mode & FILE_ATTRIBUTE_DIRECTORY)) {
+ if (!(finfo->attr & FILE_ATTRIBUTE_DIRECTORY)) {
rname = talloc_asprintf(ctx,
"%s%s",
client_get_cur_dir(),
return false;
}
- tmp = unix_timespec_to_nt_time(b_time);
+ tmp = full_timespec_to_nt_time(&b_time);
d_printf("create_time: %s\n", nt_time_string(talloc_tos(), tmp));
- tmp = unix_timespec_to_nt_time(a_time);
+ tmp = full_timespec_to_nt_time(&a_time);
d_printf("access_time: %s\n", nt_time_string(talloc_tos(), tmp));
- tmp = unix_timespec_to_nt_time(m_time);
+ tmp = full_timespec_to_nt_time(&m_time);
d_printf("write_time: %s\n", nt_time_string(talloc_tos(), tmp));
- tmp = unix_timespec_to_nt_time(c_time);
+ tmp = full_timespec_to_nt_time(&c_time);
d_printf("change_time: %s\n", nt_time_string(talloc_tos(), tmp));
d_printf("attributes: %s (%x)\n", attr_str(talloc_tos(), mode), mode);
return NT_STATUS_NO_MEMORY;
}
- if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
+ if (finfo->attr & FILE_ATTRIBUTE_DIRECTORY) {
TALLOC_FREE(mask);
return NT_STATUS_OK;
}
return NT_STATUS_NO_MEMORY;
}
- if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
+ if (finfo->attr & FILE_ATTRIBUTE_DIRECTORY) {
dt->isdir = true;
}
}
status = cli_posix_stat(targetcli, targetname, &sbuf);
- if (!NT_STATUS_IS_OK(cli_posix_stat(targetcli, targetname, &sbuf))) {
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("%s getfacl doing a stat on file %s\n",
nt_errstr(status), src);
return 1;
return true;
}
- if (lp_client_min_protocol() > PROTOCOL_NT1) {
- return false;
- }
-
if (smbXcli_conn_protocol(cli->conn) > PROTOCOL_NT1) {
return false;
}
return 0;
}
-/**
- * set_remote_times - set times of a remote file
- * @filename: path to the file name
- * @create_time: New create time
- * @access_time: New access time
- * @write_time: New write time
- * @change_time: New metadata change time
- *
- * Update the file times with the ones provided.
- */
-static int set_remote_times(const char *filename, time_t create_time,
- time_t access_time, time_t write_time,
- time_t change_time)
-{
- extern struct cli_state *cli;
- NTSTATUS status;
-
- status = cli_setpathinfo_basic(cli, filename, create_time,
- access_time, write_time,
- change_time, -1);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("cli_setpathinfo_basic failed: %s\n",
- nt_errstr(status));
- return 1;
- }
-
- return 0;
-}
-
/**
* cmd_utimes - interactive command to set the four times
*
*/
static int cmd_utimes(void)
{
- const extern char *cmd_ptr;
char *buf;
char *fname = NULL;
- time_t times[4] = {0, 0, 0, 0};
+ struct timespec times[4] = {{0}};
+ struct timeval_buf tbuf[4];
int time_count = 0;
int err = 0;
bool ok;
TALLOC_CTX *ctx = talloc_new(NULL);
+ NTSTATUS status;
+
if (ctx == NULL) {
return 1;
}
time_count < 4) {
const char *s = buf;
struct tm tm = {0,};
+ time_t t;
char *ret;
if (strlen(s) == 2 && strcmp(s, "-1") == 0) {
- times[time_count] = 0;
+ times[time_count] = make_omit_timespec();
time_count++;
continue;
- } else {
- ret = strptime(s, "%y:%m:%d-%H:%M:%S", &tm);
+ }
+
+ ret = strptime(s, "%y:%m:%d-%H:%M:%S", &tm);
+
+ if (ret == NULL) {
+ ret = strptime(s, "%Y:%m:%d-%H:%M:%S", &tm);
}
/* We could not match all the chars, so print error */
d_printf("Invalid date format: %s\n", s);
d_printf("utimes <filename> <create-time> "
"<access-time> <write-time> <change-time>\n");
- d_printf("Dates should be in YY:MM:DD-HH:MM:SS format "
- "or -1 for no change\n");
+ d_printf("Dates should be in [YY]YY:MM:DD-HH:MM:SS "
+ "format or -1 for no change\n");
err = 1;
goto out;
}
/* Convert tm to a time_t */
- times[time_count] = mktime(&tm);
+ t = mktime(&tm);
+ times[time_count] = (struct timespec){.tv_sec = t};
time_count++;
}
}
DEBUG(10, ("times\nCreate: %sAccess: %s Write: %sChange: %s\n",
- talloc_strdup(ctx, ctime(×[0])),
- talloc_strdup(ctx, ctime(×[1])),
- talloc_strdup(ctx, ctime(×[2])),
- talloc_strdup(ctx, ctime(×[3]))));
+ timespec_string_buf(×[0], false, &tbuf[0]),
+ timespec_string_buf(×[1], false, &tbuf[1]),
+ timespec_string_buf(×[2], false, &tbuf[2]),
+ timespec_string_buf(×[3], false, &tbuf[3])));
- set_remote_times(fname, times[0], times[1], times[2], times[3]);
+ status = cli_setpathinfo_ext(
+ cli, fname, times[0], times[1], times[2], times[3], -1);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("cli_setpathinfo_ext failed: %s\n",
+ nt_errstr(status));
+ err = 1;
+ goto out;
+ }
out:
talloc_free(ctx);
return err;
*/
int cmd_setmode(void)
{
- const extern char *cmd_ptr;
char *buf;
char *fname = NULL;
uint16_t attr[2] = {0};
{"scopy",cmd_scopy,"<src> <dest> server-side copy file",{COMPL_REMOTE,COMPL_REMOTE}},
{"stat",cmd_stat,"<file name> Do a UNIX extensions stat call on a file",{COMPL_REMOTE,COMPL_NONE}},
{"symlink",cmd_symlink,"<oldname> <newname> create a UNIX symlink",{COMPL_REMOTE,COMPL_REMOTE}},
- {"tar",cmd_tar,"tar <c|x>[IXFqbgNan] current directory to/from <file name>",{COMPL_NONE,COMPL_NONE}},
+ {"tar",cmd_tar,"tar <c|x>[IXFvbgNan] current directory to/from <file name>",{COMPL_NONE,COMPL_NONE}},
{"tarmode",cmd_tarmode,"<full|inc|reset|noreset> tar's behaviour towards archive bits",{COMPL_NONE,COMPL_NONE}},
{"timeout",cmd_timeout,"timeout <number> - set the per-operation timeout in seconds (default 20)",{COMPL_NONE,COMPL_NONE}},
{"translate",cmd_translate,"toggle text translation for printing",{COMPL_NONE,COMPL_NONE}},
NTSTATUS status;
status = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : desthost,
+ desthost,
service, popt_get_cmdline_auth_info(),
smb_encrypt,
- max_protocol, port, name_type,
+ max_protocol,
+ have_ip ? &dest_ss : NULL, port,
+ name_type,
&cli);
if (!NT_STATUS_IS_OK(status)) {
return 1;
return NT_STATUS_OK;
}
- if ((info->dirmask[0] == 0) && !(f->mode & FILE_ATTRIBUTE_DIRECTORY))
+ if ((info->dirmask[0] == 0) && !(f->attr & FILE_ATTRIBUTE_DIRECTORY))
info->matches[info->count] = SMB_STRDUP(f->name);
else {
TALLOC_CTX *ctx = talloc_stackframe();
TALLOC_FREE(ctx);
return NT_STATUS_NO_MEMORY;
}
- if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
+ if (f->attr & FILE_ATTRIBUTE_DIRECTORY) {
tmp = talloc_asprintf_append(tmp, "%s",
CLI_DIRSEP_STR);
}
if (info->matches[info->count] == NULL) {
return NT_STATUS_OK;
}
- if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
+ if (f->attr & FILE_ATTRIBUTE_DIRECTORY) {
smb_readline_ca_char(0);
}
if (info->count == 1) {
NTSTATUS status;
status = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : desthost,
+ desthost,
service, popt_get_cmdline_auth_info(),
- smb_encrypt, max_protocol, port,
+ smb_encrypt, max_protocol,
+ have_ip ? &dest_ss : NULL, port,
name_type, &cli);
if (!NT_STATUS_IS_OK(status)) {
return 1;
NTSTATUS status;
status = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : query_host,
+ query_host,
"IPC$", popt_get_cmdline_auth_info(),
- smb_encrypt, max_protocol, port,
+ smb_encrypt, max_protocol,
+ have_ip ? &dest_ss : NULL, port,
name_type, &cli);
if (!NT_STATUS_IS_OK(status)) {
return 1;
cli_shutdown(cli);
d_printf("Reconnecting with SMB1 for workgroup listing.\n");
status = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : query_host,
+ query_host,
"IPC$", popt_get_cmdline_auth_info(),
smb_encrypt, max_proto,
- NBT_SMB_PORT, name_type, &cli);
+ have_ip ? &dest_ss : NULL, NBT_SMB_PORT,
+ name_type, &cli);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Unable to connect with SMB1 "
"-- no workgroup available\n");
NTSTATUS status;
status = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : desthost,
+ desthost,
service, popt_get_cmdline_auth_info(),
smb_encrypt, max_protocol,
- port, name_type, &cli);
+ have_ip ? &dest_ss : NULL, port,
+ name_type, &cli);
if (!NT_STATUS_IS_OK(status)) {
ret = 1;
goto out;
.arg = NULL,
.val = 'T',
.descrip = "Command line tar",
- .argDescrip = "<c|x>IXFqgbNan",
+ .argDescrip = "<c|x>IXFvgbNan",
},
{
.longName = "directory",
while ((opt = poptGetNextOpt(pc)) != -1) {
- /* if the tar option has been called previouslt, now we need to eat out the leftovers */
+ /*
+ * if the tar option has been called previously, now
+ * we need to eat out the leftovers
+ */
/* I see no other way to keep things sane --SSS */
if (tar_opt == true) {
while (poptPeekArg(pc)) {