Hello
There is nice utility called newsyslog. You just need
to patch it to copy/truncate the log instead of moving it
and squid is happy.
A.K.
--- newsyslog.c.orig Fri Feb 25 10:21:26 2000
+++ newsyslog.c Fri Feb 25 10:30:38 2000
@@ -485,17 +485,21 @@
(void) unlink(log);
} else {
if (noaction)
- printf("mv %s to %s\n",log,file1);
+ printf("cp %s to %s\n",log,file1);
else
- (void) rename(log,file1);
+ (void) copy(log,file1,perm);
+ (void) chown(file1,owner_uid, group_gid);
}
if (noaction)
printf("Start new log...");
else {
- fd = creat(log,perm);
+
+ fd = open(log,O_WRONLY | O_CREAT | O_TRUNC);
if (fd < 0)
err(1, "can't start \'%s\' log", log);
+ if (fchmod(fd, perm))
+ err(1, "can't chmod \'%s\' log file", log);
if (fchown(fd, owner_uid, group_gid))
err(1, "can't chown \'%s\' log file", log);
(void) close(fd);
@@ -504,9 +508,9 @@
err(1, "can't add status message to log \'%s\'", log);
}
if (noaction)
- printf("chmod %o %s...",perm,log);
+ printf("chmod %o %s...",perm,file1);
else
- (void) chmod(log,perm);
+ (void) chmod(file1,perm);
if (noaction)
printf("kill -HUP %d\n",daemon_pid);
else if (daemon_pid < MIN_PID || daemon_pid > MAX_PID)
@@ -736,3 +740,26 @@
{
pclose(pfp);
}
+
+int copy(old,new,perm)
+char* old;
+char* new;
+int perm;
+{
+ int fd,fd_;
+ char c[4096];
+ int bytes;
+ fd = open(new,O_WRONLY | O_TRUNC | O_CREAT);
+ if(fd<0) return -1;
+ if(fchmod(fd,perm)) return -1;
+ fd_ = open(old,O_RDONLY);
+ if(fd_<0) return -1;
+ for(;;) {
+ bytes=read(fd_,c,4096);
+ if(bytes==0) break;
+ write(fd,c,bytes);
+ };
+ close(fd);
+ close(fd_);
+};
+
Received on Fri Feb 25 2000 - 01:40:49 MST
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:51:34 MST