Esempio n. 1
0
util::Error DirAllowed(const User& user, const fs::VirtualPath& path)
{
  if (path.IsEmpty()) return util::Error::Failure(EINVAL);
  if (path.ToString()[path.Length() - 1] != '/') 
    return InnerAllowed<type>(user, fs::VirtualPath(path.ToString() + '/'));
  else
    return InnerAllowed<type>(user, path);
}
Esempio n. 2
0
 boost::optional<db::nuking::Nuke> LookupUnnuke()
 {
   boost::optional<db::nuking::Nuke> nuke;
   std::string id = GetNukeID(real);
   if (!id.empty()) nuke = db::nuking::LookupUnnukeByID(id);   
   if (!nuke) nuke = db::nuking::LookupUnnukeByPath(path.ToString());
   return nuke;
 }
Esempio n. 3
0
bool STORCommand::CalcCRC(const fs::VirtualPath& path)
{
  for (auto& mask : cfg::Get().CalcCrc())
  {
    if (util::WildcardMatch(mask, path.ToString())) return true;
  }
  
  return false;
}
Esempio n. 4
0
bool PrivatePath(const fs::VirtualPath& path, const User& user)
{
  auto info = user.ACLInfo();
  for (const auto& pp : cfg::Get().Privpath())
  {
    if (!path.ToString().compare(0, pp.Path().length(), pp.Path()))
      return !pp.ACL().Evaluate(info);
  }
  return false;
}
Esempio n. 5
0
 db::nuking::Nuke LookupNuke()
 {
   boost::optional<db::nuking::Nuke> nuke;
   std::string id = GetNukeID(nukedPath);
   if (!id.empty()) nuke = db::nuking::LookupNukeByID(id);   
   if (!nuke)
   {
     nuke = db::nuking::LookupNukeByPath(path.ToString());
     if (!nuke) throw util::RuntimeError("Unable to locate nuke data");
   }
   return *nuke;      
 }
Esempio n. 6
0
 DoNuke(const fs::VirtualPath& path, int multiplier, bool isPercent, 
        const std::string& reason, acl::UserID nukerUID) :
   config(cfg::Get()),
   path(path),
   real(fs::MakeReal(path)),
   multiplier(multiplier),
   isPercent(isPercent),
   reason(reason),
   nukerUID(nukerUID),
   modTime(0),
   totalKBytes(0),
   section(config.SectionMatch(path.ToString(), true))
 { }
Esempio n. 7
0
 void UpdateDatabase()
 {
   std::vector<db::nuking::Nukee> nukees2;
   for (const auto& kv : nukees)
   {
     nukees2.emplace_back(kv.first, kv.second.kBytes, 
                          kv.second.files, kv.second.credits);
   }
   
   // remove old unnuke data if dir was unnuked in past
   auto unnuke = LookupUnnuke();
   if (unnuke) db::nuking::DelUnnuke(*unnuke);
   
   nuke = db::nuking::Nuke(path.ToString(), section ? section->Name() : "", 
                           reason, nukerUID, multiplier, isPercent, modTime, nukees2);
   db::nuking::AddNuke(*nuke);
 }
Esempio n. 8
0
bool InsideHomeDir(const User& user, const fs::VirtualPath& path)
{
  if (user.HomeDir().empty()) return false;
  if (user.HomeDir().back() == '/') return util::StartsWith(path.ToString(), user.HomeDir());
  else return util::StartsWith(path.ToString(), user.HomeDir() + '/');
}