summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2012-03-13 18:13:45 +0100
committerSebastien Helleu <flashcode@flashtux.org>2012-03-13 18:13:45 +0100
commit3a2a1ce6f276d7fec7bddade3ef0471a72d691b4 (patch)
tree0991f19660330eeeba934d7332bb189b15c21d77
parentfc5f5a56dc9e444573aa226ae2a84df360b4f549 (diff)
downloadweechat-3a2a1ce6f276d7fec7bddade3ef0471a72d691b4.zip
core: follow symbolic links when writing configuration files (.conf) (task #11779)
-rw-r--r--ChangeLog4
-rw-r--r--src/core/wee-config-file.c18
2 files changed, 20 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8e229a4fa..daa82ab17 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,14 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
-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 <limits.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
@@ -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)") : "");