Fossil SCM

This does not need to be globally scoped.

andybradford 2014-02-01 05:40 UTC http-auth
Commit 6315fd8a3d88641953ef2dbfb49e7bdc47457302
2 files changed +7 -2 -2
+7 -2
--- src/http.c
+++ src/http.c
@@ -76,10 +76,15 @@
7676
blob_reset(&pw);
7777
blob_reset(&sig);
7878
blob_reset(&nonce);
7979
}
8080
81
+/*
82
+** Use HTTP Basic Authorization if a 401 is seen.
83
+*/
84
+static int fUseHttpAuth = 0;
85
+
8186
/*
8287
** Construct an appropriate HTTP request header. Write the header
8388
** into pHdr. This routine initializes the pHdr blob. pPayload is
8489
** the complete payload (including the login card) already compressed.
8590
*/
@@ -96,11 +101,11 @@
96101
}
97102
blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep);
98103
if( g.urlProxyAuth ){
99104
blob_appendf(pHdr, "Proxy-Authorization: %s\r\n", g.urlProxyAuth);
100105
}
101
- if( g.urlPasswd && g.urlUser && g.fUseHttpAuth ){
106
+ if( g.urlPasswd && g.urlUser && fUseHttpAuth ){
102107
char *zCredentials = mprintf("%s:%s", g.urlUser, g.urlPasswd);
103108
char *zEncoded = encode64(zCredentials, -1);
104109
blob_appendf(pHdr, "Authorization: Basic %s\r\n", zEncoded);
105110
fossil_free(zEncoded);
106111
fossil_free(zCredentials);
@@ -200,11 +205,11 @@
200205
while( (zLine = transport_receive_line(GLOBAL_URL()))!=0 && zLine[0]!=0 ){
201206
/* printf("[%s]\n", zLine); fflush(stdout); */
202207
if( fossil_strnicmp(zLine, "http/1.", 7)==0 ){
203208
if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err;
204209
if( rc==401 ){
205
- g.fUseHttpAuth = 1;
210
+ fUseHttpAuth = 1;
206211
transport_close(GLOBAL_URL());
207212
if( --maxRedirect == 0 ){
208213
fossil_fatal("http authorization limit exceeded");
209214
}
210215
return http_exchange(pSend, pReply, useLogin, maxRedirect);
211216
--- src/http.c
+++ src/http.c
@@ -76,10 +76,15 @@
76 blob_reset(&pw);
77 blob_reset(&sig);
78 blob_reset(&nonce);
79 }
80
 
 
 
 
 
81 /*
82 ** Construct an appropriate HTTP request header. Write the header
83 ** into pHdr. This routine initializes the pHdr blob. pPayload is
84 ** the complete payload (including the login card) already compressed.
85 */
@@ -96,11 +101,11 @@
96 }
97 blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep);
98 if( g.urlProxyAuth ){
99 blob_appendf(pHdr, "Proxy-Authorization: %s\r\n", g.urlProxyAuth);
100 }
101 if( g.urlPasswd && g.urlUser && g.fUseHttpAuth ){
102 char *zCredentials = mprintf("%s:%s", g.urlUser, g.urlPasswd);
103 char *zEncoded = encode64(zCredentials, -1);
104 blob_appendf(pHdr, "Authorization: Basic %s\r\n", zEncoded);
105 fossil_free(zEncoded);
106 fossil_free(zCredentials);
@@ -200,11 +205,11 @@
200 while( (zLine = transport_receive_line(GLOBAL_URL()))!=0 && zLine[0]!=0 ){
201 /* printf("[%s]\n", zLine); fflush(stdout); */
202 if( fossil_strnicmp(zLine, "http/1.", 7)==0 ){
203 if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err;
204 if( rc==401 ){
205 g.fUseHttpAuth = 1;
206 transport_close(GLOBAL_URL());
207 if( --maxRedirect == 0 ){
208 fossil_fatal("http authorization limit exceeded");
209 }
210 return http_exchange(pSend, pReply, useLogin, maxRedirect);
211
--- src/http.c
+++ src/http.c
@@ -76,10 +76,15 @@
76 blob_reset(&pw);
77 blob_reset(&sig);
78 blob_reset(&nonce);
79 }
80
81 /*
82 ** Use HTTP Basic Authorization if a 401 is seen.
83 */
84 static int fUseHttpAuth = 0;
85
86 /*
87 ** Construct an appropriate HTTP request header. Write the header
88 ** into pHdr. This routine initializes the pHdr blob. pPayload is
89 ** the complete payload (including the login card) already compressed.
90 */
@@ -96,11 +101,11 @@
101 }
102 blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep);
103 if( g.urlProxyAuth ){
104 blob_appendf(pHdr, "Proxy-Authorization: %s\r\n", g.urlProxyAuth);
105 }
106 if( g.urlPasswd && g.urlUser && fUseHttpAuth ){
107 char *zCredentials = mprintf("%s:%s", g.urlUser, g.urlPasswd);
108 char *zEncoded = encode64(zCredentials, -1);
109 blob_appendf(pHdr, "Authorization: Basic %s\r\n", zEncoded);
110 fossil_free(zEncoded);
111 fossil_free(zCredentials);
@@ -200,11 +205,11 @@
205 while( (zLine = transport_receive_line(GLOBAL_URL()))!=0 && zLine[0]!=0 ){
206 /* printf("[%s]\n", zLine); fflush(stdout); */
207 if( fossil_strnicmp(zLine, "http/1.", 7)==0 ){
208 if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err;
209 if( rc==401 ){
210 fUseHttpAuth = 1;
211 transport_close(GLOBAL_URL());
212 if( --maxRedirect == 0 ){
213 fossil_fatal("http authorization limit exceeded");
214 }
215 return http_exchange(pSend, pReply, useLogin, maxRedirect);
216
-2
--- src/main.c
+++ src/main.c
@@ -139,11 +139,10 @@
139139
int fSqlTrace; /* True if --sqltrace flag is present */
140140
int fSqlStats; /* True if --sqltrace or --sqlstats are present */
141141
int fSqlPrint; /* True if -sqlprint flag is present */
142142
int fQuiet; /* True if -quiet flag is present */
143143
int fHttpTrace; /* Trace outbound HTTP requests */
144
- int fUseHttpAuth; /* Use HTTP Basic Authentication in requests */
145144
int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
146145
int fSshTrace; /* Trace the SSH setup traffic */
147146
int fSshClient; /* HTTP client flags for SSH client */
148147
char *zSshCmd; /* SSH command string */
149148
int fNoSync; /* Do not do an autosync ever. --nosync */
@@ -649,11 +648,10 @@
649648
g.fSshClient = 0;
650649
g.zSshCmd = 0;
651650
if( g.fSqlTrace ) g.fSqlStats = 1;
652651
g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
653652
g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
654
- g.fUseHttpAuth = 0;
655653
g.zLogin = find_option("user", "U", 1);
656654
g.zSSLIdentity = find_option("ssl-identity", 0, 1);
657655
g.zErrlog = find_option("errorlog", 0, 1);
658656
if( find_option("utc",0,0) ) g.fTimeFormat = 1;
659657
if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
660658
--- src/main.c
+++ src/main.c
@@ -139,11 +139,10 @@
139 int fSqlTrace; /* True if --sqltrace flag is present */
140 int fSqlStats; /* True if --sqltrace or --sqlstats are present */
141 int fSqlPrint; /* True if -sqlprint flag is present */
142 int fQuiet; /* True if -quiet flag is present */
143 int fHttpTrace; /* Trace outbound HTTP requests */
144 int fUseHttpAuth; /* Use HTTP Basic Authentication in requests */
145 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
146 int fSshTrace; /* Trace the SSH setup traffic */
147 int fSshClient; /* HTTP client flags for SSH client */
148 char *zSshCmd; /* SSH command string */
149 int fNoSync; /* Do not do an autosync ever. --nosync */
@@ -649,11 +648,10 @@
649 g.fSshClient = 0;
650 g.zSshCmd = 0;
651 if( g.fSqlTrace ) g.fSqlStats = 1;
652 g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
653 g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
654 g.fUseHttpAuth = 0;
655 g.zLogin = find_option("user", "U", 1);
656 g.zSSLIdentity = find_option("ssl-identity", 0, 1);
657 g.zErrlog = find_option("errorlog", 0, 1);
658 if( find_option("utc",0,0) ) g.fTimeFormat = 1;
659 if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
660
--- src/main.c
+++ src/main.c
@@ -139,11 +139,10 @@
139 int fSqlTrace; /* True if --sqltrace flag is present */
140 int fSqlStats; /* True if --sqltrace or --sqlstats are present */
141 int fSqlPrint; /* True if -sqlprint flag is present */
142 int fQuiet; /* True if -quiet flag is present */
143 int fHttpTrace; /* Trace outbound HTTP requests */
 
144 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
145 int fSshTrace; /* Trace the SSH setup traffic */
146 int fSshClient; /* HTTP client flags for SSH client */
147 char *zSshCmd; /* SSH command string */
148 int fNoSync; /* Do not do an autosync ever. --nosync */
@@ -649,11 +648,10 @@
648 g.fSshClient = 0;
649 g.zSshCmd = 0;
650 if( g.fSqlTrace ) g.fSqlStats = 1;
651 g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
652 g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
 
653 g.zLogin = find_option("user", "U", 1);
654 g.zSSLIdentity = find_option("ssl-identity", 0, 1);
655 g.zErrlog = find_option("errorlog", 0, 1);
656 if( find_option("utc",0,0) ) g.fTimeFormat = 1;
657 if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
658

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button