Fossil SCM
Fix to the db_open_local() function in the case where the root directory is writable by the current user.
Commit
d0d4c5f5753e7c82049658c5fa1992f057fd895b
Parent
0c227fa40679a87…
1 file changed
+6
-3
M
src/db.c
+6
-3
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -527,23 +527,26 @@ | ||
| 527 | 527 | if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ |
| 528 | 528 | db_err("pwd too big: max %d", sizeof(zPwd)-20); |
| 529 | 529 | } |
| 530 | 530 | n = strlen(zPwd); |
| 531 | 531 | while( n>0 ){ |
| 532 | - if( access(zPwd, W_OK) ) return 0; | |
| 532 | + if( access(zPwd, W_OK) ) break; | |
| 533 | 533 | strcpy(&zPwd[n], "/_FOSSIL_"); |
| 534 | 534 | if( isValidLocalDb(zPwd) ){ |
| 535 | + /* Found a valid _FOSSIL_ file */ | |
| 535 | 536 | zPwd[n] = 0; |
| 536 | 537 | g.zLocalRoot = mprintf("%s/", zPwd); |
| 537 | - break; | |
| 538 | + return 1; | |
| 538 | 539 | } |
| 539 | 540 | n--; |
| 540 | 541 | while( n>0 && zPwd[n]!='/' ){ n--; } |
| 541 | 542 | while( n>0 && zPwd[n-1]=='/' ){ n--; } |
| 542 | 543 | zPwd[n] = 0; |
| 543 | 544 | } |
| 544 | - return 1; | |
| 545 | + | |
| 546 | + /* A _FOSSIL_ file could not be found */ | |
| 547 | + return 0; | |
| 545 | 548 | } |
| 546 | 549 | |
| 547 | 550 | /* |
| 548 | 551 | ** Open the repository database given by zDbName. If zDbName==NULL then |
| 549 | 552 | ** get the name from the already open local database. |
| 550 | 553 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -527,23 +527,26 @@ | |
| 527 | if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ |
| 528 | db_err("pwd too big: max %d", sizeof(zPwd)-20); |
| 529 | } |
| 530 | n = strlen(zPwd); |
| 531 | while( n>0 ){ |
| 532 | if( access(zPwd, W_OK) ) return 0; |
| 533 | strcpy(&zPwd[n], "/_FOSSIL_"); |
| 534 | if( isValidLocalDb(zPwd) ){ |
| 535 | zPwd[n] = 0; |
| 536 | g.zLocalRoot = mprintf("%s/", zPwd); |
| 537 | break; |
| 538 | } |
| 539 | n--; |
| 540 | while( n>0 && zPwd[n]!='/' ){ n--; } |
| 541 | while( n>0 && zPwd[n-1]=='/' ){ n--; } |
| 542 | zPwd[n] = 0; |
| 543 | } |
| 544 | return 1; |
| 545 | } |
| 546 | |
| 547 | /* |
| 548 | ** Open the repository database given by zDbName. If zDbName==NULL then |
| 549 | ** get the name from the already open local database. |
| 550 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -527,23 +527,26 @@ | |
| 527 | if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ |
| 528 | db_err("pwd too big: max %d", sizeof(zPwd)-20); |
| 529 | } |
| 530 | n = strlen(zPwd); |
| 531 | while( n>0 ){ |
| 532 | if( access(zPwd, W_OK) ) break; |
| 533 | strcpy(&zPwd[n], "/_FOSSIL_"); |
| 534 | if( isValidLocalDb(zPwd) ){ |
| 535 | /* Found a valid _FOSSIL_ file */ |
| 536 | zPwd[n] = 0; |
| 537 | g.zLocalRoot = mprintf("%s/", zPwd); |
| 538 | return 1; |
| 539 | } |
| 540 | n--; |
| 541 | while( n>0 && zPwd[n]!='/' ){ n--; } |
| 542 | while( n>0 && zPwd[n-1]=='/' ){ n--; } |
| 543 | zPwd[n] = 0; |
| 544 | } |
| 545 | |
| 546 | /* A _FOSSIL_ file could not be found */ |
| 547 | return 0; |
| 548 | } |
| 549 | |
| 550 | /* |
| 551 | ** Open the repository database given by zDbName. If zDbName==NULL then |
| 552 | ** get the name from the already open local database. |
| 553 |