Config file handling

Pavel Roskin proski at gnu.org
Fri Mar 21 07:15:52 UTC 2003


Hello!

> Patch to write config to temporary file and then 'atomically' move it
> to proper place.

Thank you!

> Moreover it is a fix for following nasty bug which happens when no
> ~/.mc/ini is found:
>
> open("/usr/local/share/mc/mc.ini",
> O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = -1 EACCES (Permission
> denied)
>
> We should not try to write to public files, so profile_name should be
> used only for reading... But dump_profile still wants to save file
> (even unmodified), so we check and save only in home_dir.

Not sure if it's the right fix.  Sometimes there is more that one way to
write home directory.  For example. /home is a link to /usr/home by
default on some versions of FreeBSD.

More importantly, mc shouldn't even attempt to save anything to mc.ini.
dump_profile() shouldn't be called for global files.  I think the fix
should be in some other place.

I like the idea of using stat() on the config file.  When "Auto Save
Setup" is used, the changes made manually are lost.  Maybe the
modification time should be checked.

-- 
Regards,
Pavel Roskin



More information about the mc-devel mailing list