Commit e4709081 authored by Steven Murray's avatar Steven Murray
Browse files

CASTOR-4791 RFE: CASTOR 2.1.15-x should not allow writes to owner-less tape pools

Fixed.
parent 312ac7c7
......@@ -292,6 +292,19 @@ void castor::tape::tapeserver::daemon::CatalogueTransferSession::
m_log(LOG_INFO, "Queried vmgr for the pool of the tape for migration",
params);
// A pool has no owner if either its user or group ID is 0
//
// There is no such concept as a pool owned by the user root or the group root
const bool poolHasOwner = 0 != vmgrPool.poolUid && 0 != vmgrPool.poolGid;
if(!poolHasOwner) {
castor::exception::Exception ex;
ex.getMessage() <<
"Cannot migrate files to a tape belonging to an owner-less tape-pool"
": vid=" << vid;
throw ex;
}
// Only the owner of the pool of a tape can migrate files to that tape
const bool userIsPoolOwner = m_vdqmJob.clientEuid == vmgrPool.poolUid &&
m_vdqmJob.clientEgid == vmgrPool.poolGid;
......
......@@ -303,29 +303,13 @@ void castor::tape::tpcp::WriteTpCommand::checkUserHasTapeWritePermission(
" User can write to tape: User owns tape pool \"" << poolName << "\"" <<
std::endl;
} else {
castor::exception::PermissionDenied ex;
const bool userIsAdmin =
Cupv_check(userId, groupId, sourceHost, "TAPE_SERVERS",P_ADMIN) == 0 ||
Cupv_check(userId, groupId, sourceHost, NULL ,P_ADMIN) == 0;
if(userIsAdmin) {
// Command-line user feedback
std::ostream &os = std::cout;
time_t now = time(NULL);
castor::utils::writeTime(os, now, TIMEFORMAT);
os <<
" User can write to tape: User has ADMIN privilege" << std::endl;
} else {
castor::exception::PermissionDenied ex;
ex.getMessage() <<
"User cannot write to tape"
": User must own the \"" << poolName << "\" tape pool or "
"have the ADMIN privilege";
ex.getMessage() <<
"User cannot write to tape"
": User must own the \"" << poolName << "\" tape pool";
throw ex;
}
throw ex;
}
}
......
......@@ -62,8 +62,8 @@ int vmgrchecki(char *vid, char *vsn, char *dgn, char *den, char *lbl, int mode,
return (EINVAL);
sleep (60);
}
if (((pool_uid && pool_uid != uid && uid != 0) ||
(pool_gid && pool_gid != gid && gid != 0)) &&
if (((pool_uid != uid && uid != 0) ||
(pool_gid != gid && gid != 0)) &&
(Cupv_check (uid, gid, clienthost, "TAPE_SERVERS", P_ADMIN) &&
Cupv_check (uid, gid, clienthost, NULL, P_ADMIN)))
return (EACCES);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment