summaryrefslogtreecommitdiff
path: root/source3/lib
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
commit1ece349db580ff8ca5a90339d20381dcb24f1c4c (patch)
treedebca9283965b62eb1c9aec8de568112257e5b27 /source3/lib
parent805749baab4e79fbdb9897f22b2c801d9dd9efc2 (diff)
downloadsamba-1ece349db580ff8ca5a90339d20381dcb24f1c4c.tar.gz
samba-1ece349db580ff8ca5a90339d20381dcb24f1c4c.tar.bz2
samba-1ece349db580ff8ca5a90339d20381dcb24f1c4c.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) (This used to be commit 1448f528b60402170257c1cdf6831cc40b4c86c9)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 701f324554..4e6bfb7054 100644
--- a/source3/lib/util.c
+++ b/source3/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);
}