From 779b49d0f743d811eb6b928e47f0b599d11a7825 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Wed, 25 Jun 1997 03:22:59 +0200
Subject: [PATCH] * modules/files/file.c (file_open): Added optional third
 argument to open, specifying access permissions of created files.

Rev: src/modules/files/file.c:1.45
---
 src/modules/files/file.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/modules/files/file.c b/src/modules/files/file.c
index 3002394a90..1b947931da 100644
--- a/src/modules/files/file.c
+++ b/src/modules/files/file.c
@@ -6,7 +6,7 @@
 #define READ_BUFFER 8192
 
 #include "global.h"
-RCSID("$Id: file.c,v 1.44 1997/06/24 19:26:15 nisse Exp $");
+RCSID("$Id: file.c,v 1.45 1997/06/25 01:22:59 nisse Exp $");
 #include "interpret.h"
 #include "svalue.h"
 #include "stralloc.h"
@@ -547,6 +547,7 @@ static void file_close(INT32 args)
 static void file_open(INT32 args)
 {
   int flags,fd;
+  int access;
   struct pike_string *str;
   do_close(FD, FILE_READ | FILE_WRITE);
   FD=-1;
@@ -560,6 +561,14 @@ static void file_open(INT32 args)
   if(sp[1-args].type != T_STRING)
     error("Bad argument 2 to file->open()\n");
 
+  if (args > 2)
+  {
+    if (sp[2-args].type != T_INT)
+      error("Bad argument 3 to file->open()\n");
+    access = sp[2-args].u.integer;
+  } else
+    access = 00666;
+      
   str=sp[-args].u.string;
   
   flags=parse(sp[1-args].u.string->str);
@@ -569,7 +578,7 @@ static void file_open(INT32 args)
 
   THREADS_ALLOW();
   do {
-    fd=open(str->str,map(flags), 00666);
+    fd=open(str->str,map(flags), access);
   } while(fd < 0 && errno == EINTR);
   THREADS_DISALLOW();
 
-- 
GitLab