Skip to content

Instantly share code, notes, and snippets.

@166MMX
Last active October 14, 2015 18:16
Show Gist options
  • Save 166MMX/9766101 to your computer and use it in GitHub Desktop.
Save 166MMX/9766101 to your computer and use it in GitHub Desktop.
add upload_fmode and upload_dmode to https://github.com/osxfuse/sshfs
#!/bin/sh
umask 0002
exec /usr/lib/ssh/sftp-server "$@"
diff --git a/sshfs.c b/sshfs.c
index b09484c..c3cdc4b 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -284,6 +284,8 @@ struct sshfs {
int ext_posix_rename;
int ext_statvfs;
int ext_hardlink;
+ mode_t upload_fmode;
+ mode_t upload_dmode;
mode_t mnt_mode;
/* statistics */
@@ -398,6 +400,8 @@ static struct fuse_opt sshfs_opts[] = {
SSHFS_OPT("delay_connect", delay_connect, 1),
SSHFS_OPT("slave", slave, 1),
SSHFS_OPT("disable_hardlink", disable_hardlink, 1),
+ SSHFS_OPT("upload_fmode=%o", upload_fmode, 0),
+ SSHFS_OPT("upload_dmode=%o", upload_dmode, 0),
FUSE_OPT_KEY("-p ", KEY_PORT),
FUSE_OPT_KEY("-C", KEY_COMPRESS),
@@ -2246,6 +2250,9 @@ static int sshfs_mkdir(const char *path, mode_t mode)
{
int err;
struct buffer buf;
+ if (sshfs.upload_dmode > 0) {
+ mode |= sshfs.upload_dmode;
+ }
buf_init(&buf, 0);
buf_add_path(&buf, path);
buf_add_uint32(&buf, SSH_FILEXFER_ATTR_PERMISSIONS);
@@ -3153,6 +3160,9 @@ static int sshfs_statfs(const char *path, struct statfs *buf)
static int sshfs_create(const char *path, mode_t mode,
struct fuse_file_info *fi)
{
+ if (sshfs.upload_fmode > 0) {
+ mode |= sshfs.upload_fmode;
+ }
return sshfs_open_common(path, mode, fi);
}
@@ -3438,6 +3448,8 @@ static void usage(const char *progname)
" -o no_check_root don't check for existence of 'dir' on server\n"
" -o password_stdin read password from stdin (only for pam_mount!)\n"
" -o SSHOPT=VAL ssh options (see man ssh_config)\n"
+" -o upload_fmode=M set permissions for new remote files (octal)\n"
+" -o upload_dmode=M set permissions for new remote directories (octal)\n"
"\n", progname);
}
diff --git a/Library/Formula/sshfs.rb b/Library/Formula/sshfs.rb
index 89bbbae..07a1258 100644
--- a/Library/Formula/sshfs.rb
+++ b/Library/Formula/sshfs.rb
@@ -25,6 +25,11 @@ class Sshfs < Formula
# Fixes issue https://github.com/osxfuse/sshfs/pull/4
patch :DATA
+ # Adds upload_fmode and upload_dmode options
+ patch do
+ url "https://gist.githubusercontent.com/166MMX/9766101/raw/sshfs.c.diff"
+ sha256 "61facac2c9e21fce443eff767ccd9ea46621f2eeecbf05a17a178d6fd6400606"
+ end
def install
args = %W[
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment