Bug 2398 - smbclient's tar to /dev/null behaves unexpectedly
Summary: smbclient's tar to /dev/null behaves unexpectedly
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: Client Tools (show other bugs)
Version: 3.0.10
Hardware: All Linux
: P3 normal
Target Milestone: none
Assignee: Samba Bugzilla Account
QA Contact: Samba QA Contact
Depends on:
Reported: 2005-02-28 14:36 UTC by Kevin Dalley
Modified: 2005-08-24 10:25 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Dalley 2005-02-28 14:36:28 UTC
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

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


		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 usern
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) {
 		} else if ((tar_type=='x' && (tarhandle = sys_open(argv[Optind], O_RDONLY,
0)) == -1)
 					|| (tar_type=='c' && (tarhandle=sys_creat(argv[Optind], 0644)) < 0)) {
Comment 1 Jeremy Allison 2005-03-07 16:53:23 UTC
Applied, thanks !
Comment 2 Gerald (Jerry) Carter (dead mail address) 2005-08-24 10:25:39 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.