Fossil

Check-in [35e37e9b]
Login

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

Overview
Comment:Attempt to always enforce the --no-symlinks option.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | noSymlinks
Files: files | file ages | folders
SHA1: 35e37e9ba8160f989dc8f3c4a04fdf8d119fa67d
User & Date: mistachkin 2017-02-01 02:32:54.269
Context
2017-02-01
02:42
The file_wd_isdir() function must honor the symlinks options. ... (check-in: de053c77 user: mistachkin tags: noSymlinks)
02:32
Attempt to always enforce the --no-symlinks option. ... (check-in: 35e37e9b user: mistachkin tags: noSymlinks)
02:16
Add the --no-symlinks global command line option. ... (check-in: 85277aa3 user: mistachkin tags: noSymlinks)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/db.c.
1431
1432
1433
1434
1435
1436
1437








1438
1439
1440
1441
1442
1443
1444
int db_allow_symlinks_by_default(void){
#if defined(_WIN32)
  return 0;
#else
  return !g.fNoSymlinks;
#endif
}









/*
** Open the repository database given by zDbName.  If zDbName==NULL then
** get the name from the already open local database.
*/
void db_open_repository(const char *zDbName){
  if( g.repositoryOpen ) return;







>
>
>
>
>
>
>
>







1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
int db_allow_symlinks_by_default(void){
#if defined(_WIN32)
  return 0;
#else
  return !g.fNoSymlinks;
#endif
}

/*
** Returns non-zero if support for symlinks is currently enabled.
*/
int db_allow_symlinks(void){
  if( g.fNoSymlinks ) return 0;
  return g.allowSymlinks;
}

/*
** Open the repository database given by zDbName.  If zDbName==NULL then
** get the name from the already open local database.
*/
void db_open_repository(const char *zDbName){
  if( g.repositoryOpen ) return;
Changes to src/file.c.
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on.
**
*/
static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){
  int rc;
  void *zMbcs = fossil_utf8_to_path(zFilename, 0);
#if !defined(_WIN32)
  if( isWd && g.allowSymlinks ){
    rc = lstat(zMbcs, buf);
  }else{
    rc = stat(zMbcs, buf);
  }
#else
  rc = win32_stat(zMbcs, buf, isWd);
#endif







|







87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
** lstat() is called on Unix if isWd is TRUE and allow-symlinks setting is on.
**
*/
static int fossil_stat(const char *zFilename, struct fossilStat *buf, int isWd){
  int rc;
  void *zMbcs = fossil_utf8_to_path(zFilename, 0);
#if !defined(_WIN32)
  if( isWd && db_allow_symlinks() ){
    rc = lstat(zMbcs, buf);
  }else{
    rc = stat(zMbcs, buf);
  }
#else
  rc = win32_stat(zMbcs, buf, isWd);
#endif
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
** Create symlink to file on Unix, or plain-text file with
** symlink target if "allow-symlinks" is off or we're on Windows.
**
** Arguments: target file (symlink will point to it), link file
**/
void symlink_create(const char *zTargetFile, const char *zLinkFile){
#if !defined(_WIN32)
  if( g.allowSymlinks ){
    int i, nName;
    char *zName, zBuf[1000];

    nName = strlen(zLinkFile);
    if( nName>=sizeof(zBuf) ){
      zName = mprintf("%s", zLinkFile);
    }else{







|







189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
** Create symlink to file on Unix, or plain-text file with
** symlink target if "allow-symlinks" is off or we're on Windows.
**
** Arguments: target file (symlink will point to it), link file
**/
void symlink_create(const char *zTargetFile, const char *zLinkFile){
#if !defined(_WIN32)
  if( db_allow_symlinks() ){
    int i, nName;
    char *zName, zBuf[1000];

    nName = strlen(zLinkFile);
    if( nName>=sizeof(zBuf) ){
      zName = mprintf("%s", zLinkFile);
    }else{
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
**   - PERM_REG for all other cases (regular file, directory, fifo, etc).
*/
int file_wd_perm(const char *zFilename){
#if !defined(_WIN32)
  if( !getStat(zFilename, 1) ){
     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;
  }
#endif
  return PERM_REG;
}

/*







|







246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
**   - PERM_REG for all other cases (regular file, directory, fifo, etc).
*/
int file_wd_perm(const char *zFilename){
#if !defined(_WIN32)
  if( !getStat(zFilename, 1) ){
     if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
      return PERM_EXE;
    else if( db_allow_symlinks() && S_ISLNK(fileStat.st_mode) )
      return PERM_LNK;
  }
#endif
  return PERM_REG;
}

/*