e.g.: 07555 means: 7 for owner 5 for group 5 for others 5 for guests (not logged users) added: the sticky bit for directories e.g. permissions to a directory with a sticky bit set can be set to: 017555 rewritten: rm/mv winix functions to correctly understand the sticky bit added: Dir::FollowLink() recognizes ".." and "." now consequently System::FollowAllLinks recognizes it too added: umask -- calculating privileges for new files/directories all users have their own umask (in meta) and there is one in the config (for guests and when a user has not definied its own one) removed: mount option: only_root_remove git-svn-id: svn://ttmath.org/publicrep/winix/trunk@801 e52654a7-88a9-db11-a3e9-0013d4bc506e
92 lines
1.5 KiB
C++
Executable File
92 lines
1.5 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2008-2012, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include "mkdir.h"
|
|
#include "functions.h"
|
|
|
|
|
|
|
|
namespace Fun
|
|
{
|
|
|
|
Mkdir::Mkdir()
|
|
{
|
|
fun.url = L"mkdir";
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Mkdir::HasAccess(const Item & item)
|
|
{
|
|
// you can create a directory only in a directory
|
|
if( item.type != Item::dir )
|
|
return false;
|
|
|
|
if( cur->session->puser && cur->session->puser->super_user )
|
|
// super user can use mkdir everywhere
|
|
return true;
|
|
|
|
if( !system->HasWriteAccess(item) )
|
|
return false;
|
|
|
|
if( !system->mounts.pmount->IsPar(system->mounts.MountParMkdirOn()) )
|
|
return true;
|
|
|
|
if( system->mounts.pmount->IsArg(system->mounts.MountParMkdirOn(), cur->request->dir_tab.size()) )
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
bool Mkdir::HasAccess()
|
|
{
|
|
if( cur->request->is_item || !HasAccess(*cur->request->dir_tab.back()) )
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
|
|
void Mkdir::PostFunMkdir(bool add_to_dir_tab, int privileges)
|
|
{
|
|
functions->ReadItem(cur->request->item, Item::dir);
|
|
functions->SetUser(cur->request->item);
|
|
cur->request->item.privileges = privileges;
|
|
|
|
cur->request->status = system->dirs.AddDirectory(cur->request->item, add_to_dir_tab);
|
|
|
|
if( cur->request->status == WINIX_ERR_OK )
|
|
{
|
|
system->RedirectTo(cur->request->item);
|
|
}
|
|
else
|
|
{
|
|
log << log1 << "Content: PostFunMkdir: Error: " << cur->request->status << logend;
|
|
}
|
|
}
|
|
|
|
|
|
void Mkdir::MakePost()
|
|
{
|
|
PostFunMkdir(false, system->NewDirPrivileges());
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|