Advertisement
Guest User

using bindfs to hide symbolic links from subversion

a guest
Nov 8th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.70 KB | None | 0 0
  1. diff -ru bindfs-1.12.3_orig/src/bindfs.c bindfs-1.12.3/src/bindfs.c
  2. --- bindfs-1.12.3_orig/src/bindfs.c 2013-09-23 22:59:23.000000000 +0200
  3. +++ bindfs-1.12.3/src/bindfs.c  2013-11-09 02:31:54.000000000 +0100
  4. @@ -132,7 +132,7 @@
  5.  
  6.      int ctime_from_mtime;
  7.      int hide_hard_links;
  8. -    
  9. +    int follow_symbolic_links;
  10.  } settings;
  11.  
  12.  
  13. @@ -241,6 +241,13 @@
  14.          return path;
  15.  }
  16.  
  17. +static int lstat_wrap(const char *path, struct stat *stbuf)
  18. +{
  19. +    if (settings.follow_symbolic_links)
  20. +      return stat(path, stbuf);
  21. +    return lstat(path, stbuf);
  22. +}
  23. +
  24.  static int getattr_common(const char *procpath, struct stat *stbuf)
  25.  {
  26.      struct fuse_context *fc = fuse_get_context();
  27. @@ -309,7 +316,7 @@
  28.  
  29.          path_copy = strdup(path);
  30.          dir_path = my_dirname(path_copy);
  31. -        if (lstat(dir_path, &stbuf) != -1 && stbuf.st_mode & S_ISGID)
  32. +        if (lstat_wrap(dir_path, &stbuf) != -1 && stbuf.st_mode & S_ISGID)
  33.              file_group = -1;
  34.          free(path_copy);
  35.      } else {
  36. @@ -362,7 +369,7 @@
  37.  {
  38.      path = process_path(path);
  39.  
  40. -    if (lstat(path, stbuf) == -1)
  41. +    if (lstat_wrap(path, stbuf) == -1)
  42.          return -errno;
  43.      return getattr_common(path, stbuf);
  44.  }
  45. @@ -444,9 +451,13 @@
  46.              break;
  47.          }
  48.          
  49. -        memset(&st, 0, sizeof(st));
  50. -        st.st_ino = de->d_ino;
  51. -        st.st_mode = de->d_type << 12;
  52. +        if (settings.follow_symbolic_links) {
  53. +            lstat_wrap(de->d_name, &st);
  54. +        } else {
  55. +            memset(&st, 0, sizeof(st));
  56. +            st.st_ino = de->d_ino;
  57. +            st.st_mode = de->d_type << 12;
  58. +        }
  59.          if (filler(buf, de->d_name, &st, telldir(dp)))
  60.              break;
  61.      }
  62. @@ -586,7 +597,7 @@
  63.  
  64.      if (settings.chmod_allow_x) {
  65.          /* Get the old permission bits and see which bits would change. */
  66. -        if (lstat(path, &st) == -1)
  67. +        if (lstat_wrap(path, &st) == -1)
  68.              return -errno;
  69.  
  70.          if (S_ISREG(st.st_mode)) {
  71. @@ -981,6 +992,7 @@
  72.             "  --ctime-from-mtime        Read file properties' change time\n"
  73.             "                            from file content modification time.\n"
  74.             "  --hide-hard-links         Always report a hard link count of 1.\n"
  75. +           "  --follow-symbolic-links   Follow (hide) symbolic links.\n"
  76.             "  --multithreaded           Enable multithreaded mode. See man page\n"
  77.             "                            for security issue with current implementation.\n"
  78.             "\n"
  79. @@ -1019,6 +1031,7 @@
  80.      OPTKEY_REALISTIC_PERMISSIONS,
  81.      OPTKEY_CTIME_FROM_MTIME,
  82.      OPTKEY_HIDE_HARD_LINKS,
  83. +    OPTKEY_FOLLOW_SYMBOLIC_LINKS,
  84.      OPTKEY_MULTITHREADED
  85.  };
  86.  
  87. @@ -1100,6 +1113,9 @@
  88.      case OPTKEY_HIDE_HARD_LINKS:
  89.          settings.hide_hard_links = 1;
  90.          return 0;
  91. +    case OPTKEY_FOLLOW_SYMBOLIC_LINKS:
  92. +        settings.follow_symbolic_links = 1;
  93. +        return 0;
  94.  
  95.      case OPTKEY_NONOPTION:
  96.          if (!settings.mntsrc) {
  97. @@ -1400,6 +1416,7 @@
  98.          OPT2("--realistic-permissions", "realistic-permissions", OPTKEY_REALISTIC_PERMISSIONS),
  99.          OPT2("--ctime-from-mtime", "ctime-from-mtime", OPTKEY_CTIME_FROM_MTIME),
  100.          OPT2("--hide-hard-links", "hide-hard-links", OPTKEY_HIDE_HARD_LINKS),
  101. +        OPT2("--follow-symbolic-links", "follow-symbolic-links", OPTKEY_FOLLOW_SYMBOLIC_LINKS),
  102.          OPT_OFFSET2("--multithreaded", "multithreaded", multithreaded, -1),
  103.          FUSE_OPT_END
  104.      };
  105. @@ -1436,6 +1453,7 @@
  106.      settings.realistic_permissions = 0;
  107.      settings.ctime_from_mtime = 0;
  108.      settings.hide_hard_links = 0;
  109. +    settings.follow_symbolic_links = 0;
  110.      atexit(&atexit_func);
  111.      
  112.      /* Parse options */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement