diff --git a/encfs/RawFileIO.cpp b/encfs/RawFileIO.cpp index 7395d46..34d126f 100644 --- a/encfs/RawFileIO.cpp +++ b/encfs/RawFileIO.cpp @@ -72,29 +72,6 @@ RawFileIO::~RawFileIO() { rel::Interface RawFileIO::interface() const { return RawFileIO_iface; } -/* - Workaround for opening a file for write when permissions don't allow. - Since the kernel has already checked permissions, we can assume it is ok to - provide access. So force it by changing permissions temporarily. Should - be called with a lock around it so that there won't be a race condition - with calls to lstat picking up the wrong permissions. -*/ -static int open_readonly_workaround(const char *path, int flags) { - int fd = -1; - struct stat stbuf; - memset(&stbuf, 0, sizeof(struct stat)); - if (lstat(path, &stbuf) != -1) { - // make sure user has read/write permission.. - chmod(path, stbuf.st_mode | 0600); - fd = ::open(path, flags); - chmod(path, stbuf.st_mode); - } else { - rInfo("can't stat file %s", path); - } - - return fd; -} - /* We shouldn't have to support all possible open flags, so untaint the flags argument by only taking ones we understand and accept. @@ -128,11 +105,6 @@ int RawFileIO::open(int flags) { rDebug("open file with flags %i, result = %i", finalFlags, newFd); - if ((newFd == -1) && (errno == EACCES)) { - rDebug("using readonly workaround for open"); - newFd = open_readonly_workaround(name.c_str(), finalFlags); - } - if (newFd >= 0) { if (oldfd >= 0) { rError("leaking FD?: oldfd = %i, fd = %i, newfd = %i", oldfd, fd,