[Xfce4-commits] [xfce/libxfce4util] 01/01: Add support for rc files as symlinks
noreply at xfce.org
noreply at xfce.org
Sat Sep 22 22:13:14 CEST 2018
This is an automated email from the git hooks/post-receive script.
s k u n n y k p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/libxfce4util.
commit 5b23e5190b0ac90793344d720044711413743c2d
Author: Igor <f2404 at yandex.ru>
Date: Mon Sep 17 12:23:21 2018 -0400
Add support for rc files as symlinks
This prevents a symlink from being overwritten with an actual file contents.
Instead, the symlink is preserved, and its target gets updated.
Fixes bug #14698
---
libxfce4util/xfce-rc-simple.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/libxfce4util/xfce-rc-simple.c b/libxfce4util/xfce-rc-simple.c
index c615d93..d2604da 100644
--- a/libxfce4util/xfce-rc-simple.c
+++ b/libxfce4util/xfce-rc-simple.c
@@ -699,7 +699,8 @@ void
_xfce_rc_simple_flush (XfceRc *rc)
{
XfceRcSimple *simple = XFCE_RC_SIMPLE (rc);
- gchar tmp_path[PATH_MAX];
+ gchar *filename = simple->filename;
+ gchar tmp_path[PATH_MAX], buf[PATH_MAX] = {0};
if (G_UNLIKELY (!simple->dirty))
return;
@@ -707,11 +708,15 @@ _xfce_rc_simple_flush (XfceRc *rc)
g_snprintf (tmp_path, PATH_MAX, "%s.%d.tmp", simple->filename, (int)getpid ());
if (simple_write (simple, tmp_path))
{
- if (rename (tmp_path, simple->filename) < 0)
+ /* support rc file being a symlink: see bug #14698 */
+ if (readlink (simple->filename, buf, sizeof (buf)-1) != -1)
+ filename = buf;
+
+ if (rename (tmp_path, filename) < 0)
{
g_critical ("Unable to rename %s to %s: %s",
tmp_path,
- simple->filename,
+ filename,
g_strerror (errno));
unlink (tmp_path);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list