IOHandler* VfsIODriver::createIOHandler(const std::string& pfn,
- int openmode,
- const Extensible& extras) throw (DmException)
+ int flags,
+ const Extensible& extras,
+ mode_t mode) throw (DmException)
{
- if (!extras.hasField("token"))
- throw DmException(EACCES, "Missing token");
+ if (!(flags & IODriver::kInsecure)) {
+ if (!extras.hasField("token"))
+ throw DmException(EACCES, "Missing token");
+ }
std::string userId;
if (this->useIp_)
if (dmlite::validateToken(extras.getString("token"),
userId,
pfn, this->passwd_,
- openmode != O_RDONLY) != kTokenOK)
+ flags != O_RDONLY) != kTokenOK)
throw DmException(EACCES, "Token does not validate (using %s)",
this->useIp_?"IP":"DN");
// Create
- return new VfsIOHandler(pfn, openmode);
+ return new VfsIOHandler(pfn, flags, mode);
}
VfsIOHandler::VfsIOHandler(const std::string& path,
- int openmode) throw (DmException):
+ int flags, mode_t mode) throw (DmException):
eof_(false), pos_(0)
{
std::string real;
real = path.substr(4);
- this->fd_ = ::open(real.c_str(), openmode, 0644);
+ this->fd_ = ::open(real.c_str(), flags, mode);
if (this->fd_ == -1)
throw DmException(errno, "Could not open %s", path.c_str());
}
void setStackInstance(StackInstance* si) throw (DmException);
void setSecurityContext(const SecurityContext* ctx) throw (DmException);
- IOHandler* createIOHandler(const std::string& pfn, int openmode,
- const Extensible& extras) throw (DmException);
+ IOHandler* createIOHandler(const std::string& pfn, int flags,
+ const Extensible& extras, mode_t mode) throw (DmException);
void doneWriting(const std::string& pfn,
const Extensible& params) throw (DmException);
class VfsIOHandler: public IOHandler {
public:
VfsIOHandler(const std::string& path,
- int openmode) throw (DmException);
+ int flags, mode_t mode) throw (DmException);
~VfsIOHandler();
void close(void) throw (DmException);