Fossil SCM

Fix the "fossil all ui" logic so that it still works for directory listings inside of chroot jails.

drh 2016-12-01 16:27 UTC all-ui
Commit 226a0990d3aacb85f13d5bec23c85b4d05a29476
1 file changed +10 -3
+10 -3
--- src/main.c
+++ src/main.c
@@ -139,10 +139,11 @@
139139
int minPrefix; /* Number of digits needed for a distinct UUID */
140140
int fSqlTrace; /* True if --sqltrace flag is present */
141141
int fSqlStats; /* True if --sqltrace or --sqlstats are present */
142142
int fSqlPrint; /* True if -sqlprint flag is present */
143143
int fQuiet; /* True if -quiet flag is present */
144
+ int fJail; /* True if running with a chroot jail */
144145
int fHttpTrace; /* Trace outbound HTTP requests */
145146
int fAnyTrace; /* Any kind of tracing */
146147
char *zHttpAuth; /* HTTP Authorization user:pass information */
147148
int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
148149
int fSshTrace; /* Trace the SSH setup traffic */
@@ -1149,10 +1150,11 @@
11491150
if( !noJail ){
11501151
if( file_isdir(zDir)==1 ){
11511152
if( file_chdir(zDir, 1) ){
11521153
fossil_fatal("unable to chroot into %s", zDir);
11531154
}
1155
+ g.fJail = 1;
11541156
zRepo = "/";
11551157
}else{
11561158
for(i=strlen(zDir)-1; i>0 && zDir[i]!='/'; i--){}
11571159
if( zDir[i]!='/' ) fossil_fatal("bad repository name: %s", zRepo);
11581160
if( i>0 ){
@@ -1183,24 +1185,29 @@
11831185
11841186
/*
11851187
** Generate a web-page that lists all repositories located under the
11861188
** g.zRepositoryName directory and return non-zero.
11871189
**
1188
-** For the special case of g.zRepositoryName equal to "/",
1190
+** For the special case when g.zRepositoryName a non-chroot-jail "/",
11891191
** compose the list using the "repo:" entries in the global_config
11901192
** table of the configuration database. These entries comprise all
1191
-** of the repositories known to the "all" command.
1193
+** of the repositories known to the "all" command. The special case
1194
+** processing is disallowed for chroot jails because g.zRepositoryName
1195
+** is always "/" inside a chroot jail and so it cannot be used as a flag
1196
+** to signal the special processing in that case. The special case
1197
+** processing is intended for the "fossil all ui" command which never
1198
+** runs in a chroot jail anyhow.
11921199
**
11931200
** Or, if no repositories can be located beneath g.zRepositoryName,
11941201
** return 0.
11951202
*/
11961203
static int repo_list_page(void){
11971204
Blob base;
11981205
int n = 0;
11991206
12001207
assert( g.db==0 );
1201
- if( fossil_strcmp(g.zRepositoryName,"/")==0 ){
1208
+ if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){
12021209
/* For the special case of the "repository directory" being "/",
12031210
** show all of the repositories named in the ~/.fossil database.
12041211
**
12051212
** On unix systems, then entries are of the form "repo:/home/..."
12061213
** and on Windows systems they are like "repo:C:/Users/...". We want
12071214
--- src/main.c
+++ src/main.c
@@ -139,10 +139,11 @@
139 int minPrefix; /* Number of digits needed for a distinct UUID */
140 int fSqlTrace; /* True if --sqltrace flag is present */
141 int fSqlStats; /* True if --sqltrace or --sqlstats are present */
142 int fSqlPrint; /* True if -sqlprint flag is present */
143 int fQuiet; /* True if -quiet flag is present */
 
144 int fHttpTrace; /* Trace outbound HTTP requests */
145 int fAnyTrace; /* Any kind of tracing */
146 char *zHttpAuth; /* HTTP Authorization user:pass information */
147 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
148 int fSshTrace; /* Trace the SSH setup traffic */
@@ -1149,10 +1150,11 @@
1149 if( !noJail ){
1150 if( file_isdir(zDir)==1 ){
1151 if( file_chdir(zDir, 1) ){
1152 fossil_fatal("unable to chroot into %s", zDir);
1153 }
 
1154 zRepo = "/";
1155 }else{
1156 for(i=strlen(zDir)-1; i>0 && zDir[i]!='/'; i--){}
1157 if( zDir[i]!='/' ) fossil_fatal("bad repository name: %s", zRepo);
1158 if( i>0 ){
@@ -1183,24 +1185,29 @@
1183
1184 /*
1185 ** Generate a web-page that lists all repositories located under the
1186 ** g.zRepositoryName directory and return non-zero.
1187 **
1188 ** For the special case of g.zRepositoryName equal to "/",
1189 ** compose the list using the "repo:" entries in the global_config
1190 ** table of the configuration database. These entries comprise all
1191 ** of the repositories known to the "all" command.
 
 
 
 
 
1192 **
1193 ** Or, if no repositories can be located beneath g.zRepositoryName,
1194 ** return 0.
1195 */
1196 static int repo_list_page(void){
1197 Blob base;
1198 int n = 0;
1199
1200 assert( g.db==0 );
1201 if( fossil_strcmp(g.zRepositoryName,"/")==0 ){
1202 /* For the special case of the "repository directory" being "/",
1203 ** show all of the repositories named in the ~/.fossil database.
1204 **
1205 ** On unix systems, then entries are of the form "repo:/home/..."
1206 ** and on Windows systems they are like "repo:C:/Users/...". We want
1207
--- src/main.c
+++ src/main.c
@@ -139,10 +139,11 @@
139 int minPrefix; /* Number of digits needed for a distinct UUID */
140 int fSqlTrace; /* True if --sqltrace flag is present */
141 int fSqlStats; /* True if --sqltrace or --sqlstats are present */
142 int fSqlPrint; /* True if -sqlprint flag is present */
143 int fQuiet; /* True if -quiet flag is present */
144 int fJail; /* True if running with a chroot jail */
145 int fHttpTrace; /* Trace outbound HTTP requests */
146 int fAnyTrace; /* Any kind of tracing */
147 char *zHttpAuth; /* HTTP Authorization user:pass information */
148 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
149 int fSshTrace; /* Trace the SSH setup traffic */
@@ -1149,10 +1150,11 @@
1150 if( !noJail ){
1151 if( file_isdir(zDir)==1 ){
1152 if( file_chdir(zDir, 1) ){
1153 fossil_fatal("unable to chroot into %s", zDir);
1154 }
1155 g.fJail = 1;
1156 zRepo = "/";
1157 }else{
1158 for(i=strlen(zDir)-1; i>0 && zDir[i]!='/'; i--){}
1159 if( zDir[i]!='/' ) fossil_fatal("bad repository name: %s", zRepo);
1160 if( i>0 ){
@@ -1183,24 +1185,29 @@
1185
1186 /*
1187 ** Generate a web-page that lists all repositories located under the
1188 ** g.zRepositoryName directory and return non-zero.
1189 **
1190 ** For the special case when g.zRepositoryName a non-chroot-jail "/",
1191 ** compose the list using the "repo:" entries in the global_config
1192 ** table of the configuration database. These entries comprise all
1193 ** of the repositories known to the "all" command. The special case
1194 ** processing is disallowed for chroot jails because g.zRepositoryName
1195 ** is always "/" inside a chroot jail and so it cannot be used as a flag
1196 ** to signal the special processing in that case. The special case
1197 ** processing is intended for the "fossil all ui" command which never
1198 ** runs in a chroot jail anyhow.
1199 **
1200 ** Or, if no repositories can be located beneath g.zRepositoryName,
1201 ** return 0.
1202 */
1203 static int repo_list_page(void){
1204 Blob base;
1205 int n = 0;
1206
1207 assert( g.db==0 );
1208 if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){
1209 /* For the special case of the "repository directory" being "/",
1210 ** show all of the repositories named in the ~/.fossil database.
1211 **
1212 ** On unix systems, then entries are of the form "repo:/home/..."
1213 ** and on Windows systems they are like "repo:C:/Users/...". We want
1214

Keyboard Shortcuts

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