Fossil SCM
Attempt to always enforce the --no-symlinks option.
Commit
35e37e9ba8160f989dc8f3c4a04fdf8d119fa67d
Parent
85277aa3b3239d4…
2 files changed
+8
+3
-3
M
src/db.c
+8
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1433,10 +1433,18 @@ | ||
| 1433 | 1433 | return 0; |
| 1434 | 1434 | #else |
| 1435 | 1435 | return !g.fNoSymlinks; |
| 1436 | 1436 | #endif |
| 1437 | 1437 | } |
| 1438 | + | |
| 1439 | +/* | |
| 1440 | +** Returns non-zero if support for symlinks is currently enabled. | |
| 1441 | +*/ | |
| 1442 | +int db_allow_symlinks(void){ | |
| 1443 | + if( g.fNoSymlinks ) return 0; | |
| 1444 | + return g.allowSymlinks; | |
| 1445 | +} | |
| 1438 | 1446 | |
| 1439 | 1447 | /* |
| 1440 | 1448 | ** Open the repository database given by zDbName. If zDbName==NULL then |
| 1441 | 1449 | ** get the name from the already open local database. |
| 1442 | 1450 | */ |
| 1443 | 1451 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1433,10 +1433,18 @@ | |
| 1433 | return 0; |
| 1434 | #else |
| 1435 | return !g.fNoSymlinks; |
| 1436 | #endif |
| 1437 | } |
| 1438 | |
| 1439 | /* |
| 1440 | ** Open the repository database given by zDbName. If zDbName==NULL then |
| 1441 | ** get the name from the already open local database. |
| 1442 | */ |
| 1443 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1433,10 +1433,18 @@ | |
| 1433 | return 0; |
| 1434 | #else |
| 1435 | return !g.fNoSymlinks; |
| 1436 | #endif |
| 1437 | } |
| 1438 | |
| 1439 | /* |
| 1440 | ** Returns non-zero if support for symlinks is currently enabled. |
| 1441 | */ |
| 1442 | int db_allow_symlinks(void){ |
| 1443 | if( g.fNoSymlinks ) return 0; |
| 1444 | return g.allowSymlinks; |
| 1445 | } |
| 1446 | |
| 1447 | /* |
| 1448 | ** Open the repository database given by zDbName. If zDbName==NULL then |
| 1449 | ** get the name from the already open local database. |
| 1450 | */ |
| 1451 |
+3
-3
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -89,11 +89,11 @@ | ||
| 89 | 89 | */ |
| 90 | 90 | static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){ |
| 91 | 91 | int rc; |
| 92 | 92 | void *zMbcs = fossil_utf8_to_path(zFilename, 0); |
| 93 | 93 | #if !defined(_WIN32) |
| 94 | - if( isWd && g.allowSymlinks ){ | |
| 94 | + if( isWd && db_allow_symlinks() ){ | |
| 95 | 95 | rc = lstat(zMbcs, buf); |
| 96 | 96 | }else{ |
| 97 | 97 | rc = stat(zMbcs, buf); |
| 98 | 98 | } |
| 99 | 99 | #else |
| @@ -191,11 +191,11 @@ | ||
| 191 | 191 | ** |
| 192 | 192 | ** Arguments: target file (symlink will point to it), link file |
| 193 | 193 | **/ |
| 194 | 194 | void symlink_create(const char *zTargetFile, const char *zLinkFile){ |
| 195 | 195 | #if !defined(_WIN32) |
| 196 | - if( g.allowSymlinks ){ | |
| 196 | + if( db_allow_symlinks() ){ | |
| 197 | 197 | int i, nName; |
| 198 | 198 | char *zName, zBuf[1000]; |
| 199 | 199 | |
| 200 | 200 | nName = strlen(zLinkFile); |
| 201 | 201 | if( nName>=sizeof(zBuf) ){ |
| @@ -248,11 +248,11 @@ | ||
| 248 | 248 | int file_wd_perm(const char *zFilename){ |
| 249 | 249 | #if !defined(_WIN32) |
| 250 | 250 | if( !getStat(zFilename, 1) ){ |
| 251 | 251 | if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 ) |
| 252 | 252 | return PERM_EXE; |
| 253 | - else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) ) | |
| 253 | + else if( db_allow_symlinks() && S_ISLNK(fileStat.st_mode) ) | |
| 254 | 254 | return PERM_LNK; |
| 255 | 255 | } |
| 256 | 256 | #endif |
| 257 | 257 | return PERM_REG; |
| 258 | 258 | } |
| 259 | 259 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -89,11 +89,11 @@ | |
| 89 | */ |
| 90 | static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){ |
| 91 | int rc; |
| 92 | void *zMbcs = fossil_utf8_to_path(zFilename, 0); |
| 93 | #if !defined(_WIN32) |
| 94 | if( isWd && g.allowSymlinks ){ |
| 95 | rc = lstat(zMbcs, buf); |
| 96 | }else{ |
| 97 | rc = stat(zMbcs, buf); |
| 98 | } |
| 99 | #else |
| @@ -191,11 +191,11 @@ | |
| 191 | ** |
| 192 | ** Arguments: target file (symlink will point to it), link file |
| 193 | **/ |
| 194 | void symlink_create(const char *zTargetFile, const char *zLinkFile){ |
| 195 | #if !defined(_WIN32) |
| 196 | if( g.allowSymlinks ){ |
| 197 | int i, nName; |
| 198 | char *zName, zBuf[1000]; |
| 199 | |
| 200 | nName = strlen(zLinkFile); |
| 201 | if( nName>=sizeof(zBuf) ){ |
| @@ -248,11 +248,11 @@ | |
| 248 | int file_wd_perm(const char *zFilename){ |
| 249 | #if !defined(_WIN32) |
| 250 | if( !getStat(zFilename, 1) ){ |
| 251 | if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 ) |
| 252 | return PERM_EXE; |
| 253 | else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) ) |
| 254 | return PERM_LNK; |
| 255 | } |
| 256 | #endif |
| 257 | return PERM_REG; |
| 258 | } |
| 259 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -89,11 +89,11 @@ | |
| 89 | */ |
| 90 | static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){ |
| 91 | int rc; |
| 92 | void *zMbcs = fossil_utf8_to_path(zFilename, 0); |
| 93 | #if !defined(_WIN32) |
| 94 | if( isWd && db_allow_symlinks() ){ |
| 95 | rc = lstat(zMbcs, buf); |
| 96 | }else{ |
| 97 | rc = stat(zMbcs, buf); |
| 98 | } |
| 99 | #else |
| @@ -191,11 +191,11 @@ | |
| 191 | ** |
| 192 | ** Arguments: target file (symlink will point to it), link file |
| 193 | **/ |
| 194 | void symlink_create(const char *zTargetFile, const char *zLinkFile){ |
| 195 | #if !defined(_WIN32) |
| 196 | if( db_allow_symlinks() ){ |
| 197 | int i, nName; |
| 198 | char *zName, zBuf[1000]; |
| 199 | |
| 200 | nName = strlen(zLinkFile); |
| 201 | if( nName>=sizeof(zBuf) ){ |
| @@ -248,11 +248,11 @@ | |
| 248 | int file_wd_perm(const char *zFilename){ |
| 249 | #if !defined(_WIN32) |
| 250 | if( !getStat(zFilename, 1) ){ |
| 251 | if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 ) |
| 252 | return PERM_EXE; |
| 253 | else if( db_allow_symlinks() && S_ISLNK(fileStat.st_mode) ) |
| 254 | return PERM_LNK; |
| 255 | } |
| 256 | #endif |
| 257 | return PERM_REG; |
| 258 | } |
| 259 |