Fossil SCM

Initial changes to support HOST: prefixes on the REPOSITORY argument of the "fossil ui" command.

drh 2021-06-30 19:14 trunk
Commit cb34f1a8ac57ea78b397a70d3cdadfb562b1cabd056265aba714a64b151607d4
--- src/alerts.c
+++ src/alerts.c
@@ -397,17 +397,10 @@
397397
iCol += 3;
398398
}
399399
}
400400
}
401401
402
-#if defined(_WIN32) || defined(WIN32)
403
-# undef popen
404
-# define popen _popen
405
-# undef pclose
406
-# define pclose _pclose
407
-#endif
408
-
409402
#if INTERFACE
410403
/*
411404
** An instance of the following object is used to send emails.
412405
*/
413406
struct AlertSender {
414407
--- src/alerts.c
+++ src/alerts.c
@@ -397,17 +397,10 @@
397 iCol += 3;
398 }
399 }
400 }
401
402 #if defined(_WIN32) || defined(WIN32)
403 # undef popen
404 # define popen _popen
405 # undef pclose
406 # define pclose _pclose
407 #endif
408
409 #if INTERFACE
410 /*
411 ** An instance of the following object is used to send emails.
412 */
413 struct AlertSender {
414
--- src/alerts.c
+++ src/alerts.c
@@ -397,17 +397,10 @@
397 iCol += 3;
398 }
399 }
400 }
401
 
 
 
 
 
 
 
402 #if INTERFACE
403 /*
404 ** An instance of the following object is used to send emails.
405 */
406 struct AlertSender {
407
--- src/config.h
+++ src/config.h
@@ -66,10 +66,16 @@
6666
typedef int socklen_t;
6767
# endif
6868
# ifndef _WIN32
6969
# define _WIN32
7070
# endif
71
+# include <io.h>
72
+# include <fcntl.h>
73
+# undef popen
74
+# define popen _popen
75
+# undef pclose
76
+# define pclose _pclose
7177
#else
7278
# include <sys/types.h>
7379
# include <signal.h>
7480
# include <pwd.h>
7581
#endif
7682
--- src/config.h
+++ src/config.h
@@ -66,10 +66,16 @@
66 typedef int socklen_t;
67 # endif
68 # ifndef _WIN32
69 # define _WIN32
70 # endif
 
 
 
 
 
 
71 #else
72 # include <sys/types.h>
73 # include <signal.h>
74 # include <pwd.h>
75 #endif
76
--- src/config.h
+++ src/config.h
@@ -66,10 +66,16 @@
66 typedef int socklen_t;
67 # endif
68 # ifndef _WIN32
69 # define _WIN32
70 # endif
71 # include <io.h>
72 # include <fcntl.h>
73 # undef popen
74 # define popen _popen
75 # undef pclose
76 # define pclose _pclose
77 #else
78 # include <sys/types.h>
79 # include <signal.h>
80 # include <pwd.h>
81 #endif
82
--- src/export.c
+++ src/export.c
@@ -38,17 +38,10 @@
3838
int rid; /* Corresponding object in the BLOB table */
3939
char uuid[65]; /* The GIT hash name for this object */
4040
};
4141
#endif
4242
43
-#if defined(_WIN32) || defined(WIN32)
44
-# undef popen
45
-# define popen _popen
46
-# undef pclose
47
-# define pclose _pclose
48
-#endif
49
-
5043
/*
5144
** Output a "committer" record for the given user.
5245
** NOTE: the given user name may be an email itself.
5346
*/
5447
static void print_person(const char *zUser){
5548
--- src/export.c
+++ src/export.c
@@ -38,17 +38,10 @@
38 int rid; /* Corresponding object in the BLOB table */
39 char uuid[65]; /* The GIT hash name for this object */
40 };
41 #endif
42
43 #if defined(_WIN32) || defined(WIN32)
44 # undef popen
45 # define popen _popen
46 # undef pclose
47 # define pclose _pclose
48 #endif
49
50 /*
51 ** Output a "committer" record for the given user.
52 ** NOTE: the given user name may be an email itself.
53 */
54 static void print_person(const char *zUser){
55
--- src/export.c
+++ src/export.c
@@ -38,17 +38,10 @@
38 int rid; /* Corresponding object in the BLOB table */
39 char uuid[65]; /* The GIT hash name for this object */
40 };
41 #endif
42
 
 
 
 
 
 
 
