Re: [PATCH] Prompt for a username when an HTTP request 401s

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Shawn O. Pearce" <spearce@xxxxxxxxxxx> writes:

> Scott Chacon <schacon@xxxxxxxxx> wrote:
>> @@ -815,7 +815,18 @@ static int http_request(const char *url, void
>> *result, int target, int options)
>>  			ret = HTTP_OK;
>>  		else if (missing_target(&results))
>>  			ret = HTTP_MISSING_TARGET;
>> -		else
>> +		else if (results.http_code == 401) {
>> +			if (user_name) {
>> +				ret = HTTP_NOAUTH;
>> +			} else {
>> +				// it is neccesary to use getpass here because
>> +				// there appears to be no other clean way to
>> +				// read/write stdout/stdin
>> +				user_name = xstrdup(getpass("Username: "));
>
> No, getpass is needed here because its very likely stdin/stdout are
> pipes to our parent process.  So we instead need to use /dev/tty,
> but that is non-portable.  Using getpass() can at least be stubbed
> on other platforms with a different implementation if/when necessary.

In addition to the obligatory "no C++/C99 double-slash comments, please ",
I think by the time this gets into an applicable shape, Frank's f206063
(git-core: Support retrieving passwords with GIT_ASKPASS, 2010-03-04) will
have graduated to the 'master'.  It would be a good idea to build this
change on top of that one.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]