[telepathy-mission-control/master] mcd-misc: add _mcd_chmod_private()

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Sep 7 08:56:18 PDT 2009


---
 src/mcd-misc.c |   31 +++++++++++++++++++++++++++++++
 src/mcd-misc.h |    2 ++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/src/mcd-misc.c b/src/mcd-misc.c
index 2151755..53ce80d 100644
--- a/src/mcd-misc.c
+++ b/src/mcd-misc.c
@@ -36,6 +36,9 @@
 #include <telepathy-glib/errors.h>
 #include <telepathy-glib/util.h>
 #include <libmcclient/mc-errors.h>
+
+#include "mcd-debug.h"
+
 #include "_gen/signals-marshal.h"
 #include "_gen/register-dbus-glib-marshallers-body.h"
 
@@ -223,3 +226,31 @@ _mcd_file_set_contents (const gchar *filename, const gchar *contents,
 
     return g_file_set_contents (filename, contents, length, error);
 }
+
+int
+_mcd_chmod_private (const gchar *filename)
+{
+    struct stat buf;
+    int ret;
+
+    ret = g_stat (filename, &buf);
+
+    if (ret < 0)
+    {
+        DEBUG ("g_stat: %s", g_strerror (errno));
+        return ret;
+    }
+
+    if ((buf.st_mode & 0077) != 0)
+    {
+        DEBUG ("chmod go-rwx %s", filename);
+        ret = g_chmod (filename, (buf.st_mode & ~0077));
+
+        if (ret < 0)
+        {
+            DEBUG ("g_chmod: %s", g_strerror (errno));
+        }
+    }
+
+    return ret;
+}
diff --git a/src/mcd-misc.h b/src/mcd-misc.h
index 82b2f70..2ac6191 100644
--- a/src/mcd-misc.h
+++ b/src/mcd-misc.h
@@ -58,5 +58,7 @@ gboolean _mcd_file_set_contents (const gchar *filename, const gchar *contents,
 G_GNUC_INTERNAL
 void _mc_ext_register_dbus_glib_marshallers (void);
 
+G_GNUC_INTERNAL int _mcd_chmod_private (const gchar *filename);
+
 G_END_DECLS
 #endif /* MCD_MISC_H */
-- 
1.5.6.5




More information about the telepathy-commits mailing list