Re: [PATCH] compat: add a getpass() compatibility function

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

 



Am 19.05.2011 um 20:07 schrieb Erik Faye-Lund:

> On Thu, May 19, 2011 at 7:27 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>> 
>> Probably a properly abstracted common version would look like a function
>> that calls four platform-dependent helper funcions in this order:
>> 
>>        0. prompt
>>        1. start "noecho" mode
>>        2. get whole line
>>        3. exit "noecho" mode
>> 
> 
> When I think about it a bit more, it feels a bit pointless:
> 0. is identical (fputs)
> 1. is different (tc[gs]etattr vs nop)
> 2. is different (getc vs _getch)
> 3. is different (tcsetattr vs nop)
> 
> So there's probably not much code to share here. There's a bit of
> logic, but I'm not entirely sure this should be the same either,
> because on Windows we have to take care of '\r' (since we open stdin
> in binary mode at start-up).
> 

I agree, 0 would even have to be different, too, as we have to write to /dev/tty (which would have to be opened first) or (as fallback) stderr on POSIX.


> diff --git a/compat/mingw.h b/compat/mingw.h
> index 62eccd3..e37d557 100644
> --- a/compat/mingw.h
> +++ b/compat/mingw.h
> @@ -48,6 +48,8 @@ typedef int socklen_t;
> #define EAFNOSUPPORT WSAEAFNOSUPPORT
> #define ECONNABORTED WSAECONNABORTED
> 
> +#define PASS_MAX 512
> +

It might be worth to have this in git-compat-util.h, so it can also be used by compat/getpass.c. I'm not sure about the name, however; it's a remote password and MAX_PASS is about local passwords AFAIK. Maybe PASS_MAX_REMOTE or something similiar. Like that, compat/getpass.c could also be used in case MAX_PASS has some insanely low value on a platform.

--
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]