diff --git a/ChangeLog b/ChangeLog index 8e229a4fa..daa82ab17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,14 @@ WeeChat ChangeLog ================= Sébastien Helleu -v0.3.8-dev, 2012-03-12 +v0.3.8-dev, 2012-03-13 Version 0.3.8 (under dev!) -------------------------- +* core: follow symbolic links when writing configuration files (.conf) + (task #11779) * core: fix lost scroll when switching to a buffer with a pending search * core: add support of terminal "bracketed paste mode", new options weechat.look.paste_bracketed and weechat.look.paste_bracketed_timer_delay diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index dbcc231f0..59c9da9e2 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -26,6 +26,7 @@ #include "config.h" #endif +#include #include #include #include @@ -1911,7 +1912,7 @@ config_file_write_internal (struct t_config_file *config_file, int default_options) { int filename_length, rc; - char *filename, *filename2; + char *filename, *filename2, resolved_path[PATH_MAX]; struct t_config_section *ptr_section; struct t_config_option *ptr_option; @@ -1939,6 +1940,21 @@ config_file_write_internal (struct t_config_file *config_file, } snprintf (filename2, filename_length + 32, "%s.weechattmp", filename); + /* if filename is a symbolic link, use target as filename */ + if (realpath (filename, resolved_path)) + { + if (strcmp (filename, resolved_path) != 0) + { + free (filename); + filename = strdup (resolved_path); + if (!filename) + { + free (filename2); + return WEECHAT_CONFIG_WRITE_MEMORY_ERROR; + } + } + } + log_printf (_("Writing configuration file %s %s"), config_file->filename, (default_options) ? _("(default options)") : "");