summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@gnome.org>2020-06-19 10:12:04 +0200
committerAntoine Jacoutot <ajacoutot@gnome.org>2020-06-20 11:11:02 +0000
commit1926ae7021a2f8e842ad566a49f3a947c02cec92 (patch)
tree1a59946653a97209853b019ad2e91606cb90e0ce
parent02e13daa5a6a532181b66c8a197930b6f0171909 (diff)
pledge: add support to remaining utilities
-rw-r--r--src/install.c17
-rw-r--r--src/update-desktop-database.c4
-rw-r--r--src/validator.c11
3 files changed, 30 insertions, 2 deletions
diff --git a/src/install.c b/src/install.c
index fba3a7c..915ed58 100644
--- a/src/install.c
+++ b/src/install.c
@@ -837,6 +837,13 @@ main (int argc, char **argv)
mode_t dir_permissions;
char *basename;
+#ifdef HAVE_PLEDGE
+ if (pledge ("stdio rpath wpath cpath fattr", NULL) == -1) {
+ g_printerr ("pledge\n");
+ return 1;
+ }
+#endif
+
setlocale (LC_ALL, "");
basename = g_path_get_basename (argv[0]);
@@ -854,6 +861,16 @@ main (int argc, char **argv)
g_option_group_add_entries (group, install_options);
g_option_context_add_group (context, group);
}
+#ifdef HAVE_PLEDGE
+ else
+ {
+ /* In edit mode we can drop the fattr pledge. */
+ if (pledge ("stdio rpath wpath cpath", NULL) == -1) {
+ g_printerr ("pledge in edit_mode\n");
+ return 1;
+ }
+ }
+#endif
group = g_option_group_new ("edit", _("Edition options for desktop file"), _("Show desktop file edition options"), NULL, NULL);
g_option_group_add_entries (group, edit_options);
diff --git a/src/update-desktop-database.c b/src/update-desktop-database.c
index b1bca9c..5a8dc56 100644
--- a/src/update-desktop-database.c
+++ b/src/update-desktop-database.c
@@ -451,8 +451,8 @@ main (int argc,
{ NULL }
};
-#if HAVE_PLEDGE
- if (pledge("stdio rpath wpath cpath fattr", NULL) == -1) {
+#ifdef HAVE_PLEDGE
+ if (pledge ("stdio rpath wpath cpath fattr", NULL) == -1) {
g_printerr ("pledge\n");
return 1;
}
diff --git a/src/validator.c b/src/validator.c
index 104369d..151d507 100644
--- a/src/validator.c
+++ b/src/validator.c
@@ -28,6 +28,10 @@
#include <locale.h>
+#ifdef HAVE_PLEDGE
+#include <unistd.h>
+#endif
+
#include "validate.h"
static gboolean warn_kde = FALSE;
@@ -51,6 +55,13 @@ main (int argc, char *argv[])
int i;
gboolean all_valid;
+#ifdef HAVE_PLEDGE
+ if (pledge ("stdio rpath", NULL) == -1) {
+ g_printerr ("pledge\n");
+ return 1;
+ }
+#endif
+
setlocale (LC_ALL, "");
context = g_option_context_new (NULL);