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.

wyoung 2022-08-13 22:15 trunk
Commit e94621186f71c5f6aac52ca50b59d5c1d1da2a1527d97f69d6e3e8f93a539463
1 file changed +3 -3
+3 -3
--- src/main.c
+++ src/main.c
@@ -1499,13 +1499,10 @@
14991499
15001500
file_canonical_name(zRepo, &dir, 0);
15011501
zDir = blob_str(&dir);
15021502
if( !noJail ){
15031503
if( file_isdir(zDir, ExtFILE)==1 ){
1504
- if( file_chdir(zDir, 1) ){
1505
- fossil_panic("unable to chroot into %s", zDir);
1506
- }
15071504
if( g.zRepositoryName ){
15081505
size_t n = strlen(zDir);
15091506
Blob repo;
15101507
file_canonical_name(g.zRepositoryName, &repo, 0);
15111508
zRepo = blob_str(&repo);
@@ -1516,10 +1513,13 @@
15161513
if( *zRepo == '\0' ) zRepo = "/";
15171514
}else {
15181515
zRepo = "/";
15191516
g.fJail = 1;
15201517
}
1518
+ if( file_chdir(zDir, 1) ){
1519
+ fossil_panic("unable to chroot into %s", zDir);
1520
+ }
15211521
}else{
15221522
for(i=strlen(zDir)-1; i>0 && zDir[i]!='/'; i--){}
15231523
if( zDir[i]!='/' ) fossil_fatal("bad repository name: %s", zRepo);
15241524
if( i>0 ){
15251525
zDir[i] = 0;
15261526
--- 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

Keyboard Shortcuts

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