smbclient output

Andrew Tridgell tridge at
Thu Aug 13 01:52:02 GMT 1998

> > I've asked that question myself.  The prompt is actually output with a
> > call to DEBUG(),
> this is wrong.  all smbclient output (genuine smbclient output) should go
> to stdout, including interactive error mesages.  more comprehensive error
> messages, and general decoding (smb message parsing) should go to DEBUG().
> i fixed a number of these in BRANCH_NTDOM / smbclient, however it was a
> large task and not a high priority, so i didn't cover it comprehensively,
> only as-and=when.

I've moved this to samba-technical.

as far as I can remember smbclient originally used fprintf() to output
messages. I switched it to DEBUG() a long time ago to take advantage
of the debug levels. The idea was that debug level 0 would be used for
critical error messages and level 1 for interactive stuff like the
prompt. When run as a script (for example via /etc/printcap) it would
not display the prompt which kept the output to just the stuff that
should be logged. When run interactively the debug level was set to 1
and the prompt (among other things) was displayed.

Then -E was added to allow the DEBUG() output to be redirected to
stderr. To answer Chris's earlier question, it wasn't till much later
that syslog support was added to Samba, and when it was added noone
considered the implications for smbclient.

All of this has got corrupted beyond recognition over the
years. Everyone who has hacked on smbclient has used their own way of
handling interactive and non-interactive output. Someone even changed
the prompt output to be level 0 (probably when smbclient started
reading smb.conf and the debug level got set to zero by the config

I think that we need a whole new set of DEBUG() style code for
interactive utilities. It should use a debuglevel independent of the
current DEBUGLEVEL so it doesn't get stuffed by smb.conf. There should
perhaps be:

imesg(int level, char *format, ...) : replacing the current DEBUG()
	                              calls. Note that it doesn't need
	                              to be a macro because the
	                              function call is trivial in a
	                              interactive program

imesg_set_level(int ):  set the level that is output. Called _only_
                        from command line processing code.

imesg_set_stderr():     called from command line processing to handle -E

sound ok?

More information about the samba-technical mailing list