smbclient's tar to /dev/null behaves unexpectedly
Kevin Dalley
kevin at kelphead.org
Mon Feb 28 23:59:16 GMT 2005
I recently reported this samba bug to bugzilla:
https://bugzilla.samba.org/show_bug.cgi?id=2398
but I want to add this to the samba-technical list since it is a
request to slightly change the behavior of smbclient.
If I use smbclient to create a tar file at /dev/null, it skips most of
the steps. This behavior is unexpected, and I suggest a change, for
which I have included a patch.
I'm using samba-3.0.10, on a Debian x86 machine, Debian version
3.0.10-1, which includes patches, but nothing relevant to this
problem.
If I type something like this:
smbclient '\\puffin\c$' -U 'amanda%password' -E -d1 -Tca /dev/null
'/Kathy/DATA/2120 WNmod/*'
I receive the following message:
Output is /dev/null, assuming dry_run
source/client/clitar.c:
if (tar_type=='c' && (dry_run || strcmp(argv[Optind], "/dev/null")==0)) {
if (!dry_run) {
DEBUG(0,("Output is /dev/null, assuming dry_run\n"));
dry_run = True;
}
This is unexpected behavior. If a person wants to use a dry run, the
"-n" option is available. The OS will decide what to do when /dev/null is
encountered; smbclient shouldn't know or care whether its output is
thrown away or kept.
By performing a dry_run, smbclient is skipping the list of the files
in the tar file and the actual transfer of data, something which
setting the output device to /dev/null should not do. If the user
wants to throw away the data, that is the user's decision.
To quote from the GNU standards document, which is generally a worthy
document even when the project is not GNU:
Likewise, please don't make the behavior of the program depend on
the type of output device it is used with. Device independence is
an important principle of the system's design
I have included a patch below:
--- working directory: /home/kevin/src/samba-3.0.10/
% diff -u source/client/clitar.c.orig source/client/clitar.c
--- source/client/clitar.c.orig 2005-02-28 13:14:08.000000000 -0800
+++ source/client/clitar.c 2005-02-28 12:07:02.000000000 -0800
@@ -1791,11 +1791,7 @@
}
} else {
- if (tar_type=='c' && (dry_run || strcmp(argv[Optind], "/dev/null")==0)) {
- if (!dry_run) {
- DEBUG(0,("Output is /dev/null, assuming dry_run\n"));
- dry_run = True;
- }
+ if (tar_type=='c' && dry_run) {
tarhandle=-1;
} else if ((tar_type=='x' && (tarhandle = sys_open(argv[Optind], O_RDONLY,
0)) == -1)
|| (tar_type=='c' && (tarhandle=sys_creat(argv[Optind], 0644)) < 0)) {
--
Kevin Dalley
kevin at kelphead.org
More information about the samba-technical
mailing list