Blob Blame History Raw
From eba6c5376e707d2ca0b9c40ea2387c19e8db1c5c Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 23 Nov 2016 17:55:20 +0100
Subject: [PATCH] configure --with-state-file: specify default state file

Closes #85

Upstream-commit: 72827266598b7c1c58e785069e955dea3523cc59
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
 config.h     |  6 +++---
 configure.ac | 17 +++++++++++++++++
 logrotate.8  |  2 +-
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/config.h b/config.h
index d715c5a..6740878 100644
--- a/config.h
+++ b/config.h
@@ -8,23 +8,23 @@
 #define DEFAULT_MAIL_COMMAND "/usr/bin/mailx"
 #define COMPRESS_COMMAND "/usr/contrib/bin/gzip"
 #define UNCOMPRESS_COMMAND "/usr/contrib/bin/gunzip"
+#ifndef STATEFILE
 #define STATEFILE "/var/run/logrotate.status"
+#endif /* STATEFILE */
 #endif
 
 #ifdef SunOS
 #define DEFAULT_MAIL_COMMAND "/usr/bin/mailx"
-#define STATEFILE "/var/log/logrotate.status"
 #endif
 
 #ifdef __NetBSD__
 #define DEFAULT_MAIL_COMMAND "/usr/bin/mail -s"
 #define COMPRESS_COMMAND "/usr/bin/gzip"
 #define UNCOMPRESS_COMMAND "/usr/bin/gunzip"
-#define STATEFILE "/var/log/logrotate.status"
 #endif
 
 /*
- * Default settings for Linux - leave these last.
+ * Default settings (mainly for Linux) - leave these last.
  */
 #ifndef DEFAULT_MAIL_COMMAND
 #define DEFAULT_MAIL_COMMAND "/bin/mail"
diff --git a/configure.ac b/configure.ac
index a6580f1..63c016c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,6 +40,23 @@ AS_CASE(["$with_acl"],
 AS_IF([test "$ac_cv_lib_acl_acl_get_file" = yes],
   echo "1" > ./test/test.ACL;, echo "0" > ./test/test.ACL;)
 
+AC_ARG_WITH([state-file-path],
+  AC_HELP_STRING([--with-state-file-path=PATH],
+                 [path to state file (/var/lib/logrotate.status by default)]),
+  [
+    case "$withval" in
+      yes|no)
+        AC_MSG_ERROR([--with-state-file-path=PATH requires a path to be specified])
+        ;;
+      *)
+        STATE_FILE_PATH="$withval"
+        ;;
+    esac
+  ],
+  [
+    STATE_FILE_PATH="/var/lib/logrotate.status"
+  ])
+AC_DEFINE_UNQUOTED([STATEFILE], "$STATE_FILE_PATH")
 
 AC_CHECK_FUNCS([strptime qsort fork vfork madvise vsyslog])
 
diff --git a/logrotate.8 b/logrotate.8
index 3f30472..77fdd4b 100644
--- a/logrotate.8
+++ b/logrotate.8
@@ -558,7 +558,7 @@ Log files are rotated if the current year is not the same as the last rotation.
 .SH FILES
 .PD 0
 .TP 27
-\fI/var/lib/logrotate.status\fR
+\fI/var/lib/logrotate/logrotate.status\fR
 Default state file.
 .TP 27
 \fI/etc/logrotate.conf\fR
-- 
2.7.4