Fossil SCM

Fix Fossil's handling of file permission bits on systems which have ACL's. In that case, group permissions can give unexpected values, which results in unnecessary slowdown repeatedly trying to unset the flags which doesn't work. More explanation: [https://cygwin.com/faq/faq.html#faq.using.ssh-pubkey-stops-working]. Noted on latest Cygwin (1.7.34) which added support for ACL handling.

jan.nijtmans 2015-02-08 10:20 trunk
Commit 3d0e8c01fe45d0167b55e72de228f147579f2fcc
1 file changed +3 -13
+3 -13
--- src/file.c
+++ src/file.c
@@ -230,19 +230,10 @@
230230
blob_read_link(&content, zFrom);
231231
symlink_create(blob_str(&content), zTo);
232232
blob_reset(&content);
233233
}
234234
235
-#ifdef __CYGWIN__
236
-/* On Cygwin (and possibly other IEEE 1003.1 ("POSIX.1") compliant systems)
237
-** the group permission cannot be relied upon for security reasons. See:
238
-** https://cygwin.com/faq/faq.html#faq.using.ssh-pubkey-stops-working
239
-*/
240
-# undef S_IXGRP
241
-# define S_IXGRP 0
242
-#endif
243
-
244235
/*
245236
** Return file permissions (normal, executable, or symlink):
246237
** - PERM_EXE if file is executable;
247238
** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
248239
** - PERM_REG for all other cases (regular file, directory, fifo, etc).
@@ -256,12 +247,11 @@
256247
if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
257248
return PERM_EXE;
258249
else
259250
return PERM_REG;
260251
#else
261
- if( S_ISREG(fileStat.st_mode) &&
262
- ((S_IXUSR|S_IXGRP|S_IXOTH)&fileStat.st_mode)!=0 )
252
+ if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
263253
return PERM_EXE;
264254
else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
265255
return PERM_LNK;
266256
else
267257
return PERM_REG;
@@ -441,16 +431,16 @@
441431
#if !defined(_WIN32)
442432
struct stat buf;
443433
if( fossil_stat(zFilename, &buf, 1)!=0 || S_ISLNK(buf.st_mode) ) return 0;
444434
if( onoff ){
445435
int targetMode = (buf.st_mode & 0444)>>2;
446
- if( (buf.st_mode & 0111)!=targetMode ){
436
+ if( (buf.st_mode & 0100) == 0 ){
447437
chmod(zFilename, buf.st_mode | targetMode);
448438
rc = 1;
449439
}
450440
}else{
451
- if( (buf.st_mode & 0111)!=0 ){
441
+ if( (buf.st_mode & 0100) != 0 ){
452442
chmod(zFilename, buf.st_mode & ~0111);
453443
rc = 1;
454444
}
455445
}
456446
#endif /* _WIN32 */
457447
--- src/file.c
+++ src/file.c
@@ -230,19 +230,10 @@
230 blob_read_link(&content, zFrom);
231 symlink_create(blob_str(&content), zTo);
232 blob_reset(&content);
233 }
234
235 #ifdef __CYGWIN__
236 /* On Cygwin (and possibly other IEEE 1003.1 ("POSIX.1") compliant systems)
237 ** the group permission cannot be relied upon for security reasons. See:
238 ** https://cygwin.com/faq/faq.html#faq.using.ssh-pubkey-stops-working
239 */
240 # undef S_IXGRP
241 # define S_IXGRP 0
242 #endif
243
244 /*
245 ** Return file permissions (normal, executable, or symlink):
246 ** - PERM_EXE if file is executable;
247 ** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
248 ** - PERM_REG for all other cases (regular file, directory, fifo, etc).
@@ -256,12 +247,11 @@
256 if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
257 return PERM_EXE;
258 else
259 return PERM_REG;
260 #else
261 if( S_ISREG(fileStat.st_mode) &&
262 ((S_IXUSR|S_IXGRP|S_IXOTH)&fileStat.st_mode)!=0 )
263 return PERM_EXE;
264 else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
265 return PERM_LNK;
266 else
267 return PERM_REG;
@@ -441,16 +431,16 @@
441 #if !defined(_WIN32)
442 struct stat buf;
443 if( fossil_stat(zFilename, &buf, 1)!=0 || S_ISLNK(buf.st_mode) ) return 0;
444 if( onoff ){
445 int targetMode = (buf.st_mode & 0444)>>2;
446 if( (buf.st_mode & 0111)!=targetMode ){
447 chmod(zFilename, buf.st_mode | targetMode);
448 rc = 1;
449 }
450 }else{
451 if( (buf.st_mode & 0111)!=0 ){
452 chmod(zFilename, buf.st_mode & ~0111);
453 rc = 1;
454 }
455 }
456 #endif /* _WIN32 */
457
--- src/file.c
+++ src/file.c
@@ -230,19 +230,10 @@
230 blob_read_link(&content, zFrom);
231 symlink_create(blob_str(&content), zTo);
232 blob_reset(&content);
233 }
234
 
 
 
 
 
 
 
 
 
235 /*
236 ** Return file permissions (normal, executable, or symlink):
237 ** - PERM_EXE if file is executable;
238 ** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
239 ** - PERM_REG for all other cases (regular file, directory, fifo, etc).
@@ -256,12 +247,11 @@
247 if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
248 return PERM_EXE;
249 else
250 return PERM_REG;
251 #else
252 if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
 
253 return PERM_EXE;
254 else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
255 return PERM_LNK;
256 else
257 return PERM_REG;
@@ -441,16 +431,16 @@
431 #if !defined(_WIN32)
432 struct stat buf;
433 if( fossil_stat(zFilename, &buf, 1)!=0 || S_ISLNK(buf.st_mode) ) return 0;
434 if( onoff ){
435 int targetMode = (buf.st_mode & 0444)>>2;
436 if( (buf.st_mode & 0100) == 0 ){
437 chmod(zFilename, buf.st_mode | targetMode);
438 rc = 1;
439 }
440 }else{
441 if( (buf.st_mode & 0100) != 0 ){
442 chmod(zFilename, buf.st_mode & ~0111);
443 rc = 1;
444 }
445 }
446 #endif /* _WIN32 */
447

Keyboard Shortcuts

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