static void get_screenhacks (saver_preferences *p);
+static char *
+chase_symlinks (const char *file)
+{
+# ifdef HAVE_REALPATH
+ if (file)
+ {
+ char buf [2048];
+ if (realpath (file, buf))
+ return strdup (buf);
+
+ sprintf (buf, "%s: realpath", blurb());
+ perror(buf);
+ }
+# endif /* HAVE_REALPATH */
+ return 0;
+}
+
+
const char *
init_file_name (void)
{
{
const char *name = init_file_name();
const char *suffix = ".tmp";
+
+ char *n2 = chase_symlinks (name);
+ if (n2) name = n2;
+
if (!name || !*name)
file = "";
else
strcpy(file, name);
strcat(file, suffix);
}
+
+ if (n2) free (n2);
}
if (file && *file)
if (!p->db) abort();
handle_entry (&p->db, key, value, name, line);
}
+ fclose (in);
free(buf);
p->init_file_date = write_date;
{
const char *name = init_file_name();
const char *tmp_name = init_file_tmp_name();
+ char *n2 = chase_symlinks (name);
struct stat st;
int i, j;
char *stderr_font;
FILE *out;
- if (!name) return;
+ if (!name) goto END;
+
+ if (n2) name = n2;
if (p->verbose_p)
fprintf (stderr, "%s: writing \"%s\".\n", blurb(), name);
sprintf(buf, "%s: error writing \"%s\"", blurb(), name);
perror(buf);
free(buf);
- return;
+ goto END;
}
/* Give the new .xscreensaver file the same permissions as the old one;
tmp_name, (unsigned int) mode);
perror(buf);
free(buf);
- return;
+ goto END;
}
}
perror(buf);
unlink (tmp_name);
free(buf);
- return;
+ goto END;
}
if (rename (tmp_name, name) != 0)
perror(buf);
unlink (tmp_name);
free(buf);
- return;
+ goto END;
}
else
{
perror(buf);
free(buf);
unlink (tmp_name);
- return;
+ goto END;
}
+
+ END:
+ if (n2) free (n2);
}
\f