mirror of
https://github.com/vgough/encfs.git
synced 2025-06-20 03:37:50 +02:00
Remove open_readonly_workaround
Since commit 82ceb88998fccfdbe21d2e66cd8764adef7d55e5 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:
parent
ed058fabcd
commit
c2e046b694
@ -72,29 +72,6 @@ RawFileIO::~RawFileIO() {
|
|||||||
|
|
||||||
rel::Interface RawFileIO::interface() const { return RawFileIO_iface; }
|
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
|
We shouldn't have to support all possible open flags, so untaint the flags
|
||||||
argument by only taking ones we understand and accept.
|
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);
|
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 (newFd >= 0) {
|
||||||
if (oldfd >= 0) {
|
if (oldfd >= 0) {
|
||||||
rError("leaking FD?: oldfd = %i, fd = %i, newfd = %i", oldfd, fd,
|
rError("leaking FD?: oldfd = %i, fd = %i, newfd = %i", oldfd, fd,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user