Fossil

Changes On Branch ipv6
Login

Changes On Branch ipv6

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch ipv6 Excluding Merge-Ins

This is equivalent to a diff from b894afad3d to d5f6e08c09

2013-06-10
21:07
Disable the database file alias warnings on Mac due to Time-Machine issues. ... (check-in: 14b1e90f21 user: drh tags: trunk)
13:32
Merge all the latest trunk changes into the ipv6 branch. ... (Closed-Leaf check-in: d5f6e08c09 user: drh tags: ipv6)
07:07
A typo in help screen (reported by Sergei Gavrikov) ... (check-in: b894afad3d user: jan.nijtmans tags: trunk)
2013-06-05
08:12
make "fossil rm FOO" work as expected on case-insensitive file systems, where committed files "foo/*" exist. ... (check-in: fa6311a507 user: jan.nijtmans tags: trunk)
2012-07-07
14:07
Update the inetd handler so that it works with IPv6. ... (check-in: 89fb414274 user: drh tags: ipv6)

Changes to src/cgi.c.
37
38
39
40
41
42
43

44
45
46
47
48
49
50
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51







+







#ifdef __EMX__
  typedef int socklen_t;
#endif
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include "cgi.h"

#if INTERFACE
/*
** Shortcuts for cgi_parameter.  P("x") returns the value of query parameter
** or cookie "x", or NULL if there is no such parameter or cookie.  PD("x","y")
** does the same except "y" is returned in place of NULL if there is not match.
1153
1154
1155
1156
1157
1158
1159











1160
1161
1162
1163
1164
1165
1166
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178







+
+
+
+
+
+
+
+
+
+
+







    zInput++;
    while( fossil_isspace(*zInput) ){ zInput++; }
  }
  if( zLeftOver ){ *zLeftOver = zInput; }
  return zResult;
}

/*
** All possible forms of an IP address.  Needed to work around GCC strict
** aliasing rules.
*/
typedef union {
  struct sockaddr sa;              /* Abstract superclass */
  struct sockaddr_in sa4;          /* IPv4 */
  struct sockaddr_in6 sa6;         /* IPv6 */
  struct sockaddr_storage sas;     /* Should be the maximum of the above 3 */
} address;

/*
** This routine handles a single HTTP request which is coming in on
** g.httpIn and which replies on g.httpOut
**
** The HTTP request is read from g.httpIn and is used to initialize
** entries in the cgi_parameter() hash, as if those entries were
** environment variables.  A call to cgi_init() completes
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204









1205
1206
1207
1208
1209
1210
1211
1205
1206
1207
1208
1209
1210
1211





1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227







-
-
-
-
-
+
+
+
+
+
+
+
+
+







    malformed_request();
  }
  cgi_setenv("REQUEST_URI", zToken);
  for(i=0; zToken[i] && zToken[i]!='?'; i++){}
  if( zToken[i] ) zToken[i++] = 0;
  cgi_setenv("PATH_INFO", zToken);
  cgi_setenv("QUERY_STRING", &zToken[i]);
  if( zIpAddr==0 &&
        getpeername(fileno(g.httpIn), (struct sockaddr*)&remoteName, 
                                &size)>=0
  ){
    zIpAddr = inet_ntoa(remoteName.sin_addr);
  if( zIpAddr==0 ){
    address remoteAddr;
    unsigned int size = sizeof(remoteAddr);
    char zHost[NI_MAXHOST];
    if( getpeername(fileno(g.httpIn), &remoteAddr.sa, &size)>=0 ){
      getnameinfo(&remoteAddr.sa, size, zHost, sizeof(zHost), 0, 0,
                  NI_NUMERICHOST);
      zIpAddr = mprintf("%s", zHost);
    }
  }
  if( zIpAddr ){   
    cgi_setenv("REMOTE_ADDR", zIpAddr);
    g.zIpAddr = mprintf("%s", zIpAddr);
  }
 
  /* Get all the optional fields that follow the first line.
Changes to src/http_socket.c.
36
37
38
39
40
41
42

43
44
45
46
47
48
49
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50







+







#  include <arpa/inet.h>
#  include <sys/socket.h>
#  include <netdb.h>
#endif
#include <assert.h>
#include <sys/types.h>
#include <signal.h>
#include <errno.h>

/*
** There can only be a single socket connection open at a time.
** State information about that socket is stored in the following
** local variables:
*/
static int socketIsInit = 0;    /* True after global initialization */
131
132
133
134
135
136
137
138


139
140
141
142
143
144
145
146
147
148
149












150
151
152
153
154


155
156



157
158
159

160
161
162
163
164
165
166
167
168
169
170
171
172
173


























174
175
176
177
178
179
180
132
133
134
135
136
137
138

139
140
141
142
143








144
145
146
147
148
149
150
151
152
153
154
155





156
157


158
159
160
161
162

163














164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196







-
+
+



-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
-
-
+
+
+


-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







