summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorboydgreenfield <boyd.greenfield@gmail.com>2014-05-05 16:42:30 -0700
committerboydgreenfield <boyd.greenfield@gmail.com>2014-05-05 16:42:30 -0700
commita309a5f38abd7c6d57f1e80a3aef81c3c3501f65 (patch)
treefb69f15094fa114c3a5c2600760eac5eacb104a2 /lib
parentc210e1255cc902130ba76d4d1f014ac0f724d145 (diff)
downloadNim-a309a5f38abd7c6d57f1e80a3aef81c3c3501f65.tar.gz
Update posix open() call to incl. permissions
This explicitly grants user read/write access to newly-created mmap files. Previously, on some systems files would be created but could not be re-opened as the user lacked sufficient permissions.
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/memfiles.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/pure/memfiles.nim b/lib/pure/memfiles.nim
index 97220b90b..31fefc6c8 100644
--- a/lib/pure/memfiles.nim
+++ b/lib/pure/memfiles.nim
@@ -178,8 +178,11 @@ proc open*(filename: string, mode: TFileMode = fmRead,
 
     if newFileSize != -1:
       flags = flags or O_CREAT or O_TRUNC
+      var permissions_mode = S_IRUSR or S_IWUSR
+      result.handle = open(filename, flags, permissions_mode)
+    else:
+      result.handle = open(filename, flags)
 
-    result.handle = open(filename, flags)
     if result.handle == -1:
       # XXX: errno is supposed to be set here
       # Is there an exception that wraps it?