nfs4: Abandon owner and owner_group when id mapping causes problems

This commit is contained in:
Pawel Dziepak
2012-07-03 22:16:08 +02:00
parent 16ff38f828
commit 8f57d30ea4
3 changed files with 23 additions and 6 deletions
@@ -340,6 +340,8 @@ Inode::Rename(Inode* from, Inode* to, const char* fromName, const char* toName)
status_t status_t
Inode::CreateLink(const char* name, const char* path, int mode) Inode::CreateLink(const char* name, const char* path, int mode)
{ {
bool badOwner = false;
do { do {
RPC::Server* serv = fFilesystem->Server(); RPC::Server* serv = fFilesystem->Server();
Request request(serv); Request request(serv);
@@ -354,14 +356,14 @@ Inode::CreateLink(const char* name, const char* path, int mode)
cattr[i].fData.fValue32 = mode; cattr[i].fData.fValue32 = mode;
i++; i++;
if (fFilesystem->IsAttrSupported(FATTR4_OWNER)) { if (!badOwner && fFilesystem->IsAttrSupported(FATTR4_OWNER)) {
cattr[i].fAttribute = FATTR4_OWNER; cattr[i].fAttribute = FATTR4_OWNER;
cattr[i].fFreePointer = true; cattr[i].fFreePointer = true;
cattr[i].fData.fPointer = gIdMapper->GetOwner(getuid()); cattr[i].fData.fPointer = gIdMapper->GetOwner(getuid());
i++; i++;
} }
if (fFilesystem->IsAttrSupported(FATTR4_OWNER_GROUP)) { if (!badOwner && fFilesystem->IsAttrSupported(FATTR4_OWNER_GROUP)) {
cattr[i].fAttribute = FATTR4_OWNER_GROUP; cattr[i].fAttribute = FATTR4_OWNER_GROUP;
cattr[i].fFreePointer = true; cattr[i].fFreePointer = true;
cattr[i].fData.fPointer = gIdMapper->GetOwnerGroup(getgid()); cattr[i].fData.fPointer = gIdMapper->GetOwnerGroup(getgid());
@@ -376,6 +378,10 @@ Inode::CreateLink(const char* name, const char* path, int mode)
ReplyInterpreter& reply = request.Reply(); ReplyInterpreter& reply = request.Reply();
if (reply.NFS4Error() == NFS4ERR_BADOWNER) {
badOwner = true;
continue;
}
if (_HandleErrors(reply.NFS4Error(), serv)) if (_HandleErrors(reply.NFS4Error(), serv))
continue; continue;
@@ -20,6 +20,8 @@
status_t status_t
Inode::CreateDir(const char* name, int mode) Inode::CreateDir(const char* name, int mode)
{ {
bool badOwner = false;
do { do {
RPC::Server* serv = fFilesystem->Server(); RPC::Server* serv = fFilesystem->Server();
Request request(serv); Request request(serv);
@@ -34,14 +36,14 @@ Inode::CreateDir(const char* name, int mode)
cattr[i].fData.fValue32 = mode; cattr[i].fData.fValue32 = mode;
i++; i++;
if (fFilesystem->IsAttrSupported(FATTR4_OWNER)) { if (!badOwner && fFilesystem->IsAttrSupported(FATTR4_OWNER)) {
cattr[i].fAttribute = FATTR4_OWNER; cattr[i].fAttribute = FATTR4_OWNER;
cattr[i].fFreePointer = true; cattr[i].fFreePointer = true;
cattr[i].fData.fPointer = gIdMapper->GetOwner(getuid()); cattr[i].fData.fPointer = gIdMapper->GetOwner(getuid());
i++; i++;
} }
if (fFilesystem->IsAttrSupported(FATTR4_OWNER_GROUP)) { if (!badOwner && fFilesystem->IsAttrSupported(FATTR4_OWNER_GROUP)) {
cattr[i].fAttribute = FATTR4_OWNER_GROUP; cattr[i].fAttribute = FATTR4_OWNER_GROUP;
cattr[i].fFreePointer = true; cattr[i].fFreePointer = true;
cattr[i].fData.fPointer = gIdMapper->GetOwnerGroup(getgid()); cattr[i].fData.fPointer = gIdMapper->GetOwnerGroup(getgid());
@@ -56,6 +58,10 @@ Inode::CreateDir(const char* name, int mode)
ReplyInterpreter& reply = request.Reply(); ReplyInterpreter& reply = request.Reply();
if (reply.NFS4Error() == NFS4ERR_BADOWNER) {
badOwner = true;
continue;
}
if (_HandleErrors(reply.NFS4Error(), serv)) if (_HandleErrors(reply.NFS4Error(), serv))
continue; continue;
@@ -66,6 +66,7 @@ Inode::Create(const char* name, int mode, int perms, OpenFileCookie* cookie,
cookie->fSequence = 0; cookie->fSequence = 0;
cookie->fLocks = NULL; cookie->fLocks = NULL;
bool badOwner = false;
Filehandle fh; Filehandle fh;
do { do {
cookie->fClientId = fFilesystem->NFSServer()->ClientId(); cookie->fClientId = fFilesystem->NFSServer()->ClientId();
@@ -91,14 +92,14 @@ Inode::Create(const char* name, int mode, int perms, OpenFileCookie* cookie,
cattr[i].fData.fValue32 = perms; cattr[i].fData.fValue32 = perms;
i++; i++;
if (fFilesystem->IsAttrSupported(FATTR4_OWNER)) { if (!badOwner && fFilesystem->IsAttrSupported(FATTR4_OWNER)) {
cattr[i].fAttribute = FATTR4_OWNER; cattr[i].fAttribute = FATTR4_OWNER;
cattr[i].fFreePointer = true; cattr[i].fFreePointer = true;
cattr[i].fData.fPointer = gIdMapper->GetOwner(getuid()); cattr[i].fData.fPointer = gIdMapper->GetOwner(getuid());
i++; i++;
} }
if (fFilesystem->IsAttrSupported(FATTR4_OWNER_GROUP)) { if (!badOwner && fFilesystem->IsAttrSupported(FATTR4_OWNER_GROUP)) {
cattr[i].fAttribute = FATTR4_OWNER_GROUP; cattr[i].fAttribute = FATTR4_OWNER_GROUP;
cattr[i].fFreePointer = true; cattr[i].fFreePointer = true;
cattr[i].fData.fPointer = gIdMapper->GetOwnerGroup(getgid()); cattr[i].fData.fPointer = gIdMapper->GetOwnerGroup(getgid());
@@ -122,6 +123,10 @@ Inode::Create(const char* name, int mode, int perms, OpenFileCookie* cookie,
ReplyInterpreter& reply = request.Reply(); ReplyInterpreter& reply = request.Reply();
if (reply.NFS4Error() == NFS4ERR_BADOWNER) {
badOwner = true;
continue;
}
if (_HandleErrors(reply.NFS4Error(), serv)) if (_HandleErrors(reply.NFS4Error(), serv))
continue; continue;