[PATCH] Re: proxy setup help
Max Bowsher
maxb@ukf.net
Fri Mar 7 15:24:00 GMT 2003
vijay kiran kamuju wrote:
> i am trying to setup cygwin. i am behind a firewall n it also
> uses
> a proxy server. my proxy server id has no password, and i dont
> have the permission to change it. the setup program asks me to
> enter the proxy server id n its passwd, it does not take a null
> passwd.
> plz hlp me.
This is a bug in setup. I'm submitting a patch to fix it.
Robert: Can we fast-track this patch, and a subsequent snapshot, since it's
stopping someone installing Cygwin at all?
Technical description of the bug:
Setup was considering an empty password to be invalid - obviously it's not.
Whilst troubleshooting this, I found that eget was returning NULL for an
empty edit control, rather than a valid pointer to an empty char-string
(admittedly, because of Microsoft's stupid API, which uses zero as an error
indication, and the length of the string for success - so when string is
length 0...).
Fixing that in dialog.cc then required tweaks throughout n*.cc to test for
null strings as well as null pointers, and also accepting empty passwords as
valid.
BEGIN_PATCH
Index: dialog.cc
===================================================================
RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/dialog.cc,v
retrieving revision 2.7
diff -u -p -r2.7 dialog.cc
--- dialog.cc 4 May 2002 12:15:56 -0000 2.7
+++ dialog.cc 7 Mar 2003 15:18:23 -0000
@@ -38,7 +38,8 @@ eget (HWND h, int id, char *var)
delete [] var;
var = NULL;
}
- if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0)
+ if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0
+ || GetLastError() == ERROR_SUCCESS)
{
var = new char [strlen (tmp) + 1];
var [strlen (tmp)] = '\0';
@@ -52,7 +53,8 @@ egetString (HWND h, int id)
{
String aString;
char tmp[4000];
- if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0)
+ if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0
+ || GetLastError() == ERROR_SUCCESS)
aString = String (tmp);
return aString;
}
Index: net.cc
===================================================================
RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/net.cc,v
retrieving revision 2.12
diff -u -p -r2.12 net.cc
--- net.cc 21 Sep 2002 09:36:46 -0000 2.12
+++ net.cc 7 Mar 2003 14:59:35 -0000
@@ -50,7 +50,7 @@ NetPage::CheckIfEnableNext ()
else if (net_method == IDC_NET_PROXY)
{
p = pu = 1;
- if (net_proxy_host && net_proxy_port)
+ if (net_proxy_host && net_proxy_host[0] && net_proxy_port)
e = 1;
}
if (e)
Index: netio.cc
===================================================================
RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/netio.cc,v
retrieving revision 2.8
diff -u -p -r2.8 netio.cc
--- netio.cc 4 May 2002 12:15:56 -0000 2.8
+++ netio.cc 7 Mar 2003 15:18:39 -0000
@@ -170,7 +170,7 @@ static void
check_if_enable_ok (HWND h)
{
int e = 0;
- if (*user && *passwd)
+ if (*user && (*user)[0])
e = 1;
EnableWindow (GetDlgItem (h, IDOK), e);
}
Index: nio-ftp.cc
===================================================================
RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/nio-ftp.cc,v
retrieving revision 2.13
diff -u -p -r2.13 nio-ftp.cc
--- nio-ftp.cc 25 Nov 2002 22:02:49 -0000 2.13
+++ nio-ftp.cc 7 Mar 2003 15:04:23 -0000
@@ -79,14 +79,14 @@ NetIO_FTP::NetIO_FTP (char const *Purl,
code = ftp_line (c);
auth_retry:
- if (net_ftp_user)
+ if (net_ftp_user && net_ftp_user[0])
c->printf ("USER %s\r\n", net_ftp_user);
else
c->printf ("USER anonymous\r\n");
code = ftp_line (c);
if (code == 331)
{
- if (net_ftp_passwd)
+ if (net_ftp_user && net_ftp_user[0])
c->printf ("PASS %s\r\n", net_ftp_passwd);
else
c->printf ("PASS cygwin-setup@\r\n");
@@ -95,7 +95,7 @@ NetIO_FTP::NetIO_FTP (char const *Purl,
if (code == 530) /* Authentication failed, retry */
{
get_ftp_auth (NULL);
- if (net_ftp_user && net_ftp_passwd)
+ if (net_ftp_user && net_ftp_user[0])
goto auth_retry;
}
Index: nio-http.cc
===================================================================
RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/nio-http.cc,v
retrieving revision 2.14
diff -u -p -r2.14 nio-http.cc
--- nio-http.cc 11 Dec 2002 22:29:00 -0000 2.14
+++ nio-http.cc 7 Mar 2003 15:07:47 -0000
@@ -122,11 +122,11 @@ retry_get:
else
s->printf ("Host: %s:%d\r\n", host, port);
- if (net_user && net_passwd)
+ if (net_user && net_user[0])
s->printf ("Authorization: Basic %s\r\n",
base64_encode (net_user, net_passwd));
- if (net_proxy_user && net_proxy_passwd)
+ if (net_proxy_user && net_proxy_user[0])
s->printf ("Proxy-Authorization: Basic %s\r\n",
base64_encode (net_proxy_user, net_proxy_passwd));
@@ -174,7 +174,7 @@ retry_get:
&& net_method == IDC_NET_PROXY && !strncmp (Purl, "ftp://", 6))
{
get_ftp_auth (NULL);
- if (net_ftp_user && net_ftp_passwd)
+ if (net_ftp_user && net_ftp_user[0])
{
delete
s;
Index: nio-ie5.cc
===================================================================
RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/nio-ie5.cc,v
retrieving revision 2.6
diff -u -p -r2.6 nio-ie5.cc
--- nio-ie5.cc 15 Jun 2002 12:13:29 -0000 2.6
+++ nio-ie5.cc 7 Mar 2003 15:06:16 -0000
@@ -64,7 +64,7 @@ NetIO (_url)
try_again:
- if (net_user && net_passwd)
+ if (net_user && net_user[0])
{
InternetSetOption (connection, INTERNET_OPTION_USERNAME,
net_user, strlen (net_user));
@@ -72,7 +72,7 @@ try_again:
net_passwd, strlen (net_passwd));
}
- if (net_proxy_user && net_proxy_passwd)
+ if (net_proxy_user && net_proxy_user[0])
{
InternetSetOption (connection, INTERNET_OPTION_PROXY_USERNAME,
net_proxy_user, strlen (net_proxy_user));
END_PATCH
More information about the Cygwin-apps
mailing list