aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2014-02-10 14:09:13 +0100
committerMiklos Szeredi <mszeredi@suse.cz>2014-02-10 14:09:13 +0100
commit48122e8043c0d7393688346f7567dff89dcc772b (patch)
treefb669810e0315801d7c6d5ea1ac077f96ce5d5f6
parent6b4415ada44e0cbf1924f534cd04d117a5a4dbd3 (diff)
downloadsshfs-48122e8043c0d7393688346f7567dff89dcc772b.tar
sshfs-48122e8043c0d7393688346f7567dff89dcc772b.tar.gz
sshfs-48122e8043c0d7393688346f7567dff89dcc772b.tar.bz2
sshfs-48122e8043c0d7393688346f7567dff89dcc772b.zip
sshfs-return-the-correct-x_ok-access
sshfs-fuse always returned 0 in access(file, X_OK) calls, causing nautilus to prompt "Do you want to run "login.defs", or display its contents?" for text files that were not executable. Reported by: Alkis Georgopoulos
-rw-r--r--ChangeLog5
-rw-r--r--cache.c1
-rw-r--r--sshfs.c26
3 files changed, 29 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 7919f7b..0a15d54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-10 Miklos Szeredi <miklos@szeredi.hu>
+
+ * sshfs: return the correct X_OK access. Reported by: Alkis
+ Georgopoulos
+
2014-01-14 Miklos Szeredi <miklos@szeredi.hu>
* Released 2.5
diff --git a/cache.c b/cache.c
index 2a06726..6e93157 100644
--- a/cache.c
+++ b/cache.c
@@ -490,6 +490,7 @@ static void cache_unity_fill(struct fuse_cache_operations *oper,
cache_oper->init = oper->oper.init;
#endif
cache_oper->getattr = oper->oper.getattr;
+ cache_oper->access = oper->oper.access;
cache_oper->readlink = oper->oper.readlink;
cache_oper->getdir = cache_unity_getdir;
cache_oper->mknod = oper->oper.mknod;
diff --git a/sshfs.c b/sshfs.c
index 96b98a5..5768ec2 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -254,6 +254,7 @@ struct sshfs {
int ext_statvfs;
int ext_hardlink;
mode_t mnt_mode;
+ struct fuse_operations *op;
/* statistics */
uint64_t bytes_sent;
@@ -1932,6 +1933,22 @@ static int sshfs_getattr(const char *path, struct stat *stbuf)
return err;
}
+static int sshfs_access(const char *path, int mask)
+{
+ struct stat stbuf;
+ int err = 0;
+
+ if (mask & X_OK) {
+ err = sshfs.op->getattr(path, &stbuf);
+ if (!err) {
+ if (S_ISREG(stbuf.st_mode) &&
+ !(stbuf.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))
+ err = -EACCES;
+ }
+ }
+ return err;
+}
+
static int count_components(const char *p)
{
int ctr;
@@ -3234,6 +3251,7 @@ static struct fuse_cache_operations sshfs_oper = {
.oper = {
.init = sshfs_init,
.getattr = sshfs_getattr,
+ .access = sshfs_access,
.readlink = sshfs_readlink,
.mknod = sshfs_mknod,
.mkdir = sshfs_mkdir,
@@ -3336,10 +3354,11 @@ static int is_ssh_opt(const char *arg)
static int sshfs_fuse_main(struct fuse_args *args)
{
+ sshfs.op = cache_init(&sshfs_oper);
#if FUSE_VERSION >= 26
- return fuse_main(args->argc, args->argv, cache_init(&sshfs_oper), NULL);
+ return fuse_main(args->argc, args->argv, sshfs.op, NULL);
#else
- return fuse_main(args->argc, args->argv, cache_init(&sshfs_oper));
+ return fuse_main(args->argc, args->argv, sshfs.op);
#endif
}
@@ -3977,7 +3996,8 @@ int main(int argc, char *argv[])
if (res == -1)
perror("WARNING: failed to set FD_CLOEXEC on fuse device");
- fuse = fuse_new(ch, &args, cache_init(&sshfs_oper),
+ sshfs.op = cache_init(&sshfs_oper);
+ fuse = fuse_new(ch, &args, sshfs.op,
sizeof(struct fuse_operations), NULL);
if (fuse == NULL) {
fuse_unmount(mountpoint, ch);