1 Index: libtransmission/rpc-server.c
2 ===================================================================
3 --- libtransmission/rpc-server.c (revision 13057)
4 +++ libtransmission/rpc-server.c (working copy)
9 +#include "native-auth.h"
10 #include "platform.h" /* tr_getWebClientDir() */
16 bool isPasswordEnabled;
17 + bool isNativeAuthenticationEnabled;
18 bool isWhitelistEnabled;
25 +isUserAllowed( struct tr_rpc_server* server, const char * user, const char * pass)
29 + if( !server->isPasswordEnabled )
32 + if( !user || !pass )
37 + if( server->isNativeAuthenticationEnabled )
39 + tr_rpcNativeAuthenticationResult authResult;
40 + tr_performNativeAuthentication( user, pass, &authResult);
41 + successAuth = (NATIVE_AUTHENTICATON_SUCCESS == authResult);
45 + successAuth = !strcmp( server->username, user ) &&
46 + tr_ssha1_matches( server->password, pass);
54 test_session_id( struct tr_rpc_server * server, struct evhttp_request * req )
56 const char * ours = get_current_session_id( server );
58 "<p>If you're editing settings.json, see the 'rpc-whitelist' and 'rpc-whitelist-enabled' entries.</p>"
59 "<p>If you're still using ACLs, use a whitelist instead. See the transmission-daemon manpage for details.</p>" );
61 - else if( server->isPasswordEnabled
62 - && ( !pass || !user || strcmp( server->username, user )
63 - || !tr_ssha1_matches( server->password,
65 + else if( !isUserAllowed( server, user, pass ) )
67 evhttp_add_header( req->output_headers,
70 return server->isPasswordEnabled;
74 +tr_rpcSetNativeAuthenticationEnabled( tr_rpc_server * server, bool isEnabled )
76 + server->isNativeAuthenticationEnabled = isEnabled;
77 + dbgmsg( "setting 'native authenication enabled' to %d", (int)isEnabled );
81 +tr_rpcIsNativeAuthenticationEnabled( const tr_rpc_server * server )
83 + return server->isNativeAuthenticationEnabled;
87 tr_rpcGetBindAddress( const tr_rpc_server * server )
91 tr_rpcSetPasswordEnabled( s, boolVal );
93 + key = TR_PREFS_KEY_RPC_NATIVE_AUTH_ENABLED;
94 + if ( !tr_bencDictFindBool( settings, key, &boolVal ) )
95 + tr_nerr( MY_NAME, _( "Couldn't find settings key \"%s\"" ), key );
97 + tr_rpcSetNativeAuthenticationEnabled( s, boolVal );
99 key = TR_PREFS_KEY_RPC_WHITELIST;
100 if( !tr_bencDictFindStr( settings, key, &str ) && str )
101 tr_nerr( MY_NAME, _( "Couldn't find settings key \"%s\"" ), key );