Bug 1041 - smbd logging to stdout bug (smbd -FS)
Summary: smbd logging to stdout bug (smbd -FS)
Status: RESOLVED DUPLICATE of bug 1847
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: File Services (show other bugs)
Version: 3.0.2
Hardware: All FreeBSD
: P3 normal
Target Milestone: none
Assignee: Samba Bugzilla Account
QA Contact:
Depends on:
Reported: 2004-02-06 02:43 UTC by Alexandr
Modified: 2006-04-08 22:54 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Alexandr 2004-02-06 02:43:24 UTC
samba3 have built-in (without any patches) ability to run in foreground (smbd -
F) and to write log to stdout (smbd -FS). But realisation of logging to stdout 
is broken: only few first strings of log appears in stdout, all other strings 
of log are disappear.

You can simply check this: run "smbd -FS", connect clients, do some operations 
and watch log output to console. Then run smbd as usually (logging in syslog or 
log files), connect clients, do the same operations. Then compare stdout log 
and usual log. Stdout log is limited by few strings, when usual log is complete.

I investigated this problem since samba v2.2.8. In this version ability to run 
in foreground and logging to stdout was added by patches from Michael Handler 
(www.grendel.net). By the way, these patches was applied for samba3 source 
tree, so in samba3-release abilities to run in foreground and log to stdout are 

For samba3 problem in file smbd/server.c, in call of procedure close_low_fds
(False) - it closing stdout and log disappears. By the way, "False" in calling 
of this procedure means not to close stderr (see lib/util.c). 

I noticed that in smbd/server.c procedure close_low_fds called 2 times, and 
both times with "False" argument. So, if we not closing stderr, maybe direct 
log to stderr will be more reasonable?

I do this by editing lib/debug.c. In fragment:
	if (interactive) {
		stdout_logging = True;
		dbf = x_stdout;
		x_setbuf( x_stdout, NULL );
i replaced x_stdout to x_stderr. Then i run smbd daemon:
exec 2>&1
exec /usr/local/samba/bin/smbd -FS
logging to stdout works great!
Comment 1 Gerald (Jerry) Carter (dead mail address) 2005-11-14 09:27:58 UTC
database cleanup
Comment 2 Gerald (Jerry) Carter (dead mail address) 2006-04-08 22:54:17 UTC

*** This bug has been marked as a duplicate of 1847 ***