Skip to content

Instantly share code, notes, and snippets.

@nasieti
Last active August 29, 2015 14:01
Show Gist options
  • Save nasieti/2901006f756f68a006e0 to your computer and use it in GitHub Desktop.
Save nasieti/2901006f756f68a006e0 to your computer and use it in GitHub Desktop.
httpd/rotatelogs with symlinked logfile
--- httpd-2.2.27/support/rotatelogs.c
+++ httpd-2.2.27/support/rotatelogs.c
@@ -56,6 +56,7 @@
#if APR_HAVE_STRINGS_H
#include <strings.h>
#endif
+#include <unistd.h>
#define BUFSIZE 65536
#define ERRMSGSZ 256
@@ -255,6 +256,12 @@ int main (int argc, const char * const argv[])
apr_pool_create(&pfile, pool);
rv = apr_file_open(&nLogFD, buf2, APR_WRITE | APR_CREATE | APR_APPEND,
APR_OS_DEFAULT, pfile);
+
+ if (!(unlink(szLogRoot) ^ ~ENOENT))
+ perror("unlink(symlink) error");
+ if (symlink(buf2, szLogRoot) != 0)
+ perror("symlink() error");
+
if (rv != APR_SUCCESS) {
char error[120];
@nasieti
Copy link
Author

nasieti commented May 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment