Fossil SCM
Moved the chdir() call within enter_chroot_jail() down below the new repo name canonicalization code to allow use of relative path names. Before, you had to give an absolute path to the repo, since we'd cd'd away from that directory before we started to validate the path.
Commit
e94621186f71c5f6aac52ca50b59d5c1d1da2a1527d97f69d6e3e8f93a539463
Parent
324d232c2553c14…
1 file changed
+3
-3
+3
-3
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -1499,13 +1499,10 @@ | ||
| 1499 | 1499 | |
| 1500 | 1500 | file_canonical_name(zRepo, &dir, 0); |
| 1501 | 1501 | zDir = blob_str(&dir); |
| 1502 | 1502 | if( !noJail ){ |
| 1503 | 1503 | if( file_isdir(zDir, ExtFILE)==1 ){ |
| 1504 | - if( file_chdir(zDir, 1) ){ | |
| 1505 | - fossil_panic("unable to chroot into %s", zDir); | |
| 1506 | - } | |
| 1507 | 1504 | if( g.zRepositoryName ){ |
| 1508 | 1505 | size_t n = strlen(zDir); |
| 1509 | 1506 | Blob repo; |
| 1510 | 1507 | file_canonical_name(g.zRepositoryName, &repo, 0); |
| 1511 | 1508 | zRepo = blob_str(&repo); |
| @@ -1516,10 +1513,13 @@ | ||
| 1516 | 1513 | if( *zRepo == '\0' ) zRepo = "/"; |
| 1517 | 1514 | }else { |
| 1518 | 1515 | zRepo = "/"; |
| 1519 | 1516 | g.fJail = 1; |
| 1520 | 1517 | } |
| 1518 | + if( file_chdir(zDir, 1) ){ | |
| 1519 | + fossil_panic("unable to chroot into %s", zDir); | |
| 1520 | + } | |
| 1521 | 1521 | }else{ |
| 1522 | 1522 | for(i=strlen(zDir)-1; i>0 && zDir[i]!='/'; i--){} |
| 1523 | 1523 | if( zDir[i]!='/' ) fossil_fatal("bad repository name: %s", zRepo); |
| 1524 | 1524 | if( i>0 ){ |
| 1525 | 1525 | zDir[i] = 0; |
| 1526 | 1526 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1499,13 +1499,10 @@ | |
| 1499 | |
| 1500 | file_canonical_name(zRepo, &dir, 0); |
| 1501 | zDir = blob_str(&dir); |
| 1502 | if( !noJail ){ |
| 1503 | if( file_isdir(zDir, ExtFILE)==1 ){ |
| 1504 | if( file_chdir(zDir, 1) ){ |
| 1505 | fossil_panic("unable to chroot into %s", zDir); |
| 1506 | } |
| 1507 | if( g.zRepositoryName ){ |
| 1508 | size_t n = strlen(zDir); |
| 1509 | Blob repo; |
| 1510 | file_canonical_name(g.zRepositoryName, &repo, 0); |
| 1511 | zRepo = blob_str(&repo); |
| @@ -1516,10 +1513,13 @@ | |
| 1516 | if( *zRepo == '\0' ) zRepo = "/"; |
| 1517 | }else { |
| 1518 | zRepo = "/"; |
| 1519 | g.fJail = 1; |
| 1520 | } |
| 1521 | }else{ |
| 1522 | for(i=strlen(zDir)-1; i>0 && zDir[i]!='/'; i--){} |
| 1523 | if( zDir[i]!='/' ) fossil_fatal("bad repository name: %s", zRepo); |
| 1524 | if( i>0 ){ |
| 1525 | zDir[i] = 0; |
| 1526 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1499,13 +1499,10 @@ | |
| 1499 | |
| 1500 | file_canonical_name(zRepo, &dir, 0); |
| 1501 | zDir = blob_str(&dir); |
| 1502 | if( !noJail ){ |
| 1503 | if( file_isdir(zDir, ExtFILE)==1 ){ |
| 1504 | if( g.zRepositoryName ){ |
| 1505 | size_t n = strlen(zDir); |
| 1506 | Blob repo; |
| 1507 | file_canonical_name(g.zRepositoryName, &repo, 0); |
| 1508 | zRepo = blob_str(&repo); |
| @@ -1516,10 +1513,13 @@ | |
| 1513 | if( *zRepo == '\0' ) zRepo = "/"; |
| 1514 | }else { |
| 1515 | zRepo = "/"; |
| 1516 | g.fJail = 1; |
| 1517 | } |
| 1518 | if( file_chdir(zDir, 1) ){ |
| 1519 | fossil_panic("unable to chroot into %s", zDir); |
| 1520 | } |
| 1521 | }else{ |
| 1522 | for(i=strlen(zDir)-1; i>0 && zDir[i]!='/'; i--){} |
| 1523 | if( zDir[i]!='/' ) fossil_fatal("bad repository name: %s", zRepo); |
| 1524 | if( i>0 ){ |
| 1525 | zDir[i] = 0; |
| 1526 |