]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Permit rotate logs from cachemgr
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 13 Aug 2010 11:54:31 +0000 (23:54 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 13 Aug 2010 11:54:31 +0000 (23:54 +1200)
Given that reconfigure, shutdown and offline already have password-protected
remote actions available it makes sense to permit the less critical rotate
as well.

src/CacheManager.h
src/cache_manager.cc

index 975c96617b6155955ee7e55b51c580a894c6380c..e3651325817610321a2abfa32dc9ad9dfbb492e0 100644 (file)
@@ -125,6 +125,12 @@ protected:
         virtual void run (StoreEntry *sentry);
         ReconfigureAction();
     };
+    class RotateAction : public CacheManagerAction
+    {
+    public:
+        virtual void run (StoreEntry *sentry);
+        RotateAction();
+    };
     class OfflineToggleAction : public CacheManagerAction
     {
     public:
index 23ae897b8bcbb6f9307401b249d1a24ff2c9bc28..807ff10da3343da2a87a9863be14921837d38b56 100644 (file)
@@ -56,6 +56,7 @@ CacheManager::CacheManager()
     registerAction(new OfflineToggleAction);
     registerAction(new ShutdownAction);
     registerAction(new ReconfigureAction);
+    registerAction(new RotateAction);
     registerAction(new MenuAction(this));
 }
 
@@ -372,6 +373,21 @@ CacheManager::ReconfigureAction::run(StoreEntry * sentry)
 /// \ingroup CacheManagerInternal
 CacheManager::ReconfigureAction::ReconfigureAction() : CacheManagerAction("reconfigure","Reconfigure Squid", 1, 1) { }
 
+/// \ingroup CacheManagerInternal
+void
+CacheManager::RotateAction::run(StoreEntry * sentry)
+{
+    debugs(16, DBG_IMPORTANT, "Rotate Logs by Cache Manager command.");
+    storeAppendPrintf(sentry, "Rotating Squid Process Logs ....");
+#ifdef _SQUID_LINUX_THREADS_
+    rotate_logs(SIGQUIT);
+#else
+    rotate_logs(SIGUSR1);
+#endif
+}
+/// \ingroup CacheManagerInternal
+CacheManager::RotateAction::RotateAction() : CacheManagerAction("rotate","Rotate Squid Logs", 1, 1) { }
+
 /// \ingroup CacheManagerInternal
 void
 CacheManager::OfflineToggleAction::run(StoreEntry * sentry)