------------------------------------------------------------ revno: 13426 revision-id: squid3@treenet.co.nz-20140531170005-hmn4d8s7ljmlvcvq parent: squid3@treenet.co.nz-20140531162244-ktaq95vv84xzpk72 committer: Amos Jeffries branch nick: trunk timestamp: Sat 2014-05-31 10:00:05 -0700 message: Cleanup: de-duplicate auth_param program parameter code Moves the "program" parse and dump code into Auth::Config. Also, changes API to Auth::Config::dump() to not dump any config settings for schemes which are not configured with a "program". Including scheme specific settings. Also, fixes missing Digest "utf8" parameter in config dump. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20140531170005-hmn4d8s7ljmlvcvq # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: 8e113858865a56b2f73fd0cb6452a4834c5da8e6 # timestamp: 2014-05-31 17:53:55 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: squid3@treenet.co.nz-20140531162244-\ # ktaq95vv84xzpk72 # # Begin patch === modified file 'src/auth/Config.cc' --- src/auth/Config.cc 2014-05-31 15:51:14 +0000 +++ src/auth/Config.cc 2014-05-31 17:00:05 +0000 @@ -40,6 +40,7 @@ #include "format/Format.h" #include "globals.h" #include "Store.h" +#include "wordlist.h" Auth::ConfigVector Auth::TheConfig; @@ -94,7 +95,15 @@ void Auth::Config::parse(Auth::Config * scheme, int n_configured, char *param_str) { - if (strcmp(param_str, "realm") == 0) { + if (strcmp(param_str, "program") == 0) { + if (authenticateProgram) + wordlistDestroy(&authenticateProgram); + + parse_wordlist(&authenticateProgram); + + requirePathnameExists("Authentication helper program", authenticateProgram->key); + + } else if (strcmp(param_str, "realm") == 0) { realm.clear(); char *token = ConfigParser::NextQuotedOrToEol(); @@ -135,9 +144,20 @@ } } -void -Auth::Config::dump(StoreEntry *entry, const char *name, Auth::Config *scheme) +bool +Auth::Config::dump(StoreEntry *entry, const char *name, Auth::Config *scheme) const { + if (!authenticateProgram) + return false; // not configured + + wordlist *list = authenticateProgram; + storeAppendPrintf(entry, "%s %s", name, scheme->type()); + while (list != NULL) { + storeAppendPrintf(entry, " %s", list->key); + list = list->next; + } + storeAppendPrintf(entry, "\n"); + storeAppendPrintf(entry, "%s %s realm " SQUIDSBUFPH "\n", name, scheme->type(), SQUIDSBUFPRINT(realm)); storeAppendPrintf(entry, "%s %s children %d startup=%d idle=%d concurrency=%d\n", @@ -147,6 +167,8 @@ if (keyExtrasLine.size() > 0) storeAppendPrintf(entry, "%s %s key_extras \"%s\"\n", name, scheme->type(), keyExtrasLine.termedBuf()); + + return true; } void === modified file 'src/auth/Config.h' --- src/auth/Config.h 2014-05-31 15:51:14 +0000 +++ src/auth/Config.h 2014-05-31 17:00:05 +0000 @@ -122,8 +122,9 @@ /** * Responsible for writing to the StoreEntry the configuration parameters that a user * would put in a config file to recreate the running configuration. + * Returns whether the scheme is configured. */ - virtual void dump(StoreEntry *, const char *, Config *); + virtual bool dump(StoreEntry *, const char *, Config *) const; /** add headers as needed when challenging for auth */ virtual void fixHeader(UserRequest::Pointer, HttpReply *, http_hdr_type, HttpRequest *) = 0; === modified file 'src/auth/basic/auth_basic.cc' --- src/auth/basic/auth_basic.cc 2014-05-31 15:51:14 +0000 +++ src/auth/basic/auth_basic.cc 2014-05-31 17:00:05 +0000 @@ -130,22 +130,16 @@ wordlistDestroy(&authenticateProgram); } -void -Auth::Basic::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme) +bool +Auth::Basic::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme) const { - wordlist *list = authenticateProgram; - storeAppendPrintf(entry, "%s %s", name, "basic"); - - while (list != NULL) { - storeAppendPrintf(entry, " %s", list->key); - list = list->next; - } - - storeAppendPrintf(entry, "\n"); + if (!Auth::Config::dump(entry, name, scheme)) + return false; // not configured storeAppendPrintf(entry, "%s basic credentialsttl %d seconds\n", name, (int) credentialsTTL); storeAppendPrintf(entry, "%s basic casesensitive %s\n", name, casesensitive ? "on" : "off"); - Auth::Config::dump(entry, name, scheme); + storeAppendPrintf(entry, "%s basic utf8 %s\n", name, utf8 ? "on" : "off"); + return true; } Auth::Basic::Config::Config() : @@ -160,14 +154,7 @@ void Auth::Basic::Config::parse(Auth::Config * scheme, int n_configured, char *param_str) { - if (strcmp(param_str, "program") == 0) { - if (authenticateProgram) - wordlistDestroy(&authenticateProgram); - - parse_wordlist(&authenticateProgram); - - requirePathnameExists("auth_param basic program", authenticateProgram->key); - } else if (strcmp(param_str, "credentialsttl") == 0) { + if (strcmp(param_str, "credentialsttl") == 0) { parse_time_t(&credentialsTTL); } else if (strcmp(param_str, "casesensitive") == 0) { parse_onoff(&casesensitive); === modified file 'src/auth/basic/auth_basic.h' --- src/auth/basic/auth_basic.h 2014-05-31 15:51:14 +0000 +++ src/auth/basic/auth_basic.h 2014-05-31 17:00:05 +0000 @@ -28,7 +28,7 @@ virtual Auth::UserRequest::Pointer decode(char const *proxy_auth, const char *requestRealm); virtual void done(); virtual void rotateHelpers(); - virtual void dump(StoreEntry *, const char *, Auth::Config *); + virtual bool dump(StoreEntry *, const char *, Auth::Config *) const; virtual void fixHeader(Auth::UserRequest::Pointer, HttpReply *, http_hdr_type, HttpRequest *); virtual void init(Auth::Config *); virtual void parse(Auth::Config *, int, char *); === modified file 'src/auth/digest/auth_digest.cc' --- src/auth/digest/auth_digest.cc 2014-05-31 15:51:14 +0000 +++ src/auth/digest/auth_digest.cc 2014-05-31 17:00:05 +0000 @@ -487,23 +487,18 @@ /* NP: dynamic helper restart will ensure they start up again as needed. */ } -void -Auth::Digest::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme) +bool +Auth::Digest::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme) const { - wordlist *list = authenticateProgram; - debugs(29, 9, "Dumping configuration"); - storeAppendPrintf(entry, "%s %s", name, "digest"); - - while (list != NULL) { - storeAppendPrintf(entry, " %s", list->key); - list = list->next; - } - - storeAppendPrintf(entry, "\n%s %s nonce_max_count %d\n%s %s nonce_max_duration %d seconds\n%s %s nonce_garbage_interval %d seconds\n", + if (!Auth::Config::dump(entry, name, scheme)) + return false; + + storeAppendPrintf(entry, "%s %s nonce_max_count %d\n%s %s nonce_max_duration %d seconds\n%s %s nonce_garbage_interval %d seconds\n", name, "digest", noncemaxuses, name, "digest", (int) noncemaxduration, name, "digest", (int) nonceGCInterval); - Auth::Config::dump(entry, name, scheme); + storeAppendPrintf(entry, "%s digest utf8 %s\n", name, utf8 ? "on" : "off"); + return true; } bool === modified file 'src/auth/digest/auth_digest.h' --- src/auth/digest/auth_digest.h 2014-05-31 15:51:14 +0000 +++ src/auth/digest/auth_digest.h 2014-05-31 17:00:05 +0000 @@ -75,7 +75,7 @@ virtual Auth::UserRequest::Pointer decode(char const *proxy_auth, const char *requestRealm); virtual void done(); virtual void rotateHelpers(); - virtual void dump(StoreEntry *, const char *, Auth::Config *); + virtual bool dump(StoreEntry *, const char *, Auth::Config *) const; virtual void fixHeader(Auth::UserRequest::Pointer, HttpReply *, http_hdr_type, HttpRequest *); virtual void init(Auth::Config *); virtual void parse(Auth::Config *, int, char *); === modified file 'src/auth/negotiate/auth_negotiate.cc' --- src/auth/negotiate/auth_negotiate.cc 2014-05-28 11:38:34 +0000 +++ src/auth/negotiate/auth_negotiate.cc 2014-05-31 17:00:05 +0000 @@ -108,19 +108,14 @@ debugs(29, DBG_IMPORTANT, "Reconfigure: Negotiate authentication configuration cleared."); } -void -Auth::Negotiate::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme) +bool +Auth::Negotiate::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme) const { - wordlist *list = authenticateProgram; - storeAppendPrintf(entry, "%s %s", name, "negotiate"); - - while (list != NULL) { - storeAppendPrintf(entry, " %s", list->key); - list = list->next; - } - - storeAppendPrintf(entry, "\n%s %s keep_alive %s\n", name, "negotiate", keep_alive ? "on" : "off"); - Auth::Config::dump(entry, name, scheme); + if (!Auth::Config::dump(entry, name, scheme)) + return false; + + storeAppendPrintf(entry, "%s negotiate keep_alive %s\n", name, keep_alive ? "on" : "off"); + return true; } Auth::Negotiate::Config::Config() : keep_alive(1) === modified file 'src/auth/negotiate/auth_negotiate.h' --- src/auth/negotiate/auth_negotiate.h 2013-12-06 14:59:47 +0000 +++ src/auth/negotiate/auth_negotiate.h 2014-05-31 17:00:05 +0000 @@ -34,7 +34,7 @@ virtual Auth::UserRequest::Pointer decode(char const *proxy_auth, const char *requestRealm); virtual void done(); virtual void rotateHelpers(); - virtual void dump(StoreEntry *, const char *, Auth::Config *); + virtual bool dump(StoreEntry *, const char *, Auth::Config *) const; virtual void fixHeader(Auth::UserRequest::Pointer, HttpReply *, http_hdr_type, HttpRequest *); virtual void init(Auth::Config *); virtual void parse(Auth::Config *, int, char *); === modified file 'src/auth/ntlm/auth_ntlm.cc' --- src/auth/ntlm/auth_ntlm.cc 2014-05-28 11:38:34 +0000 +++ src/auth/ntlm/auth_ntlm.cc 2014-05-31 17:00:05 +0000 @@ -100,19 +100,14 @@ debugs(29, DBG_IMPORTANT, "Reconfigure: NTLM authentication configuration cleared."); } -void -Auth::Ntlm::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme) +bool +Auth::Ntlm::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme) const { - wordlist *list = authenticateProgram; - storeAppendPrintf(entry, "%s %s", name, "ntlm"); - - while (list != NULL) { - storeAppendPrintf(entry, " %s", list->key); - list = list->next; - } - - storeAppendPrintf(entry, "\n%s %s keep_alive %s\n", name, "ntlm", keep_alive ? "on" : "off"); - Auth::Config::dump(entry, name, scheme); + if (!Auth::Config::dump(entry, name, scheme)) + return false; + + storeAppendPrintf(entry, "%s ntlm keep_alive %s\n", name, keep_alive ? "on" : "off"); + return true; } Auth::Ntlm::Config::Config() : keep_alive(1) === modified file 'src/auth/ntlm/auth_ntlm.h' --- src/auth/ntlm/auth_ntlm.h 2013-12-06 14:59:47 +0000 +++ src/auth/ntlm/auth_ntlm.h 2014-05-31 17:00:05 +0000 @@ -30,7 +30,7 @@ virtual Auth::UserRequest::Pointer decode(char const *proxy_auth, const char *requestRealm); virtual void done(); virtual void rotateHelpers(); - virtual void dump(StoreEntry *, const char *, Auth::Config *); + virtual bool dump(StoreEntry *, const char *, Auth::Config *) const; virtual void fixHeader(Auth::UserRequest::Pointer, HttpReply *, http_hdr_type, HttpRequest *); virtual void init(Auth::Config *); virtual void parse(Auth::Config *, int, char *);