aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-11-24 02:46:46 +0000
committerdos-reis <gdr@axiomatics.org>2008-11-24 02:46:46 +0000
commit81dc2af2e2cab54deda566b72949d3d58ee532bf (patch)
tree2c6e789c83135432b7ba3399decfd96e6c31788c /src
parent103c8a62af0e8ea55a76aa6b33c496c03f6837e6 (diff)
downloadopen-axiom-81dc2af2e2cab54deda566b72949d3d58ee532bf.tar.gz
* lib/cfuns-c.c (oa_copy_file): Specify permission mode for the
new file.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/lib/cfuns-c.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f1944965..d1f605e7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
2008-11-23 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * lib/cfuns-c.c (oa_copy_file): Specify permission mode for the
+ new file.
+
+2008-11-23 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* algebra/lodop.spad.pamphlet (OrdinaryDifferentialRing): Tidy.
* algebra/sex.spad.pamphlet (SExpressionCategory): Fix breakage
from last commit.
diff --git a/src/lib/cfuns-c.c b/src/lib/cfuns-c.c
index 31cfff6e..bf3b7f7c 100644
--- a/src/lib/cfuns-c.c
+++ b/src/lib/cfuns-c.c
@@ -617,13 +617,14 @@ oa_copy_file(const char* src, const char* dst)
return CopyFile(src,dst, /* bFailIfExists = */ 0) ? 0 : -1;
#else
#define OA_BUFSZ 512
+#define OA_DEFAULT_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
char buf[OA_BUFSZ];
int src_fd;
int dst_fd;
int count;
if((src_fd = open(src, O_RDONLY)) < 0)
return -1;
- if ((dst_fd = open(dst, O_WRONLY | O_CREAT | O_TRUNC)) < 0) {
+ if ((dst_fd = creat(dst, OA_DEFAULT_MODE)) < 0) {
close(src_fd);
return -1;
}
@@ -632,6 +633,7 @@ oa_copy_file(const char* src, const char* dst)
if (write(dst_fd, buf, count) != count)
break;
+#undef OA_DEFAULT_MODE
#undef OA_BUFSZ
return (close(dst_fd) < 0 || close(src_fd) < 0 || count < 0) ? -1 : 0;
#endif