Fossil SCM
Add the --unix-socket option to the "fossil server" command.
Commit
7fc2902126d43f87f897a46d12209f5b04d71d2cb50acd08ffad94c9b0c6aba6
Parent
71e9ca7869f0307…
2 files changed
+52
-20
+16
-1
+52
-20
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -70,16 +70,18 @@ | ||
| 70 | 70 | # endif |
| 71 | 71 | # include <winsock2.h> |
| 72 | 72 | # include <ws2tcpip.h> |
| 73 | 73 | #else |
| 74 | 74 | # include <sys/socket.h> |
| 75 | +# include <sys/un.h> | |
| 75 | 76 | # include <netinet/in.h> |
| 76 | 77 | # include <arpa/inet.h> |
| 77 | 78 | # include <sys/times.h> |
| 78 | 79 | # include <sys/time.h> |
| 79 | 80 | # include <sys/wait.h> |
| 80 | 81 | # include <sys/select.h> |
| 82 | +# include <errno.h> | |
| 81 | 83 | #endif |
| 82 | 84 | #ifdef __EMX__ |
| 83 | 85 | typedef int socklen_t; |
| 84 | 86 | #endif |
| 85 | 87 | #include <time.h> |
| @@ -2475,10 +2477,11 @@ | ||
| 2475 | 2477 | #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */ |
| 2476 | 2478 | #define HTTP_SERVER_HAD_REPOSITORY 0x0004 /* Was the repository open? */ |
| 2477 | 2479 | #define HTTP_SERVER_HAD_CHECKOUT 0x0008 /* Was a checkout open? */ |
| 2478 | 2480 | #define HTTP_SERVER_REPOLIST 0x0010 /* Allow repo listing */ |
| 2479 | 2481 | #define HTTP_SERVER_NOFORK 0x0020 /* Do not call fork() */ |
| 2482 | +#define HTTP_SERVER_UNIXDOMAINSOCK 0x0040 /* Use a unix-domain socket */ | |
| 2480 | 2483 | |
| 2481 | 2484 | #endif /* INTERFACE */ |
| 2482 | 2485 | |
| 2483 | 2486 | /* |
| 2484 | 2487 | ** Maximum number of child processes that we can have running |
| @@ -2515,58 +2518,87 @@ | ||
| 2515 | 2518 | socklen_t lenaddr; /* Length of the inaddr structure */ |
| 2516 | 2519 | int child; /* PID of the child process */ |
| 2517 | 2520 | int nchildren = 0; /* Number of child processes */ |
| 2518 | 2521 | struct timeval delay; /* How long to wait inside select() */ |
| 2519 | 2522 | struct sockaddr_in inaddr; /* The socket address */ |
| 2523 | + struct sockaddr_un uxaddr; /* The address for unix-domain sockets */ | |
| 2520 | 2524 | int opt = 1; /* setsockopt flag */ |
| 2521 | - int iPort = mnPort; | |
| 2525 | + int rc; /* Result code from system calls */ | |
| 2526 | + int iPort = mnPort; /* Port to try to use */ | |
| 2522 | 2527 | |
| 2523 | 2528 | while( iPort<=mxPort ){ |
| 2524 | - memset(&inaddr, 0, sizeof(inaddr)); | |
| 2525 | - inaddr.sin_family = AF_INET; | |
| 2526 | - if( zIpAddr ){ | |
| 2527 | - inaddr.sin_addr.s_addr = inet_addr(zIpAddr); | |
| 2528 | - if( inaddr.sin_addr.s_addr == INADDR_NONE ){ | |
| 2529 | - fossil_fatal("not a valid IP address: %s", zIpAddr); | |
| 2530 | - } | |
| 2531 | - }else if( flags & HTTP_SERVER_LOCALHOST ){ | |
| 2532 | - inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); | |
| 2529 | + if( flags & HTTP_SERVER_UNIXDOMAINSOCK ){ | |
| 2530 | + memset(&uxaddr, 0, sizeof(uxaddr)); | |
| 2531 | + if( strlen(zIpAddr)>sizeof(uxaddr.sun_path) ){ | |
| 2532 | + fossil_fatal("name of unix-domain socket too big: %s\n" | |
| 2533 | + "max size: %d\n", zIpAddr, (int)sizeof(uxaddr.sun_path)); | |
| 2534 | + } | |
| 2535 | + if( unlink(zIpAddr)==-1 && errno!=ENOENT ){ | |
| 2536 | + fossil_fatal("Cannot remove existing file at %s\n", zIpAddr); | |
| 2537 | + } | |
| 2538 | + uxaddr.sun_family = AF_UNIX; | |
| 2539 | + strncpy(uxaddr.sun_path, zIpAddr, sizeof(uxaddr.sun_path)-1); | |
| 2540 | + listener = socket(AF_UNIX, SOCK_STREAM, 0); | |
| 2533 | 2541 | }else{ |
| 2534 | - inaddr.sin_addr.s_addr = htonl(INADDR_ANY); | |
| 2542 | + memset(&inaddr, 0, sizeof(inaddr)); | |
| 2543 | + inaddr.sin_family = AF_INET; | |
| 2544 | + if( zIpAddr ){ | |
| 2545 | + inaddr.sin_addr.s_addr = inet_addr(zIpAddr); | |
| 2546 | + if( inaddr.sin_addr.s_addr == INADDR_NONE ){ | |
| 2547 | + fossil_fatal("not a valid IP address: %s", zIpAddr); | |
| 2548 | + } | |
| 2549 | + }else if( flags & HTTP_SERVER_LOCALHOST ){ | |
| 2550 | + inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); | |
| 2551 | + }else{ | |
| 2552 | + inaddr.sin_addr.s_addr = htonl(INADDR_ANY); | |
| 2553 | + } | |
| 2554 | + inaddr.sin_port = htons(iPort); | |
| 2555 | + listener = socket(AF_INET, SOCK_STREAM, 0); | |
| 2535 | 2556 | } |
| 2536 | - inaddr.sin_port = htons(iPort); | |
| 2537 | - listener = socket(AF_INET, SOCK_STREAM, 0); | |
| 2538 | 2557 | if( listener<0 ){ |
| 2539 | 2558 | iPort++; |
| 2540 | 2559 | continue; |
| 2541 | 2560 | } |
| 2542 | 2561 | |
| 2543 | 2562 | /* if we can't terminate nicely, at least allow the socket to be reused */ |
| 2544 | 2563 | setsockopt(listener,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt)); |
| 2545 | - | |
| 2546 | - if( bind(listener, (struct sockaddr*)&inaddr, sizeof(inaddr))<0 ){ | |
| 2564 | + | |
| 2565 | + if( flags & HTTP_SERVER_UNIXDOMAINSOCK ){ | |
| 2566 | + rc = bind(listener, (struct sockaddr*)&uxaddr, sizeof(uxaddr)); | |
| 2567 | + }else{ | |
| 2568 | + rc = bind(listener, (struct sockaddr*)&inaddr, sizeof(inaddr)); | |
| 2569 | + } | |
| 2570 | + if( rc<0 ){ | |
| 2547 | 2571 | close(listener); |
| 2548 | 2572 | iPort++; |
| 2549 | 2573 | continue; |
| 2550 | 2574 | } |
| 2551 | 2575 | break; |
| 2552 | 2576 | } |
| 2553 | 2577 | if( iPort>mxPort ){ |
| 2554 | - if( mnPort==mxPort ){ | |
| 2578 | + if( flags & HTTP_SERVER_UNIXDOMAINSOCK ){ | |
| 2579 | + fossil_fatal("unable to listen on unix-domain socket %s", zIpAddr); | |
| 2580 | + }else if( mnPort==mxPort ){ | |
| 2555 | 2581 | fossil_fatal("unable to open listening socket on port %d", mnPort); |
| 2556 | 2582 | }else{ |
| 2557 | 2583 | fossil_fatal("unable to open listening socket on any" |
| 2558 | 2584 | " port in the range %d..%d", mnPort, mxPort); |
| 2559 | 2585 | } |
| 2560 | 2586 | } |
| 2561 | 2587 | if( iPort>mxPort ) return 1; |
| 2562 | 2588 | listen(listener,10); |
| 2563 | - fossil_print("Listening for %s requests on TCP port %d\n", | |
| 2564 | - (flags & HTTP_SERVER_SCGI)!=0 ? "SCGI" : | |
| 2565 | - g.httpUseSSL?"TLS-encrypted HTTPS":"HTTP", iPort); | |
| 2589 | + if( flags & HTTP_SERVER_UNIXDOMAINSOCK ){ | |
| 2590 | + fossil_print("Listening for %s requests on unix-domain socket %s\n", | |
| 2591 | + (flags & HTTP_SERVER_SCGI)!=0 ? "SCGI" : | |
| 2592 | + g.httpUseSSL?"TLS-encrypted HTTPS":"HTTP", zIpAddr); | |
| 2593 | + }else{ | |
| 2594 | + fossil_print("Listening for %s requests on TCP port %d\n", | |
| 2595 | + (flags & HTTP_SERVER_SCGI)!=0 ? "SCGI" : | |
| 2596 | + g.httpUseSSL?"TLS-encrypted HTTPS":"HTTP", iPort); | |
| 2597 | + } | |
| 2566 | 2598 | fflush(stdout); |
| 2567 | - if( zBrowser ){ | |
| 2599 | + if( zBrowser && (flags & HTTP_SERVER_UNIXDOMAINSOCK)==0 ){ | |
| 2568 | 2600 | assert( strstr(zBrowser,"%d")!=0 ); |
| 2569 | 2601 | zBrowser = mprintf(zBrowser /*works-like:"%d"*/, iPort); |
| 2570 | 2602 | #if defined(__CYGWIN__) |
| 2571 | 2603 | /* On Cygwin, we can do better than "echo" */ |
| 2572 | 2604 | if( fossil_strncmp(zBrowser, "echo ", 5)==0 ){ |
| 2573 | 2605 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -70,16 +70,18 @@ | |
| 70 | # endif |
| 71 | # include <winsock2.h> |
| 72 | # include <ws2tcpip.h> |
| 73 | #else |
| 74 | # include <sys/socket.h> |
| 75 | # include <netinet/in.h> |
| 76 | # include <arpa/inet.h> |
| 77 | # include <sys/times.h> |
| 78 | # include <sys/time.h> |
| 79 | # include <sys/wait.h> |
| 80 | # include <sys/select.h> |
| 81 | #endif |
| 82 | #ifdef __EMX__ |
| 83 | typedef int socklen_t; |
| 84 | #endif |
| 85 | #include <time.h> |
| @@ -2475,10 +2477,11 @@ | |
| 2475 | #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */ |
| 2476 | #define HTTP_SERVER_HAD_REPOSITORY 0x0004 /* Was the repository open? */ |
| 2477 | #define HTTP_SERVER_HAD_CHECKOUT 0x0008 /* Was a checkout open? */ |
| 2478 | #define HTTP_SERVER_REPOLIST 0x0010 /* Allow repo listing */ |
| 2479 | #define HTTP_SERVER_NOFORK 0x0020 /* Do not call fork() */ |
| 2480 | |
| 2481 | #endif /* INTERFACE */ |
| 2482 | |
| 2483 | /* |
| 2484 | ** Maximum number of child processes that we can have running |
| @@ -2515,58 +2518,87 @@ | |
| 2515 | socklen_t lenaddr; /* Length of the inaddr structure */ |
| 2516 | int child; /* PID of the child process */ |
| 2517 | int nchildren = 0; /* Number of child processes */ |
| 2518 | struct timeval delay; /* How long to wait inside select() */ |
| 2519 | struct sockaddr_in inaddr; /* The socket address */ |
| 2520 | int opt = 1; /* setsockopt flag */ |
| 2521 | int iPort = mnPort; |
| 2522 | |
| 2523 | while( iPort<=mxPort ){ |
| 2524 | memset(&inaddr, 0, sizeof(inaddr)); |
| 2525 | inaddr.sin_family = AF_INET; |
| 2526 | if( zIpAddr ){ |
| 2527 | inaddr.sin_addr.s_addr = inet_addr(zIpAddr); |
| 2528 | if( inaddr.sin_addr.s_addr == INADDR_NONE ){ |
| 2529 | fossil_fatal("not a valid IP address: %s", zIpAddr); |
| 2530 | } |
| 2531 | }else if( flags & HTTP_SERVER_LOCALHOST ){ |
| 2532 | inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
| 2533 | }else{ |
| 2534 | inaddr.sin_addr.s_addr = htonl(INADDR_ANY); |
| 2535 | } |
| 2536 | inaddr.sin_port = htons(iPort); |
| 2537 | listener = socket(AF_INET, SOCK_STREAM, 0); |
| 2538 | if( listener<0 ){ |
| 2539 | iPort++; |
| 2540 | continue; |
| 2541 | } |
| 2542 | |
| 2543 | /* if we can't terminate nicely, at least allow the socket to be reused */ |
| 2544 | setsockopt(listener,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt)); |
| 2545 | |
| 2546 | if( bind(listener, (struct sockaddr*)&inaddr, sizeof(inaddr))<0 ){ |
| 2547 | close(listener); |
| 2548 | iPort++; |
| 2549 | continue; |
| 2550 | } |
| 2551 | break; |
| 2552 | } |
| 2553 | if( iPort>mxPort ){ |
| 2554 | if( mnPort==mxPort ){ |
| 2555 | fossil_fatal("unable to open listening socket on port %d", mnPort); |
| 2556 | }else{ |
| 2557 | fossil_fatal("unable to open listening socket on any" |
| 2558 | " port in the range %d..%d", mnPort, mxPort); |
| 2559 | } |
| 2560 | } |
| 2561 | if( iPort>mxPort ) return 1; |
| 2562 | listen(listener,10); |
| 2563 | fossil_print("Listening for %s requests on TCP port %d\n", |
| 2564 | (flags & HTTP_SERVER_SCGI)!=0 ? "SCGI" : |
| 2565 | g.httpUseSSL?"TLS-encrypted HTTPS":"HTTP", iPort); |
| 2566 | fflush(stdout); |
| 2567 | if( zBrowser ){ |
| 2568 | assert( strstr(zBrowser,"%d")!=0 ); |
| 2569 | zBrowser = mprintf(zBrowser /*works-like:"%d"*/, iPort); |
| 2570 | #if defined(__CYGWIN__) |
| 2571 | /* On Cygwin, we can do better than "echo" */ |
| 2572 | if( fossil_strncmp(zBrowser, "echo ", 5)==0 ){ |
| 2573 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -70,16 +70,18 @@ | |
| 70 | # endif |
| 71 | # include <winsock2.h> |
| 72 | # include <ws2tcpip.h> |
| 73 | #else |
| 74 | # include <sys/socket.h> |
| 75 | # include <sys/un.h> |
| 76 | # include <netinet/in.h> |
| 77 | # include <arpa/inet.h> |
| 78 | # include <sys/times.h> |
| 79 | # include <sys/time.h> |
| 80 | # include <sys/wait.h> |
| 81 | # include <sys/select.h> |
| 82 | # include <errno.h> |
| 83 | #endif |
| 84 | #ifdef __EMX__ |
| 85 | typedef int socklen_t; |
| 86 | #endif |
| 87 | #include <time.h> |
| @@ -2475,10 +2477,11 @@ | |
| 2477 | #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */ |
| 2478 | #define HTTP_SERVER_HAD_REPOSITORY 0x0004 /* Was the repository open? */ |
| 2479 | #define HTTP_SERVER_HAD_CHECKOUT 0x0008 /* Was a checkout open? */ |
| 2480 | #define HTTP_SERVER_REPOLIST 0x0010 /* Allow repo listing */ |
| 2481 | #define HTTP_SERVER_NOFORK 0x0020 /* Do not call fork() */ |
| 2482 | #define HTTP_SERVER_UNIXDOMAINSOCK 0x0040 /* Use a unix-domain socket */ |
| 2483 | |
| 2484 | #endif /* INTERFACE */ |
| 2485 | |
| 2486 | /* |
| 2487 | ** Maximum number of child processes that we can have running |
| @@ -2515,58 +2518,87 @@ | |
| 2518 | socklen_t lenaddr; /* Length of the inaddr structure */ |
| 2519 | int child; /* PID of the child process */ |
| 2520 | int nchildren = 0; /* Number of child processes */ |
| 2521 | struct timeval delay; /* How long to wait inside select() */ |
| 2522 | struct sockaddr_in inaddr; /* The socket address */ |
| 2523 | struct sockaddr_un uxaddr; /* The address for unix-domain sockets */ |
| 2524 | int opt = 1; /* setsockopt flag */ |
| 2525 | int rc; /* Result code from system calls */ |
| 2526 | int iPort = mnPort; /* Port to try to use */ |
| 2527 | |
| 2528 | while( iPort<=mxPort ){ |
| 2529 | if( flags & HTTP_SERVER_UNIXDOMAINSOCK ){ |
| 2530 | memset(&uxaddr, 0, sizeof(uxaddr)); |
| 2531 | if( strlen(zIpAddr)>sizeof(uxaddr.sun_path) ){ |
| 2532 | fossil_fatal("name of unix-domain socket too big: %s\n" |
| 2533 | "max size: %d\n", zIpAddr, (int)sizeof(uxaddr.sun_path)); |
| 2534 | } |
| 2535 | if( unlink(zIpAddr)==-1 && errno!=ENOENT ){ |
| 2536 | fossil_fatal("Cannot remove existing file at %s\n", zIpAddr); |
| 2537 | } |
| 2538 | uxaddr.sun_family = AF_UNIX; |
| 2539 | strncpy(uxaddr.sun_path, zIpAddr, sizeof(uxaddr.sun_path)-1); |
| 2540 | listener = socket(AF_UNIX, SOCK_STREAM, 0); |
| 2541 | }else{ |
| 2542 | memset(&inaddr, 0, sizeof(inaddr)); |
| 2543 | inaddr.sin_family = AF_INET; |
| 2544 | if( zIpAddr ){ |
| 2545 | inaddr.sin_addr.s_addr = inet_addr(zIpAddr); |
| 2546 | if( inaddr.sin_addr.s_addr == INADDR_NONE ){ |
| 2547 | fossil_fatal("not a valid IP address: %s", zIpAddr); |
| 2548 | } |
| 2549 | }else if( flags & HTTP_SERVER_LOCALHOST ){ |
| 2550 | inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
| 2551 | }else{ |
| 2552 | inaddr.sin_addr.s_addr = htonl(INADDR_ANY); |
| 2553 | } |
| 2554 | inaddr.sin_port = htons(iPort); |
| 2555 | listener = socket(AF_INET, SOCK_STREAM, 0); |
| 2556 | } |
| 2557 | if( listener<0 ){ |
| 2558 | iPort++; |
| 2559 | continue; |
| 2560 | } |
| 2561 | |
| 2562 | /* if we can't terminate nicely, at least allow the socket to be reused */ |
| 2563 | setsockopt(listener,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt)); |
| 2564 | |
| 2565 | if( flags & HTTP_SERVER_UNIXDOMAINSOCK ){ |
| 2566 | rc = bind(listener, (struct sockaddr*)&uxaddr, sizeof(uxaddr)); |
| 2567 | }else{ |
| 2568 | rc = bind(listener, (struct sockaddr*)&inaddr, sizeof(inaddr)); |
| 2569 | } |
| 2570 | if( rc<0 ){ |
| 2571 | close(listener); |
| 2572 | iPort++; |
| 2573 | continue; |
| 2574 | } |
| 2575 | break; |
| 2576 | } |
| 2577 | if( iPort>mxPort ){ |
| 2578 | if( flags & HTTP_SERVER_UNIXDOMAINSOCK ){ |
| 2579 | fossil_fatal("unable to listen on unix-domain socket %s", zIpAddr); |
| 2580 | }else if( mnPort==mxPort ){ |
| 2581 | fossil_fatal("unable to open listening socket on port %d", mnPort); |
| 2582 | }else{ |
| 2583 | fossil_fatal("unable to open listening socket on any" |
| 2584 | " port in the range %d..%d", mnPort, mxPort); |
| 2585 | } |
| 2586 | } |
| 2587 | if( iPort>mxPort ) return 1; |
| 2588 | listen(listener,10); |
| 2589 | if( flags & HTTP_SERVER_UNIXDOMAINSOCK ){ |
| 2590 | fossil_print("Listening for %s requests on unix-domain socket %s\n", |
| 2591 | (flags & HTTP_SERVER_SCGI)!=0 ? "SCGI" : |
| 2592 | g.httpUseSSL?"TLS-encrypted HTTPS":"HTTP", zIpAddr); |
| 2593 | }else{ |
| 2594 | fossil_print("Listening for %s requests on TCP port %d\n", |
| 2595 | (flags & HTTP_SERVER_SCGI)!=0 ? "SCGI" : |
| 2596 | g.httpUseSSL?"TLS-encrypted HTTPS":"HTTP", iPort); |
| 2597 | } |
| 2598 | fflush(stdout); |
| 2599 | if( zBrowser && (flags & HTTP_SERVER_UNIXDOMAINSOCK)==0 ){ |
| 2600 | assert( strstr(zBrowser,"%d")!=0 ); |
| 2601 | zBrowser = mprintf(zBrowser /*works-like:"%d"*/, iPort); |
| 2602 | #if defined(__CYGWIN__) |
| 2603 | /* On Cygwin, we can do better than "echo" */ |
| 2604 | if( fossil_strncmp(zBrowser, "echo ", 5)==0 ){ |
| 2605 |
+16
-1
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -3186,10 +3186,12 @@ | ||
| 3186 | 3186 | ** --repolist If REPOSITORY is dir, URL "/" lists repos |
| 3187 | 3187 | ** --scgi Accept SCGI rather than HTTP |
| 3188 | 3188 | ** --skin LABEL Use override skin LABEL, or the site's default skin if |
| 3189 | 3189 | ** LABEL is an empty string. |
| 3190 | 3190 | ** --th-trace Trace TH1 execution (for debugging purposes) |
| 3191 | +** --unix-socket NAME Listen on unix-domain socket NAME rather than on a | |
| 3192 | +** TCP/IP port. | |
| 3191 | 3193 | ** --usepidkey Use saved encryption key from parent process. This is |
| 3192 | 3194 | ** only necessary when using SEE on Windows or Linux. |
| 3193 | 3195 | ** |
| 3194 | 3196 | ** See also: [[cgi]], [[http]], [[winsrv]] |
| 3195 | 3197 | */ |
| @@ -3207,11 +3209,11 @@ | ||
| 3207 | 3209 | const char *zTimeout = 0; /* Max runtime of any single HTTP request */ |
| 3208 | 3210 | #endif |
| 3209 | 3211 | int allowRepoList; /* List repositories on URL "/" */ |
| 3210 | 3212 | const char *zAltBase; /* Argument to the --baseurl option */ |
| 3211 | 3213 | const char *zFileGlob; /* Static content must match this */ |
| 3212 | - char *zIpAddr = 0; /* Bind to this IP address */ | |
| 3214 | + char *zIpAddr = 0; /* Bind to this IP address or UN socket */ | |
| 3213 | 3215 | int fCreate = 0; /* The --create flag */ |
| 3214 | 3216 | int fNoBrowser = 0; /* Do not auto-launch web-browser */ |
| 3215 | 3217 | const char *zInitPage = 0; /* Start on this page. --page option */ |
| 3216 | 3218 | int findServerArg = 2; /* argv index for find_server_repository() */ |
| 3217 | 3219 | char *zRemote = 0; /* Remote host on which to run "fossil ui" */ |
| @@ -3283,10 +3285,23 @@ | ||
| 3283 | 3285 | g.zMainMenuFile = find_option("mainmenu",0,1); |
| 3284 | 3286 | if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){ |
| 3285 | 3287 | fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile); |
| 3286 | 3288 | } |
| 3287 | 3289 | if( find_option("acme",0,0)!=0 ) g.fAllowACME = 1; |
| 3290 | + zIpAddr = (char*)find_option("unix-socket",0,1); | |
| 3291 | + if( zIpAddr ){ | |
| 3292 | +#if defined(_WIN32) | |
| 3293 | + fossil_fatal("unix sockets are not supported on Windows"); | |
| 3294 | +#endif | |
| 3295 | + if( zPort ){ | |
| 3296 | + fossil_fatal("cannot specify a port number for a unix socket"); | |
| 3297 | + } | |
| 3298 | + if( isUiCmd && !fNoBrowser ){ | |
| 3299 | + fossil_fatal("cannot start a web-browser on a unix socket"); | |
| 3300 | + } | |
| 3301 | + flags |= HTTP_SERVER_UNIXDOMAINSOCK; | |
| 3302 | + } | |
| 3288 | 3303 | |
| 3289 | 3304 | /* Undocumented option: --debug-nofork |
| 3290 | 3305 | ** |
| 3291 | 3306 | ** This sets the HTTP_SERVER_NOFORK flag, which causes only the |
| 3292 | 3307 | ** very first incoming TCP/IP connection to be processed. Used for |
| 3293 | 3308 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -3186,10 +3186,12 @@ | |
| 3186 | ** --repolist If REPOSITORY is dir, URL "/" lists repos |
| 3187 | ** --scgi Accept SCGI rather than HTTP |
| 3188 | ** --skin LABEL Use override skin LABEL, or the site's default skin if |
| 3189 | ** LABEL is an empty string. |
| 3190 | ** --th-trace Trace TH1 execution (for debugging purposes) |
| 3191 | ** --usepidkey Use saved encryption key from parent process. This is |
| 3192 | ** only necessary when using SEE on Windows or Linux. |
| 3193 | ** |
| 3194 | ** See also: [[cgi]], [[http]], [[winsrv]] |
| 3195 | */ |
| @@ -3207,11 +3209,11 @@ | |
| 3207 | const char *zTimeout = 0; /* Max runtime of any single HTTP request */ |
| 3208 | #endif |
| 3209 | int allowRepoList; /* List repositories on URL "/" */ |
| 3210 | const char *zAltBase; /* Argument to the --baseurl option */ |
| 3211 | const char *zFileGlob; /* Static content must match this */ |
| 3212 | char *zIpAddr = 0; /* Bind to this IP address */ |
| 3213 | int fCreate = 0; /* The --create flag */ |
| 3214 | int fNoBrowser = 0; /* Do not auto-launch web-browser */ |
| 3215 | const char *zInitPage = 0; /* Start on this page. --page option */ |
| 3216 | int findServerArg = 2; /* argv index for find_server_repository() */ |
| 3217 | char *zRemote = 0; /* Remote host on which to run "fossil ui" */ |
| @@ -3283,10 +3285,23 @@ | |
| 3283 | g.zMainMenuFile = find_option("mainmenu",0,1); |
| 3284 | if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){ |
| 3285 | fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile); |
| 3286 | } |
| 3287 | if( find_option("acme",0,0)!=0 ) g.fAllowACME = 1; |
| 3288 | |
| 3289 | /* Undocumented option: --debug-nofork |
| 3290 | ** |
| 3291 | ** This sets the HTTP_SERVER_NOFORK flag, which causes only the |
| 3292 | ** very first incoming TCP/IP connection to be processed. Used for |
| 3293 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -3186,10 +3186,12 @@ | |
| 3186 | ** --repolist If REPOSITORY is dir, URL "/" lists repos |
| 3187 | ** --scgi Accept SCGI rather than HTTP |
| 3188 | ** --skin LABEL Use override skin LABEL, or the site's default skin if |
| 3189 | ** LABEL is an empty string. |
| 3190 | ** --th-trace Trace TH1 execution (for debugging purposes) |
| 3191 | ** --unix-socket NAME Listen on unix-domain socket NAME rather than on a |
| 3192 | ** TCP/IP port. |
| 3193 | ** --usepidkey Use saved encryption key from parent process. This is |
| 3194 | ** only necessary when using SEE on Windows or Linux. |
| 3195 | ** |
| 3196 | ** See also: [[cgi]], [[http]], [[winsrv]] |
| 3197 | */ |
| @@ -3207,11 +3209,11 @@ | |
| 3209 | const char *zTimeout = 0; /* Max runtime of any single HTTP request */ |
| 3210 | #endif |
| 3211 | int allowRepoList; /* List repositories on URL "/" */ |
| 3212 | const char *zAltBase; /* Argument to the --baseurl option */ |
| 3213 | const char *zFileGlob; /* Static content must match this */ |
| 3214 | char *zIpAddr = 0; /* Bind to this IP address or UN socket */ |
| 3215 | int fCreate = 0; /* The --create flag */ |
| 3216 | int fNoBrowser = 0; /* Do not auto-launch web-browser */ |
| 3217 | const char *zInitPage = 0; /* Start on this page. --page option */ |
| 3218 | int findServerArg = 2; /* argv index for find_server_repository() */ |
| 3219 | char *zRemote = 0; /* Remote host on which to run "fossil ui" */ |
| @@ -3283,10 +3285,23 @@ | |
| 3285 | g.zMainMenuFile = find_option("mainmenu",0,1); |
| 3286 | if( g.zMainMenuFile!=0 && file_size(g.zMainMenuFile,ExtFILE)<0 ){ |
| 3287 | fossil_fatal("Cannot read --mainmenu file %s", g.zMainMenuFile); |
| 3288 | } |
| 3289 | if( find_option("acme",0,0)!=0 ) g.fAllowACME = 1; |
| 3290 | zIpAddr = (char*)find_option("unix-socket",0,1); |
| 3291 | if( zIpAddr ){ |
| 3292 | #if defined(_WIN32) |
| 3293 | fossil_fatal("unix sockets are not supported on Windows"); |
| 3294 | #endif |
| 3295 | if( zPort ){ |
| 3296 | fossil_fatal("cannot specify a port number for a unix socket"); |
| 3297 | } |
| 3298 | if( isUiCmd && !fNoBrowser ){ |
| 3299 | fossil_fatal("cannot start a web-browser on a unix socket"); |
| 3300 | } |
| 3301 | flags |= HTTP_SERVER_UNIXDOMAINSOCK; |
| 3302 | } |
| 3303 | |
| 3304 | /* Undocumented option: --debug-nofork |
| 3305 | ** |
| 3306 | ** This sets the HTTP_SERVER_NOFORK flag, which causes only the |
| 3307 | ** very first incoming TCP/IP connection to be processed. Used for |
| 3308 |