+
+static inline gboolean try_exec(const ObtPaths *const p,
+ const gchar *const path)
+{
+ struct stat st;
+ guint i;
+
+ stat(path, &st);
+
+ if (!S_ISREG(st.st_mode))
+ return FALSE;
+ if (st.st_uid == p->uid)
+ return st.st_mode & S_IXUSR;
+ for (i = 0; i < p->n_gid; ++i)
+ if (st.st_gid == p->gid[i])
+ return st.st_mode & S_IXGRP;
+ return st.st_mode & S_IXOTH;
+}
+
+gboolean obt_paths_try_exec(ObtPaths *p, const gchar *path)
+{
+ if (path[0] == '/') {
+ return try_exec(p, path);
+ }
+ else {
+ GSList *it;
+
+ for (it = p->exec_dirs; it; it = g_slist_next(it)) {
+ gchar *f = g_strdup_printf(it->data, G_DIR_SEPARATOR_S, path);
+ gboolean e = try_exec(p, f);
+ g_free(f);
+ if (e) return TRUE;
+ }
+ }
+
+ return FALSE;
+}