// Save the old log if configured to do so
if (stack_config->get_btsnoop_should_save_last()) {
char last_log_path[PATH_MAX];
- snprintf(last_log_path, PATH_MAX, "%s.last", log_path);
+ snprintf(last_log_path, PATH_MAX, "%s.%llu", log_path, btsnoop_timestamp());
if (!rename(log_path, last_log_path) && errno != ENOENT)
- LOG_ERROR("%s unable to rename '%s' to '%s': %s", __func__, log_path, last_log_path, strerror(errno));
+ LOG_ERROR(LOG_TAG, "%s unable to rename '%s' to '%s': %s", __func__, log_path, last_log_path, strerror(errno));
}
logfile_fd = open(log_path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
fflush(fp);
fclose(fp);
+ // Change the file's permissions to Read/Write by User and Group
+ if (chmod(temp_filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) == -1) {
+ LOG_ERROR("%s unable to change file permissions '%s': %s", __func__, filename, strerror(errno));
+ goto error;
+ }
+
if (rename(temp_filename, filename) == -1) {
- LOG_ERROR("%s unable to commit file '%s': %s", __func__, filename, strerror(errno));
+ LOG_ERROR(LOG_TAG, "%s unable to commit file '%s': %s", __func__, filename, strerror(errno));
goto error;
}