From ee82937c98da4e6db0dea4f70643b516cee24d5e Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Mon, 10 Sep 2012 11:44:06 +0200 Subject: [PATCH] renamed cachemgr_passwd to CacheMgrPasswd and moved to own header. --- src/CacheManager.h | 3 ++- src/CacheMgrPasswd.cc | 36 +++++++++++++++++++++++++++++++++ src/CacheMgrPasswd.h | 47 +++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 14 +++++++++++++ src/SquidConfig.h | 7 ++++--- src/cache_cf.cc | 17 ++++++++-------- src/cache_manager.cc | 5 +++-- src/structs.h | 11 +--------- 8 files changed, 116 insertions(+), 24 deletions(-) create mode 100644 src/CacheMgrPasswd.cc create mode 100644 src/CacheMgrPasswd.h diff --git a/src/CacheManager.h b/src/CacheManager.h index 7a1dc2d75f..a5ea87d130 100644 --- a/src/CacheManager.h +++ b/src/CacheManager.h @@ -48,6 +48,7 @@ */ class HttpRequest; +class CacheMgrPasswd; /** \ingroup CacheManagerAPI * a CacheManager - the menu system for interacting with squid. @@ -83,7 +84,7 @@ protected: Mgr::CommandPointer ParseUrl(const char *url); void ParseHeaders(const HttpRequest * request, Mgr::ActionParams ¶ms); int CheckPassword(const Mgr::Command &cmd); - char *PasswdGet(cachemgr_passwd *, const char *); + char *PasswdGet(CacheMgrPasswd *, const char *); void registerProfile(const Mgr::ActionProfilePointer &profile); diff --git a/src/CacheMgrPasswd.cc b/src/CacheMgrPasswd.cc new file mode 100644 index 0000000000..7c6dc78390 --- /dev/null +++ b/src/CacheMgrPasswd.cc @@ -0,0 +1,36 @@ +/* + * DEBUG: section + * AUTHOR: + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#include "squid.h" +#include "CacheMgrPasswd.h" + + diff --git a/src/CacheMgrPasswd.h b/src/CacheMgrPasswd.h new file mode 100644 index 0000000000..f48edceeba --- /dev/null +++ b/src/CacheMgrPasswd.h @@ -0,0 +1,47 @@ +#ifndef SQUID_CACHEMGRPASSWD_H_ +#define SQUID_CACHEMGRPASSWD_H_ +/* + * DEBUG: section + * AUTHOR: + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +class wordlist; + +//TODO: this class is misnamed and C-ish. Split into CacheMgrPasswd and +// CacheMgrPasswdList (std::list-derived) +class CacheMgrPasswd { +public: + char *passwd; + wordlist *actions; + CacheMgrPasswd *next; +}; + + +#endif /* SQUID_CACHEMGRPASSWD_H_ */ diff --git a/src/Makefile.am b/src/Makefile.am index bd3937f6e0..1510f7e379 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -272,6 +272,8 @@ squid_SOURCES = \ YesNoNone.h \ YesNoNone.cc \ RefreshPattern.h \ + CacheMgrPasswd.h \ + CacheMgrPasswd.cc \ cache_cf.cc \ CacheDigest.h \ CacheDigest.cc \ @@ -1383,6 +1385,8 @@ tests_testCacheManager_SOURCES = \ YesNoNone.h \ YesNoNone.cc \ RefreshPattern.h \ + CacheMgrPasswd.h \ + CacheMgrPasswd.cc \ cache_cf.cc \ CacheDigest.h \ CacheDigest.cc \ @@ -1774,6 +1778,8 @@ tests_testEvent_SOURCES = \ YesNoNone.h \ YesNoNone.cc \ RefreshPattern.h \ + CacheMgrPasswd.h \ + CacheMgrPasswd.cc \ cache_cf.cc \ cache_manager.cc \ carp.h \ @@ -2012,6 +2018,8 @@ tests_testEventLoop_SOURCES = \ YesNoNone.h \ YesNoNone.cc \ RefreshPattern.h \ + CacheMgrPasswd.h \ + CacheMgrPasswd.cc \ cache_cf.cc \ carp.h \ carp.cc \ @@ -2245,6 +2253,8 @@ tests_test_http_range_SOURCES = \ YesNoNone.h \ YesNoNone.cc \ RefreshPattern.h \ + CacheMgrPasswd.h \ + CacheMgrPasswd.cc \ cache_cf.cc \ cache_manager.cc \ CacheDigest.h \ @@ -2534,6 +2544,8 @@ tests_testHttpRequest_SOURCES = \ YesNoNone.h \ YesNoNone.cc \ RefreshPattern.h \ + CacheMgrPasswd.h \ + CacheMgrPasswd.cc \ cache_cf.cc \ debug.cc \ CacheDigest.h \ @@ -3593,6 +3605,8 @@ tests_testURL_SOURCES = \ YesNoNone.h \ YesNoNone.cc \ RefreshPattern.h \ + CacheMgrPasswd.h \ + CacheMgrPasswd.cc \ cache_cf.cc \ cache_manager.cc \ CacheDigest.h \ diff --git a/src/SquidConfig.h b/src/SquidConfig.h index 337f8ac284..747f9d3fb7 100644 --- a/src/SquidConfig.h +++ b/src/SquidConfig.h @@ -47,12 +47,13 @@ #endif class acl_access; -class AclDenyInfoList; class acl_size_t; +class AclDenyInfoList; +class CacheMgrPasswd; class HeaderManglers; class RefreshPattern; -class SwapDir; class RemovalPolicySettings; +class SwapDir; namespace AnyP { class PortCfg; @@ -265,7 +266,7 @@ public: } fqdncache; int minDirectHops; int minDirectRtt; - cachemgr_passwd *passwd_list; + CacheMgrPasswd *passwd_list; struct { int objectsPerBucket; diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 4fe46c3b56..d8cb234dde 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -40,6 +40,7 @@ #include "anyp/PortCfg.h" #include "AuthReg.h" #include "base/RunnersRegistry.h" +#include "CacheMgrPasswd.h" #include "CachePeer.h" #include "cache_cf.h" #include "ConfigParser.h" @@ -2369,7 +2370,7 @@ free_peer(CachePeer ** P) } static void -dump_cachemgrpasswd(StoreEntry * entry, const char *name, cachemgr_passwd * list) +dump_cachemgrpasswd(StoreEntry * entry, const char *name, CacheMgrPasswd * list) { wordlist *w; @@ -2389,15 +2390,15 @@ dump_cachemgrpasswd(StoreEntry * entry, const char *name, cachemgr_passwd * list } static void -parse_cachemgrpasswd(cachemgr_passwd ** head) +parse_cachemgrpasswd(CacheMgrPasswd ** head) { char *passwd = NULL; wordlist *actions = NULL; - cachemgr_passwd *p; - cachemgr_passwd **P; + CacheMgrPasswd *p; + CacheMgrPasswd **P; parse_string(&passwd); parse_wordlist(&actions); - p = static_cast(xcalloc(1, sizeof(cachemgr_passwd))); + p = new CacheMgrPasswd; p->passwd = passwd; p->actions = actions; @@ -2406,7 +2407,7 @@ parse_cachemgrpasswd(cachemgr_passwd ** head) * See if any of the actions from this line already have a * password from previous lines. The password checking * routines in cache_manager.c take the the password from - * the first cachemgr_passwd struct that contains the + * the first CacheMgrPasswd struct that contains the * requested action. Thus, we should warn users who might * think they can have two passwords for the same action. */ @@ -2427,9 +2428,9 @@ parse_cachemgrpasswd(cachemgr_passwd ** head) } static void -free_cachemgrpasswd(cachemgr_passwd ** head) +free_cachemgrpasswd(CacheMgrPasswd ** head) { - cachemgr_passwd *p; + CacheMgrPasswd *p; while ((p = *head) != NULL) { *head = p->next; diff --git a/src/cache_manager.cc b/src/cache_manager.cc index 5322d2ae85..0b14abba7b 100644 --- a/src/cache_manager.cc +++ b/src/cache_manager.cc @@ -32,6 +32,7 @@ #include "squid.h" #include "base/TextException.h" +#include "CacheMgrPasswd.h" #include "CacheManager.h" #include "comm/Connection.h" #include "Debug.h" @@ -459,12 +460,12 @@ CacheManager::ActionProtection(const Mgr::ActionProfile::Pointer &profile) } /* - \ingroup CacheManagerInternal + * \ingroup CacheManagerInternal * gets from the global Config the password the user would need to supply * for the action she queried */ char * -CacheManager::PasswdGet(cachemgr_passwd * a, const char *action) +CacheManager::PasswdGet(CacheMgrPasswd * a, const char *action) { wordlist *w; diff --git a/src/structs.h b/src/structs.h index 5f75f1648c..af8a4b7b4e 100644 --- a/src/structs.h +++ b/src/structs.h @@ -104,7 +104,7 @@ class RemovalPolicySettings; class external_acl; class Store; class CustomLog; -class cachemgr_passwd; +class CacheMgrPasswd; namespace AnyP { struct PortCfg; @@ -304,15 +304,6 @@ private: unsigned int destinationIPLookedUp_:1; }; - -class cachemgr_passwd { -public: - char *passwd; - wordlist *actions; - cachemgr_passwd *next; -}; - - #if USE_SSL struct _sslproxy_cert_sign { int alg; -- 2.47.2