aboutsummaryrefslogtreecommitdiff
path: root/sshfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'sshfs.c')
-rw-r--r--sshfs.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/sshfs.c b/sshfs.c
index b09484c..eab48c9 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -139,6 +139,8 @@
#define READDIR_START 2
#define READDIR_MAX 32
+#define MAX_PASSWORD 1024
+
#ifdef __APPLE__
#ifndef LIBDIR
@@ -285,6 +287,7 @@ struct sshfs {
int ext_statvfs;
int ext_hardlink;
mode_t mnt_mode;
+ struct fuse_operations *op;
/* statistics */
uint64_t bytes_sent;
@@ -2009,6 +2012,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;
@@ -3351,6 +3370,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,
@@ -3458,10 +3478,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
}
@@ -3590,7 +3611,7 @@ static void check_large_read(struct fuse_args *args)
static int read_password(void)
{
int size = getpagesize();
- int max_password = 64;
+ int max_password = MIN(MAX_PASSWORD, size - 1);
int n;
sshfs.password = mmap(NULL, size, PROT_READ | PROT_WRITE,
@@ -3951,8 +3972,8 @@ int main(int argc, char *argv[])
if (!realpath(*exec_path, sshfs_program_path)) {
memset(sshfs_program_path, 0, PATH_MAX);
}
-
- /* Until this gets fixed somewhere else. */
+
+ /* Until this gets fixed somewhere else. */
g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);
#endif /* __APPLE__ */
g_thread_init(NULL);
@@ -4133,7 +4154,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);