f86590fcbf59b9582691bc4d377d06e091dcb226
Stefan Schuermans add copyright & license

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp  1) /**
libpermissioner/src/Config.cpp  2)  * Permissioner: set file ownerships and permissions
libpermissioner/src/Config.cpp  3)  * Copyright 2020: Stefan Schuermans, Aachen, Germany <stefan@schuermans.info>
libpermissioner/src/Config.cpp  4)  * Copyleft: GNU GENERAL PUBLIC LICENSE version 3 (see LICENSE)
libpermissioner/src/Config.cpp  5)  */
libpermissioner/src/Config.cpp  6) 
Stefan Schuermans move most sources into libp...

Stefan Schuermans authored 4 years ago

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

Stefan Schuermans authored 4 years ago

permissionerd/src/Config.cpp    8) 
Stefan Schuermans fix long shutdown delay aft...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp  9) #include <permissioner/Callback.h>
Stefan Schuermans make timing configurable, s...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 10) #include <permissioner/Float.h>
Stefan Schuermans fix long shutdown delay aft...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 11) #include <permissioner/StringUtils.h>
Stefan Schuermans move most sources into libp...

Stefan Schuermans authored 4 years ago

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

Stefan Schuermans authored 4 years ago

permissionerd/src/Config.cpp   13) 
permissionerd/src/Config.cpp   14) #include <boost/filesystem.hpp>
permissionerd/src/Config.cpp   15) #include <fstream>
permissionerd/src/Config.cpp   16) #include <map>
permissionerd/src/Config.cpp   17) #include <sstream>
permissionerd/src/Config.cpp   18) #include <stdexcept>
permissionerd/src/Config.cpp   19) #include <string>
permissionerd/src/Config.cpp   20) 
Stefan Schuermans make timing configurable, s...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 21) Config::Config()
libpermissioner/src/Config.cpp 22)     : sleepTime("sleepTime", 0.0f, 1.0f, 1.0e-6f),
libpermissioner/src/Config.cpp 23)       waitFactor("waitFactor", 0.0f, 1.0e3f, 10.0f),
libpermissioner/src/Config.cpp 24)       waitTime("waitTime", 0.0f, 3.6e3f, 1.0f) {}
libpermissioner/src/Config.cpp 25) 
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Config.cpp   26) void Config::parseFile(std::string const &configFileName) {
permissionerd/src/Config.cpp   27)   std::ifstream configFile(configFileName, std::ios::in);
Stefan Schuermans make timing configurable, s...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 28)   if (!configFile.is_open()) {
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Config.cpp   29)     std::stringstream msg;
permissionerd/src/Config.cpp   30)     msg << "cannot open file \"" << configFileName << "\" for reading";
permissionerd/src/Config.cpp   31)     throw std::runtime_error(msg.str());
permissionerd/src/Config.cpp   32)   }
permissionerd/src/Config.cpp   33) 
Stefan Schuermans make timing configurable, s...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 34)   for (std::string line; std::getline(configFile, line);) {
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Config.cpp   35)     std::string::size_type pos = 0;
permissionerd/src/Config.cpp   36)     std::string typeStr;
permissionerd/src/Config.cpp   37)     try {
permissionerd/src/Config.cpp   38)       StringUtils::getNextField(line, pos, typeStr, "config line type");
permissionerd/src/Config.cpp   39)     } catch (std::exception const &e) {
permissionerd/src/Config.cpp   40)       continue; // empty line -> ignore
permissionerd/src/Config.cpp   41)     }
permissionerd/src/Config.cpp   42)     if (typeStr == "#") {
permissionerd/src/Config.cpp   43)       continue; // comment line -> ignore
permissionerd/src/Config.cpp   44)     }
Stefan Schuermans canonicalize root paths

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 45)     // actual configuration lines
Stefan Schuermans add nice and I/O idle config

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 46)     if (typeStr == "nice") {
libpermissioner/src/Config.cpp 47)       nice.parseParams(line.substr(pos));
libpermissioner/src/Config.cpp 48)       continue;
libpermissioner/src/Config.cpp 49)     }
Stefan Schuermans make timing configurable, s...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 50)     if (typeStr == "sleepTime") {
libpermissioner/src/Config.cpp 51)       sleepTime.parseParams(line.substr(pos));
libpermissioner/src/Config.cpp 52)       continue;
libpermissioner/src/Config.cpp 53)     }
libpermissioner/src/Config.cpp 54)     if (typeStr == "waitFactor") {
libpermissioner/src/Config.cpp 55)       waitFactor.parseParams(line.substr(pos));
libpermissioner/src/Config.cpp 56)       continue;
libpermissioner/src/Config.cpp 57)     }
libpermissioner/src/Config.cpp 58)     if (typeStr == "waitTime") {
libpermissioner/src/Config.cpp 59)       waitTime.parseParams(line.substr(pos));
libpermissioner/src/Config.cpp 60)       continue;
libpermissioner/src/Config.cpp 61)     }
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Config.cpp   62)     if (typeStr == "tree") {
permissionerd/src/Config.cpp   63)       Tree tree;
permissionerd/src/Config.cpp   64)       tree.parseParams(line.substr(pos));
Stefan Schuermans add config getters

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 65)       trees[tree.getRoot()] = tree;
Stefan Schuermans begin of permissioner confi...

Stefan Schuermans authored 4 years ago

permissionerd/src/Config.cpp   66)       continue;
permissionerd/src/Config.cpp   67)     }
permissionerd/src/Config.cpp   68)     // unknown configuration line
permissionerd/src/Config.cpp   69)     std::stringstream msg;
permissionerd/src/Config.cpp   70)     msg << "unknown configuration type \"" << typeStr << "\"";
permissionerd/src/Config.cpp   71)     throw std::runtime_error(msg.str());
permissionerd/src/Config.cpp   72)   }
permissionerd/src/Config.cpp   73) }
Stefan Schuermans add config getters

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 74) 
Stefan Schuermans make timing configurable, s...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 75) Nice const &Config::getNice() const { return nice; }
Stefan Schuermans add nice and I/O idle config

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 76) 
Stefan Schuermans make timing configurable, s...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 77) Float const &Config::getSleepTime() const { return sleepTime; }
libpermissioner/src/Config.cpp 78) 
libpermissioner/src/Config.cpp 79) Float const &Config::getWaitFactor() const { return waitFactor; }
libpermissioner/src/Config.cpp 80) 
libpermissioner/src/Config.cpp 81) Float const &Config::getWaitTime() const { return waitTime; }
libpermissioner/src/Config.cpp 82) 
libpermissioner/src/Config.cpp 83) TreeMap const &Config::getTrees() const { return trees; }
Stefan Schuermans implement chown/chmod

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 84) 
Stefan Schuermans fix long shutdown delay aft...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 85) bool Config::setPermissions(Callback &callback) const {
Stefan Schuermans make timing configurable, s...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 86)   for (auto const &path_tree : trees) {
libpermissioner/src/Config.cpp 87)     Tree const &tree = path_tree.second;
libpermissioner/src/Config.cpp 88)     if (!tree.setPermissions(trees, callback)) { // exclude all other trees
Stefan Schuermans fix long shutdown delay aft...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 89)       return false;
libpermissioner/src/Config.cpp 90)     }
Stefan Schuermans implement chown/chmod

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 91)   }
Stefan Schuermans fix long shutdown delay aft...

Stefan Schuermans authored 4 years ago

libpermissioner/src/Config.cpp 92)   return true;