X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;ds=sidebyside;f=unix%2Fuxsftp.c;h=651047e99c1a5e97142cd74c1dc741c79f494229;hb=5c00b581c8b83f6e7be9d53a77d9c61ef4d817a5;hp=3170ecf37bc162759f74861aa1e3b0acc936f35c;hpb=a1f3b7a358adaa7c2a98359cd0373aa823eeb14b;p=PuTTY.git diff --git a/unix/uxsftp.c b/unix/uxsftp.c index 3170ecf3..651047e9 100644 --- a/unix/uxsftp.c +++ b/unix/uxsftp.c @@ -125,7 +125,8 @@ struct RFile { }; RFile *open_existing_file(char *name, uint64 *size, - unsigned long *mtime, unsigned long *atime) + unsigned long *mtime, unsigned long *atime, + long *perms) { int fd; RFile *ret; @@ -137,7 +138,7 @@ RFile *open_existing_file(char *name, uint64 *size, ret = snew(RFile); ret->fd = fd; - if (size || mtime || atime) { + if (size || mtime || atime || perms) { struct stat statbuf; if (fstat(fd, &statbuf) < 0) { fprintf(stderr, "%s: stat: %s\n", name, strerror(errno)); @@ -153,6 +154,9 @@ RFile *open_existing_file(char *name, uint64 *size, if (atime) *atime = statbuf.st_atime; + + if (perms) + *perms = statbuf.st_mode; } return ret; @@ -174,12 +178,13 @@ struct WFile { char *name; }; -WFile *open_new_file(char *name) +WFile *open_new_file(char *name, long perms) { int fd; WFile *ret; - fd = open(name, O_CREAT | O_TRUNC | O_WRONLY, 0666); + fd = open(name, O_CREAT | O_TRUNC | O_WRONLY, + (mode_t)(perms ? perms : 0666)); if (fd < 0) return NULL;