diff --git a/daemon/remote.c b/daemon/remote.c index 7f6c82bf9..ab4b0fafa 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -76,6 +76,7 @@ static tr_option opts[] = { 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", 0, NULL }, { 'M', "no-portmap", "Disable portmapping", "M", 0, NULL }, { 'n', "auth", "Set authentication info", "n", 1, "" }, + { 'N', "netrc", "Set authentication info from a .netrc file", "N", 1, "" }, { 'p', "port", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "p", 1, "" }, { 900, "priority-high", "Set the files' priorities as high", "ph", 1, "" }, { 901, "priority-normal", "Set the files' priorities as normal", "pn", 1, "" }, @@ -123,6 +124,7 @@ static char * reqs[256]; /* arbitrary max */ static int reqCount = 0; static int debug = 0; static char * auth = NULL; +static char * netrc = NULL; static char* tr_getcwd( void ) @@ -399,6 +401,11 @@ readargs( int argc, addArg = FALSE; break; + case 'N': + netrc = tr_strdup( optarg ); + addArg = FALSE; + break; + case 'p': tr_bencDictAddStr( &top, "method", "session-set" ); tr_bencDictAddInt( args, "port", numarg( optarg ) ); @@ -1212,17 +1219,17 @@ processRequests( const char * host, #ifdef HAVE_LIBZ curl_easy_setopt( curl, CURLOPT_ENCODING, "deflate" ); #endif - curl_easy_setopt( curl, CURLOPT_USERAGENT, - MY_NAME "/" LONG_VERSION_STRING ); + curl_easy_setopt( curl, CURLOPT_USERAGENT, MY_NAME "/" LONG_VERSION_STRING ); curl_easy_setopt( curl, CURLOPT_WRITEFUNCTION, writeFunc ); curl_easy_setopt( curl, CURLOPT_WRITEDATA, buf ); curl_easy_setopt( curl, CURLOPT_POST, 1 ); curl_easy_setopt( curl, CURLOPT_URL, url ); + curl_easy_setopt( curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL ); + curl_easy_setopt( curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY ); + if( netrc ) + curl_easy_setopt( curl, CURLOPT_NETRC_FILE, netrc ); if( auth ) - { curl_easy_setopt( curl, CURLOPT_USERPWD, auth ); - curl_easy_setopt( curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY ); - } for( i = 0; i < reqCount; ++i ) { diff --git a/daemon/transmission-remote.1 b/daemon/transmission-remote.1 index 26043c13b..0eebed524 100644 --- a/daemon/transmission-remote.1 +++ b/daemon/transmission-remote.1 @@ -24,6 +24,7 @@ and .Op Fl l .Op Fl m | M .Op Fl n Ar user:pass +.Op Fl N Ar netrc .Op Fl p Ar port .Op Fl ph Ar files .Op Fl pl Ar files @@ -116,6 +117,11 @@ and .Ar password for authentication +.It Fl N Fl -netrc Ar filename +Set the authentication information from a +.Ar netrc file. +See netrc(5) for more information. + .It Fl p Fl -port Ar port Set the .Ar port