43 /*
44 ** Output a "committer" record for the given user.
45 ** NOTE: the given user name may be an email itself.
46 */
47 static void print_person(const char *zUser){
48
--- src/extcgi.c
+++ src/extcgi.c
@@ -30,17 +30,10 @@
3030
*/
3131
#include "config.h"
3232
#include "extcgi.h"
3333
#include <assert.h>
3434
35
-#if defined(_WIN32) || defined(WIN32)
36
-# undef popen
37
-# define popen _popen
38
-# undef pclose
39
-# define pclose _pclose
40
-#endif
41
-
4235
/*
4336
** These are the environment variables that should be set for CGI
4437
** extension programs:
4538
*/
4639
static const char *azCgiEnv[] = {
4740
--- src/extcgi.c
+++ src/extcgi.c
@@ -30,17 +30,10 @@
30 */
31 #include "config.h"
32 #include "extcgi.h"
33 #include <assert.h>
34
35 #if defined(_WIN32) || defined(WIN32)
36 # undef popen
37 # define popen _popen
38 # undef pclose
39 # define pclose _pclose
40 #endif
41
42 /*
43 ** These are the environment variables that should be set for CGI
44 ** extension programs:
45 */
46 static const char *azCgiEnv[] = {
47
--- src/extcgi.c
+++ src/extcgi.c
@@ -30,17 +30,10 @@
30 */
31 #include "config.h"
32 #include "extcgi.h"
33 #include <assert.h>
34
 
 
 
 
 
 
 
35 /*
36 ** These are the environment variables that should be set for CGI
37 ** extension programs:
38 */
39 static const char *azCgiEnv[] = {
40
--- src/http_transport.c
+++ src/http_transport.c
@@ -93,13 +93,13 @@
9393
9494
/*
9595
** Default SSH command
9696
*/
9797
#if 0 /* was: defined(_WIN32). Windows generally has ssh now. */
98
-static const char zDefaultSshCmd[] = "plink -ssh -T";
98
+static const char zDefaultSshCmd[] = "plink -ssh";
9999
#else
100
-static const char zDefaultSshCmd[] = "ssh -e none -T";
100
+static const char zDefaultSshCmd[] = "ssh -e none";
101101
#endif
102102
103103
/*
104104
** Initialize a Blob to the name of the configured SSH command.
105105
*/
@@ -122,11 +122,11 @@
122122
socket_ssh_resolve_addr(pUrlData);
123123
transport_ssh_command(&zCmd);
124124
if( pUrlData->port!=pUrlData->dfltPort && pUrlData->port ){
125125
blob_appendf(&zCmd, " -p %d", pUrlData->port);
126126
}
127
- blob_appendf(&zCmd, " --"); /* End of switches */
127
+ blob_appendf(&zCmd, " -T --"); /* End of switches */
128128
if( pUrlData->user && pUrlData->user[0] ){
129129
zHost = mprintf("%s@%s", pUrlData->user, pUrlData->name);
130130
blob_append_escaped_arg(&zCmd, zHost, 0);
131131
fossil_free(zHost);
132132
}else{
133133
--- src/http_transport.c
+++ src/http_transport.c
@@ -93,13 +93,13 @@
93
94 /*
95 ** Default SSH command
96 */
97 #if 0 /* was: defined(_WIN32). Windows generally has ssh now. */
98 static const char zDefaultSshCmd[] = "plink -ssh -T";
99 #else
100 static const char zDefaultSshCmd[] = "ssh -e none -T";
101 #endif
102
103 /*
104 ** Initialize a Blob to the name of the configured SSH command.
105 */
@@ -122,11 +122,11 @@
122 socket_ssh_resolve_addr(pUrlData);
123 transport_ssh_command(&zCmd);
124 if( pUrlData->port!=pUrlData->dfltPort && pUrlData->port ){
125 blob_appendf(&zCmd, " -p %d", pUrlData->port);
126 }
127 blob_appendf(&zCmd, " --"); /* End of switches */
128 if( pUrlData->user && pUrlData->user[0] ){
129 zHost = mprintf("%s@%s", pUrlData->user, pUrlData->name);
130 blob_append_escaped_arg(&zCmd, zHost, 0);
131 fossil_free(zHost);
132 }else{
133
--- src/http_transport.c
+++ src/http_transport.c
@@ -93,13 +93,13 @@
93
94 /*
95 ** Default SSH command
96 */
97 #if 0 /* was: defined(_WIN32). Windows generally has ssh now. */
98 static const char zDefaultSshCmd[] = "plink -ssh";
99 #else
100 static const char zDefaultSshCmd[] = "ssh -e none";
101 #endif
102
103 /*
104 ** Initialize a Blob to the name of the configured SSH command.
105 */
@@ -122,11 +122,11 @@
122 socket_ssh_resolve_addr(pUrlData);
123 transport_ssh_command(&zCmd);
124 if( pUrlData->port!=pUrlData->dfltPort && pUrlData->port ){
125 blob_appendf(&zCmd, " -p %d", pUrlData->port);
126 }
127 blob_appendf(&zCmd, " -T --"); /* End of switches */
128 if( pUrlData->user && pUrlData->user[0] ){
129 zHost = mprintf("%s@%s", pUrlData->user, pUrlData->name);
130 blob_append_escaped_arg(&zCmd, zHost, 0);
131 fossil_free(zHost);
132 }else{
133
+67 -24
--- src/main.c
+++ src/main.c
@@ -2816,13 +2816,19 @@
28162816
** also present.
28172817
**
28182818
** If the REPOSITORY is a directory name which is the root of a
28192819
** checkout, it will chdir to that directory and, unless overridden by
28202820
** the --page option, select the current checkout version in the
2821
-** timeline by default.
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.
28222828
**
2823
-** For the special case REPOSITORY name of "/", the list global configuration
2829
+** For the special case REPOSITORY name of "/", the global configuration
28242830
** database is consulted for a list of all known repositories. The --repolist
28252831
** option is implied by this special case. See also the "fossil all ui"
28262832
** command.
28272833
**
28282834
** By default, the "ui" command provides full administrative access without
@@ -2892,10 +2898,12 @@
28922898
const char *zFileGlob; /* Static content must match this */
28932899
char *zIpAddr = 0; /* Bind to this IP address */
28942900
int fCreate = 0; /* The --create flag */
28952901
const char *zInitPage = 0; /* Start on this page. --page option */
28962902
int findServerArg = 2; /* argv index for find_server_repository() */
2903
+ char *zRemote = 0; /* Remote host on which to run "fossil ui" */
2904
+
28972905
28982906
#if defined(_WIN32)
28992907
const char *zStopperFile; /* Name of file used to terminate server */
29002908
zStopperFile = find_option("stopper", 0, 1);
29012909
#endif
@@ -2973,16 +2981,30 @@
29732981
fCreate = 0;
29742982
g.argv[2] = 0;
29752983
--g.argc;
29762984
}
29772985
}
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));
2994
+ n = (int)(zRepoTail - g.argv[2]) - 1;
2995
+ zRemote = mprintf("%.*s", n, g.argv[2]);
2996
+ g.argv[2] = (char*)zRepoTail;
2997
+ }
29782998
if( isUiCmd ){
29792999
flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
29803000
g.useLocalauth = 1;
29813001
allowRepoList = 1;
29823002
}
2983
- find_server_repository(findServerArg, fCreate);
3003
+ if( !zRemote ){
3004
+ find_server_repository(findServerArg, fCreate);
3005
+ }
29843006
if( zInitPage==0 ){
29853007
if( isUiCmd && g.localOpen ){
29863008
zInitPage = "timeline?c=current";
29873009
}else{
29883010
zInitPage = "";
@@ -3004,25 +3026,59 @@
30043026
iPort = mxPort = atoi(zPort);
30053027
}else{
30063028
iPort = db_get_int("http-port", 8080);
30073029
mxPort = iPort+100;
30083030
}
3009
-#if !defined(_WIN32)
3010
- /* Unix implementation */
30113031
if( isUiCmd ){
3032
+ char *zBrowserArg;
30123033
zBrowser = fossil_web_browser();
30133034
if( zIpAddr==0 ){
3014
- zBrowserCmd = mprintf("%s \"http://localhost:%%d/%s\" &",
3015
- zBrowser, zInitPage);
3035
+ zBrowserArg = mprintf("http://localhost:%%d/%s", zInitPage);
30163036
}else if( strchr(zIpAddr,':') ){
3017
- zBrowserCmd = mprintf("%s \"http://[%s]:%%d/%s\" &",
3018
- zBrowser, zIpAddr, zInitPage);
3037
+ zBrowserArg = mprintf("http://[%s]:%%d/%s", zIpAddr, zInitPage);
30193038
}else{
3020
- zBrowserCmd = mprintf("%s \"http://%s:%%d/%s\" &",
3021
- zBrowser, zIpAddr, zInitPage);
3039
+ zBrowserArg = mprintf("http://%s:%%d/%s", zIpAddr, zInitPage);
3040
+ }
3041
+#ifdef _WIN32
3042
+ zBrowserCmd = mprintf("%s %s &", zBrowser, zBrowserArg);
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
+ fossil_free(zBrowserCmd);
3071
+ zBrowserCmd = 0;
3072
+ }
30223073
}
3074
+ pclose(sshIn);
3075
+ fossil_free(zBrowserCmd);
3076
+ return;
30233077
}
3078
+#if !defined(_WIN32)
3079
+ /* Unix implementation */
30243080
if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
30253081
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
30263082
db_close(1);
30273083
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
30283084
fossil_fatal("unable to listen on TCP socket %d", iPort);
@@ -3069,23 +3125,10 @@
30693125
fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
30703126
getpid());
30713127
}
30723128
#else
30733129
/* Win32 implementation */
3074
- if( isUiCmd ){
3075
- zBrowser = fossil_web_browser();
3076
- if( zIpAddr==0 ){
3077
- zBrowserCmd = mprintf("%s http://localhost:%%d/%s &",
3078
- zBrowser, zInitPage);
3079
- }else if( strchr(zIpAddr,':') ){
3080
- zBrowserCmd = mprintf("%s http://[%s]:%%d/%s &",
3081
- zBrowser, zIpAddr, zInitPage);
3082
- }else{
3083
- zBrowserCmd = mprintf("%s http://%s:%%d/%s &",
3084
- zBrowser, zIpAddr, zInitPage);
3085
- }
3086
- }
30873130
if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
30883131
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
30893132
db_close(1);
30903133
if( allowRepoList ){
30913134
flags |= HTTP_SERVER_REPOLIST;
30923135
--- src/main.c
+++ src/main.c
@@ -2816,13 +2816,19 @@
2816 ** also present.
2817 **
2818 ** If the REPOSITORY is a directory name which is the root of a
2819 ** checkout, it will chdir to that directory and, unless overridden by
2820 ** the --page option, select the current checkout version in the
2821 ** timeline by default.
 
 
 
 
 
 
2822 **
2823 ** For the special case REPOSITORY name of "/", the list global configuration
2824 ** database is consulted for a list of all known repositories. The --repolist
2825 ** option is implied by this special case. See also the "fossil all ui"
2826 ** command.
2827 **
2828 ** By default, the "ui" command provides full administrative access without
@@ -2892,10 +2898,12 @@
2892 const char *zFileGlob; /* Static content must match this */
2893 char *zIpAddr = 0; /* Bind to this IP address */
2894 int fCreate = 0; /* The --create flag */
2895 const char *zInitPage = 0; /* Start on this page. --page option */
2896 int findServerArg = 2; /* argv index for find_server_repository() */
 
 
2897
2898 #if defined(_WIN32)
2899 const char *zStopperFile; /* Name of file used to terminate server */
2900 zStopperFile = find_option("stopper", 0, 1);
2901 #endif
@@ -2973,16 +2981,30 @@
2973 fCreate = 0;
2974 g.argv[2] = 0;
2975 --g.argc;
2976 }
2977 }
 
 
 
 
 
 
 
 
 
 
 
 
2978 if( isUiCmd ){
2979 flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
2980 g.useLocalauth = 1;
2981 allowRepoList = 1;
2982 }
2983 find_server_repository(findServerArg, fCreate);
 
 
2984 if( zInitPage==0 ){
2985 if( isUiCmd && g.localOpen ){
2986 zInitPage = "timeline?c=current";
2987 }else{
2988 zInitPage = "";
@@ -3004,25 +3026,59 @@
3004 iPort = mxPort = atoi(zPort);
3005 }else{
3006 iPort = db_get_int("http-port", 8080);
3007 mxPort = iPort+100;
3008 }
3009 #if !defined(_WIN32)
3010 /* Unix implementation */
3011 if( isUiCmd ){
 
3012 zBrowser = fossil_web_browser();
3013 if( zIpAddr==0 ){
3014 zBrowserCmd = mprintf("%s \"http://localhost:%%d/%s\" &",
3015 zBrowser, zInitPage);
3016 }else if( strchr(zIpAddr,':') ){
3017 zBrowserCmd = mprintf("%s \"http://[%s]:%%d/%s\" &",
3018 zBrowser, zIpAddr, zInitPage);
3019 }else{
3020 zBrowserCmd = mprintf("%s \"http://%s:%%d/%s\" &",
3021 zBrowser, zIpAddr, zInitPage);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3022 }
 
 
 
3023 }
 
 
3024 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
3025 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
3026 db_close(1);
3027 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
3028 fossil_fatal("unable to listen on TCP socket %d", iPort);
@@ -3069,23 +3125,10 @@
3069 fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
3070 getpid());
3071 }
3072 #else
3073 /* Win32 implementation */
3074 if( isUiCmd ){
3075 zBrowser = fossil_web_browser();
3076 if( zIpAddr==0 ){
3077 zBrowserCmd = mprintf("%s http://localhost:%%d/%s &",
3078 zBrowser, zInitPage);
3079 }else if( strchr(zIpAddr,':') ){
3080 zBrowserCmd = mprintf("%s http://[%s]:%%d/%s &",
3081 zBrowser, zIpAddr, zInitPage);
3082 }else{
3083 zBrowserCmd = mprintf("%s http://%s:%%d/%s &",
3084 zBrowser, zIpAddr, zInitPage);
3085 }
3086 }
3087 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
3088 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
3089 db_close(1);
3090 if( allowRepoList ){
3091 flags |= HTTP_SERVER_REPOLIST;
3092
--- src/main.c
+++ src/main.c
@@ -2816,13 +2816,19 @@
2816 ** also present.
2817 **
2818 ** If the REPOSITORY is a directory name which is the root of a
2819 ** checkout, it will chdir to that directory and, unless overridden by
2820 ** the --page option, select the current checkout version in the
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"
2832 ** command.
2833 **
2834 ** By default, the "ui" command provides full administrative access without
@@ -2892,10 +2898,12 @@
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
2906 #if defined(_WIN32)
2907 const char *zStopperFile; /* Name of file used to terminate server */
2908 zStopperFile = find_option("stopper", 0, 1);
2909 #endif
@@ -2973,16 +2981,30 @@
2981 fCreate = 0;
2982 g.argv[2] = 0;
2983 --g.argc;
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));
2994 n = (int)(zRepoTail - g.argv[2]) - 1;
2995 zRemote = mprintf("%.*s", n, g.argv[2]);
2996 g.argv[2] = (char*)zRepoTail;
2997 }
2998 if( isUiCmd ){
2999 flags |= HTTP_SERVER_LOCALHOST|HTTP_SERVER_REPOLIST;
3000 g.useLocalauth = 1;
3001 allowRepoList = 1;
3002 }
3003 if( !zRemote ){
3004 find_server_repository(findServerArg, fCreate);
3005 }
3006 if( zInitPage==0 ){
3007 if( isUiCmd && g.localOpen ){
3008 zInitPage = "timeline?c=current";
3009 }else{
3010 zInitPage = "";
@@ -3004,25 +3026,59 @@
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,':') ){
3037 zBrowserArg = mprintf("http://[%s]:%%d/%s", zIpAddr, zInitPage);
 
3038 }else{
3039 zBrowserArg = mprintf("http://%s:%%d/%s", zIpAddr, zInitPage);
3040 }
3041 #ifdef _WIN32
3042 zBrowserCmd = mprintf("%s %s &", zBrowser, zBrowserArg);
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 fossil_free(zBrowserCmd);
3071 zBrowserCmd = 0;
3072 }
3073 }
3074 pclose(sshIn);
3075 fossil_free(zBrowserCmd);
3076 return;
3077 }
3078 #if !defined(_WIN32)
3079 /* Unix implementation */
3080 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
3081 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
3082 db_close(1);
3083 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
3084 fossil_fatal("unable to listen on TCP socket %d", iPort);
@@ -3069,23 +3125,10 @@
3125 fprintf(stderr, "/***** Webpage finished in subprocess %d *****/\n",
3126 getpid());
3127 }
3128 #else
3129 /* Win32 implementation */
 
 
 
 
 
 
 
 
 
 
 
 
 
