Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Naur transmission-2.92/daemon/daemon.c transmission-2.92.new/daemon/daemon.c
- --- transmission-2.92/daemon/daemon.c 2016-02-23 15:22:59.365863760 +1100
- +++ transmission-2.92.new/daemon/daemon.c 2016-06-05 11:24:15.024000000 +1000
- @@ -107,6 +107,7 @@
- { 'p', "port", "RPC port (Default: " TR_DEFAULT_RPC_PORT_STR ")", "p", 1, "<port>" },
- { 't', "auth", "Require authentication", "t", 0, NULL },
- { 'T', "no-auth", "Don't require authentication", "T", 0, NULL },
- + { 969, "auth-bypass", "Authentication not required for IP addresses.", NULL, 1, "<list>" },
- { 'u', "username", "Set username for authentication", "u", 1, "<username>" },
- { 'v', "password", "Set password for authentication", "v", 1, "<password>" },
- { 'V', "version", "Show version number and exit", "V", 0, NULL },
- @@ -384,6 +385,9 @@
- break;
- case 'T': tr_variantDictAddBool (settings, TR_KEY_rpc_authentication_required, false);
- break;
- + case 969: tr_variantDictAddStr (settings, TR_KEY_rpc_auth_bypass_whitelist, optarg);
- + tr_variantDictAddBool (settings, TR_KEY_rpc_auth_bypass_enabled, true);
- + break;
- case 'u': tr_variantDictAddStr (settings, TR_KEY_rpc_username, optarg);
- break;
- case 'v': tr_variantDictAddStr (settings, TR_KEY_rpc_password, optarg);
- diff -Naur transmission-2.92/libtransmission/quark.c transmission-2.92.new/libtransmission/quark.c
- --- transmission-2.92/libtransmission/quark.c 2016-01-10 05:02:58.738698801 +1100
- +++ transmission-2.92.new/libtransmission/quark.c 2016-06-05 12:03:15.324000000 +1000
- @@ -286,6 +286,8 @@
- { "rename-partial-files", 20 },
- { "reqq", 4 },
- { "result", 6 },
- + { "rpc-auth-bypass-enabled", 23 },
- + { "rpc-auth-bypass-whitelist", 25 },
- { "rpc-authentication-required", 27 },
- { "rpc-bind-address", 16 },
- { "rpc-enabled", 11 },
- diff -Naur transmission-2.92/libtransmission/quark.h transmission-2.92.new/libtransmission/quark.h
- --- transmission-2.92/libtransmission/quark.h 2015-06-29 05:23:49.613528096 +1000
- +++ transmission-2.92.new/libtransmission/quark.h 2016-06-05 11:24:15.024000000 +1000
- @@ -288,6 +288,8 @@
- TR_KEY_rename_partial_files,
- TR_KEY_reqq,
- TR_KEY_result,
- + TR_KEY_rpc_auth_bypass_enabled,
- + TR_KEY_rpc_auth_bypass_whitelist,
- TR_KEY_rpc_authentication_required,
- TR_KEY_rpc_bind_address,
- TR_KEY_rpc_enabled,
- diff -Naur transmission-2.92/libtransmission/rpc-server.c transmission-2.92.new/libtransmission/rpc-server.c
- --- transmission-2.92/libtransmission/rpc-server.c 2016-01-10 05:02:58.740698836 +1100
- +++ transmission-2.92.new/libtransmission/rpc-server.c 2016-06-05 13:19:47.048000000 +1000
- @@ -52,6 +52,7 @@
- bool isEnabled;
- bool isPasswordEnabled;
- bool isWhitelistEnabled;
- + bool isAuthBypassEnabled;
- tr_port port;
- char * url;
- struct in_addr bindAddress;
- @@ -63,6 +64,8 @@
- char * password;
- char * whitelistStr;
- tr_list * whitelist;
- + char * authBypassWhitelistStr;
- + tr_list * authBypassWhitelist;
- char * sessionId;
- time_t sessionIdExpiresAt;
- @@ -589,6 +592,21 @@
- }
- static bool
- +isAddressAuthBypassed (const tr_rpc_server * server, const char * address)
- +{
- + tr_list * l;
- +
- + if (!server->isAuthBypassEnabled)
- + return false;
- +
- + for (l=server->authBypassWhitelist; l!=NULL; l=l->next)
- + if (tr_wildmat (address, l->data))
- + return true;
- +
- + return false;
- +}
- +
- +static bool
- test_session_id (struct tr_rpc_server * server, struct evhttp_request * req)
- {
- const char * ours = get_current_session_id (server);
- @@ -638,6 +656,7 @@
- "<p>If you're still using ACLs, use a whitelist instead. See the transmission-daemon manpage for details.</p>");
- }
- else if (server->isPasswordEnabled
- + && !isAddressAuthBypassed(server, req->remote_host)
- && (!pass || !user || strcmp (server->username, user)
- || !tr_ssha1_matches (server->password,
- pass)))
- @@ -931,6 +950,62 @@
- }
- /****
- +***** AUTHBYPASS
- +****/
- +
- +void
- +tr_rpcSetAuthBypassWhitelist (tr_rpc_server * server, const char * authBypassWhitelistStr)
- +{
- + void * tmp;
- + const char * walk;
- +
- + /* keep the string */
- + tmp = server->authBypassWhitelistStr;
- + server->authBypassWhitelistStr = tr_strdup (authBypassWhitelistStr);
- + tr_free (tmp);
- +
- + /* clear out the old authBypassWhitelist entries */
- + while ((tmp = tr_list_pop_front (&server->authBypassWhitelist)))
- + tr_free (tmp);
- +
- + /* build the new authBypassWhitelist entries */
- + for (walk=authBypassWhitelistStr; walk && *walk;)
- + {
- + const char * delimiters = " ,;";
- + const size_t len = strcspn (walk, delimiters);
- + char * token = tr_strndup (walk, len);
- + tr_list_append (&server->authBypassWhitelist, token);
- + tr_logAddNamedInfo (MY_NAME, "Adding address to authBypassWhitelist: %s", token);
- +
- + if (walk[len]=='\0')
- + break;
- +
- + walk += len + 1;
- + }
- +}
- +
- +const char*
- +tr_rpcGetAuthBypassWhitelist (const tr_rpc_server * server)
- +{
- + return server->authBypassWhitelistStr ? server->authBypassWhitelistStr : "";
- +}
- +
- +void
- +tr_rpcSetAuthBypassEnabled (tr_rpc_server * server,
- + bool isEnabled)
- +{
- + assert (tr_isBool (isEnabled));
- +
- + server->isAuthBypassEnabled = isEnabled;
- +}
- +
- +bool
- +tr_rpcGetAuthBypassEnabled (const tr_rpc_server * server)
- +{
- + return server->isAuthBypassEnabled;
- +}
- +
- +/****
- ***** PASSWORD
- ****/
- @@ -1063,6 +1138,12 @@
- else
- tr_rpcSetWhitelistEnabled (s, boolVal);
- + key = TR_KEY_rpc_auth_bypass_enabled;
- + if (!tr_variantDictFindBool (settings, key, &boolVal))
- + missing_settings_key (key);
- + else
- + tr_rpcSetAuthBypassEnabled (s, boolVal);
- +
- key = TR_KEY_rpc_authentication_required;
- if (!tr_variantDictFindBool (settings, key, &boolVal))
- missing_settings_key (key);
- @@ -1075,6 +1156,12 @@
- else
- tr_rpcSetWhitelist (s, str);
- + key = TR_KEY_rpc_auth_bypass_whitelist;
- + if (!tr_variantDictFindStr (settings, key, &str, NULL) && str)
- + missing_settings_key (key);
- + else
- + tr_rpcSetAuthBypassWhitelist (s, str);
- +
- key = TR_KEY_rpc_username;
- if (!tr_variantDictFindStr (settings, key, &str, NULL))
- missing_settings_key (key);
- @@ -1119,3 +1206,4 @@
- return s;
- }
- +
- diff -Naur transmission-2.92/libtransmission/rpc-server.h transmission-2.92.new/libtransmission/rpc-server.h
- --- transmission-2.92/libtransmission/rpc-server.h 2014-12-11 06:22:42.938222700 +1100
- +++ transmission-2.92.new/libtransmission/rpc-server.h 2016-06-05 11:24:15.028000000 +1000
- @@ -65,4 +65,15 @@
- const char* tr_rpcGetBindAddress (const tr_rpc_server * server);
- +void tr_rpcSetAuthBypassEnabled (tr_rpc_server * server,
- + bool isEnabled);
- +
- +bool tr_rpcGetAuthBypassEnabled (const tr_rpc_server * server);
- +
- +void tr_rpcSetAuthBypassWhitelist (tr_rpc_server * server,
- + const char * whitelist);
- +
- +const char* tr_rpcGetAuthBypassWhitelist (const tr_rpc_server * server);
- +
- +
- #endif
- diff -Naur transmission-2.92/libtransmission/session.c transmission-2.92.new/libtransmission/session.c
- --- transmission-2.92/libtransmission/session.c 2016-01-10 05:02:58.743698889 +1100
- +++ transmission-2.92.new/libtransmission/session.c 2016-06-05 11:24:15.028000000 +1000
- @@ -352,6 +352,8 @@
- tr_variantDictAddReal (d, TR_KEY_ratio_limit, 2.0);
- tr_variantDictAddBool (d, TR_KEY_ratio_limit_enabled, false);
- tr_variantDictAddBool (d, TR_KEY_rename_partial_files, true);
- + tr_variantDictAddBool (d, TR_KEY_rpc_auth_bypass_enabled, false);
- + tr_variantDictAddBool (d, TR_KEY_rpc_auth_bypass_whitelist, "");
- tr_variantDictAddBool (d, TR_KEY_rpc_authentication_required, false);
- tr_variantDictAddStr (d, TR_KEY_rpc_bind_address, "0.0.0.0");
- tr_variantDictAddBool (d, TR_KEY_rpc_enabled, false);
- @@ -424,6 +426,8 @@
- tr_variantDictAddReal (d, TR_KEY_ratio_limit, s->desiredRatio);
- tr_variantDictAddBool (d, TR_KEY_ratio_limit_enabled, s->isRatioLimited);
- tr_variantDictAddBool (d, TR_KEY_rename_partial_files, tr_sessionIsIncompleteFileNamingEnabled (s));
- + tr_variantDictAddBool (d, TR_KEY_rpc_auth_bypass_enabled, tr_sessionGetRPCAuthBypassEnabled (s));
- + tr_variantDictAddStr (d, TR_KEY_rpc_auth_bypass_whitelist, tr_sessionGetRPCAuthBypassWhitelist (s));
- tr_variantDictAddBool (d, TR_KEY_rpc_authentication_required, tr_sessionIsRPCPasswordEnabled (s));
- tr_variantDictAddStr (d, TR_KEY_rpc_bind_address, tr_sessionGetRPCBindAddress (s));
- tr_variantDictAddBool (d, TR_KEY_rpc_enabled, tr_sessionIsRPCEnabled (s));
- @@ -2723,6 +2727,39 @@
- return tr_rpcGetBindAddress (session->rpcServer);
- }
- +void
- +tr_sessionSetRPCAuthBypassWhitelist (tr_session * session,
- + const char * whitelist)
- +{
- + assert (tr_isSession (session));
- +
- + tr_rpcSetAuthBypassWhitelist (session->rpcServer, whitelist);
- +}
- +
- +const char*
- +tr_sessionGetRPCAuthBypassWhitelist (const tr_session * session)
- +{
- + assert (tr_isSession (session));
- +
- + return tr_rpcGetAuthBypassWhitelist (session->rpcServer);
- +}
- +
- +void
- +tr_sessionSetRPCAuthBypassEnabled (tr_session * session, bool isEnabled)
- +{
- + assert (tr_isSession (session));
- +
- + tr_rpcSetAuthBypassEnabled (session->rpcServer, isEnabled);
- +}
- +
- +bool
- +tr_sessionGetRPCAuthBypassEnabled (const tr_session * session)
- +{
- + assert (tr_isSession (session));
- +
- + return tr_rpcGetAuthBypassEnabled (session->rpcServer);
- +}
- +
- /****
- *****
- ****/
- diff -Naur transmission-2.92/libtransmission/transmission.h transmission-2.92.new/libtransmission/transmission.h
- --- transmission-2.92/libtransmission/transmission.h 2016-01-01 05:33:37.576878516 +1100
- +++ transmission-2.92.new/libtransmission/transmission.h 2016-06-05 11:24:15.028000000 +1000
- @@ -392,6 +392,16 @@
- bool tr_sessionGetRPCWhitelistEnabled (const tr_session * session);
- +void tr_sessionSetRPCAuthBypassWhitelist (tr_session * session,
- + const char * whitelist);
- +
- +const char* tr_sessionGetRPCAuthBypassWhitelist (const tr_session *);
- +
- +void tr_sessionSetRPCAuthBypassEnabled (tr_session * session,
- + bool isEnabled);
- +
- +bool tr_sessionGetRPCAuthBypassEnabled (const tr_session * session);
- +
- void tr_sessionSetRPCPassword (tr_session * session,
- const char * password);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement