tout << "link" << endl;
tout << existing << endl;
tout << newname << endl;
+
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
+ // This is for FUSE support of passing the userid
//Ticket *tk;
//if (uid == -1 || gid == -1)
// tk = get_user_ticket(getuid(), getgid());
req->set_sarg(existing);
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
MClientReply *reply = make_request(req, true);
int res = reply->get_result();
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
req->set_path(path);
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
//FIXME enforce caller uid rights?
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
req->set_sarg(to);
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
//FIXME enforce caller uid rights?
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
req->set_iarg( (int)mode );
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
//FIXME enforce caller uid rights?
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
req->set_path(path);
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
//FIXME enforce caller uid rights?
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
req->set_sarg(target);
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
//FIXME enforce caller uid rights?
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
// check whether cache content is fresh enough
int res = 0;
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+ // the ticket should be used since it must look at
+ // execute permissions in path
+ //Ticket *tk = get_user_ticket(uid, gid);
+
Dentry *dn = lookup(fpath);
inode_t inode;
time_t now = time(NULL);
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
req->set_iarg( (int)mode );
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
MClientReply *reply = make_request(req, true);
int res = reply->get_result();
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
req->set_iarg2( (int)gid );
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
//FIXME enforce caller uid rights?
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
req->set_targ2( buf->actime );
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
//FIXME enforce caller uid rights?
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
req->set_iarg( mode );
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
//FIXME enforce caller uid rights?
// fyi: typedef int (*dirfillerfunc_t) (void *handle, const char *name, int type, inodeno_t ino);
-int Client::getdir(const char *relpath, map<string,inode_t>& contents)
+int Client::getdir(const char *relpath, map<string,inode_t>& contents,
+ __int64_t uid, __int64_t gid)
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
req->set_path(path);
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
//FIXME enforce caller uid rights?
struct dirent *Client::readdir(DIR *dirp, __int64_t uid, __int64_t gid)
{
+
DirResult *d = (DirResult*)dirp;
// end of dir?
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
if (!tk) {
client_lock.Unlock();
req->set_iarg(flags);
req->set_iarg2(cmode);
+ // don't need a cap if I have one cached
+ ExtCap *ext_cap;
+ //ExtCap *ext_cap = fc->get_ext_caps(uid);
+ // !!FIX ME!! Set flag to not ask for cap if I have one already
+ if (!ext_cap)
+ cout << "No capability cached at client for file " << path << endl;
+ else
+ cout << "Cached capability found! for file " << path << endl;
+
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
MClientReply *reply = make_request(req, tryauth); // try auth if writer
int new_caps = reply->get_file_caps();
+ // need security caps? check if I even asked for one
+ ext_cap = reply->get_ext_cap();
+
+ // cache it
+ f->inode->set_ext_cap(uid, ext_cap);
+
assert(reply->get_file_caps_seq() >= f->inode->caps[mds].seq);
if (reply->get_file_caps_seq() > f->inode->caps[mds].seq) {
dout(7) << "open got caps " << cap_string(new_caps)
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
req->set_sizearg( size );
// FIXME where does FUSE maintain user information
- req->set_caller_uid(getuid());
- req->set_caller_gid(getgid());
+ req->set_caller_uid(uid);
+ req->set_caller_gid(gid);
MClientReply *reply = make_request(req, true);
int res = reply->get_result();
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
{
client_lock.Lock();
- Ticket *tk = get_user_ticket(getuid(), getgid());
+ // fix uid/gid if not supplied
+ // get it from the system
+ if (uid == -1 || gid == -1) {
+ uid = getuid();
+ gid = getgid();
+ }
+
+ Ticket *tk = get_user_ticket(uid, gid);
+ //Ticket *tk = get_user_ticket(getuid(), getgid());
if (!tk) {
client_lock.Unlock();
return -EPERM;
if (mode & FILE_MODE_W) my_want |= CAP_FILE_WRBUFFER | CAP_FILE_WR;
// register a capability
+ // checks capabilities for the file indexed by client id
+ // returns 0 if there is no cached capability
Capability *cap = in->get_client_cap(my_client);
if (!cap) {
// new cap
+ // makes a cap which only contains the desired mode (my_want)
Capability c(my_want);
+ // caches this capability in the inode
in->add_client_cap(my_client, c);
+ // pull the cap back out, why? you have a pointer to it already
+ // ah, because this is the variable used later
cap = in->get_client_cap(my_client);
// note client addr
+ // increase reference count on this clientid
mds->clientmap.add_open(my_client, req->get_client_inst());
} else {
// make sure it has sufficient caps
+ // if the mode cached is not the mode were looking for
if (cap->wanted() & ~my_want) {
// augment wanted caps for this client
+ // just changed the cached capability to the mode we want
cap->set_wanted( cap->wanted() | my_want );
}
}
// suppress file cap messages for this guy for a few moments (we'll bundle with the open() reply)
+ // is this so that issue_caps() does actually send caps to the client?
cap->set_suppress(true);
+ // checks the mode the client asked for previously
int before = cap->pending();
+ // if this MDS is the authority for the inode
if (in->is_auth()) {
// [auth] twiddle mode?
inode_file_eval(in);
issue_caps(in); // note: _eval above may have done this already...
// re-issue whatever we can
+ // this doesn't actually seem to do anything
cap->issue(cap->pending());
// ok, stop suppressing.
cap->set_suppress(false);
+ // the mode of the most recently sent, should be the desired mode?
int now = cap->pending();
if (before != now &&
(before & CAP_FILE_WR) == 0 &&
return cap;
}
+/**********
+ * This function returns a new extended capability
+ * for the user for file
+ * This function does nothing for synchronization
+ **********/
+ExtCap* Locker::issue_new_extcaps(CInode *in, int mode, MClientRequest *req) {
+ dout(3) << "issue_new_EXTcaps for mode " << mode << " on " << *in << endl;
+ // get the uid
+ int my_client = req->get_client();
+ uid_t my_user = req->get_caller_uid();
+ int my_want = 0;
+ // only care about reading a writing, no sync
+ if (mode & FILE_MODE_R) my_want |= CAP_FILE_RD;
+ if (mode & FILE_MODE_W) my_want |= CAP_FILE_WR;
+
+ // checks capabilities for the file indexed by client id
+ // returns 0 if there is no cached capability
+ ExtCap *ext_cap = in->get_user_extcap(my_user);
+ if (!ext_cap) {
+ // need to create new cap
+ ExtCap my_cap(my_want, my_user, in->ino());
+
+ // caches this capability in the inode
+ in->add_user_extcap(my_user, my_cap);
+
+ //ext_cap = (&my_cap);
+ ext_cap = in->get_user_extcap(my_user);
+
+ }
+ // we want to index based on mode, so we can cache more caps
+ // does the cached cap have the write mode?
+ else {
+ // augment the capability if not right mode
+ if (ext_cap->mode() != mode)
+ ext_cap->set_mode(mode);
+
+ }
+ return ext_cap;
+}
bool Locker::issue_caps(CInode *in)
{