3130 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
3131 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
3132 db_close(1);
3133 if( allowRepoList ){
3134 flags |= HTTP_SERVER_REPOLIST;
3135
+1 -11
--- src/patch.c
+++ src/patch.c
@@ -19,21 +19,10 @@
1919
*/
2020
#include "config.h"
2121
#include "patch.h"
2222
#include <assert.h>
2323
24
-/*
25
-** Additional windows configuration for popen */
26
-#if defined(_WIN32)
27
-# include <io.h>
28
-# include <fcntl.h>
29
-# undef popen
30
-# define popen _popen
31
-# undef pclose
32
-# define pclose _pclose
33
-#endif
34
-
3524
/*
3625
** Try to compute the name of the computer on which this process
3726
** is running.
3827
*/
3928
char *fossil_hostname(void){
@@ -679,10 +668,11 @@
679668
blob_appendf(&cmd, " patch %s%s %$ -", zRemoteCmd, zForce, zDir);
680669
}else{
681670
Blob remote;
682671
*(char*)(zDir-1) = 0;
683672
transport_ssh_command(&cmd);
673
+ blob_appendf(&cmd, " -T");
684674
blob_append_escaped_arg(&cmd, zRemote, 0);
685675
blob_init(&remote, 0, 0);
686676
blob_appendf(&remote, "fossil patch %s%s --dir64 %z -",
687677
zRemoteCmd, zForce, encode64(zDir, -1));
688678
blob_append_escaped_arg(&cmd, blob_str(&remote), 0);
689679
--- src/patch.c
+++ src/patch.c
@@ -19,21 +19,10 @@
19 */
20 #include "config.h"
21 #include "patch.h"
22 #include <assert.h>
23
24 /*
25 ** Additional windows configuration for popen */
26 #if defined(_WIN32)
27 # include <io.h>
28 # include <fcntl.h>
29 # undef popen
30 # define popen _popen
31 # undef pclose
32 # define pclose _pclose
33 #endif
34
35 /*
36 ** Try to compute the name of the computer on which this process
37 ** is running.
38 */
39 char *fossil_hostname(void){
@@ -679,10 +668,11 @@
679 blob_appendf(&cmd, " patch %s%s %$ -", zRemoteCmd, zForce, zDir);
680 }else{
681 Blob remote;
682 *(char*)(zDir-1) = 0;
683 transport_ssh_command(&cmd);
 
684 blob_append_escaped_arg(&cmd, zRemote, 0);
685 blob_init(&remote, 0, 0);
686 blob_appendf(&remote, "fossil patch %s%s --dir64 %z -",
687 zRemoteCmd, zForce, encode64(zDir, -1));
688 blob_append_escaped_arg(&cmd, blob_str(&remote), 0);
689
--- src/patch.c
+++ src/patch.c
@@ -19,21 +19,10 @@
19 */
20 #include "config.h"
21 #include "patch.h"
22 #include <assert.h>
23
 
 
 
 
 
 
 
 
 
 
 
24 /*
25 ** Try to compute the name of the computer on which this process
26 ** is running.
27 */
28 char *fossil_hostname(void){
@@ -679,10 +668,11 @@
668 blob_appendf(&cmd, " patch %s%s %$ -", zRemoteCmd, zForce, zDir);
669 }else{
670 Blob remote;
671 *(char*)(zDir-1) = 0;
672 transport_ssh_command(&cmd);
673 blob_appendf(&cmd, " -T");
674 blob_append_escaped_arg(&cmd, zRemote, 0);
675 blob_init(&remote, 0, 0);
676 blob_appendf(&remote, "fossil patch %s%s --dir64 %z -",
677 zRemoteCmd, zForce, encode64(zDir, -1));
678 blob_append_escaped_arg(&cmd, blob_str(&remote), 0);
679
-9
--- src/user.c
+++ src/user.c
@@ -112,19 +112,10 @@
112112
assert( nPwdBuffer>0 );
113113
fossil_secure_free_page(zPwdBuffer, nPwdBuffer);
114114
}
115115
#endif
116116
117
-#if defined(_WIN32) || defined(WIN32)
118
-# include <io.h>
119
-# include <fcntl.h>
120
-# undef popen
121
-# define popen _popen
122
-# undef pclose
123
-# define pclose _pclose
124
-#endif
125
-
126117
/*
127118
** Scramble substitution matrix:
128119
*/
129120
static char aSubst[256];
130121
131122
--- src/user.c
+++ src/user.c
@@ -112,19 +112,10 @@
112 assert( nPwdBuffer>0 );
113 fossil_secure_free_page(zPwdBuffer, nPwdBuffer);
114 }
115 #endif
116
117 #if defined(_WIN32) || defined(WIN32)
118 # include <io.h>
119 # include <fcntl.h>
120 # undef popen
121 # define popen _popen
122 # undef pclose
123 # define pclose _pclose
124 #endif
125
126 /*
127 ** Scramble substitution matrix:
128 */
129 static char aSubst[256];
130
131
--- src/user.c
+++ src/user.c
@@ -112,19 +112,10 @@
112 assert( nPwdBuffer>0 );
113 fossil_secure_free_page(zPwdBuffer, nPwdBuffer);
114 }
115 #endif
116
 
 
 
 
 
 
 
 
 
117 /*
118 ** Scramble substitution matrix:
119 */
120 static char aSubst[256];
121
122

Keyboard Shortcuts

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