Fossil SCM
Improvements to "fossil ui HOST:PATH".
Commit
cff1f785e1000c5aaca270ddb21fc69d5de00ba042ebb7d4d632773b6196c63c
Parent
cb34f1a8ac57ea7…
1 file changed
+13
-5
+13
-5
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -2821,11 +2821,11 @@ | ||
| 2821 | 2821 | ** timeline by default. This only works for the "fossil ui" command, |
| 2822 | 2822 | ** not the "fossil server" command. |
| 2823 | 2823 | ** |
| 2824 | 2824 | ** If the REPOSITORY argument has a "HOST:" or "USER@HOST:" prefix, then |
| 2825 | 2825 | ** the command is run on the remote host specified and the results are |
| 2826 | -** tunneled back to the localhost via SSH. This feature only works for | |
| 2826 | +** tunneled back to the local host via SSH. This feature only works for | |
| 2827 | 2827 | ** the "fossil ui" command, not the "fossil server" command. |
| 2828 | 2828 | ** |
| 2829 | 2829 | ** For the special case REPOSITORY name of "/", the global configuration |
| 2830 | 2830 | ** database is consulted for a list of all known repositories. The --repolist |
| 2831 | 2831 | ** option is implied by this special case. See also the "fossil all ui" |
| @@ -2861,10 +2861,12 @@ | ||
| 2861 | 2861 | ** and bundled modes might result in a single |
| 2862 | 2862 | ** amalgamated script or several, but both approaches |
| 2863 | 2863 | ** result in fewer HTTP requests than the separate mode. |
| 2864 | 2864 | ** --max-latency N Do not let any single HTTP request run for more than N |
| 2865 | 2865 | ** seconds (only works on unix) |
| 2866 | +** --nobrowser Do not automatically launch a web-browser for the | |
| 2867 | +** "fossil ui" command. | |
| 2866 | 2868 | ** --nocompress Do not compress HTTP replies |
| 2867 | 2869 | ** --nojail Drop root privileges but do not enter the chroot jail |
| 2868 | 2870 | ** --nossl signal that no SSL connections are available (Always |
| 2869 | 2871 | ** set by default for the "ui" command) |
| 2870 | 2872 | ** --notfound URL Redirect |
| @@ -2896,10 +2898,11 @@ | ||
| 2896 | 2898 | int allowRepoList; /* List repositories on URL "/" */ |
| 2897 | 2899 | const char *zAltBase; /* Argument to the --baseurl option */ |
| 2898 | 2900 | const char *zFileGlob; /* Static content must match this */ |
| 2899 | 2901 | char *zIpAddr = 0; /* Bind to this IP address */ |
| 2900 | 2902 | int fCreate = 0; /* The --create flag */ |
| 2903 | + int fNoBrowser = 0; /* Do not auto-launch web-browser */ | |
| 2901 | 2904 | const char *zInitPage = 0; /* Start on this page. --page option */ |
| 2902 | 2905 | int findServerArg = 2; /* argv index for find_server_repository() */ |
| 2903 | 2906 | char *zRemote = 0; /* Remote host on which to run "fossil ui" */ |
| 2904 | 2907 | |
| 2905 | 2908 | |
| @@ -2941,10 +2944,11 @@ | ||
| 2941 | 2944 | if( find_option("scgi", 0, 0)!=0 ) flags |= HTTP_SERVER_SCGI; |
| 2942 | 2945 | if( zAltBase ){ |
| 2943 | 2946 | set_base_url(zAltBase); |
| 2944 | 2947 | } |
| 2945 | 2948 | g.sslNotAvailable = find_option("nossl", 0, 0)!=0 || isUiCmd; |
| 2949 | + fNoBrowser = find_option("nobrowser", 0, 0)!=0; | |
| 2946 | 2950 | if( find_option("https",0,0)!=0 ){ |
| 2947 | 2951 | cgi_replace_parameter("HTTPS","on"); |
| 2948 | 2952 | } |
| 2949 | 2953 | if( find_option("localhost", 0, 0)!=0 ){ |
| 2950 | 2954 | flags |= HTTP_SERVER_LOCALHOST; |
| @@ -2984,10 +2988,11 @@ | ||
| 2984 | 2988 | } |
| 2985 | 2989 | } |
| 2986 | 2990 | if( isUiCmd && 3==g.argc |
| 2987 | 2991 | && (zRemote = (char*)file_skip_userhost(g.argv[2]))!=0 |
| 2988 | 2992 | ){ |
| 2993 | + /* The REPOSITORY argument has a USER@HOST: or HOST: prefix */ | |
| 2989 | 2994 | const char *zRepoTail = file_skip_userhost(g.argv[2]); |
| 2990 | 2995 | unsigned x; |
| 2991 | 2996 | int n; |
| 2992 | 2997 | sqlite3_randomness(2,&x); |
| 2993 | 2998 | zPort = mprintf("%d", 8100+(x%32000)); |
| @@ -3026,11 +3031,11 @@ | ||
| 3026 | 3031 | iPort = mxPort = atoi(zPort); |
| 3027 | 3032 | }else{ |
| 3028 | 3033 | iPort = db_get_int("http-port", 8080); |
| 3029 | 3034 | mxPort = iPort+100; |
| 3030 | 3035 | } |
| 3031 | - if( isUiCmd ){ | |
| 3036 | + if( isUiCmd && !fNoBrowser ){ | |
| 3032 | 3037 | char *zBrowserArg; |
| 3033 | 3038 | zBrowser = fossil_web_browser(); |
| 3034 | 3039 | if( zIpAddr==0 ){ |
| 3035 | 3040 | zBrowserArg = mprintf("http://localhost:%%d/%s", zInitPage); |
| 3036 | 3041 | }else if( strchr(zIpAddr,':') ){ |
| @@ -3043,27 +3048,30 @@ | ||
| 3043 | 3048 | #else |
| 3044 | 3049 | zBrowserCmd = mprintf("%s %!$ &", zBrowser, zBrowserArg); |
| 3045 | 3050 | #endif |
| 3046 | 3051 | fossil_free(zBrowserArg); |
| 3047 | 3052 | } |
| 3048 | - if( zRemote && zBrowserCmd ){ | |
| 3053 | + if( zRemote ){ | |
| 3054 | + /* If a USER@HOST:REPO argument is supplied, then use SSH to run | |
| 3055 | + ** "fossil ui --nobrowser" on the remote system and to set up a | |
| 3056 | + ** tunnel from the local machine to the remote. */ | |
| 3049 | 3057 | FILE *sshIn; |
| 3050 | 3058 | Blob ssh; |
| 3051 | 3059 | char zLine[1000]; |
| 3052 | 3060 | blob_init(&ssh, 0, 0); |
| 3053 | 3061 | transport_ssh_command(&ssh); |
| 3054 | 3062 | blob_appendf(&ssh, |
| 3055 | 3063 | " -t -L127.0.0.1:%d:127.0.0.1:%d -- %!$" |
| 3056 | - " fossil server --nossl --port %d %!$", | |
| 3064 | + " fossil ui --nobrowser --localauth --port %d %$", | |
| 3057 | 3065 | iPort, iPort, zRemote, iPort, g.argv[2]); |
| 3058 | 3066 | fossil_print("%s\n", blob_str(&ssh)); |
| 3059 | 3067 | sshIn = popen(blob_str(&ssh), "r"); |
| 3060 | 3068 | if( sshIn==0 ){ |
| 3061 | 3069 | fossil_fatal("unable to %s", blob_str(&ssh)); |
| 3062 | 3070 | } |
| 3063 | 3071 | while( fgets(zLine, sizeof(zLine), sshIn) ){ |
| 3064 | - fossil_print("%s", zLine); | |
| 3072 | + fputs(zLine, stdout); | |
| 3065 | 3073 | fflush(stdout); |
| 3066 | 3074 | if( zBrowserCmd ){ |
| 3067 | 3075 | char *zCmd = mprintf(zBrowserCmd/*works-like:"%d"*/,iPort); |
| 3068 | 3076 | fossil_system(zCmd); |
| 3069 | 3077 | fossil_free(zCmd); |
| 3070 | 3078 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -2821,11 +2821,11 @@ | |
| 2821 | ** timeline by default. This only works for the "fossil ui" command, |
| 2822 | ** not the "fossil server" command. |
| 2823 | ** |
| 2824 | ** If the REPOSITORY argument has a "HOST:" or "USER@HOST:" prefix, then |
| 2825 | ** the command is run on the remote host specified and the results are |
| 2826 | ** tunneled back to the localhost via SSH. This feature only works for |
| 2827 | ** the "fossil ui" command, not the "fossil server" command. |
| 2828 | ** |
| 2829 | ** For the special case REPOSITORY name of "/", the global configuration |
| 2830 | ** database is consulted for a list of all known repositories. The --repolist |
| 2831 | ** option is implied by this special case. See also the "fossil all ui" |
| @@ -2861,10 +2861,12 @@ | |
| 2861 | ** and bundled modes might result in a single |
| 2862 | ** amalgamated script or several, but both approaches |
| 2863 | ** result in fewer HTTP requests than the separate mode. |
| 2864 | ** --max-latency N Do not let any single HTTP request run for more than N |
| 2865 | ** seconds (only works on unix) |
| 2866 | ** --nocompress Do not compress HTTP replies |
| 2867 | ** --nojail Drop root privileges but do not enter the chroot jail |
| 2868 | ** --nossl signal that no SSL connections are available (Always |
| 2869 | ** set by default for the "ui" command) |
| 2870 | ** --notfound URL Redirect |
| @@ -2896,10 +2898,11 @@ | |
| 2896 | int allowRepoList; /* List repositories on URL "/" */ |
| 2897 | const char *zAltBase; /* Argument to the --baseurl option */ |
| 2898 | const char *zFileGlob; /* Static content must match this */ |
| 2899 | char *zIpAddr = 0; /* Bind to this IP address */ |
| 2900 | int fCreate = 0; /* The --create flag */ |
| 2901 | const char *zInitPage = 0; /* Start on this page. --page option */ |
| 2902 | int findServerArg = 2; /* argv index for find_server_repository() */ |
| 2903 | char *zRemote = 0; /* Remote host on which to run "fossil ui" */ |
| 2904 | |
| 2905 | |
| @@ -2941,10 +2944,11 @@ | |
| 2941 | if( find_option("scgi", 0, 0)!=0 ) flags |= HTTP_SERVER_SCGI; |
| 2942 | if( zAltBase ){ |
| 2943 | set_base_url(zAltBase); |
| 2944 | } |
| 2945 | g.sslNotAvailable = find_option("nossl", 0, 0)!=0 || isUiCmd; |
| 2946 | if( find_option("https",0,0)!=0 ){ |
| 2947 | cgi_replace_parameter("HTTPS","on"); |
| 2948 | } |
| 2949 | if( find_option("localhost", 0, 0)!=0 ){ |
| 2950 | flags |= HTTP_SERVER_LOCALHOST; |
| @@ -2984,10 +2988,11 @@ | |
| 2984 | } |
| 2985 | } |
| 2986 | if( isUiCmd && 3==g.argc |
| 2987 | && (zRemote = (char*)file_skip_userhost(g.argv[2]))!=0 |
| 2988 | ){ |
| 2989 | const char *zRepoTail = file_skip_userhost(g.argv[2]); |
| 2990 | unsigned x; |
| 2991 | int n; |
| 2992 | sqlite3_randomness(2,&x); |
| 2993 | zPort = mprintf("%d", 8100+(x%32000)); |
| @@ -3026,11 +3031,11 @@ | |
| 3026 | iPort = mxPort = atoi(zPort); |
| 3027 | }else{ |
| 3028 | iPort = db_get_int("http-port", 8080); |
| 3029 | mxPort = iPort+100; |
| 3030 | } |
| 3031 | if( isUiCmd ){ |
| 3032 | char *zBrowserArg; |
| 3033 | zBrowser = fossil_web_browser(); |
| 3034 | if( zIpAddr==0 ){ |
| 3035 | zBrowserArg = mprintf("http://localhost:%%d/%s", zInitPage); |
| 3036 | }else if( strchr(zIpAddr,':') ){ |
| @@ -3043,27 +3048,30 @@ | |
| 3043 | #else |
| 3044 | zBrowserCmd = mprintf("%s %!$ &", zBrowser, zBrowserArg); |
| 3045 | #endif |
| 3046 | fossil_free(zBrowserArg); |
| 3047 | } |
| 3048 | if( zRemote && zBrowserCmd ){ |
| 3049 | FILE *sshIn; |
| 3050 | Blob ssh; |
| 3051 | char zLine[1000]; |
| 3052 | blob_init(&ssh, 0, 0); |
| 3053 | transport_ssh_command(&ssh); |
| 3054 | blob_appendf(&ssh, |
| 3055 | " -t -L127.0.0.1:%d:127.0.0.1:%d -- %!$" |
| 3056 | " fossil server --nossl --port %d %!$", |
| 3057 | iPort, iPort, zRemote, iPort, g.argv[2]); |
| 3058 | fossil_print("%s\n", blob_str(&ssh)); |
| 3059 | sshIn = popen(blob_str(&ssh), "r"); |
| 3060 | if( sshIn==0 ){ |
| 3061 | fossil_fatal("unable to %s", blob_str(&ssh)); |
| 3062 | } |
| 3063 | while( fgets(zLine, sizeof(zLine), sshIn) ){ |
| 3064 | fossil_print("%s", zLine); |
| 3065 | fflush(stdout); |
| 3066 | if( zBrowserCmd ){ |
| 3067 | char *zCmd = mprintf(zBrowserCmd/*works-like:"%d"*/,iPort); |
| 3068 | fossil_system(zCmd); |
| 3069 | fossil_free(zCmd); |
| 3070 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -2821,11 +2821,11 @@ | |
| 2821 | ** timeline by default. This only works for the "fossil ui" command, |
| 2822 | ** not the "fossil server" command. |
| 2823 | ** |
| 2824 | ** If the REPOSITORY argument has a "HOST:" or "USER@HOST:" prefix, then |
| 2825 | ** the command is run on the remote host specified and the results are |
| 2826 | ** tunneled back to the local host via SSH. This feature only works for |
| 2827 | ** the "fossil ui" command, not the "fossil server" command. |
| 2828 | ** |
| 2829 | ** For the special case REPOSITORY name of "/", the global configuration |
| 2830 | ** database is consulted for a list of all known repositories. The --repolist |
| 2831 | ** option is implied by this special case. See also the "fossil all ui" |
| @@ -2861,10 +2861,12 @@ | |
| 2861 | ** and bundled modes might result in a single |
| 2862 | ** amalgamated script or several, but both approaches |
| 2863 | ** result in fewer HTTP requests than the separate mode. |
| 2864 | ** --max-latency N Do not let any single HTTP request run for more than N |
| 2865 | ** seconds (only works on unix) |
| 2866 | ** --nobrowser Do not automatically launch a web-browser for the |
| 2867 | ** "fossil ui" command. |
| 2868 | ** --nocompress Do not compress HTTP replies |
| 2869 | ** --nojail Drop root privileges but do not enter the chroot jail |
| 2870 | ** --nossl signal that no SSL connections are available (Always |
| 2871 | ** set by default for the "ui" command) |
| 2872 | ** --notfound URL Redirect |
| @@ -2896,10 +2898,11 @@ | |
| 2898 | int allowRepoList; /* List repositories on URL "/" */ |
| 2899 | const char *zAltBase; /* Argument to the --baseurl option */ |
| 2900 | const char *zFileGlob; /* Static content must match this */ |
| 2901 | char *zIpAddr = 0; /* Bind to this IP address */ |
| 2902 | int fCreate = 0; /* The --create flag */ |
| 2903 | int fNoBrowser = 0; /* Do not auto-launch web-browser */ |
| 2904 | const char *zInitPage = 0; /* Start on this page. --page option */ |
| 2905 | int findServerArg = 2; /* argv index for find_server_repository() */ |
| 2906 | char *zRemote = 0; /* Remote host on which to run "fossil ui" */ |
| 2907 | |
| 2908 | |
| @@ -2941,10 +2944,11 @@ | |
| 2944 | if( find_option("scgi", 0, 0)!=0 ) flags |= HTTP_SERVER_SCGI; |
| 2945 | if( zAltBase ){ |
| 2946 | set_base_url(zAltBase); |
| 2947 | } |
| 2948 | g.sslNotAvailable = find_option("nossl", 0, 0)!=0 || isUiCmd; |
| 2949 | fNoBrowser = find_option("nobrowser", 0, 0)!=0; |
| 2950 | if( find_option("https",0,0)!=0 ){ |
| 2951 | cgi_replace_parameter("HTTPS","on"); |
| 2952 | } |
| 2953 | if( find_option("localhost", 0, 0)!=0 ){ |
| 2954 | flags |= HTTP_SERVER_LOCALHOST; |
| @@ -2984,10 +2988,11 @@ | |
| 2988 | } |
| 2989 | } |
| 2990 | if( isUiCmd && 3==g.argc |
| 2991 | && (zRemote = (char*)file_skip_userhost(g.argv[2]))!=0 |
| 2992 | ){ |
| 2993 | /* The REPOSITORY argument has a USER@HOST: or HOST: prefix */ |
| 2994 | const char *zRepoTail = file_skip_userhost(g.argv[2]); |
| 2995 | unsigned x; |
| 2996 | int n; |
| 2997 | sqlite3_randomness(2,&x); |
| 2998 | zPort = mprintf("%d", 8100+(x%32000)); |
| @@ -3026,11 +3031,11 @@ | |
| 3031 | iPort = mxPort = atoi(zPort); |
| 3032 | }else{ |
| 3033 | iPort = db_get_int("http-port", 8080); |
| 3034 | mxPort = iPort+100; |
| 3035 | } |
| 3036 | if( isUiCmd && !fNoBrowser ){ |
| 3037 | char *zBrowserArg; |
| 3038 | zBrowser = fossil_web_browser(); |
| 3039 | if( zIpAddr==0 ){ |
| 3040 | zBrowserArg = mprintf("http://localhost:%%d/%s", zInitPage); |
| 3041 | }else if( strchr(zIpAddr,':') ){ |
| @@ -3043,27 +3048,30 @@ | |
| 3048 | #else |
| 3049 | zBrowserCmd = mprintf("%s %!$ &", zBrowser, zBrowserArg); |
| 3050 | #endif |
| 3051 | fossil_free(zBrowserArg); |
| 3052 | } |
| 3053 | if( zRemote ){ |
| 3054 | /* If a USER@HOST:REPO argument is supplied, then use SSH to run |
| 3055 | ** "fossil ui --nobrowser" on the remote system and to set up a |
| 3056 | ** tunnel from the local machine to the remote. */ |
| 3057 | FILE *sshIn; |
| 3058 | Blob ssh; |
| 3059 | char zLine[1000]; |
| 3060 | blob_init(&ssh, 0, 0); |
| 3061 | transport_ssh_command(&ssh); |
| 3062 | blob_appendf(&ssh, |
| 3063 | " -t -L127.0.0.1:%d:127.0.0.1:%d -- %!$" |
| 3064 | " fossil ui --nobrowser --localauth --port %d %$", |
| 3065 | iPort, iPort, zRemote, iPort, g.argv[2]); |
| 3066 | fossil_print("%s\n", blob_str(&ssh)); |
| 3067 | sshIn = popen(blob_str(&ssh), "r"); |
| 3068 | if( sshIn==0 ){ |
| 3069 | fossil_fatal("unable to %s", blob_str(&ssh)); |
| 3070 | } |
| 3071 | while( fgets(zLine, sizeof(zLine), sshIn) ){ |
| 3072 | fputs(zLine, stdout); |
| 3073 | fflush(stdout); |
| 3074 | if( zBrowserCmd ){ |
| 3075 | char *zCmd = mprintf(zBrowserCmd/*works-like:"%d"*/,iPort); |
| 3076 | fossil_system(zCmd); |
| 3077 | fossil_free(zCmd); |
| 3078 |