summaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-12-17 22:05:49 -0500
committerTavian Barnes <tavianator@tavianator.com>2018-12-17 22:05:49 -0500
commit18fc03882d49ff46b41a53afc0d6232e1dfbbb35 (patch)
treedec8b26d1801c4d170cfb148c3758e95dfd4e1c9 /util.h
parent50b3caa2625b4377b03fe8ca6967f769cdd6ee95 (diff)
downloadbfs-18fc03882d49ff46b41a53afc0d6232e1dfbbb35.tar.xz
color: Support coloring files with capabilities
Diffstat (limited to 'util.h')
-rw-r--r--util.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/util.h b/util.h
index e95b67d..7506924 100644
--- a/util.h
+++ b/util.h
@@ -33,10 +33,18 @@
# define BFS_HAS_INCLUDE(header, fallback) fallback
#endif
-#define BFS_HAS_MNTENT BFS_HAS_INCLUDE(<mntent.h>, __GLIBC__)
-#define BFS_HAS_SYS_MKDEV BFS_HAS_INCLUDE(<sys/mkdev.h>, false)
-#define BFS_HAS_SYS_PARAM BFS_HAS_INCLUDE(<sys/param.h>, true)
-#define BFS_HAS_SYS_SYSMACROS BFS_HAS_INCLUDE(<sys/sysmacros.h>, __GLIBC__)
+#define BFS_HAS_MNTENT BFS_HAS_INCLUDE(<mntent.h>, __GLIBC__)
+#define BFS_HAS_SYS_CAPABILITY BFS_HAS_INCLUDE(<sys/capability.h>, __linux__)
+#define BFS_HAS_SYS_MKDEV BFS_HAS_INCLUDE(<sys/mkdev.h>, false)
+#define BFS_HAS_SYS_PARAM BFS_HAS_INCLUDE(<sys/param.h>, true)
+#define BFS_HAS_SYS_SYSMACROS BFS_HAS_INCLUDE(<sys/sysmacros.h>, __GLIBC__)
+
+#if BFS_HAS_SYS_CAPABILITY
+# include <sys/capability.h>
+# ifdef CAP_CHOWN
+# define BFS_HAS_POSIX1E_CAPABILITIES true
+# endif
+#endif
#if !defined(FNM_CASEFOLD) && defined(FNM_IGNORECASE)
# define FNM_CASEFOLD FNM_IGNORECASE
@@ -187,4 +195,11 @@ int bfs_major(dev_t dev);
*/
int bfs_minor(dev_t dev);
+struct BFTW;
+
+/**
+ * Check if a file has a non-trvial capability set.
+ */
+bool bfs_check_capabilities(const struct BFTW *ftwbuf);
+
#endif // BFS_UTIL_H