Bug 446 - smbclient tar output has new format, foils amanda and ?
Summary: smbclient tar output has new format, foils amanda and ?
Status: CLOSED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: smbclient (show other bugs)
Version: 3.0.0
Hardware: All All
: P3 normal
Target Milestone: none
Assignee: Gerald (Jerry) Carter (dead mail address)
QA Contact:
URL:
Keywords:
Depends on:
Blocks: 807
  Show dependency treegraph
 
Reported: 2003-09-12 08:45 UTC by Orion Poplawski
Modified: 2005-08-24 10:21 UTC (History)
2 users (show)

See Also:


Attachments
2nd rev. of hack (433 bytes, patch)
2003-10-08 10:22 UTC, Brian Poole
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Orion Poplawski 2003-09-12 08:45:30 UTC
Looks like the output format of the DEBUG macro change somewhere from 2.2 to 3.0
so that the final tar status output from smbclient now looks like:

[2003/09/12 02:30:36, 0] client/clitar.c:process_tar(1431)
  tar: dumped 832 files and directories
[2003/09/12 02:30:36, 0] client/clitar.c:process_tar(1432)
  Total bytes written: 199168

The extra "process_tar" debug output foils amanda's processing of smbclient's
output.   While not a big deal, and amanda can be changed to handle it, it seems
like the "debug" part of the output is unnecessary since this is "normal"
program output.

Not sure what samba uses for normal output, but basically I would think this
should be done:

--- samba-3.0.0rc3/source/client/clitar.c.orig  2003-09-12 09:44:16.000000000 -0600
+++ samba-3.0.0rc3/source/client/clitar.c       2003-09-12 09:44:36.000000000 -0600
@@ -1428,8 +1428,8 @@
                        close(tarhandle);
                        SAFE_FREE(tarbuf);

-                       DEBUG(0, ("tar: dumped %d files and directories\n", ntarf));
-                       DEBUG(0, ("Total bytes written: %.0f\n", (double)ttarf));
+                       printf("tar: dumped %d files and directories\n", ntarf);
+                       printf("Total bytes written: %.0f\n", (double)ttarf);
                        break;
        }
Comment 1 Tim Potter 2003-09-14 17:34:25 UTC
This code doesn't seem to have changed from 2.2 -> 3.0.  It's still a DEBUG(0,
...) in both cases.  Are you running smbclient with a different configuration
file?  If you set the 'debug timestamp' option to true you will not get the
extra date and time message for each line in the log file.
Comment 2 Orion Poplawski 2003-09-15 09:06:56 UTC
It's not the clitar.c code that's changed, it's the way that client.c
initializes logging.  

In 2.2:

setup_logging(pname,True);

which set interactive to true, which set stdout_logging to True, which disabled
the printing of the timestamp header by dbghdr.

In 3.0:
        DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
        dbf = x_stderr;
        x_setbuf( x_stderr, NULL );

(perhaps there is other configuration somewhere else?)

I don't want to turn off debug timestamp because I still want them in the
smb.log files, but I don't want them in the output of smbclient, and which were
not present in 2.2.
Comment 3 Brian Poole 2003-10-08 10:18:35 UTC
Note that this is still a problem.. we hit it as well when upgrading our samba
as it is also used by amanda for backups here.

The patch in the comments is a broken hack from what I can tell though. I have
made the following change in our local copy as I think it will be more
functional (to be tested tonight.) This is a hack too mind you, not what I would
suggest for the proper fix. Not familiar with Samba's debugging facilities
enough to propose a proper fix there.

--- clitar.c.orig       Wed Oct  8 12:10:26 2003
+++ clitar.c    Wed Oct  8 12:11:03 2003
@@ -1430,8 +1430,8 @@   
                        close(tarhandle);
                        SAFE_FREE(tarbuf);

-                       DEBUG(0, ("tar: dumped %d files and directories\n", ntarf));
-                       DEBUG(0, ("Total bytes written: %.0f\n", (double)ttarf));
+                       x_fprintf(dbf, "tar: dumped %d files and directories\n",
ntarf);
+                       x_fprintf(dbf, "Total bytes written: %.0f\n",
(double)ttarf);
                        break;
        }

This way it prints to the debug file handle instead of to stdout.. stdout causes
problems if you use tar piped to stdout (like smbclient -Tc -).

Any Samba members care to fix this the proper way? It is a rather annoying
buglet in my opinion.
Comment 4 Brian Poole 2003-10-08 10:22:31 UTC
Created attachment 190 [details]
2nd rev. of hack

Just making an attachment because pasting it in as a comment gave some ugly
results. Changes two DEBUGs -> x_fprintf's so that Amanda can grok the response
properly (otherwise a timestamp is attached, breaing parsing & compatibility.)
Solely a hack to make it work until it is fixed in the tree, not intended as a
proper fix.
Comment 5 Giulio 2003-10-25 03:03:39 UTC
I have similar problems with plain smbclient output.

