1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 05:46:38 +02:00

core: follow symbolic links when writing configuration files (.conf) (task #11779)

This commit is contained in:
Sebastien Helleu
2012-03-13 18:13:45 +01:00
parent fc5f5a56dc
commit 3a2a1ce6f2
2 changed files with 20 additions and 2 deletions
+3 -1
View File
@@ -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
+17 -1
View File
@@ -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)") : "");