2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
|
** "*.fossil*" will be served as static content. With the "ui" command,
** the REPOSITORY can only be a directory if the --notfound option is
** also present.
**
** If the REPOSITORY is a directory name which is the root of a
** checkout, it will chdir to that directory and, unless overridden by
** the --page option, select the current checkout version in the
** timeline by default.
**
** For the special case REPOSITORY name of "/", the list global configuration
** database is consulted for a list of all known repositories. The --repolist
** option is implied by this special case. See also the "fossil all ui"
** command.
**
** By default, the "ui" command provides full administrative access without
** having to log in. This can be disabled by turning off the "localauth"
** setting. Automatic login for the "server" command is available if the
|
|
>
>
>
>
>
>
|
|
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
|
** "*.fossil*" will be served as static content. With the "ui" command,
** the REPOSITORY can only be a directory if the --notfound option is
** also present.
**
** If the REPOSITORY is a directory name which is the root of a
** checkout, it will chdir to that directory and, unless overridden by
** the --page option, select the current checkout version in the
** timeline by default. This only works for the "fossil ui" command,
** not the "fossil server" command.
**
** If the REPOSITORY argument has a "HOST:" or "USER@HOST:" prefix, then
** the command is run on the remote host specified and the results are
** tunneled back to the localhost via SSH. This feature only works for
** the "fossil ui" command, not the "fossil server" command.
**
** For the special case REPOSITORY name of "/", the global configuration
** database is consulted for a list of all known repositories. The --repolist
** option is implied by this special case. See also the "fossil all ui"
** command.
**
** By default, the "ui" command provides full administrative access without
** having to log in. This can be disabled by turning off the "localauth"
** setting. Automatic login for the "server" command is available if the
|
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
|
int allowRepoList; /* List repositories on URL "/" */
const char *zAltBase; /* Argument to the --baseurl option */
const char *zFileGlob; /* Static content must match this */
char *zIpAddr = 0; /* Bind to this IP address */
int fCreate = 0; /* The --create flag */
const char *zInitPage = 0; /* Start on this page. --page option */
int findServerArg = 2; /* argv index for find_server_repository() */
#if defined(_WIN32)
const char *zStopperFile; /* Name of file used to terminate server */
zStopperFile = find_option("stopper", 0, 1);
#endif
if( g.zErrlog==0 ){
|
>
>
|
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
|
int allowRepoList; /* List repositories on URL "/" */
const char *zAltBase; /* Argument to the --baseurl option */
const char *zFileGlob; /* Static content must match this */
char *zIpAddr = 0; /* Bind to this IP address */
int fCreate = 0; /* The --create flag */
const char *zInitPage = 0; /* Start on this page. --page option */
int findServerArg = 2; /* argv index for find_server_repository() */
char *zRemote = 0; /* Remote host on which to run "fossil ui" */
#if defined(_WIN32)
const char *zStopperFile; /* Name of file used to terminate server */
zStopperFile = find_option("stopper", 0, 1);
#endif
if( g.zErrlog==0 ){
|
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
|
}
findServerArg = 99;
fCreate = 0;
g.argv[2] = 0;
--g.argc;
}
}
if( isUiCmd ){
flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
g.useLocalauth = 1;
allowRepoList = 1;
}
find_server_repository(findServerArg, fCreate);
if( zInitPage==0 ){
if( isUiCmd && g.localOpen ){
zInitPage = "timeline?c=current";
}else{
zInitPage = "";
}
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
|
}
findServerArg = 99;
fCreate = 0;
g.argv[2] = 0;
--g.argc;
}
}
if( isUiCmd && 3==g.argc
&& (zRemote = (char*)file_skip_userhost(g.argv[2]))!=0
){
const char *zRepoTail = file_skip_userhost(g.argv[2]);
unsigned x;
int n;
sqlite3_randomness(2,&x);
zPort = mprintf("%d", 8100+(x%32000));
n = (int)(zRepoTail - g.argv[2]) - 1;
zRemote = mprintf("%.*s", n, g.argv[2]);
g.argv[2] = (char*)zRepoTail;
}
if( isUiCmd ){
flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
g.useLocalauth = 1;
allowRepoList = 1;
}
if( !zRemote ){
find_server_repository(findServerArg, fCreate);
}
if( zInitPage==0 ){
if( isUiCmd && g.localOpen ){
zInitPage = "timeline?c=current";
}else{
zInitPage = "";
}
}
|
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
|
}
}
iPort = mxPort = atoi(zPort);
}else{
iPort = db_get_int("http-port", 8080);
mxPort = iPort+100;
}
#if !defined(_WIN32)
/* Unix implementation */
if( isUiCmd ){
zBrowser = fossil_web_browser();
if( zIpAddr==0 ){
zBrowserCmd = mprintf("%s \"http://localhost:%%d/%s\" &",
zBrowser, zInitPage);
}else if( strchr(zIpAddr,':') ){
zBrowserCmd = mprintf("%s \"http://[%s]:%%d/%s\" &",
zBrowser, zIpAddr, zInitPage);
}else{
zBrowserCmd = mprintf("%s \"http://%s:%%d/%s\" &",
zBrowser, zIpAddr, zInitPage);
}
}
if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
db_close(1);
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
fossil_fatal("unable to listen on TCP socket %d", iPort);
}
/* For the parent process, the cgi_http_server() command above never
|
<
<
>
|
<
|
>
|
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
>
>
>
>
>
>
|
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
|
}
}
iPort = mxPort = atoi(zPort);
}else{
iPort = db_get_int("http-port", 8080);
mxPort = iPort+100;
}
if( isUiCmd ){
char *zBrowserArg;
zBrowser = fossil_web_browser();
if( zIpAddr==0 ){
zBrowserArg = mprintf("http://localhost:%%d/%s", zInitPage);
}else if( strchr(zIpAddr,':') ){
zBrowserArg = mprintf("http://[%s]:%%d/%s", zIpAddr, zInitPage);
}else{
zBrowserArg = mprintf("http://%s:%%d/%s", zIpAddr, zInitPage);
}
#ifdef _WIN32
zBrowserCmd = mprintf("%s %s &", zBrowser, zBrowserArg);
#else
zBrowserCmd = mprintf("%s %!$ &", zBrowser, zBrowserArg);
#endif
fossil_free(zBrowserArg);
}
if( zRemote && zBrowserCmd ){
FILE *sshIn;
Blob ssh;
char zLine[1000];
blob_init(&ssh, 0, 0);
transport_ssh_command(&ssh);
blob_appendf(&ssh,
" -t -L127.0.0.1:%d:127.0.0.1:%d -- %!$"
" fossil server --nossl --port %d %!$",
iPort, iPort, zRemote, iPort, g.argv[2]);
fossil_print("%s\n", blob_str(&ssh));
sshIn = popen(blob_str(&ssh), "r");
if( sshIn==0 ){
fossil_fatal("unable to %s", blob_str(&ssh));
}
while( fgets(zLine, sizeof(zLine), sshIn) ){
fossil_print("%s", zLine);
fflush(stdout);
if( zBrowserCmd ){
char *zCmd = mprintf(zBrowserCmd/*works-like:"%d"*/,iPort);
fossil_system(zCmd);
fossil_free(zCmd);
fossil_free(zBrowserCmd);
zBrowserCmd = 0;
}
}
pclose(sshIn);
fossil_free(zBrowserCmd);
return;
}
#if !defined(_WIN32)
/* Unix implementation */
if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
db_close(1);
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
fossil_fatal("unable to listen on TCP socket %d", iPort);
}
/* For the parent process, the cgi_http_server() command above never
|
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
|
process_one_web_page(zNotFound, glob_create(zFileGlob), allowRepoList);
if( g.fAnyTrace ){
fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
getpid());
}
#else
/* Win32 implementation */
if( isUiCmd ){
zBrowser = fossil_web_browser();
if( zIpAddr==0 ){
zBrowserCmd = mprintf("%s http://localhost:%%d/%s &",
zBrowser, zInitPage);
}else if( strchr(zIpAddr,':') ){
zBrowserCmd = mprintf("%s http://[%s]:%%d/%s &",
zBrowser, zIpAddr, zInitPage);
}else{
zBrowserCmd = mprintf("%s http://%s:%%d/%s &",
zBrowser, zIpAddr, zInitPage);
}
}
if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
db_close(1);
if( allowRepoList ){
flags |= HTTP_SERVER_REPOLIST;
}
if( win32_http_service(iPort, zAltBase, zNotFound, zFileGlob, flags) ){
|
<
<
<
<
<
<
<
<
<
<
<
<
<
|
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
|
process_one_web_page(zNotFound, glob_create(zFileGlob), allowRepoList);
if( g.fAnyTrace ){
fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
getpid());
}
#else
/* Win32 implementation */
if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
db_close(1);
if( allowRepoList ){
flags |= HTTP_SERVER_REPOLIST;
}
if( win32_http_service(iPort, zAltBase, zNotFound, zFileGlob, flags) ){
|