summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1997-10-10 02:32:01 +0000
committerAndrew Tridgell <tridge@samba.org>1997-10-10 02:32:01 +0000
commit1448f528b60402170257c1cdf6831cc40b4c86c9 (patch)
tree93c2703c4a4318ea871291b72258069b0591c058
parent53915bd160eda8c099482ddcef74d1d7606e752b (diff)
downloadsamba-1448f528b60402170257c1cdf6831cc40b4c86c9.tar.gz
samba-1448f528b60402170257c1cdf6831cc40b4c86c9.tar.xz
samba-1448f528b60402170257c1cdf6831cc40b4c86c9.zip
fixed the log wrapping bug.
This is a very nasty bug that I think explains quite a few intermittent problems people have been having with Samba. It may be worth checking on other cases where errno can be overwritten by seemingly innocuous things (in this case a DEBUG() line)
-rw-r--r--source/lib/util.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/source/lib/util.c b/source/lib/util.c
index 701f3245541..4e6bfb7054a 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -156,7 +156,7 @@ static void check_log_size(void)
int maxlog;
struct stat st;
- if (debug_count++ < 100) return;
+ if (debug_count++ < 100 || getuid() != 0) return;
maxlog = lp_max_log_size() * 1024;
if (!dbf || maxlog <= 0) return;
@@ -190,7 +190,8 @@ va_dcl
char *format_str;
#endif
va_list ap;
-
+ int old_errno = errno;
+
if (stdout_logging) {
#ifdef __STDC__
va_start(ap, format_str);
@@ -200,6 +201,7 @@ va_dcl
#endif
vfprintf(dbf,format_str,ap);
va_end(ap);
+ errno = old_errno;
return(0);
}
@@ -207,16 +209,17 @@ va_dcl
if (!lp_syslog_only())
#endif
{
- if (!dbf)
- {
- int oldumask = umask(022);
- dbf = fopen(debugf,"w");
- umask(oldumask);
- if (dbf)
- setbuf(dbf,NULL);
- else
- return(0);
- }
+ if (!dbf) {
+ int oldumask = umask(022);
+ dbf = fopen(debugf,"w");
+ umask(oldumask);
+ if (dbf) {
+ setbuf(dbf,NULL);
+ } else {
+ errno = old_errno;
+ return(0);
+ }
+ }
}
#ifdef SYSLOG
@@ -273,6 +276,8 @@ va_dcl
check_log_size();
+ errno = old_errno;
+
return(0);
}