summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <DaveDavenport@users.noreply.github.com>2017-07-04 13:38:26 +0200
committerGitHub <noreply@github.com>2017-07-04 13:38:26 +0200
commitc7e8776c7852f73cb4a728aa54905708b7f2dcaf (patch)
tree6f54d54e68db5708bbc08811c75486346fd8701b
parentb3caeac38e71fae951983dedf54c167065290073 (diff)
Add try exec test (#620)
* Add try exec test * [DRun] Free after g_find_program_in_path
-rw-r--r--source/dialogs/drun.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index c3fff896..c891429b 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -185,7 +185,7 @@ static void exec_cmd_entry ( DRunModeEntry *e )
}
const gchar *fp = g_strstrip ( str );
- gchar *exec_path = g_key_file_get_string ( e->key_file, "Desktop Entry", "Path", NULL );
+ gchar *exec_path = g_key_file_get_string ( e->key_file, "Desktop Entry", "Path", NULL );
if ( exec_path != NULL && strlen ( exec_path ) == 0 ) {
// If it is empty, ignore this property. (#529)
g_free ( exec_path );
@@ -290,6 +290,28 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c
g_key_file_free ( kf );
return FALSE;
}
+
+ if ( g_key_file_has_key ( kf, "Desktop Entry", "TryExec", NULL ) ) {
+ char *te = g_key_file_get_string ( kf, "Desktop Entry", "TryExec", NULL );
+ if ( !g_path_is_absolute ( te ) ) {
+ char *fp = g_find_program_in_path ( te );
+ if ( fp == NULL ) {
+ g_free ( te );
+ g_key_file_free ( kf );
+ return FALSE;
+ }
+ g_free ( fp );
+ }
+ else {
+ if ( g_file_test ( te, G_FILE_TEST_IS_EXECUTABLE ) == FALSE ) {
+ g_free ( te );
+ g_key_file_free ( kf );
+ return FALSE;
+ }
+ }
+ g_free ( te );
+ }
+
size_t nl = ( ( pd->cmd_list_length ) + 1 );
if ( nl >= pd->cmd_list_length_actual ) {
pd->cmd_list_length_actual += 256;