Fossil SCM

If the 'allow-symlinks' option is enabled (or the '--no-dir-symlinks' flag is specified), do not traverse into symlinked directories.

mistachkin 2017-02-13 20:10 UTC trunk
Commit 3e949e17614a79e72a51e40af130ef0ec711d166
2 files changed +7 -2 +4 -4
+7 -2
--- src/db.c
+++ src/db.c
@@ -1436,12 +1436,17 @@
14361436
}
14371437
14381438
/*
14391439
** Returns non-zero if support for symlinks is currently enabled.
14401440
*/
1441
-int db_allow_symlinks(void){
1442
- return g.allowSymlinks;
1441
+int db_allow_symlinks(int traversal){
1442
+ if( traversal ){
1443
+ if( g.allowSymlinks ) return 1;
1444
+ return g.fNoDirSymlinks;
1445
+ }else{
1446
+ return g.allowSymlinks;
1447
+ }
14431448
}
14441449
14451450
/*
14461451
** Open the repository database given by zDbName. If zDbName==NULL then
14471452
** get the name from the already open local database.
14481453
--- src/db.c
+++ src/db.c
@@ -1436,12 +1436,17 @@
1436 }
1437
1438 /*
1439 ** Returns non-zero if support for symlinks is currently enabled.
1440 */
1441 int db_allow_symlinks(void){
1442 return g.allowSymlinks;
 
 
 
 
 
1443 }
1444
1445 /*
1446 ** Open the repository database given by zDbName. If zDbName==NULL then
1447 ** get the name from the already open local database.
1448
--- src/db.c
+++ src/db.c
@@ -1436,12 +1436,17 @@
1436 }
1437
1438 /*
1439 ** Returns non-zero if support for symlinks is currently enabled.
1440 */
1441 int db_allow_symlinks(int traversal){
1442 if( traversal ){
1443 if( g.allowSymlinks ) return 1;
1444 return g.fNoDirSymlinks;
1445 }else{
1446 return g.allowSymlinks;
1447 }
1448 }
1449
1450 /*
1451 ** Open the repository database given by zDbName. If zDbName==NULL then
1452 ** get the name from the already open local database.
1453
+4 -4
--- src/file.c
+++ src/file.c
@@ -89,11 +89,11 @@
8989
*/
9090
static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){
9191
int rc;
9292
void *zMbcs = fossil_utf8_to_path(zFilename, 0);
9393
#if !defined(_WIN32)
94
- if( isWd && db_allow_symlinks() ){
94
+ if( isWd && db_allow_symlinks(0) ){
9595
rc = lstat(zMbcs, buf);
9696
}else{
9797
rc = stat(zMbcs, buf);
9898
}
9999
#else
@@ -191,11 +191,11 @@
191191
**
192192
** Arguments: target file (symlink will point to it), link file
193193
**/
194194
void symlink_create(const char *zTargetFile, const char *zLinkFile){
195195
#if !defined(_WIN32)
196
- if( db_allow_symlinks() ){
196
+ if( db_allow_symlinks(0) ){
197197
int i, nName;
198198
char *zName, zBuf[1000];
199199
200200
nName = strlen(zLinkFile);
201201
if( nName>=sizeof(zBuf) ){
@@ -248,11 +248,11 @@
248248
int file_wd_perm(const char *zFilename){
249249
#if !defined(_WIN32)
250250
if( !getStat(zFilename, 1) ){
251251
if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
252252
return PERM_EXE;
253
- else if( db_allow_symlinks() && S_ISLNK(fileStat.st_mode) )
253
+ else if( db_allow_symlinks(0) && S_ISLNK(fileStat.st_mode) )
254254
return PERM_LNK;
255255
}
256256
#endif
257257
return PERM_REG;
258258
}
@@ -309,11 +309,11 @@
309309
rc = getStat(zFN, 1);
310310
if( rc ){
311311
rc = 0; /* It does not exist at all. */
312312
}else if( S_ISDIR(fileStat.st_mode) ){
313313
rc = 1; /* It exists and is a real directory. */
314
- }else if( !g.fNoDirSymlinks && S_ISLNK(fileStat.st_mode) ){
314
+ }else if( !db_allow_symlinks(1) && S_ISLNK(fileStat.st_mode) ){
315315
Blob content;
316316
blob_read_link(&content, zFN); /* It exists and is a link. */
317317
rc = file_wd_isdir(blob_str(&content)); /* Points to directory? */
318318
blob_reset(&content);
319319
}else{
320320
--- 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 }
@@ -309,11 +309,11 @@
309 rc = getStat(zFN, 1);
310 if( rc ){
311 rc = 0; /* It does not exist at all. */
312 }else if( S_ISDIR(fileStat.st_mode) ){
313 rc = 1; /* It exists and is a real directory. */
314 }else if( !g.fNoDirSymlinks && S_ISLNK(fileStat.st_mode) ){
315 Blob content;
316 blob_read_link(&content, zFN); /* It exists and is a link. */
317 rc = file_wd_isdir(blob_str(&content)); /* Points to directory? */
318 blob_reset(&content);
319 }else{
320
--- 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(0) ){
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(0) ){
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(0) && S_ISLNK(fileStat.st_mode) )
254 return PERM_LNK;
255 }
256 #endif
257 return PERM_REG;
258 }
@@ -309,11 +309,11 @@
309 rc = getStat(zFN, 1);
310 if( rc ){
311 rc = 0; /* It does not exist at all. */
312 }else if( S_ISDIR(fileStat.st_mode) ){
313 rc = 1; /* It exists and is a real directory. */
314 }else if( !db_allow_symlinks(1) && S_ISLNK(fileStat.st_mode) ){
315 Blob content;
316 blob_read_link(&content, zFN); /* It exists and is a link. */
317 rc = file_wd_isdir(blob_str(&content)); /* Points to directory? */
318 blob_reset(&content);
319 }else{
320

Keyboard Shortcuts

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