示例#1
0
文件: path.cpp 项目: arrrrrrr/ebftpd
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);
}
示例#2
0
文件: nuking.cpp 项目: glftpd/ebftpd
 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;
 }
示例#3
0
文件: stor.cpp 项目: glftpd/ebftpd
bool STORCommand::CalcCRC(const fs::VirtualPath& path)
{
  for (auto& mask : cfg::Get().CalcCrc())
  {
    if (util::WildcardMatch(mask, path.ToString())) return true;
  }
  
  return false;
}
示例#4
0
文件: path.cpp 项目: arrrrrrr/ebftpd
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;
}
示例#5
0
文件: nuking.cpp 项目: glftpd/ebftpd
 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;      
 }
示例#6
0
文件: nuking.cpp 项目: glftpd/ebftpd
 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))
 { }
示例#7
0
文件: chmod.cpp 项目: arrrrrrr/ebftpd
void CHMODCommand::Process(fs::VirtualPath pathmask)
{
  auto flags = fs::GlobIterator::NoFlags;
  if (recursive) flags |= fs::GlobIterator::Recursive;

  try
  {
    for (auto& entry : fs::GlobContainer(client.User(), pathmask, flags))
    {
      fs::VirtualPath entryPath(pathmask.Dirname() / entry);
      try
      {
        util::path::Status status(fs::MakeReal(entryPath).ToString());
        util::Error e = fs::Chmod(client.User(), entryPath, *mode);
        if (!e)
        {
          ++failed;
          control.PartReply(ftp::CommandOkay, "CHOWN " +
              entryPath.ToString() + ": " + e.Message());
        }
        else
        if (status.IsDirectory()) ++dirs;
        else ++files;
      }
      catch (const util::SystemError& e)
      {
        ++failed;
        control.PartReply(ftp::CommandOkay, "CHOWN " +
            entryPath.ToString() + ": " + e.Message());
      }
    }
  }
  catch (const util::SystemError& e)
  {
    ++failed;
    control.PartReply(ftp::CommandOkay,
        "CHMOD " + pathmask.Dirname().ToString() + ": " + e.Message());
  }
}
示例#8
0
文件: nuking.cpp 项目: glftpd/ebftpd
 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);
 }
示例#9
0
文件: path.cpp 项目: arrrrrrr/ebftpd
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() + '/');
}