The branch, master has been updated
via d512b27563b clitar: use modern DBG macros
via 199f44ff875 smbtar: adopt for new tar verbose option
via d2d5007936b smbclient/tar: add verbose mode
via 9e67b6b9515 smbd: Protect against non-string "close-share"
sharenames
via be0a5ab852a test3: Fix usage check for test_sharesec.sh
via 46565a049ed lib: Avoid an unnecessary include
via 8100b56b553 lib: Remove "msg_ctx" from server_id_watch_send()
via 4546aff887c lib: Use tevent version of timeval_current_ofs()
via 75ddd1d6ab8 nfs4acl: Align integer types
from dc74b437c2e docs-xml: 'mangled names = illegal' is the new default
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit d512b27563b32f7bcb35da21781e87473830c906
Author: Björn Jacke <[email protected]>
Date: Mon Jan 13 16:43:21 2020 +0100
clitar: use modern DBG macros
Signed-off-by: Bjoern Jacke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
Autobuild-User(master): Jeremy Allison <[email protected]>
Autobuild-Date(master): Tue Jan 14 20:42:10 UTC 2020 on sn-devel-184
commit 199f44ff87504b5e323bcccb0b3e7922c328ad38
Author: Björn Jacke <[email protected]>
Date: Tue Jan 7 12:04:49 2020 +0100
smbtar: adopt for new tar verbose option
Signed-off-by: Bjoern Jacke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
commit d2d5007936ba4f48edad61c7613bed07c31da463
Author: Björn Jacke <[email protected]>
Date: Sat Jan 4 21:47:59 2020 +0100
smbclient/tar: add verbose mode
A verbose mode got lost with the introduction of libarchive support.
The verbose mode is optional, default is quiet mode.
The output format is close to the verbose output format of POSIX tar
implementations and should be good parsable.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11642
Signed-off-by: Bjoern Jacke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
commit 9e67b6b9515d1bc456c9f0f4edd0aea430b6d870
Author: Volker Lendecke <[email protected]>
Date: Mon Jan 13 15:23:45 2020 +0100
smbd: Protect against non-string "close-share" sharenames
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
commit be0a5ab852a66a041f0d6c6a96abbe296476b13a
Author: Volker Lendecke <[email protected]>
Date: Tue Jan 14 13:10:05 2020 +0100
test3: Fix usage check for test_sharesec.sh
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
commit 46565a049ed7e3ba0ead9b756960e400142db7b0
Author: Volker Lendecke <[email protected]>
Date: Tue Jan 14 13:05:00 2020 +0100
lib: Avoid an unnecessary include
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
commit 8100b56b55352983c0965f99c6f8ba515e55a929
Author: Volker Lendecke <[email protected]>
Date: Tue Jan 14 13:03:45 2020 +0100
lib: Remove "msg_ctx" from server_id_watch_send()
Not needed
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
commit 4546aff887c3bf9babb663f014d147dc2052a463
Author: Volker Lendecke <[email protected]>
Date: Tue Jan 14 13:02:27 2020 +0100
lib: Use tevent version of timeval_current_ofs()
We have tevent available anyway, use that infrastructure
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
commit 75ddd1d6ab84028a422d4be1c115880fc564c089
Author: Volker Lendecke <[email protected]>
Date: Tue Jan 14 11:21:01 2020 +0100
nfs4acl: Align integer types
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
-----------------------------------------------------------------------
Summary of changes:
docs-xml/manpages/smbclient.1.xml | 9 +-
source3/client/client.c | 4 +-
source3/client/clitar.c | 201 ++++++++++++++++++++--------------
source3/lib/dbwrap/dbwrap_watch.c | 2 +-
source3/lib/server_id_watch.c | 9 +-
source3/lib/server_id_watch.h | 3 -
source3/modules/nfs4acl_xattr_xdr.c | 2 +-
source3/script/smbtar | 1 +
source3/script/tests/test_sharesec.sh | 2 +-
source3/smbd/conn_msg.c | 5 +
10 files changed, 139 insertions(+), 99 deletions(-)
Changeset truncated at 500 lines:
diff --git a/docs-xml/manpages/smbclient.1.xml
b/docs-xml/manpages/smbclient.1.xml
index ab62c12f36e..0f556a874db 100644
--- a/docs-xml/manpages/smbclient.1.xml
+++ b/docs-xml/manpages/smbclient.1.xml
@@ -69,7 +69,7 @@
<arg choice="opt">-R <name resolve order></arg>
<arg choice="opt">-s <smb config file></arg>
<arg choice="opt">-t <per-operation timeout in
seconds></arg>
- <arg choice="opt">-T<c|x>IXFqgbNan</arg>
+ <arg choice="opt">-T<c|x>IXFvgbNan</arg>
<arg choice="opt">-k</arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -413,8 +413,9 @@
files that have the archive bit set. Useful only with
the
<parameter>c</parameter> flag. </para></listitem>
- <listitem><para><parameter>q</parameter> - Quiet. Keeps
tar from printing
- diagnostics as it works. This is the same as tarmode
quiet.
+ <listitem><para><parameter>v</parameter> - Verbose.
Makes tar
+ print out the files being processed. By default tar is
not verbose.
+ This is the same as tarmode verbose.
</para></listitem>
<listitem><para><parameter>r</parameter> - Use wildcard
@@ -1102,7 +1103,7 @@
</varlistentry>
<varlistentry>
- <term>tarmode
<full|inc|reset|noreset|system|nosystem|hidden|nohidden></term>
+ <term>tarmode
<full|inc|reset|noreset|system|nosystem|hidden|nohidden|verbose|noverbose></term>
<listitem><para>Changes tar's behavior with regard to DOS
attributes. There are 4 modes which can be turned on or
off.</para>
diff --git a/source3/client/client.c b/source3/client/client.c
index cca88bd7893..29754806e63 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -5619,7 +5619,7 @@ static struct {
{"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}},
@@ -6416,7 +6416,7 @@ int main(int argc,char *argv[])
.arg = NULL,
.val = 'T',
.descrip = "Command line tar",
- .argDescrip = "<c|x>IXFqgbNan",
+ .argDescrip = "<c|x>IXFvgbNan",
},
{
.longName = "directory",
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index b598bde4ee8..76596067f2d 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -153,6 +153,10 @@ struct tar {
/* archive handle */
struct archive *archive;
+
+ /* counters */
+ uint64_t numdir;
+ uint64_t numfile;
};
/**
@@ -211,8 +215,7 @@ static int make_remote_path(const char *full_path);
static int max_token (const char *str);
static NTSTATUS is_subpath(const char *sub, const char *full,
bool *_subpath_match);
-
-/**
+ /*
* tar_get_ctx - retrieve global tar context handle
*/
struct tar *tar_get_ctx()
@@ -285,10 +288,8 @@ int cmd_tarmode(void)
{"nosystem", &tar_ctx.mode.system, false},
{"hidden", &tar_ctx.mode.hidden, true },
{"nohidden", &tar_ctx.mode.hidden, false},
- {"verbose", &tar_ctx.mode.verbose, true },
- {"noquiet", &tar_ctx.mode.verbose, true },
- {"quiet", &tar_ctx.mode.verbose, false},
- {"noverbose", &tar_ctx.mode.verbose, false},
+ {"verbose", &tar_ctx.mode.verbose, false},
+ {"noverbose", &tar_ctx.mode.verbose, true },
};
ctx = talloc_new(NULL);
@@ -305,15 +306,15 @@ int cmd_tarmode(void)
}
if (i == ARRAY_SIZE(table))
- DBG(0, ("tarmode: unrecognised option %s\n", buf));
+ d_printf("tarmode: unrecognised option %s\n", buf);
}
- DBG(0, ("tarmode is now %s, %s, %s, %s, %s\n",
+ d_printf("tarmode is now %s, %s, %s, %s, %s\n",
tar_ctx.mode.incremental ? "incremental" :
"full",
tar_ctx.mode.system ? "system" :
"nosystem",
tar_ctx.mode.hidden ? "hidden" :
"nohidden",
tar_ctx.mode.reset ? "reset" :
"noreset",
- tar_ctx.mode.verbose ? "verbose" :
"quiet"));
+ tar_ctx.mode.verbose ? "verbose" :
"noverbose");
talloc_free(ctx);
return 0;
@@ -342,7 +343,7 @@ int cmd_tar(void)
ok = next_token_talloc(ctx, &cmd_ptr, &buf, NULL);
if (!ok) {
- DBG(0, ("tar <c|x>[IXFbganN] [options] <tar file> [path
list]\n"));
+ d_printf("tar <c|x>[IXFbgvanN] [options] <tar file> [path
list]\n");
err = 1;
goto out;
}
@@ -360,14 +361,14 @@ int cmd_tar(void)
rc = tar_parse_args(&tar_ctx, flag, val, i);
if (rc != 0) {
- DBG(0, ("parse_args failed\n"));
+ d_printf("parse_args failed\n");
err = 1;
goto out;
}
rc = tar_process(&tar_ctx);
if (rc != 0) {
- DBG(0, ("tar_process failed\n"));
+ d_printf("tar_process failed\n");
err = 1;
goto out;
}
@@ -416,7 +417,7 @@ int tar_parse_args(struct tar* t,
int rc;
if (t == NULL) {
- DBG(0, ("Invalid tar context\n"));
+ DBG_WARNING("Invalid tar context\n");
return 1;
}
@@ -439,14 +440,14 @@ int tar_parse_args(struct tar* t,
/* operation */
case 'c':
if (t->mode.operation != TAR_NO_OPERATION) {
- printf("Tar must be followed by only one of c
or x.\n");
+ d_printf("Tar must be followed by only one of c
or x.\n");
return 1;
}
t->mode.operation = TAR_CREATE;
break;
case 'x':
if (t->mode.operation != TAR_NO_OPERATION) {
- printf("Tar must be followed by only one of c
or x.\n");
+ d_printf("Tar must be followed by only one of c
or x.\n");
return 1;
}
t->mode.operation = TAR_EXTRACT;
@@ -455,21 +456,21 @@ int tar_parse_args(struct tar* t,
/* selection */
case 'I':
if (t->mode.selection != TAR_NO_SELECTION) {
- DBG(0,("Only one of I,X,F must be
specified\n"));
+ d_printf("Only one of I,X,F must be
specified\n");
return 1;
}
t->mode.selection = TAR_INCLUDE;
break;
case 'X':
if (t->mode.selection != TAR_NO_SELECTION) {
- DBG(0,("Only one of I,X,F must be
specified\n"));
+ d_printf("Only one of I,X,F must be
specified\n");
return 1;
}
t->mode.selection = TAR_EXCLUDE;
break;
case 'F':
if (t->mode.selection != TAR_NO_SELECTION) {
- DBG(0,("Only one of I,X,F must be
specified\n"));
+ d_printf("Only one of I,X,F must be
specified\n");
return 1;
}
t->mode.selection = TAR_INCLUDE;
@@ -479,12 +480,12 @@ int tar_parse_args(struct tar* t,
/* blocksize */
case 'b':
if (ival >= valsize) {
- DBG(0, ("Option b must be followed by a
blocksize\n"));
+ d_printf("Option b must be followed by a
blocksize\n");
return 1;
}
if (tar_set_blocksize(t, atoi(val[ival]))) {
- DBG(0, ("Option b must be followed by a valid
blocksize\n"));
+ d_printf("Option b must be followed by a valid
blocksize\n");
return 1;
}
@@ -499,12 +500,12 @@ int tar_parse_args(struct tar* t,
/* newer than */
case 'N':
if (ival >= valsize) {
- DBG(0, ("Option N must be followed by valid
file name\n"));
+ d_printf("Option N must be followed by valid
file name\n");
return 1;
}
if (tar_set_newer_than(t, val[ival])) {
- DBG(0,("Error setting newer-than time\n"));
+ d_printf("Error setting newer-than time\n");
return 1;
}
@@ -517,7 +518,7 @@ int tar_parse_args(struct tar* t,
break;
/* verbose */
- case 'q':
+ case 'v':
t->mode.verbose = true;
break;
@@ -529,16 +530,16 @@ int tar_parse_args(struct tar* t,
/* dry run mode */
case 'n':
if (t->mode.operation != TAR_CREATE) {
- DBG(0, ("n is only meaningful when creating a
tar-file\n"));
+ d_printf("n is only meaningful when creating a
tar-file\n");
return 1;
}
t->mode.dry = true;
- DBG(0, ("dry_run set\n"));
+ d_printf("dry_run set\n");
break;
default:
- DBG(0,("Unknown tar option\n"));
+ d_printf("Unknown tar option\n");
return 1;
}
@@ -551,7 +552,7 @@ int tar_parse_args(struct tar* t,
}
if (valsize - ival < 1) {
- DBG(0, ("No tar file given.\n"));
+ d_printf("No tar file given.\n");
return 1;
}
@@ -575,7 +576,7 @@ int tar_parse_args(struct tar* t,
/* flag F -> read file list */
if (do_read_list) {
if (valsize - ival != 1) {
- DBG(0,("Option F must be followed by exactly one
filename.\n"));
+ d_printf("Option F must be followed by exactly one
filename.\n");
return 1;
}
@@ -611,7 +612,7 @@ int tar_process(struct tar *t)
int rc = 0;
if (t == NULL) {
- DBG(0, ("Invalid tar context\n"));
+ DBG_WARNING("Invalid tar context\n");
return 1;
}
@@ -623,7 +624,7 @@ int tar_process(struct tar *t)
rc = tar_create(t);
break;
default:
- DBG(0, ("Invalid tar state\n"));
+ DBG_WARNING("Invalid tar state\n");
rc = 1;
}
@@ -642,18 +643,23 @@ static int tar_create(struct tar* t)
int err = 0;
NTSTATUS status;
const char *mask;
+ struct timespec tp_start, tp_end;
TALLOC_CTX *ctx = talloc_new(NULL);
if (ctx == NULL) {
return 1;
}
+ clock_gettime_mono(&tp_start);
+
+ t->numfile = 0;
+ t->numdir = 0;
t->archive = archive_write_new();
if (!t->mode.dry) {
const int bsize = t->mode.blocksize * TAR_BLOCK_UNIT;
r = archive_write_set_bytes_per_block(t->archive, bsize);
if (r != ARCHIVE_OK) {
- DBG(0, ("Can't use a block size of %d bytes", bsize));
+ d_printf("Can't use a block size of %d bytes", bsize);
err = 1;
goto out;
}
@@ -665,8 +671,8 @@ static int tar_create(struct tar* t)
*/
r = archive_write_set_format_pax_restricted(t->archive);
if (r != ARCHIVE_OK) {
- DBG(0, ("Can't use pax restricted format: %s\n",
-
archive_error_string(t->archive)));
+ d_printf("Can't use pax restricted format: %s\n",
+
archive_error_string(t->archive));
err = 1;
goto out;
}
@@ -678,8 +684,8 @@ static int tar_create(struct tar* t)
}
if (r != ARCHIVE_OK) {
- DBG(0, ("Can't open %s: %s\n", t->tar_path,
-
archive_error_string(t->archive)));
+ d_printf("Can't open %s: %s\n", t->tar_path,
+
archive_error_string(t->archive));
err = 1;
goto out_close;
}
@@ -713,13 +719,19 @@ static int tar_create(struct tar* t)
}
}
+ clock_gettime_mono(&tp_end);
+ d_printf("tar: dumped %"PRIu64" files and %"PRIu64" directories\n",
+ t->numfile, t->numdir);
+ d_printf("Total bytes written: %"PRIu64" (%.1f MiB/s)\n",
+ t->total_size,
+ t->total_size/timespec_elapsed2(&tp_start, &tp_end)/1024/1024);
+
out_close:
- DBG(0, ("Total bytes received: %" PRIu64 "\n", t->total_size));
if (!t->mode.dry) {
r = archive_write_close(t->archive);
if (r != ARCHIVE_OK) {
- DBG(0, ("Fatal: %s\n",
archive_error_string(t->archive)));
+ d_printf("Fatal: %s\n",
archive_error_string(t->archive));
err = 1;
goto out;
}
@@ -823,8 +835,11 @@ static NTSTATUS get_file_callback(struct cli_state *cli,
{
NTSTATUS status = NT_STATUS_OK;
char *remote_name;
+ char *old_dir = NULL;
+ char *new_dir = NULL;
const char *initial_dir = client_get_cur_dir();
bool skip = false;
+ bool isdir;
int rc;
TALLOC_CTX *ctx = talloc_new(NULL);
if (ctx == NULL) {
@@ -846,7 +861,19 @@ static NTSTATUS get_file_callback(struct cli_state *cli,
goto out;
}
- status = tar_create_skip_path(&tar_ctx, remote_name, finfo, &skip);
+ isdir = finfo->mode & FILE_ATTRIBUTE_DIRECTORY;
+ if (isdir) {
+ old_dir = talloc_strdup(ctx, initial_dir);
+ new_dir = talloc_asprintf(ctx, "%s\\", remote_name);
+ if ((old_dir == NULL) || (new_dir == NULL)) {
+ status = NT_STATUS_NO_MEMORY;
+ goto out;
+ }
+ }
+
+ status = tar_create_skip_path(&tar_ctx,
+ isdir ? new_dir : remote_name,
+ finfo, &skip);
if (!NT_STATUS_IS_OK(status)) {
goto out;
}
@@ -857,18 +884,8 @@ static NTSTATUS get_file_callback(struct cli_state *cli,
goto out;
}
- if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
- char *old_dir;
- char *new_dir;
+ if (isdir) {
char *mask;
-
- old_dir = talloc_strdup(ctx, initial_dir);
- new_dir = talloc_asprintf(ctx, "%s%s\\",
- initial_dir, finfo->name);
- if ((old_dir == NULL) || (new_dir == NULL)) {
- status = NT_STATUS_NO_MEMORY;
- goto out;
- }
mask = talloc_asprintf(ctx, "%s*", new_dir);
if (mask == NULL) {
status = NT_STATUS_NO_MEMORY;
@@ -889,6 +906,7 @@ static NTSTATUS get_file_callback(struct cli_state *cli,
client_set_cur_dir(new_dir);
do_list(mask, TAR_DO_LIST_ATTR, get_file_callback, false, true);
client_set_cur_dir(old_dir);
+ tar_ctx.numdir++;
} else {
rc = tar_get_file(&tar_ctx, remote_name, finfo);
if (rc != 0) {
@@ -922,6 +940,7 @@ static int tar_get_file(struct tar *t,
int err = 0, r;
const bool isdir = finfo->mode & FILE_ATTRIBUTE_DIRECTORY;
TALLOC_CTX *ctx = talloc_new(NULL);
+
if (ctx == NULL) {
return 1;
}
@@ -963,36 +982,50 @@ static int tar_get_file(struct tar *t,
* signed size. Very unlikely problem (>9 exabyte file)
*/
if (finfo->size > INT64_MAX) {
- DBG(0, ("Remote file %s too big\n", full_dos_path));
+ d_printf("Remote file %s too big\n", full_dos_path);
goto out_entry;
}
archive_entry_set_size(entry, (int64_t)finfo->size);
- r = archive_write_header(t->archive, entry);
- if (r != ARCHIVE_OK) {
- DBG(0, ("Fatal: %s\n", archive_error_string(t->archive)));
- err = 1;
- goto out_entry;
- }
-
if (isdir) {
+ /* It's a directory just write a header */
+ r = archive_write_header(t->archive, entry);
+ if (r != ARCHIVE_OK) {
+ d_printf("Fatal: %s\n",
archive_error_string(t->archive));
+ err = 1;
+ }
+ if (t->mode.verbose) {
+ d_printf("a %s\\\n", full_dos_path);
+ }
DBG(5, ("get_file skip dir %s\n", full_dos_path));
goto out_entry;
}
status = cli_open(cli, full_dos_path, O_RDONLY, DENY_NONE, &remote_fd);
if (!NT_STATUS_IS_OK(status)) {
- DBG(0,("%s opening remote file %s\n",
- nt_errstr(status), full_dos_path));
+ d_printf("%s opening remote file %s\n",
+ nt_errstr(status), full_dos_path);
goto out_entry;
}
+ /* don't make tar file entry until after the file is open */
+ r = archive_write_header(t->archive, entry);
+ if (r != ARCHIVE_OK) {
+ d_printf("Fatal: %s\n", archive_error_string(t->archive));
+ err = 1;
+ goto out_entry;
+ }
+
+ if (t->mode.verbose) {
+ d_printf("a %s\n", full_dos_path);
+ }
+
do {
status = cli_read(cli, remote_fd, buf, off, sizeof(buf), &len);
if (!NT_STATUS_IS_OK(status)) {
- DBG(0,("Error reading file %s : %s\n",
- full_dos_path,
nt_errstr(status)));
+ d_printf("Error reading file %s : %s\n",
+ full_dos_path,
nt_errstr(status));
err = 1;
goto out_close;
}
@@ -1001,12 +1034,13 @@ static int tar_get_file(struct tar *t,
r = archive_write_data(t->archive, buf, len);
if (r < 0) {
- DBG(0, ("Fatal: %s\n",
archive_error_string(t->archive)));
+ d_printf("Fatal: %s\n",
archive_error_string(t->archive));
err = 1;
goto out_close;
}
} while (off < finfo->size);
+ t->numfile++;
out_close:
--
Samba Shared Repository