Skip to content

Commit

Permalink
Implement secure rc file saving.
Browse files Browse the repository at this point in the history
First data is written to a temporary file, then if nothing
was wrong, this file is renamed to the final name.
This way the risk of corrupted rc file is greatly reduced.
The code is borrowed from ELinks (http://elinks.cz).
  • Loading branch information
Laurent Monin committed Apr 8, 2008
1 parent 0e8b4aa commit ccc5386
Show file tree
Hide file tree
Showing 6 changed files with 588 additions and 186 deletions.
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ AC_DEFINE_UNQUOTED(GQVIEW_HELPDIR, "$prefix/share/doc/geeqie-$VERSION", [Locatio
AC_DEFINE_UNQUOTED(GQVIEW_HTMLDIR, "$prefix/share/doc/geeqie-$VERSION/html", [Location of html documentation])

dnl checks for functions
AC_CHECK_FUNCS(strverscmp)
AC_CHECK_FUNCS(strverscmp access fsync fflush)

dnl check for little cms (lcms, this test pulled from gimp)
AC_ARG_WITH(lcms, [ --without-lcms build without lcms support])
Expand Down
11 changes: 6 additions & 5 deletions src/filelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ gint filter_file_class(const gchar *name, FileFormatClass file_class)
return FALSE;
}

void filter_write_list(FILE *f)
void filter_write_list(SecureSaveInfo *ssi)
{
GList *work;

Expand All @@ -377,8 +377,9 @@ void filter_write_list(FILE *f)
gchar *extensions = escquote_value(fe->extensions);
gchar *description = escquote_value(fe->description);

fprintf(f, "filter_ext: \"%s%s\" %s %s\n", (fe->enabled) ? "" : "#",
fe->key, extensions, description);
secure_fprintf(ssi, "filter_ext: \"%s%s\" %s %s\n",
(fe->enabled) ? "" : "#",
fe->key, extensions, description);
g_free(extensions);
g_free(description);
}
Expand Down Expand Up @@ -490,9 +491,9 @@ void sidecar_ext_parse(const gchar *text, gint quoted)
g_free(value);
}

void sidecar_ext_write(FILE *f)
void sidecar_ext_write(SecureSaveInfo *ssi)
{
fprintf(f, "\nsidecar_ext: \"%s\"\n", sidecar_ext_to_string());
secure_fprintf(ssi, "\nsidecar_ext: \"%s\"\n", sidecar_ext_to_string());
}

char *sidecar_ext_to_string()
Expand Down
4 changes: 2 additions & 2 deletions src/filelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ GList *filter_to_list(const gchar *extensions);
gint filter_name_exists(const gchar *name);
gint filter_file_class(const gchar *name, FileFormatClass file_class);

void filter_write_list(FILE *f);
void filter_write_list(SecureSaveInfo *ssi);
void filter_parse(const gchar *text);

void sidecar_ext_parse(const gchar *text, gint quoted);
void sidecar_ext_write(FILE *f);
void sidecar_ext_write(SecureSaveInfo *ssi);
char *sidecar_ext_to_string();
void sidecar_ext_add_defaults();

Expand Down
Loading

0 comments on commit ccc5386

Please sign in to comment.