Thread (7 messages) flat view 7 messages, 4 authors, 2016-06-15

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

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:48:27

Scott Chacon [off-list ref] wrote:
On Fri, Mar 19, 2010 at 7:32 AM, Shawn O. Pearce [off-list ref] wrote:
quoted
Scott Chacon [off-list ref] wrote:
quoted
@@ -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.
Should I roll a new patch for this?
Yea, you probably should since I think the comment could be improved.

-- 
Shawn.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help