Fossil

Check-in [3d0e8c01]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:3d0e8c01fe45d0167b55e72de228f147579f2fcc
User & Date: jan.nijtmans 2015-02-08 10:20:49
Context
2015-02-08
18:02
Fix a typo in artifact descriptions. check-in: 88ed5122 user: drh tags: trunk
10:20
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. check-in: 3d0e8c01 user: jan.nijtmans tags: trunk
00:22
Fix formatting issues on the object description in /artifact check-in: ca30907b user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/file.c.

228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
...
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
...
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
void symlink_copy(const char *zFrom, const char *zTo){
  Blob content;
  blob_read_link(&content, zFrom);
  symlink_create(blob_str(&content), zTo);
  blob_reset(&content);
}

#ifdef __CYGWIN__
/* On Cygwin (and possibly other IEEE 1003.1 ("POSIX.1") compliant systems)
** the group permission cannot be relied upon for security reasons. See:
** https://cygwin.com/faq/faq.html#faq.using.ssh-pubkey-stops-working
*/
# undef S_IXGRP
# define S_IXGRP 0
#endif

/*
** Return file permissions (normal, executable, or symlink):
**   - PERM_EXE if file is executable;
**   - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
**   - PERM_REG for all other cases (regular file, directory, fifo, etc).
*/
int file_wd_perm(const char *zFilename){
................................................................................
#    define S_IXUSR  _S_IEXEC
#  endif
  if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
    return PERM_EXE;
  else
    return PERM_REG;
#else
  if( S_ISREG(fileStat.st_mode) &&
      ((S_IXUSR|S_IXGRP|S_IXOTH)&fileStat.st_mode)!=0 )
    return PERM_EXE;
  else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
    return PERM_LNK;
  else
    return PERM_REG;
#endif
}
................................................................................
int file_wd_setexe(const char *zFilename, int onoff){
  int rc = 0;
#if !defined(_WIN32)
  struct stat buf;
  if( fossil_stat(zFilename, &buf, 1)!=0 || S_ISLNK(buf.st_mode) ) return 0;
  if( onoff ){
    int targetMode = (buf.st_mode & 0444)>>2;
    if( (buf.st_mode & 0111)!=targetMode ){
      chmod(zFilename, buf.st_mode | targetMode);
      rc = 1;
    }
  }else{
    if( (buf.st_mode & 0111)!=0 ){
      chmod(zFilename, buf.st_mode & ~0111);
      rc = 1;
    }
  }
#endif /* _WIN32 */
  return rc;
}







<
<
<
<
<
<
<
<
<







 







|
<







 







|




|







228
229
230
231
232
233
234









235
236
237
238
239
240
241
...
245
246
247
248
249
250
251
252

253
254
255
256
257
258
259
...
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
void symlink_copy(const char *zFrom, const char *zTo){
  Blob content;
  blob_read_link(&content, zFrom);
  symlink_create(blob_str(&content), zTo);
  blob_reset(&content);
}










/*
** Return file permissions (normal, executable, or symlink):
**   - PERM_EXE if file is executable;
**   - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
**   - PERM_REG for all other cases (regular file, directory, fifo, etc).
*/
int file_wd_perm(const char *zFilename){
................................................................................
#    define S_IXUSR  _S_IEXEC
#  endif
  if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
    return PERM_EXE;
  else
    return PERM_REG;
#else
  if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )

    return PERM_EXE;
  else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
    return PERM_LNK;
  else
    return PERM_REG;
#endif
}
................................................................................
int file_wd_setexe(const char *zFilename, int onoff){
  int rc = 0;
#if !defined(_WIN32)
  struct stat buf;
  if( fossil_stat(zFilename, &buf, 1)!=0 || S_ISLNK(buf.st_mode) ) return 0;
  if( onoff ){
    int targetMode = (buf.st_mode & 0444)>>2;
    if( (buf.st_mode & 0100) == 0 ){
      chmod(zFilename, buf.st_mode | targetMode);
      rc = 1;
    }
  }else{
    if( (buf.st_mode & 0100) != 0 ){
      chmod(zFilename, buf.st_mode & ~0111);
      rc = 1;
    }
  }
#endif /* _WIN32 */
  return rc;
}