Branch: refs/heads/master
Author: Enrico Tröger <enrico.troeger(a)uvena.de>
Committer: Enrico Tröger <enrico.troeger(a)uvena.de>
Date: Sun, 08 Feb 2015 10:42:32 UTC
Commit: 16404717522c3594cc5fdfc6eca5ba9e2c0f9f0e
https://github.com/geany/geany/commit/16404717522c3594cc5fdfc6eca5ba9e2c0f9…
Log Message:
-----------
Merge pull request #413 from eht16/backup_copy_file_perm
SaveActions: Set file permissions of backup copies to 0600 (SF #125)
Modified Paths:
--------------
doc/geany.txt
plugins/saveactions.c
Modified: doc/geany.txt
19 lines changed, 17 insertions(+), 2 deletions(-)
===================================================================
@@ -5176,8 +5176,23 @@ you can configure the automatically added extension in the configure dialog
in Geany's plugin manager.
After the plugin was loaded in Geany's plugin manager, every file is
-copied into the configured backup directory when the file is saved in Geany.
-
+copied into the configured backup directory *after* the file has been saved
+in Geany.
+
+The created backup copy file permissions are set to read-write only for
+the user. This should help to not create world-readable files on possibly
+unsecure destination directories like /tmp (especially useful
+on multi-user systems).
+This applies only to non-Windows systems. On Windows, no explicit file
+permissions are set.
+
+
+Additionally, you can define how many levels of the original file's
+directory structure should be replicated in the backup copy path.
+For example, setting the option
+*Directory levels to include in the backup destination* to *2*
+cause the plugin to create the last two components of the original
+file's path in the backup copy path and place the new file there.
Contributing to this document
Modified: plugins/saveactions.c
14 lines changed, 14 insertions(+), 0 deletions(-)
===================================================================
@@ -27,6 +27,8 @@
#include "geanyplugin.h"
#include "gtkcompat.h"
+#include <stdio.h>
+#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <glib/gstdio.h>
@@ -195,6 +197,7 @@ static void backupcopy_document_save_cb(GObject *obj, GeanyDocument *doc, gpoint
gchar *dir_parts_src;
gchar *stamp;
gchar buf[512];
+ gint fd_dst = -1;
if (! enable_backupcopy)
return;
@@ -220,7 +223,14 @@ static void backupcopy_document_save_cb(GObject *obj, GeanyDocument *doc, gpoint
g_free(basename_src);
g_free(dir_parts_src);
+#ifdef G_OS_WIN32
if ((dst = g_fopen(locale_filename_dst, "wb")) == NULL)
+#else
+ /* Use g_open() on non-Windows to set file permissions to 600 atomically.
+ * On Windows, seting file permissions would require specific Windows API. */
+ fd_dst = g_open(locale_filename_dst, O_CREAT | O_WRONLY, S_IWUSR | S_IRUSR);
+ if (fd_dst == -1 || (dst = fdopen(fd_dst, "w")) == NULL)
+#endif
{
ui_set_statusbar(FALSE, _("Backup Copy: File could not be saved (%s)."),
g_strerror(errno));
@@ -228,6 +238,8 @@ static void backupcopy_document_save_cb(GObject *obj, GeanyDocument *doc, gpoint
g_free(locale_filename_dst);
g_free(stamp);
fclose(src);
+ if (fd_dst != -1)
+ close(fd_dst);
return;
}
@@ -238,6 +250,8 @@ static void backupcopy_document_save_cb(GObject *obj, GeanyDocument *doc, gpoint
fclose(src);
fclose(dst);
+ if (fd_dst != -1)
+ close(fd_dst);
g_free(locale_filename_src);
g_free(locale_filename_dst);
g_free(stamp);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sun, 08 Feb 2015 10:31:42 UTC
Commit: ca21a8759aada71a8f083ef8fc528bfb8988bc89
https://github.com/geany/geany/commit/ca21a8759aada71a8f083ef8fc528bfb8988b…
Log Message:
-----------
Don't use "echo -n" in shell scripts
The standard says:
If the first operand is -n, or if any of the operands contain a
backslash ( '\' ) character, the results are implementation-defined.
On OS X it simply prints the "-n" string and everything which follows,
including the newline.
Use printf instead.
Modified Paths:
--------------
m4/geany-status.m4
po/intl_stats.sh
Modified: m4/geany-status.m4
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -27,7 +27,7 @@ EOF
# Print a nice top bar
# description + ' : ' + value
total=`expr $dlen + 3 + $vlen`
- for i in `seq 1 $total`; do echo -n '-'; done
+ for i in `seq 1 $total`; do printf '-'; done
echo
# And print the actual content
Modified: po/intl_stats.sh
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -92,7 +92,7 @@ else
do
# maybe the regexp can be optimized, regexps are not my best friends
creationdate=`grep "PO-Revision-Date:" po/$lang.po | sed 's/.*: \([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} [0-9]\{2\}:[0-9]\{2\}[+|-][0-9]\{4\}\).*/\1/'`
- echo -n $eswitch $lang"\t("$creationdate"):\t"
+ printf "%s %s\t(%s):\t" "$eswitch" "$lang" "$creationdate"
msgfmt --check --statistics po/$lang.po;
done
fi
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).