Modify bits for old files also.
[fprobe-ulog.git] / src / fprobe-ulog.c
index 37ecde3..a9f0461 100644 (file)
@@ -474,10 +474,13 @@ unsigned get_data_file_fd(char *fname, int cur_fd) {
                if (cur_fd>0)
                        close(cur_fd);
                snprintf(nextname,MAX_PATH_LEN,"%s.%d",fname,cur_epoch);
-               if ((write_fd = open(nextname, O_RDWR|O_CREAT|O_TRUNC,S_IRWXU|S_IRGRP|S_IROTH)) < 0) {
+               if ((write_fd = open(nextname, O_RDWR|O_CREAT|O_TRUNC)) < 0) {
                        my_log(LOG_ERR, "open(): %s (%s)\n", nextname, strerror(errno));
                        exit(1);
                }
+               if (fchmod(write_fd,S_IRUSR|S_IWUSR|S_IROTH|S_IRGRP) == -1) {
+                       my_log(LOG_ERR, "fchmod() failed: %s (%s). Continuing...\n", nextname, strerror(errno));
+               }
                update_cur_epoch_file(cur_epoch);
                ret_fd = write_fd;
        }