diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2017-07-14 21:49:32 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2017-07-14 21:49:32 +0200 |
commit | fb73fc8292d507e9d6f368da5f2c2ac3e3f85e45 (patch) | |
tree | 7dd42214e222460e9ca4e3261309a2133bff3926 | |
parent | 8c658475b44eeb1a4e4867d203c73563eb029e8f (diff) | |
download | sdn-fb73fc8292d507e9d6f368da5f2c2ac3e3f85e45.tar.gz sdn-fb73fc8292d507e9d6f368da5f2c2ac3e3f85e45.tar.xz sdn-fb73fc8292d507e9d6f368da5f2c2ac3e3f85e45.zip |
Mark files that make use of POSIX ACLs
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | sdn.cpp | 15 |
3 files changed, 15 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 03f03c2..2429e2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ pkg_check_modules (NCURSESW QUIET ncursesw) add_executable (${PROJECT_NAME} ${PROJECT_NAME}.cpp) target_include_directories (${PROJECT_NAME} PUBLIC ${NCURSESW_INCLUDE_DIRS}) -target_link_libraries (${PROJECT_NAME} PUBLIC ${NCURSESW_LIBRARIES}) +target_link_libraries (${PROJECT_NAME} PUBLIC ${NCURSESW_LIBRARIES} acl) target_compile_features (${PROJECT_NAME} PUBLIC cxx_std_14) target_compile_definitions (${PROJECT_NAME} PUBLIC -DPROJECT_NAME=\"${PROJECT_NAME}\" -DPROJECT_VERSION=\"${version}\") @@ -3,7 +3,7 @@ CXXFLAGS = -g -std=c++14 -Wall -Wextra -pedantic -static-libstdc++ all: sdn %: %.cpp CMakeLists.txt - $(CXX) $(CXXFLAGS) $< -o $@ `pkg-config --libs --cflags ncursesw` \ + $(CXX) $(CXXFLAGS) $< -o $@ `pkg-config --libs --cflags ncursesw` -lacl \ `sed -ne 's/^project (\([^ )]*\).*/-DPROJECT_NAME="\1"/p' \ -e 's/^set (version \([^ )]*\).*/-DPROJECT_VERSION="\1"/p' CMakeLists.txt` clean: @@ -26,15 +26,18 @@ #include <cstdlib> #include <fstream> -#include <ncurses.h> #include <unistd.h> #include <dirent.h> #include <sys/stat.h> #include <sys/inotify.h> +#include <sys/acl.h> #include <fcntl.h> #include <pwd.h> #include <grp.h> +#include <acl/libacl.h> +#include <ncurses.h> + // Unicode is complex enough already and we might make assumptions #ifndef __STDC_ISO_10646__ #error Unicode required for wchar_t @@ -288,7 +291,15 @@ static struct { fun make_row (const string &filename, const struct stat &info) -> row { row r; - r.cols[row::MODES] = apply_attrs (decode_mode (info.st_mode), 0); + auto mode = decode_mode (info.st_mode); + if (auto acl = acl_get_file (filename.c_str (), ACL_TYPE_ACCESS)) { + mode_t m; + // This is a Linux-only extension + if (!acl_equiv_mode (acl, &m) && (m ^ info.st_mode) & 0777) + mode += L"+"; + acl_free (acl); + } + r.cols[row::MODES] = apply_attrs (mode, 0); auto user = to_wstring (info.st_uid); if (auto u = getpwuid (info.st_uid)) |