From d7ac713764c24df768beacf1c53693efb32f2456 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 12 Dec 2010 15:26:06 +0000 Subject: [PATCH] (trunk daemon) #3763 "transmission-remote should be able to read auth info from an environment variable" -- added. patch by fejesjoco. --- daemon/remote.c | 13 +++++++++++++ daemon/transmission-remote.1 | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/daemon/remote.c b/daemon/remote.c index 3c2dceb19..6a105ae5e 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -255,6 +255,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 username and password", "n", 1, "" }, + { 810, "authenv", "Set authentication info from the TRAUTH environment variable (user:pw)", "ne", 0, NULL }, { 'N', "netrc", "Set authentication info from a .netrc file", "N", 1, "" }, { 'o', "dht", "Enable distributed hash tables (DHT)", "o", 0, NULL }, { 'O', "no-dht", "Disable distributed hash tables (DHT)", "O", 0, NULL }, @@ -350,6 +351,7 @@ getOptMode( int val ) case 'a': /* add torrent */ case 'b': /* debug */ case 'n': /* auth */ + case 810: /* authenv */ case 'N': /* netrc */ case 't': /* set current torrent */ case 'V': /* show version number */ @@ -1819,6 +1821,17 @@ processArgs( const char * host, int port, int argc, const char ** argv ) auth = tr_strdup( optarg ); break; + case 810: /* authenv */ + { + char *authenv = getenv("TRAUTH"); + if( !authenv ) { + fprintf( stderr, "The TRAUTH environment variable is not set\n" ); + exit( 0 ); + } + auth = tr_strdup( authenv ); + } + break; + case 'N': /* netrc */ netrc = tr_strdup( optarg ); break; diff --git a/daemon/transmission-remote.1 b/daemon/transmission-remote.1 index 0f2e5822b..53c296228 100644 --- a/daemon/transmission-remote.1 +++ b/daemon/transmission-remote.1 @@ -33,6 +33,7 @@ and .Op Fl l .Op Fl m | M .Op Fl n Ar user:pass +.Op Fl ne .Op Fl N Ar netrc .Op Fl o | O .Op Fl p Ar port @@ -171,6 +172,11 @@ Set the and .Ar password for authentication +.It Fl ne Fl -authenv +Set the authentication information from the +.Ar TRAUTH +environment variable which must be formatted as +.Ar username:password. .It Fl N Fl -netrc Ar filename Set the authentication information from a .Ar netrc file.