Fossil SCM

Improvements to "fossil ui HOST:PATH".

drh 2021-06-30 20:15 remote-ui
Commit cff1f785e1000c5aaca270ddb21fc69d5de00ba042ebb7d4d632773b6196c63c
1 file changed +13 -5
+13 -5
--- src/main.c
+++ src/main.c
@@ -2821,11 +2821,11 @@
28212821
** timeline by default. This only works for the "fossil ui" command,
28222822
** not the "fossil server" command.
28232823
**
28242824
** If the REPOSITORY argument has a "HOST:" or "USER@HOST:" prefix, then
28252825
** 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
28272827
** the "fossil ui" command, not the "fossil server" command.
28282828
**
28292829
** For the special case REPOSITORY name of "/", the global configuration
28302830
** database is consulted for a list of all known repositories. The --repolist
28312831
** option is implied by this special case. See also the "fossil all ui"
@@ -2861,10 +2861,12 @@
28612861
** and bundled modes might result in a single
28622862
** amalgamated script or several, but both approaches
28632863
** result in fewer HTTP requests than the separate mode.
28642864
** --max-latency N Do not let any single HTTP request run for more than N
28652865
** seconds (only works on unix)
2866
+** --nobrowser Do not automatically launch a web-browser for the
2867
+** "fossil ui" command.
28662868
** --nocompress Do not compress HTTP replies
28672869
** --nojail Drop root privileges but do not enter the chroot jail
28682870
** --nossl signal that no SSL connections are available (Always
28692871
** set by default for the "ui" command)
28702872
** --notfound URL Redirect
@@ -2896,10 +2898,11 @@
28962898
int allowRepoList; /* List repositories on URL "/" */
28972899
const char *zAltBase; /* Argument to the --baseurl option */
28982900
const char *zFileGlob; /* Static content must match this */
28992901
char *zIpAddr = 0; /* Bind to this IP address */
29002902
int fCreate = 0; /* The --create flag */
2903
+ int fNoBrowser = 0; /* Do not auto-launch web-browser */
29012904
const char *zInitPage = 0; /* Start on this page. --page option */
29022905
int findServerArg = 2; /* argv index for find_server_repository() */
29032906
char *zRemote = 0; /* Remote host on which to run "fossil ui" */
29042907
29052908
@@ -2941,10 +2944,11 @@
29412944
if( find_option("scgi", 0, 0)!=0 ) flags |= HTTP_SERVER_SCGI;
29422945
if( zAltBase ){
29432946
set_base_url(zAltBase);
29442947
}
29452948
g.sslNotAvailable = find_option("nossl", 0, 0)!=0 || isUiCmd;
2949
+ fNoBrowser = find_option("nobrowser", 0, 0)!=0;
29462950
if( find_option("https",0,0)!=0 ){
29472951
cgi_replace_parameter("HTTPS","on");
29482952
}
29492953
if( find_option("localhost", 0, 0)!=0 ){
29502954
flags |= HTTP_SERVER_LOCALHOST;
@@ -2984,10 +2988,11 @@
29842988
}
29852989
}
29862990
if( isUiCmd && 3==g.argc
29872991
&& (zRemote = (char*)file_skip_userhost(g.argv[2]))!=0
29882992
){
2993
+ /* The REPOSITORY argument has a USER@HOST: or HOST: prefix */
29892994
const char *zRepoTail = file_skip_userhost(g.argv[2]);
29902995
unsigned x;
29912996
int n;
29922997
sqlite3_randomness(2,&x);
29932998
zPort = mprintf("%d", 8100+(x%32000));
@@ -3026,11 +3031,11 @@
30263031
iPort = mxPort = atoi(zPort);
30273032
}else{
30283033
iPort = db_get_int("http-port", 8080);
30293034
mxPort = iPort+100;
30303035
}
3031
- if( isUiCmd ){
3036
+ if( isUiCmd && !fNoBrowser ){
30323037
char *zBrowserArg;
30333038
zBrowser = fossil_web_browser();
30343039
if( zIpAddr==0 ){
30353040
zBrowserArg = mprintf("http://localhost:%%d/%s", zInitPage);
30363041
}else if( strchr(zIpAddr,':') ){
@@ -3043,27 +3048,30 @@
30433048
#else
30443049
zBrowserCmd = mprintf("%s %!$ &", zBrowser, zBrowserArg);
30453050
#endif
30463051
fossil_free(zBrowserArg);
30473052
}
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. */
30493057
FILE *sshIn;
30503058
Blob ssh;
30513059
char zLine[1000];
30523060
blob_init(&ssh, 0, 0);
30533061
transport_ssh_command(&ssh);
30543062
blob_appendf(&ssh,
30553063
" -t -L127.0.0.1:%d:127.0.0.1:%d -- %!$"
3056
- " fossil server --nossl --port %d %!$",
3064
+ " fossil ui --nobrowser --localauth --port %d %$",
30573065
iPort, iPort, zRemote, iPort, g.argv[2]);
30583066
fossil_print("%s\n", blob_str(&ssh));
30593067
sshIn = popen(blob_str(&ssh), "r");
30603068
if( sshIn==0 ){
30613069
fossil_fatal("unable to %s", blob_str(&ssh));
30623070
}
30633071
while( fgets(zLine, sizeof(zLine), sshIn) ){
3064
- fossil_print("%s", zLine);
3072
+ fputs(zLine, stdout);
30653073
fflush(stdout);
30663074
if( zBrowserCmd ){
30673075
char *zCmd = mprintf(zBrowserCmd/*works-like:"%d"*/,iPort);
30683076
fossil_system(zCmd);
30693077
fossil_free(zCmd);
30703078
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button