mirror of
https://github.com/vgough/encfs.git
synced 2025-08-14 16:08:29 +02:00
Improve auto unmount
more secure & libfuse3 compatible
This commit is contained in:
@ -43,11 +43,6 @@
|
|||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
#include "openssl.h"
|
#include "openssl.h"
|
||||||
|
|
||||||
// Fuse version >= 26 requires another argument to fuse_unmount, which we
|
|
||||||
// don't have. So use the backward compatible call instead..
|
|
||||||
extern "C" void fuse_unmount_compat22(const char *mountpoint);
|
|
||||||
#define fuse_unmount fuse_unmount_compat22
|
|
||||||
|
|
||||||
/* Arbitrary identifiers for long options that do
|
/* Arbitrary identifiers for long options that do
|
||||||
* not have a short version */
|
* not have a short version */
|
||||||
#define LONG_OPT_ANNOTATE 513
|
#define LONG_OPT_ANNOTATE 513
|
||||||
@ -768,9 +763,20 @@ static bool unmountFS(EncFS_Context *ctx) {
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// Time to unmount!
|
// Time to unmount!
|
||||||
RLOG(WARNING) << "Unmounting filesystem due to inactivity: "
|
int rc=1;
|
||||||
<< arg->opts->mountPoint;
|
if (access("/bin/umount", F_OK) != -1)
|
||||||
fuse_unmount(arg->opts->mountPoint.c_str());
|
rc = system(("/bin/umount "+std::string(arg->opts->mountPoint)).c_str());
|
||||||
return true;
|
else
|
||||||
|
rc = system(("/sbin/umount "+std::string(arg->opts->mountPoint)).c_str());
|
||||||
|
if (!rc) {
|
||||||
|
RLOG(WARNING) << "Filesystem " << arg->opts->mountPoint
|
||||||
|
<< " inactivity detected, unmounted";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
RLOG(ERROR) << "Filesystem " << arg->opts->mountPoint
|
||||||
|
<< " inactivity detected, but failed to unmount";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user