Fossil SCM
Fix the "fossil all ui" logic so that it still works for directory listings inside of chroot jails.
Commit
226a0990d3aacb85f13d5bec23c85b4d05a29476
Parent
8e4b8ba0e40416d…
1 file changed
+10
-3
+10
-3
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -139,10 +139,11 @@ | ||
| 139 | 139 | int minPrefix; /* Number of digits needed for a distinct UUID */ |
| 140 | 140 | int fSqlTrace; /* True if --sqltrace flag is present */ |
| 141 | 141 | int fSqlStats; /* True if --sqltrace or --sqlstats are present */ |
| 142 | 142 | int fSqlPrint; /* True if -sqlprint flag is present */ |
| 143 | 143 | int fQuiet; /* True if -quiet flag is present */ |
| 144 | + int fJail; /* True if running with a chroot jail */ | |
| 144 | 145 | int fHttpTrace; /* Trace outbound HTTP requests */ |
| 145 | 146 | int fAnyTrace; /* Any kind of tracing */ |
| 146 | 147 | char *zHttpAuth; /* HTTP Authorization user:pass information */ |
| 147 | 148 | int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ |
| 148 | 149 | int fSshTrace; /* Trace the SSH setup traffic */ |
| @@ -1149,10 +1150,11 @@ | ||
| 1149 | 1150 | if( !noJail ){ |
| 1150 | 1151 | if( file_isdir(zDir)==1 ){ |
| 1151 | 1152 | if( file_chdir(zDir, 1) ){ |
| 1152 | 1153 | fossil_fatal("unable to chroot into %s", zDir); |
| 1153 | 1154 | } |
| 1155 | + g.fJail = 1; | |
| 1154 | 1156 | zRepo = "/"; |
| 1155 | 1157 | }else{ |
| 1156 | 1158 | for(i=strlen(zDir)-1; i>0 && zDir[i]!='/'; i--){} |
| 1157 | 1159 | if( zDir[i]!='/' ) fossil_fatal("bad repository name: %s", zRepo); |
| 1158 | 1160 | if( i>0 ){ |
| @@ -1183,24 +1185,29 @@ | ||
| 1183 | 1185 | |
| 1184 | 1186 | /* |
| 1185 | 1187 | ** Generate a web-page that lists all repositories located under the |
| 1186 | 1188 | ** g.zRepositoryName directory and return non-zero. |
| 1187 | 1189 | ** |
| 1188 | -** For the special case of g.zRepositoryName equal to "/", | |
| 1190 | +** For the special case when g.zRepositoryName a non-chroot-jail "/", | |
| 1189 | 1191 | ** compose the list using the "repo:" entries in the global_config |
| 1190 | 1192 | ** 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. | |
| 1192 | 1199 | ** |
| 1193 | 1200 | ** Or, if no repositories can be located beneath g.zRepositoryName, |
| 1194 | 1201 | ** return 0. |
| 1195 | 1202 | */ |
| 1196 | 1203 | static int repo_list_page(void){ |
| 1197 | 1204 | Blob base; |
| 1198 | 1205 | int n = 0; |
| 1199 | 1206 | |
| 1200 | 1207 | assert( g.db==0 ); |
| 1201 | - if( fossil_strcmp(g.zRepositoryName,"/")==0 ){ | |
| 1208 | + if( fossil_strcmp(g.zRepositoryName,"/")==0 && !g.fJail ){ | |
| 1202 | 1209 | /* For the special case of the "repository directory" being "/", |
| 1203 | 1210 | ** show all of the repositories named in the ~/.fossil database. |
| 1204 | 1211 | ** |
| 1205 | 1212 | ** On unix systems, then entries are of the form "repo:/home/..." |
| 1206 | 1213 | ** and on Windows systems they are like "repo:C:/Users/...". We want |
| 1207 | 1214 |
| --- 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 |