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.
Commit
3d0e8c01fe45d0167b55e72de228f147579f2fcc
Parent
ca30907b0e6e092…
1 file changed
+3
-13
+3
-13
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -230,19 +230,10 @@ | ||
| 230 | 230 | blob_read_link(&content, zFrom); |
| 231 | 231 | symlink_create(blob_str(&content), zTo); |
| 232 | 232 | blob_reset(&content); |
| 233 | 233 | } |
| 234 | 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 | 235 | /* |
| 245 | 236 | ** Return file permissions (normal, executable, or symlink): |
| 246 | 237 | ** - PERM_EXE if file is executable; |
| 247 | 238 | ** - PERM_LNK on Unix if file is symlink and allow-symlinks option is on; |
| 248 | 239 | ** - PERM_REG for all other cases (regular file, directory, fifo, etc). |
| @@ -256,12 +247,11 @@ | ||
| 256 | 247 | if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 ) |
| 257 | 248 | return PERM_EXE; |
| 258 | 249 | else |
| 259 | 250 | return PERM_REG; |
| 260 | 251 | #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 ) | |
| 263 | 253 | return PERM_EXE; |
| 264 | 254 | else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) ) |
| 265 | 255 | return PERM_LNK; |
| 266 | 256 | else |
| 267 | 257 | return PERM_REG; |
| @@ -441,16 +431,16 @@ | ||
| 441 | 431 | #if !defined(_WIN32) |
| 442 | 432 | struct stat buf; |
| 443 | 433 | if( fossil_stat(zFilename, &buf, 1)!=0 || S_ISLNK(buf.st_mode) ) return 0; |
| 444 | 434 | if( onoff ){ |
| 445 | 435 | int targetMode = (buf.st_mode & 0444)>>2; |
| 446 | - if( (buf.st_mode & 0111)!=targetMode ){ | |
| 436 | + if( (buf.st_mode & 0100) == 0 ){ | |
| 447 | 437 | chmod(zFilename, buf.st_mode | targetMode); |
| 448 | 438 | rc = 1; |
| 449 | 439 | } |
| 450 | 440 | }else{ |
| 451 | - if( (buf.st_mode & 0111)!=0 ){ | |
| 441 | + if( (buf.st_mode & 0100) != 0 ){ | |
| 452 | 442 | chmod(zFilename, buf.st_mode & ~0111); |
| 453 | 443 | rc = 1; |
| 454 | 444 | } |
| 455 | 445 | } |
| 456 | 446 | #endif /* _WIN32 */ |
| 457 | 447 |
| --- 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 |