hexchat icon indicating copy to clipboard operation
hexchat copied to clipboard

Hexchat is overwriting read-only configs

Open thiagokokada opened this issue 4 years ago • 5 comments

Hexchat seems to been overwriting hexchat.conf and servlist.conf (and maybe other config files). For users that manage their configuration files inside a dotfiles or a project like Home-Manager, where you generally symlink the files to another place, it is impossible to keep those files in sync, because once Hexchat is started the symlink is deleted and replaced with the real file. Even setting hexchat.conf file to 400 permission (read-only), the file is still deleted and replaced with a file with the original permissions.

Ideally Hexchat should not overwrite those files and respect their permissions, so if it can't write the configuration file it fails without changing the file (but maybe it should log this somewhere).

Related issue: https://github.com/nix-community/home-manager/pull/1805

thiagokokada avatar Feb 21 '21 16:02 thiagokokada

So looking at the save_config function: https://github.com/hexchat/hexchat/blob/7a275812c0002fe10db5c60e29a34ba6ce4cede1/src/common/cfgfiles.c#L1003-L1064

It seems that it generates a new config file with a .new prefix, and after serializing the configuration options it renames the .new file to the old place. This seems a fine approach (i.e. probably more robust than overwrite), but it would be better to have some checks if the file is read-only or something.

thiagokokada avatar Feb 21 '21 16:02 thiagokokada

Another work around for now, if you use unix/linux os you can use chattr +i <file> to make file read-only and chattr -i <file> to make it writable again. But any changes you make while file is read-only wont apply after using chattr command.

FunctionNotFound avatar Mar 10 '21 07:03 FunctionNotFound

@thiagokokada since you now seem to understand that mechanism - pls close this issue.

fred0r avatar Apr 07 '21 01:04 fred0r

Another work around for now, if you use unix/linux os you can use chattr +i <file> to make file read-only and chattr -i <file> to make it writable again. But any changes you make while file is read-only wont apply after using chattr command.

Yeah, this works, but like you said it is just a workaround. Ideally hexchat shouldn't overwrite files marked as read-only for the user.

@thiagokokada since you now seem to understand that mechanism - pls close this issue.

No since there is no solution, only a workaround.

thiagokokada avatar Apr 07 '21 01:04 thiagokokada

patches are welcome

fred0r avatar Apr 07 '21 01:04 fred0r