+/**
+ * @brief Determine whether or not the given path is accessible.
+ *
+ * @param path
+ * The path to test.
+ *
+ * @return true if @c path is accessible to the current effective
+ * user/group, false otherwise.
+ */
+bool path_accessible(const char* path) {
+ if (path == NULL) {
+ return false;
+ }
+
+ /* Test for access using the effective user and group rather than
+ the real one. */
+ int flags = AT_EACCESS;
+
+ /* Don't follow symlinks when checking for a path's existence,
+ since we won't follow them to set its ACLs either. */
+ flags |= AT_SYMLINK_NOFOLLOW;
+
+ /* If the path is relative, interpret it relative to the current
+ working directory (just like the access() system call). */
+ int result = faccessat(AT_FDCWD, path, F_OK, flags);
+
+ if (result == 0) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+
+