1. smbclient man page says:
- default log level is 0
- Note that specifying this parameter here will override  the log level
parameter in the smb.conf file.
I have "log level = 1" in smb.conf, but smbclient still logs at log level 0. So
the man page is confusing, because "..override.." implies that smb.conf is taken
as default debuglevel.

2. Due to #1 the line with Domain=[domain] is not printed by smbclient unless I
use -d1 on the command line. This break scripts.

3. If I do -d1, I get the Domain=[domain] message twice, with the ugly timestamp:
...
[2003/10/25 11:59:56, 1] client/client.c:do_connect(2597)
  Domain=[WORKGROUP] OS=[Unix] Server=[Unix]
[2003/10/25 11:59:56, 1] client/client.c:do_connect(2597)
  Domain=[WORKGROUP] OS=[Unix] Server=[Unix]
..

also note that samba version is not printed (it should be Server=[samba.something])

4. message Domain=[domain] is to stderr instead of stdout like previous
versions; I think this is understandable, but still break scripts :(

Comment 6 Giulio 2003-10-25 10:52:03 UTC
I looked at client/client.c, some observations:

1. samba-3.0.0 lacks  
  setup_logging("smbclient",True);
which is present in 2.2.x.
Adding this will:
  a) send all messages to stdout (like it happened in 2.x) instead of stderr 
  b) eliminate the [ timestamp file function ] stuff

2. smbclient manpages of 2.2.x and 3.0.0 say that default log level is 0. This
is not true for 2.2.x where in the code the debug level is forced at 2. This
(samba-3.0.0 doing what is in the docs) may cause problem to scripts. Maybe it
would be better to correct docs to say debug is 2 and keep debug to 2?

3. smbclient man page is confusing. 
".. Note that specifying this parameter here will over-
    ride  the log level parameter in the smb.conf file..."
should be changed into
".. log level setting in smb.conf is completely ignored, always"

4. After editig client.c as in #1 and setting debug to 2, "smbclient -L server"
output is more similar to previous versions, but for the fact that

previous would say:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba.something]

3.0.0:
Doing spnego session setup (blob length=58)
Domain=[WORKGROUP] OS=[Unix] Server=[Unix]
Doing spnego session setup (blob length=58)
Domain=[WORKGROUP] OS=[Unix] Server=[Unix]

Could you, samba team, put the spnego debug to higher level than 2 and eliminate
duplicate?

Thanks
Comment 7 Gerald (Jerry) Carter (dead mail address) 2004-01-15 09:35:01 UTC
I'm wondering if the is just a docs bug.  My output looks
like the following:

 $ ./smbtar -s test98 -p read -x public -v -l 0
 server    is test98
 share     is public\\
 tar args  is
 tape      is tar.out
 blocksize is
 tarmode is now full, system, hidden, noreset, verbose
        19968 ( 1300.0 kb/s) \PrintTest1.doc
            0 (    0.0 kb/s) \testing.txt
            0 (    0.0 kb/s) \picture.bmp
         9510 ( 1326.7 kb/s) \NETLOG.TXT
 tar: dumped 4 files and directories
 Total bytes written: 31232

The key is the 'debug timestamp' option in smb.conf. 
Comment 8 Gerald (Jerry) Carter (dead mail address) 2004-01-15 11:07:23 UTC
ok.  I've fixed the the debug timestamp issue in smbclient output.  
This should take care of Amanda.  I've also fixed the Server=[] bug
( bad length return from pull_usc2() ).  I also set the debug level 
to 1 inclient.c so you get the session setup lines line in 2.2.
And I moved the spnego debug to level 3 as requested.

This will all be in 3.0.2rc1

However the multiple "Domain=[]...." lines will have to stay for now.
The issue is that we are doing 2 session setups (one for share listings
and one for workgroup listings).  This is intentional.  You can work 
around this by restricting smbclient to port 139.

E.g. 

$ bin/smbclient -L windc -U Administrator -p 139
Domain=[BOOKS] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]

        Sharename      Type      Comment
        ---------      ----      -------
        public         Disk
        IPC$           IPC       Remote IPC
        NETLOGON       Disk      Logon server share
        ADMIN$         Disk      Remote Admin
        SYSVOL         Disk      Logon server share
        C$             Disk      Default share
        files          Disk

        Server               Comment
        ---------            -------
        WINDC

        Workgroup            Master
        ---------            -------
        BOOKS                WINDC
        NARNIA               ONTEROSE
        SHELF                MAPLE
Comment 9 Giulio 2004-03-04 11:31:02 UTC
> I also set the debug level 
>to 1 inclient.c so you get the session setup lines line in 2.2.

2.2 had debug by default to 2, not to 1.
client.c:
-       DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
+       DEBUGLEVEL_CLASS[DBGC_ALL] = 2;
Comment 10 Gerald (Jerry) Carter (dead mail address) 2004-03-04 12:06:38 UTC
is the session setup line necessary for amanda?
Comment 11 Orion Poplawski 2004-03-04 12:53:43 UTC
amanda is only looking for the "Total number of bytes" line.
Comment 12 Gerald (Jerry) Carter (dead mail address) 2005-08-24 10:21:14 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.