46515a72e864fae030fe3d667617e5783ca79156
Stefan Schuermans move most sources into libp...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp   1) #include <permissioner/Tree.h>
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Tree.cpp     2) 
Stefan Schuermans user/group lookup

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp   3) #include <permissioner/Group.h>
Stefan Schuermans move most sources into libp...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp   4) #include <permissioner/Permissions.h>
Stefan Schuermans user/group lookup

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp   5) #include <permissioner/User.h>
Stefan Schuermans move most sources into libp...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp   6) #include <permissioner/StringUtils.h>
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Tree.cpp     7) 
permissionerd/src/Tree.cpp     8) #include <boost/filesystem.hpp>
permissionerd/src/Tree.cpp     9) #include <sstream>
permissionerd/src/Tree.cpp    10) #include <stdexcept>
permissionerd/src/Tree.cpp    11) #include <string>
Stefan Schuermans implement chown/chmod

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp  12) #include <unistd.h>
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Tree.cpp    13) #include <vector>
permissionerd/src/Tree.cpp    14) 
permissionerd/src/Tree.cpp    15) void Tree::parseParams(std::string const &paramStr) {
permissionerd/src/Tree.cpp    16)   // format of paramStr is: <user> " " <group> " " <permissions> " " <root>
permissionerd/src/Tree.cpp    17)   // user, group, permissions may be - for no change
permissionerd/src/Tree.cpp    18)   std::string userStr, groupStr, permissionsStr, rootStr;
permissionerd/src/Tree.cpp    19) 
permissionerd/src/Tree.cpp    20)   std::string::size_type pos = 0;
permissionerd/src/Tree.cpp    21)   StringUtils::getNextField(paramStr, pos, userStr, "user");
permissionerd/src/Tree.cpp    22)   StringUtils::getNextField(paramStr, pos, groupStr, "group");
permissionerd/src/Tree.cpp    23)   StringUtils::getNextField(paramStr, pos, permissionsStr, "permissions");
permissionerd/src/Tree.cpp    24)   if (pos >= paramStr.length()) {
permissionerd/src/Tree.cpp    25)     std::stringstream msg;
permissionerd/src/Tree.cpp    26)     msg << "<root> field missing in \"" << paramStr << "\"";
permissionerd/src/Tree.cpp    27)     throw std::runtime_error(msg.str());
permissionerd/src/Tree.cpp    28)   }
Stefan Schuermans implement chown/chmod

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp  29)   rootStr = paramStr.substr(pos);
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Tree.cpp    30) 
Stefan Schuermans user/group lookup

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp  31)   try {
libpermissioner/src/Tree.cpp  32)     user.parseUserName(userStr);
libpermissioner/src/Tree.cpp  33)   } catch (std::exception const & e) {
libpermissioner/src/Tree.cpp  34)     std::stringstream msg;
libpermissioner/src/Tree.cpp  35)     msg << "invalid <user> field \"" << userStr << "\" in \""
libpermissioner/src/Tree.cpp  36)         << paramStr << "\": " << e.what();
libpermissioner/src/Tree.cpp  37)     throw std::runtime_error(msg.str());
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Tree.cpp    38)   }
Stefan Schuermans user/group lookup

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp  39) 
libpermissioner/src/Tree.cpp  40)   try {
libpermissioner/src/Tree.cpp  41)     group.parseGroupName(groupStr);
libpermissioner/src/Tree.cpp  42)   } catch (std::exception const & e) {
libpermissioner/src/Tree.cpp  43)     std::stringstream msg;
libpermissioner/src/Tree.cpp  44)     msg << "invalid <group> field \"" << groupStr << "\" in \""
libpermissioner/src/Tree.cpp  45)         << paramStr << "\": " << e.what();
libpermissioner/src/Tree.cpp  46)     throw std::runtime_error(msg.str());
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Tree.cpp    47)   }
Stefan Schuermans user/group lookup

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp  48) 
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Tree.cpp    49)   try {
permissionerd/src/Tree.cpp    50)     permissions.parseParams(permissionsStr);
permissionerd/src/Tree.cpp    51)   } catch (std::exception const & e) {
permissionerd/src/Tree.cpp    52)     std::stringstream msg;
Stefan Schuermans user/group lookup

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp  53)     msg << "invalid <permissions> field \"" << permissionsStr << "\" in \""
libpermissioner/src/Tree.cpp  54)         << paramStr << "\": " << e.what();
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Tree.cpp    55)     throw std::runtime_error(msg.str());
permissionerd/src/Tree.cpp    56)   }
Stefan Schuermans user/group lookup

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp  57) 
Stefan Schuermans canonicalize root paths

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp  58)   try {
libpermissioner/src/Tree.cpp  59)     root = boost::filesystem::canonical(rootStr);
libpermissioner/src/Tree.cpp  60)   } catch (std::exception const & e) {
libpermissioner/src/Tree.cpp  61)     std::stringstream msg;
libpermissioner/src/Tree.cpp  62)     msg << "invalid <root> field \"" << rootStr << "\" in \""
libpermissioner/src/Tree.cpp  63)         << paramStr << "\": " << e.what();
libpermissioner/src/Tree.cpp  64)     throw std::runtime_error(msg.str());
libpermissioner/src/Tree.cpp  65)   }
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Tree.cpp    66) }
Stefan Schuermans add config getters

Stefan Schuermans authored 4 years ago

libpermissioner/src/Tree.cpp  67) 
libpermissioner/src/Tree.cpp  68) User const & Tree::getUser() const {
libpermissioner/src/Tree.cpp  69)   return user;
libpermissioner/src/Tree.cpp  70) }
libpermissioner/src/Tree.cpp  71) 
libpermissioner/src/Tree.cpp  72) Group const & Tree::getGroup() const {
libpermissioner/src/Tree.cpp  73)   return group;
libpermissioner/src/Tree.cpp  74) }
libpermissioner/src/Tree.cpp  75) 
libpermissioner/src/Tree.cpp  76) Permissions const & Tree::getPermissions() const {
libpermissioner/src/Tree.cpp  77)   return permissions;
libpermissioner/src/Tree.cpp  78) }
libpermissioner/src/Tree.cpp  79) 
libpermissioner/src/Tree.cpp  80) boost::filesystem::path const & Tree::getRoot() const {
libpermissioner/src/Tree.cpp  81)   return root;
libpermissioner/src/Tree.cpp  82) }