Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Do not do automatic login for "fossil server" and "fossil http" and "fossil cgi" unless the --localauth option is used. Continue to do automatic login for 127.0.0.1 connections for "fossil ui", though. Ticket [573727d6d93badc] |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
f7a3c6deefc5b6944555f82d4a93acbe |
| User & Date: | drh 2011-02-22 20:30:45.065 |
Context
|
2011-02-22
| ||
| 20:59 | Tweaks to the "quick start" documentation page. ... (check-in: 6f1cc96ff0 user: drh tags: trunk) | |
| 20:30 | Do not do automatic login for "fossil server" and "fossil http" and "fossil cgi" unless the --localauth option is used. Continue to do automatic login for 127.0.0.1 connections for "fossil ui", though. Ticket [573727d6d93badc] ... (check-in: f7a3c6deef user: drh tags: trunk) | |
| 12:18 | Fix issues in the graphical merge conflict resolution reported on the mailing list. ... (check-in: 60f0986332 user: drh tags: trunk) | |
Changes
Changes to src/login.c.
| ︙ | ︙ | |||
366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
/* If the HTTP connection is coming over 127.0.0.1 and if
** local login is disabled and if we are using HTTP and not HTTPS,
** then there is no need to check user credentials.
**
*/
zRemoteAddr = PD("REMOTE_ADDR","nil");
if( strcmp(zRemoteAddr, "127.0.0.1")==0
&& db_get_int("localauth",0)==0
&& P("HTTPS")==0
){
uid = db_int(0, "SELECT uid FROM user WHERE cap LIKE '%%s%%'");
g.zLogin = db_text("?", "SELECT login FROM user WHERE uid=%d", uid);
zCap = "s";
g.noPswd = 1;
| > | 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
/* If the HTTP connection is coming over 127.0.0.1 and if
** local login is disabled and if we are using HTTP and not HTTPS,
** then there is no need to check user credentials.
**
*/
zRemoteAddr = PD("REMOTE_ADDR","nil");
if( strcmp(zRemoteAddr, "127.0.0.1")==0
&& g.useLocalauth
&& db_get_int("localauth",0)==0
&& P("HTTPS")==0
){
uid = db_int(0, "SELECT uid FROM user WHERE cap LIKE '%%s%%'");
g.zLogin = db_text("?", "SELECT login FROM user WHERE uid=%d", uid);
zCap = "s";
g.noPswd = 1;
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
100 101 102 103 104 105 106 107 108 109 110 111 112 113 | char *urlPasswd; /* Password for http: */ char *urlCanonical; /* Canonical representation of the URL */ char *urlProxyAuth; /* Proxy-Authorizer: string */ char *urlFossil; /* The path of the ?fossil=path suffix on ssh: */ int dontKeepUrl; /* Do not persist the URL */ const char *zLogin; /* Login name. "" if not logged in. */ int noPswd; /* Logged in without password (on 127.0.0.1) */ int userUid; /* Integer user id */ /* Information used to populate the RCVFROM table */ int rcvid; /* The rcvid. 0 if not yet defined. */ char *zIpAddr; /* The remote IP address */ char *zNonce; /* The nonce used for login */ | > | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | char *urlPasswd; /* Password for http: */ char *urlCanonical; /* Canonical representation of the URL */ char *urlProxyAuth; /* Proxy-Authorizer: string */ char *urlFossil; /* The path of the ?fossil=path suffix on ssh: */ int dontKeepUrl; /* Do not persist the URL */ const char *zLogin; /* Login name. "" if not logged in. */ int useLocalauth; /* No login required if from 127.0.0.1 */ int noPswd; /* Logged in without password (on 127.0.0.1) */ int userUid; /* Integer user id */ /* Information used to populate the RCVFROM table */ int rcvid; /* The rcvid. 0 if not yet defined. */ char *zIpAddr; /* The remote IP address */ char *zNonce; /* The nonce used for login */ |
| ︙ | ︙ | |||
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 |
continue;
}
if( blob_eq(&key, "notfound:") && blob_token(&line, &value) ){
zNotFound = mprintf("%s", blob_str(&value));
blob_reset(&value);
continue;
}
}
blob_reset(&config);
if( g.db==0 && g.zRepositoryName==0 ){
cgi_panic("Unable to find or open the project repository");
}
cgi_init();
process_one_web_page(zNotFound);
| > > > > | 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 |
continue;
}
if( blob_eq(&key, "notfound:") && blob_token(&line, &value) ){
zNotFound = mprintf("%s", blob_str(&value));
blob_reset(&value);
continue;
}
if( blob_eq(&key, "localauth") ){
g.useLocalauth = 1;
continue;
}
}
blob_reset(&config);
if( g.db==0 && g.zRepositoryName==0 ){
cgi_panic("Unable to find or open the project repository");
}
cgi_init();
process_one_web_page(zNotFound);
|
| ︙ | ︙ | |||
1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 |
** pathname selects among the various repositories. If the pathname does
** not select a valid repository and the --notfound option is available,
** then the server redirects (HTTP code 302) to the URL of --notfound.
**
** The --host option can be used to specify the hostname for the server.
** The --https option indicates that the request came from HTTPS rather
** than HTTP.
*/
void cmd_http(void){
const char *zIpAddr;
const char *zNotFound;
const char *zHost;
zNotFound = find_option("notfound", 0, 1);
if( find_option("https",0,0)!=0 ) cgi_replace_parameter("HTTPS","on");
zHost = find_option("host", 0, 1);
if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
g.cgiOutput = 1;
if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
fossil_fatal("no repository specified");
}
| > > > > > > > | 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 |
** pathname selects among the various repositories. If the pathname does
** not select a valid repository and the --notfound option is available,
** then the server redirects (HTTP code 302) to the URL of --notfound.
**
** The --host option can be used to specify the hostname for the server.
** The --https option indicates that the request came from HTTPS rather
** than HTTP.
**
** Other options:
**
** --localauth Password signin is not required if this is true and
** the input comes from 127.0.0.1 and the "localauth"
** setting is not disabled.
*/
void cmd_http(void){
const char *zIpAddr;
const char *zNotFound;
const char *zHost;
zNotFound = find_option("notfound", 0, 1);
g.useLocalauth = find_option("localauth", 0, 0)!=0;
if( find_option("https",0,0)!=0 ) cgi_replace_parameter("HTTPS","on");
zHost = find_option("host", 0, 1);
if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
g.cgiOutput = 1;
if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
fossil_fatal("no repository specified");
}
|
| ︙ | ︙ | |||
1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 |
** the web server. The "ui" command also binds to 127.0.0.1 and so will
** only process HTTP traffic from the local machine.
**
** In the "server" command, the REPOSITORY can be a directory (aka folder)
** that contains one or more respositories with names ending in ".fossil".
** In that case, the first element of the URL is used to select among the
** various repositories.
*/
void cmd_webserver(void){
int iPort, mxPort; /* Range of TCP ports allowed */
const char *zPort; /* Value of the --port option */
char *zBrowser; /* Name of web browser program */
char *zBrowserCmd = 0; /* Command to launch the web browser */
int isUiCmd; /* True if command is "ui", not "server' */
const char *zNotFound; /* The --notfound option or NULL */
int flags = 0; /* Server flags */
#if defined(_WIN32)
const char *zStopperFile; /* Name of file used to terminate server */
zStopperFile = find_option("stopper", 0, 1);
#endif
g.thTrace = find_option("th-trace", 0, 0)!=0;
if( g.thTrace ){
blob_zero(&g.thLog);
}
zPort = find_option("port", "P", 1);
zNotFound = find_option("notfound", 0, 1);
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
isUiCmd = g.argv[1][0]=='u';
| > > > > > > > > | > > | 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
** the web server. The "ui" command also binds to 127.0.0.1 and so will
** only process HTTP traffic from the local machine.
**
** In the "server" command, the REPOSITORY can be a directory (aka folder)
** that contains one or more respositories with names ending in ".fossil".
** In that case, the first element of the URL is used to select among the
** various repositories.
**
** By default, the "ui" command provides full administrative access without
** having to log in. This can be disabled by setting turning off the
** "localauth" setting. Automatic login for the "server" command is available
** if the --localauth option is present and the "localauth" setting is off
** and the connection is from localhost.
*/
void cmd_webserver(void){
int iPort, mxPort; /* Range of TCP ports allowed */
const char *zPort; /* Value of the --port option */
char *zBrowser; /* Name of web browser program */
char *zBrowserCmd = 0; /* Command to launch the web browser */
int isUiCmd; /* True if command is "ui", not "server' */
const char *zNotFound; /* The --notfound option or NULL */
int flags = 0; /* Server flags */
#if defined(_WIN32)
const char *zStopperFile; /* Name of file used to terminate server */
zStopperFile = find_option("stopper", 0, 1);
#endif
g.thTrace = find_option("th-trace", 0, 0)!=0;
g.useLocalauth = find_option("localauth", 0, 0)!=0;
if( g.thTrace ){
blob_zero(&g.thLog);
}
zPort = find_option("port", "P", 1);
zNotFound = find_option("notfound", 0, 1);
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
isUiCmd = g.argv[1][0]=='u';
if( isUiCmd ){
flags |= HTTP_SERVER_LOCALHOST;
g.useLocalauth = 1;
}
find_server_repository(isUiCmd);
if( zPort ){
iPort = mxPort = atoi(zPort);
}else{
iPort = db_get_int("http-port", 8080);
mxPort = iPort+100;
}
|
| ︙ | ︙ |
Changes to src/setup.c.
| ︙ | ︙ | |||
761 762 763 764 765 766 767 |
style_header("Access Control Settings");
db_begin_transaction();
@ <form action="%s(g.zTop)/setup_access" method="post"><div>
login_insert_csrf_secret();
@ <hr />
onoff_attribute("Require password for local access",
"localauth", "localauth", 0);
| | | | | | | > > | > > > > > > > > > > > > | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 |
style_header("Access Control Settings");
db_begin_transaction();
@ <form action="%s(g.zTop)/setup_access" method="post"><div>
login_insert_csrf_secret();
@ <hr />
onoff_attribute("Require password for local access",
"localauth", "localauth", 0);
@ <p>When enabled, the password sign-in is always required for
@ web access. When disabled, unrestricted web access from 127.0.0.1
@ is allowed for the <a href="%s(g.zTop)/help/ui">fossil ui</a> command or
@ from the <a href="%s(g.zTop)/help/server">fossil server</a>,
@ <a href="%s(g.zTop)/help/http">fossil http</a> commands when the
@ "--localauth" command line options is used, or from the
@ <a href="%s(g.zTop)/help/cgi">fossil cgi</a> if a line containing
@ the word "localauth" appears in the CGI script.
@
@ <p>A password is always required if any one or more
@ of the following are true:
@ <ol>
@ <li> This button is checked
@ <li> The inbound TCP/IP connection is not from 127.0.0.1
@ <li> The server is started using either of the
@ <a href="%s(g.zTop)/help/server">fossil server</a> or
@ <a href="%s(g.zTop)/help/server">fossil http</a> commands
@ without the "--localauth" option.
@ <li> The server is started from CGI without the "localauth" keyword
@ in the CGI script.
@ </ol>
@ <hr />
onoff_attribute("Allow REMOTE_USER authentication",
"remote_user_ok", "remote_user_ok", 0);
@ <p>When enabled, if the REMOTE_USER environment variable is set to the
@ login name of a valid user and no other login credentials are available,
@ then the REMOTE_USER is accepted as an authenticated user.
@ </p>
|
| ︙ | ︙ |
Changes to src/winhttp.c.
| ︙ | ︙ | |||
26 27 28 29 30 31 32 |
/*
** The HttpRequest structure holds information about each incoming
** HTTP request.
*/
typedef struct HttpRequest HttpRequest;
struct HttpRequest {
| | | | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
/*
** The HttpRequest structure holds information about each incoming
** HTTP request.
*/
typedef struct HttpRequest HttpRequest;
struct HttpRequest {
int id; /* ID counter */
SOCKET s; /* Socket on which to receive data */
SOCKADDR_IN addr; /* Address from which data is coming */
const char *zOptions; /* --notfound and/or --localauth options */
};
/*
** Prefix for a temporary file.
*/
static char *zTempPrefix;
|
| ︙ | ︙ | |||
107 108 109 110 111 112 113 |
}
wanted -= got;
}
fclose(out);
out = 0;
sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s%s",
fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName,
| | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
}
wanted -= got;
}
fclose(out);
out = 0;
sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s%s",
fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName,
inet_ntoa(p->addr.sin_addr), p->zOptions
);
fossil_system(zCmd);
in = fopen(zReplyFName, "rb");
if( in ){
while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){
send(p->s, zHdr, got, 0);
}
|
| ︙ | ︙ | |||
142 143 144 145 146 147 148 |
int flags /* One or more HTTP_SERVER_ flags */
){
WSADATA wd;
SOCKET s = INVALID_SOCKET;
SOCKADDR_IN addr;
int idCnt = 0;
int iPort = mnPort;
| | > | > | | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
int flags /* One or more HTTP_SERVER_ flags */
){
WSADATA wd;
SOCKET s = INVALID_SOCKET;
SOCKADDR_IN addr;
int idCnt = 0;
int iPort = mnPort;
Blob options;
if( zStopper ) unlink(zStopper);
blob_zero(&options);
if( zNotFound ){
blob_appendf(&options, " --notfound %s", zNotFound);
}
if( g.useLocalauth ){
blob_appendf(&options, " --localauth");
}
if( WSAStartup(MAKEWORD(1,1), &wd) ){
fossil_fatal("unable to initialize winsock");
}
while( iPort<=mxPort ){
s = socket(AF_INET, SOCK_STREAM, 0);
if( s==INVALID_SOCKET ){
|
| ︙ | ︙ | |||
211 212 213 214 215 216 217 |
closesocket(s);
fossil_fatal("error from accept()");
}
p = fossil_malloc( sizeof(*p) );
p->id = ++idCnt;
p->s = client;
p->addr = client_addr;
| | | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
closesocket(s);
fossil_fatal("error from accept()");
}
p = fossil_malloc( sizeof(*p) );
p->id = ++idCnt;
p->s = client;
p->addr = client_addr;
p->zOptions = blob_str(&options);
_beginthread(win32_process_one_http_request, 0, (void*)p);
}
closesocket(s);
WSACleanup();
}
#endif /* _WIN32 -- This code is for win32 only */
|