Remove open_readonly_workaround

Since commit 82ceb88998 has removed
libfuse permissions checking, this function has caused read-only
files to writeable.

There seems to be no valid use case for writing to a read-only file (anymore?),
remove the function.

Fixes issue 112.
This commit is contained in:
Jakob Unterwurzacher 2015-10-30 22:18:17 +01:00
parent ed058fabcd
commit c2e046b694

View File

@ -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,