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