Fossil SCM

Fix to the db_open_local() function in the case where the root directory is writable by the current user.

dan 2007-07-28 08:15 trunk
Commit d0d4c5f5753e7c82049658c5fa1992f057fd895b
1 file changed +6 -3
+6 -3
--- src/db.c
+++ src/db.c
@@ -527,23 +527,26 @@
527527
if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
528528
db_err("pwd too big: max %d", sizeof(zPwd)-20);
529529
}
530530
n = strlen(zPwd);
531531
while( n>0 ){
532
- if( access(zPwd, W_OK) ) return 0;
532
+ if( access(zPwd, W_OK) ) break;
533533
strcpy(&zPwd[n], "/_FOSSIL_");
534534
if( isValidLocalDb(zPwd) ){
535
+ /* Found a valid _FOSSIL_ file */
535536
zPwd[n] = 0;
536537
g.zLocalRoot = mprintf("%s/", zPwd);
537
- break;
538
+ return 1;
538539
}
539540
n--;
540541
while( n>0 && zPwd[n]!='/' ){ n--; }
541542
while( n>0 && zPwd[n-1]=='/' ){ n--; }
542543
zPwd[n] = 0;
543544
}
544
- return 1;
545
+
546
+ /* A _FOSSIL_ file could not be found */
547
+ return 0;
545548
}
546549
547550
/*
548551
** Open the repository database given by zDbName. If zDbName==NULL then
549552
** get the name from the already open local database.
550553
--- 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

Keyboard Shortcuts

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