**    g.urlName       Name of the server.  Ex: www.fossil-scm.org
**    g.urlPort       TCP/IP port to use.  Ex: 80
**
** Return the number of errors.
*/
int socket_open(void){
  static struct sockaddr_in addr;  /* The server address */
  static int addrIsInit = 0;       /* True once addr is initialized */
  static int addrIsInit = 0;       /* True when initialized once */
  static struct addrinfo *p = 0;   /* Succcessful open */

  socket_global_init();
  if( !addrIsInit ){
    addr.sin_family = AF_INET;
    addr.sin_port = htons(g.urlPort);
    *(int*)&addr.sin_addr = inet_addr(g.urlName);
    if( -1 == *(int*)&addr.sin_addr ){
#ifndef FOSSIL_STATIC_LINK
      struct hostent *pHost;
      pHost = gethostbyname(g.urlName);
      if( pHost!=0 ){
    struct addrinfo sHints;
    int rc;
    char zPort[30];
    
    memset(&sHints, 0, sizeof(sHints));
    sHints.ai_family = AF_UNSPEC;
    sHints.ai_socktype = SOCK_STREAM;
    sHints.ai_flags = 0;
    sHints.ai_protocol = 0;
    sqlite3_snprintf(sizeof(zPort), zPort, "%d", g.urlPort);
    rc = getaddrinfo(g.urlName, zPort, &sHints, &p);
    if( rc!=0 ){
        memcpy(&addr.sin_addr,pHost->h_addr_list[0],pHost->h_length);
      }else
#endif
      {
        socket_set_errmsg("can't resolve host name: %s", g.urlName);
      fossil_fatal("getaddrinfo(\"%s\",\"%s\",...): %s",
                   g.urlName, zPort, gai_strerror(rc));
        return 1;
      }
    }
    if( p==0 ){
      fossil_fatal("no IP addresses returned by getaddrinfo()");
    }
    addrIsInit = 1;

  }
    /* Set the Global.zIpAddr variable to the server we are talking to.
    ** This is used to populate the ipaddr column of the rcvfrom table,
    ** if any files are received from the server.
    */
    g.zIpAddr = mprintf("%s", inet_ntoa(addr.sin_addr));
  }
  iSocket = socket(AF_INET,SOCK_STREAM,0);
  if( iSocket<0 ){
    socket_set_errmsg("cannot create a socket");
    return 1;
  }
  if( connect(iSocket,(struct sockaddr*)&addr,sizeof(addr))<0 ){
    socket_set_errmsg("cannot connect to host %s:%d", g.urlName, g.urlPort);
    socket_close();

  while( p ){
    char zHost[NI_MAXHOST];
    iSocket = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
    if( iSocket<0 ){
      fossil_warning("socket() failed: %s", strerror(errno));
      p = p->ai_next;
      continue;
    }
    if( connect(iSocket, p->ai_addr, p->ai_addrlen)<0 ){
      fossil_warning("connect() failed: %s", strerror(errno));
      p = p->ai_next;
      socket_close();
      continue;
    }
    p->ai_next = 0;
    if( getnameinfo(p->ai_addr, p->ai_addrlen, zHost, sizeof(zHost),
                    0, 0, NI_NUMERICHOST)==0 ){
      g.zIpAddr = mprintf("%s", zHost);
    }else{
      fossil_fatal("cannot find numeric host IP address");
    }
    break;
  }
  if( p==0 ){
    socket_set_errmsg("cannot create a socket");
    return 1;
  }
#if !defined(_WIN32)
  signal(SIGPIPE, SIG_IGN);
#endif
  return 0;
}
Changes to src/url.c.
125
126
127
128
129
130
131


132




133





134
135
136
137
138
139
140
125
126
127
128
129
130
131
132
133

134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150







+
+
-
+
+
+
+

+
+
+
+
+







      }else{
        zLogin = mprintf("%t@", g.urlUser);
      }
      for(j=i+1; (c=zUrl[j])!=0 && c!='/' && c!=':'; j++){}
      g.urlName = mprintf("%.*s", j-i-1, &zUrl[i+1]);
      i = j;
    }else{
      int inSquare = 0;
      int n;
      for(i=iStart; (c=zUrl[i])!=0 && c!='/' && c!=':'; i++){}
      for(i=iStart; (c=zUrl[i])!=0 && c!='/' && (inSquare || c!=':'); i++){
        if( c=='[' ) inSquare = 1;
        if( c==']' ) inSquare = 0;
      }
      g.urlName = mprintf("%.*s", i-iStart, &zUrl[iStart]);
      n = strlen(g.urlName);
      if( g.urlName[0]=='[' && n>2 && g.urlName[n-1]==']' ){
        g.urlName++;
        g.urlName[n-2] = 0;
      }
      zLogin = mprintf("");
    }
    url_tolower(g.urlName);
    if( c==':' ){
      g.urlPort = 0;
      i++;
      while( (c = zUrl[i])!=0 && fossil_isdigit(c) ){