Project

General

Profile

Actions

Bug #11232

open

Fix pfSense_fsync

Added by Martin VENÇON about 3 years ago. Updated about 3 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Operating System
Target version:
-
Start date:
01/07/2021
Due date:
% Done:

0%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
Affected Architecture:

Description

Hello,

pfSense_fsync has not been working for a while as this commit: https://github.com/pfsense/pfsense/commit/c5663bf5c9a830d5c265bd26e875ce271081eb3f is still in use.
All the calls to this function are commented in the pfSense code.

Here is a fix that makes the function work again:

diff --git a/devel/php-pfSense-module/files/pfSense.c b/devel/php-pfSense-module/files/pfSense.c
--- a/devel/php-pfSense-module/files/pfSense.c
+++ b/devel/php-pfSense-module/files/pfSense.c
@@ -4009,7 +4009,7 @@ PHP_FUNCTION(pfSense_fsync) {
        if ((fname = strdup(fname)) == NULL)
                RETURN_FALSE;
        parent_dir = dirname(fname);
-       fd = open(parent_dir, O_RDWR|O_CLOEXEC);
+       fd = open(parent_dir, O_RDONLY|O_CLOEXEC);
        free(fname);
        if (fd == -1)
                RETURN_FALSE;

A directory cannot be opened with write access, as mentionned in https://www.freebsd.org/cgi/man.cgi?query=open&sektion=2.

[EISDIR]        The named file is a directory, and the arguments spec-
            ify it is to be    modified.

Actions #1

Updated by Jim Pingle about 3 years ago

  • Category changed from Unknown to Operating System

It's been disabled for 2 years, I'm not sure we still want or need it.

Might be better to remove it than to fix it at this point, but it's open for debate.

Actions #2

Updated by Martin VENÇON about 3 years ago

For information, the function safe_write_file in config.lib.inc, used for writing the configuration file after a restoration for example, is not safe anymore. It is just a regular write.
I succeeded in canceling some changes to the configuration file by forcing a power cut after a change to the configuration.
Even if the function will not be used anymore, I think it is worth it to still look at the parts where it is used.

Actions

Also available in: Atom PDF