Project

General

Profile

Bug #11232

Fix pfSense_fsync

Added by Martin VENÇON 4 months ago. Updated 4 months ago.

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

0%

Estimated time:
Affected Version:
Affected Architecture:
Release Notes:
Default

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.

History

#1 Updated by Jim Pingle 4 months 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.

#2 Updated by Martin VENÇON 4 months 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.

Also available in: Atom PDF