move most sources into libp...
Stefan Schuermans authored 4 years ago
|
libpermissioner/src/Permissions.cpp 1) #include <permissioner/Permissions.h>
|
begin of permissioner confi...
Stefan Schuermans authored 4 years ago
|
permissionerd/src/Permissions.cpp 2)
|
implement chown/chmod
Stefan Schuermans authored 4 years ago
|
libpermissioner/src/Permissions.cpp 3) #include <boost/filesystem.hpp>
|
user/group lookup
Stefan Schuermans authored 4 years ago
|
libpermissioner/src/Permissions.cpp 4) #include <sstream>
libpermissioner/src/Permissions.cpp 5) #include <stdexcept>
|
begin of permissioner confi...
Stefan Schuermans authored 4 years ago
|
permissionerd/src/Permissions.cpp 6) #include <string>
permissionerd/src/Permissions.cpp 7)
permissionerd/src/Permissions.cpp 8) void Permissions::parseParams(std::string const ¶mStr) {
|
permission parsing
Stefan Schuermans authored 4 years ago
|
permissionerd/src/Permissions.cpp 9) // reset permission flags
permissionerd/src/Permissions.cpp 10) set = 0;
permissionerd/src/Permissions.cpp 11) setCond = 0;
permissionerd/src/Permissions.cpp 12) clear = 0;
permissionerd/src/Permissions.cpp 13) clearCond = 0;
permissionerd/src/Permissions.cpp 14) // parse comma-separated groups of [ugoa][+-][rwxX] settings
permissionerd/src/Permissions.cpp 15) Flags who = 0, what = 0, whatCond = 0;
permissionerd/src/Permissions.cpp 16) char action = ' ';
permissionerd/src/Permissions.cpp 17) // append comma at end to process last group
permissionerd/src/Permissions.cpp 18) for (char c : paramStr + ",") {
permissionerd/src/Permissions.cpp 19) switch (c) {
permissionerd/src/Permissions.cpp 20) case ',':
permissionerd/src/Permissions.cpp 21) switch (action) {
permissionerd/src/Permissions.cpp 22) case '=':
permissionerd/src/Permissions.cpp 23) set = who * what;
permissionerd/src/Permissions.cpp 24) setCond = who * whatCond;
permissionerd/src/Permissions.cpp 25) clear = who * (what ^ (flagRead | flagWrite | flagExecute));
permissionerd/src/Permissions.cpp 26) clearCond = who * (what ^ flagExecute);
permissionerd/src/Permissions.cpp 27) break;
permissionerd/src/Permissions.cpp 28) case '+':
permissionerd/src/Permissions.cpp 29) set = who * what;
permissionerd/src/Permissions.cpp 30) setCond = who * whatCond;
permissionerd/src/Permissions.cpp 31) break;
permissionerd/src/Permissions.cpp 32) case '-':
permissionerd/src/Permissions.cpp 33) clear = who * what;
permissionerd/src/Permissions.cpp 34) clearCond = who * whatCond;
permissionerd/src/Permissions.cpp 35) break;
permissionerd/src/Permissions.cpp 36) }
permissionerd/src/Permissions.cpp 37) who = 0;
permissionerd/src/Permissions.cpp 38) what = 0;
permissionerd/src/Permissions.cpp 39) whatCond = 0;
permissionerd/src/Permissions.cpp 40) action = ' ';
permissionerd/src/Permissions.cpp 41) break;
permissionerd/src/Permissions.cpp 42) case 'u':
permissionerd/src/Permissions.cpp 43) who |= flagUser;
permissionerd/src/Permissions.cpp 44) break;
permissionerd/src/Permissions.cpp 45) case 'g':
permissionerd/src/Permissions.cpp 46) who |= flagGroup;
permissionerd/src/Permissions.cpp 47) break;
permissionerd/src/Permissions.cpp 48) case 'o':
permissionerd/src/Permissions.cpp 49) who |= flagOther;
permissionerd/src/Permissions.cpp 50) break;
permissionerd/src/Permissions.cpp 51) case 'a':
permissionerd/src/Permissions.cpp 52) who |= flagUser | flagGroup | flagOther;
permissionerd/src/Permissions.cpp 53) break;
permissionerd/src/Permissions.cpp 54) case '=':
permissionerd/src/Permissions.cpp 55) case '+':
permissionerd/src/Permissions.cpp 56) case '-':
permissionerd/src/Permissions.cpp 57) action = c;
permissionerd/src/Permissions.cpp 58) break;
permissionerd/src/Permissions.cpp 59) case 'r':
permissionerd/src/Permissions.cpp 60) what |= flagRead;
permissionerd/src/Permissions.cpp 61) break;
permissionerd/src/Permissions.cpp 62) case 'w':
permissionerd/src/Permissions.cpp 63) what |= flagWrite;
permissionerd/src/Permissions.cpp 64) break;
permissionerd/src/Permissions.cpp 65) case 'x':
permissionerd/src/Permissions.cpp 66) what |= flagExecute;
permissionerd/src/Permissions.cpp 67) break;
permissionerd/src/Permissions.cpp 68) case 'X':
permissionerd/src/Permissions.cpp 69) whatCond |= flagExecute;
permissionerd/src/Permissions.cpp 70) break;
|
user/group lookup
Stefan Schuermans authored 4 years ago
|
libpermissioner/src/Permissions.cpp 71) default:
libpermissioner/src/Permissions.cpp 72) {
libpermissioner/src/Permissions.cpp 73) std::stringstream msg;
libpermissioner/src/Permissions.cpp 74) msg << "invalid character \"" << c << "\" in permission string \""
libpermissioner/src/Permissions.cpp 75) << paramStr << "\"";
libpermissioner/src/Permissions.cpp 76) throw std::runtime_error(msg.str());
libpermissioner/src/Permissions.cpp 77) }
|
permission parsing
Stefan Schuermans authored 4 years ago
|
permissionerd/src/Permissions.cpp 78) }
|
begin of permissioner confi...
Stefan Schuermans authored 4 years ago
|
permissionerd/src/Permissions.cpp 79) }
permissionerd/src/Permissions.cpp 80) }
|