diff options
author | Lev Walkin <vlm@lionet.info> | 2014-10-12 19:30:12 -0700 |
---|---|---|
committer | Lev Walkin <vlm@lionet.info> | 2014-10-12 19:30:12 -0700 |
commit | ebfc44d02ab218e3011df271ff1150c4d49b568e (patch) | |
tree | bd8a2a7361dde43efc56e979782f7c2f77265200 | |
parent | 67303befa43ab520213293a814f0bae15a134fb6 (diff) |
issue/32 fchmod() does not respect umask
-rw-r--r-- | libasn1compiler/asn1c_compat.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libasn1compiler/asn1c_compat.c b/libasn1compiler/asn1c_compat.c index 8cb78cde..be0f1212 100644 --- a/libasn1compiler/asn1c_compat.c +++ b/libasn1compiler/asn1c_compat.c @@ -5,11 +5,21 @@ #define MAXPATHLEN 1024 #endif +/* Normally file permissions are (DEFFILEMODE & ~umask(2)) */ #ifndef DEFFILEMODE /* Normally in <sys/stat.h> */ + #ifdef _WIN32 #define DEFFILEMODE (S_IREAD|S_IWRITE) +#define REASONABLE_FILE_MODE DEFFILEMODE #else #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#define REASONABLE_FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) +#endif +#else /* !DEFFILEMODE */ +#ifdef _WIN32 +#define REASONABLE_FILE_MODE DEFFILEMODE +#else +#define REASONABLE_FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) #endif #endif @@ -56,7 +66,8 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) { */ fd = mkstemp(fname); #ifndef _WIN32 - (void)fchmod(fd, DEFFILEMODE); + /* fchmod() does not respect umask */ + (void)fchmod(fd, REASONABLE_FILE_MODE); #endif } else { /* |