Add S_IWUSR permission bit for O_CREAT
authorAlex Pyrgiotis <apyrgio@grnet.gr>
Fri, 1 Feb 2013 10:41:14 +0000 (12:41 +0200)
committerFilippos Giannakos <philipgian@grnet.gr>
Mon, 11 Mar 2013 09:39:45 +0000 (11:39 +0200)
In Ubuntu -haven't tested it elsewhere yet- gcc has a global cflag
called "D_FORTIFY_SOURCE=2" that errs when files are not created
with explicit user permissions. Since files are O_WRONLY, I added
the S_IWUSR permission bit.

xseg/peers/user/peer.c
xseg/peers/user/pfiled.c

index b47a73f..c2a2926 100644 (file)
@@ -688,7 +688,7 @@ int pidfile_read(char *path, pid_t *pid)
 int pidfile_open(char *path, pid_t *old_pid)
 {
        //nfs version > 3
-       int fd = open(path, O_CREAT|O_EXCL|O_WRONLY);
+       int fd = open(path, O_CREAT|O_EXCL|O_WRONLY, S_IWUSR);
        if (fd < 0){
                if (errno == EEXIST)
                        pidfile_read(path, old_pid);
index ef6d22e..adc5243 100644 (file)
@@ -1093,7 +1093,7 @@ int pidfile_read(char *path, pid_t *pid)
 int pidfile_open(char *path, pid_t *old_pid)
 {       
        //nfs version > 3
-       int fd = open(path, O_CREAT|O_EXCL|O_WRONLY);
+       int fd = open(path, O_CREAT|O_EXCL|O_WRONLY, S_IWUSR);
        if (fd < 0){
                if (errno == -EEXIST)
                        pidfile_read(path, old_pid);