Commit d065297c authored by Aleksandr Konstantinov's avatar Aleksandr Konstantinov

Merge branch 'bug_3922' into 'master'

Fixed BUGZ-3922

See merge request !979
parents b695fc09 6aa87c95
Pipeline #7701 passed with stages
in 127 minutes and 51 seconds
......@@ -921,7 +921,7 @@
## - "%H" - home directory of mapped UNIX account as specified in "/etc/passwd"
## - "%Q" - default queue (see "lrms" configuration option in [lrms] block)
## - "%L" - LRMS name (see "lrms" configuration option in [lrms] block)
## - "%W" ARC installation path (corresponds to the "ARC_LOCATION" environmental variable)
## - "%W" - ARC installation path (corresponds to the "ARC_LOCATION" environmental variable)
## - "%F" - path to configuration file for this instance
## - "%I" - job ID (substituted in runtime)
## - "%S" - job state (substituted in runtime)
......
......@@ -363,8 +363,6 @@ bool GridManager::thread() {
SpaceMetrics* space_metrics = config_.GetSpaceMetrics();
if(space_metrics) space_metrics->ReportSpaceChange(config_);
jobs.WaitAttention();
logger.msg(Arc::DEBUG,"Waking up");
};
......
......@@ -299,8 +299,10 @@ const std::list<std::pair<bool,std::string> > & GMConfig::MatchingGroupsPublicIn
return matching_groups_publicinfo;
}
bool GMConfig::Substitute(std::string& param, const Arc::User& user) const {
bool GMConfig::Substitute(std::string& param, bool& userSubs, bool& otherSubs, const Arc::User& user) const {
std::string::size_type curpos = 0;
userSubs = false;
otherSubs = false;
for (;;) {
if (curpos >= param.length()) break;
std::string::size_type pos = param.find('%', curpos);
......@@ -309,16 +311,16 @@ bool GMConfig::Substitute(std::string& param, const Arc::User& user) const {
if (param[pos] == '%') { curpos=pos+1; continue; };
std::string to_put;
switch (param[pos]) {
case 'R': to_put = SessionRoot(""); break; // First session dir will be used if there are multiple
case 'C': to_put = ControlDir(); break;
case 'U': to_put = user.Name(); break;
case 'H': to_put = user.Home(); break;
case 'Q': to_put = DefaultQueue(); break;
case 'L': to_put = DefaultLRMS(); break;
case 'u': to_put = Arc::tostring(user.get_uid()); break;
case 'g': to_put = Arc::tostring(user.get_gid()); break;
case 'W': to_put = Arc::ArcLocation::Get(); break;
case 'F': to_put = conffile; break;
case 'R': to_put = SessionRoot(""); otherSubs = true; break; // First session dir will be used if there are multiple
case 'C': to_put = ControlDir(); otherSubs = true; break;
case 'U': to_put = user.Name(); userSubs = true; break;
case 'H': to_put = user.Home(); userSubs = true; break;
case 'Q': to_put = DefaultQueue(); otherSubs = true; break;
case 'L': to_put = DefaultLRMS(); otherSubs = true; break;
case 'u': to_put = Arc::tostring(user.get_uid()); userSubs = true; break;
case 'g': to_put = Arc::tostring(user.get_gid()); userSubs = true; break;
case 'W': to_put = Arc::ArcLocation::Get(); otherSubs = true; break;
case 'F': to_put = conffile; otherSubs = true; break;
case 'G':
logger.msg(Arc::ERROR, "Globus location variable substitution is not supported anymore. Please specify path directly.");
break;
......
......@@ -101,7 +101,13 @@ public:
/// Substitute characters in param specified by % with real values. An
/// optional User can be specified for the user-related substitutions.
bool Substitute(std::string& param, const Arc::User& user=Arc::User()) const;
bool Substitute(std::string& param, bool& userSubs, bool& otherSubs, const Arc::User& user=Arc::User()) const;
bool Substitute(std::string& param, const Arc::User& user=Arc::User()) const {
bool userSubs;
bool otherSubs;
return Substitute(param, userSubs, otherSubs, user);
}
/// Set control directory
void SetControlDir(const std::string &dir);
......
......@@ -111,28 +111,6 @@ class DirectUserFilePlugin: public DirectFilePlugin {
};
static void job_subst(std::string& str,void* arg) {
job_subst_t* subs = (job_subst_t*)arg;
if(subs->job) for(std::string::size_type p = 0;;) {
p=str.find('%',p);
if(p==std::string::npos) break;
if(str[p+1]=='I') {
str.replace(p,2,subs->job->c_str());
p+=subs->job->length();
} else if(str[p+1]=='S') {
str.replace(p,2,"UNKNOWN"); // WRONG
p+=7;
} else if(str[p+1]=='O') {
str.replace(p,2,subs->reason);
p+=strlen(subs->reason);
} else {
p+=2;
};
};
if(subs->user && subs->config) subs->config->Substitute(str, *(subs->user));
}
JobPlugin::JobPlugin(std::istream &cfile,userspec_t const &user_,FileNode& node):
cont_plugins(new ContinuationPlugins),
user_s(user_),
......
......@@ -283,6 +283,7 @@ ARexJob::ARexJob(const std::string& id,ARexGMConfig& config,Arc::Logger& logger,
if(!(allowed_to_see_ || allowed_to_maintain_)) { id_.clear(); return; };
// Checking for presence of session dir and identifying local user id.
struct stat st;
if(job_.sessiondir.empty()) { id_.clear(); return; };
if(stat(job_.sessiondir.c_str(),&st) != 0) { id_.clear(); return; };
uid_ = st.st_uid;
gid_ = st.st_gid;
......@@ -837,7 +838,7 @@ bool ARexJob::UpdateCredentials(const std::string& credentials) {
if(id_.empty()) return false;
if(!update_credentials(credentials)) return false;
GMJob job(id_,Arc::User(uid_),
config_.GmConfig().SessionRoot(id_)+"/"+id_,JOB_STATE_ACCEPTED);
job_.sessiondir,JOB_STATE_ACCEPTED);
if(!job_local_write_file(job,config_.GmConfig(),job_)) return false;
return true;
}
......@@ -853,7 +854,7 @@ bool ARexJob::update_credentials(const std::string& credentials) {
Arc::Credential cred(credentials,"","","","",false);
job_.expiretime = cred.GetEndTime();
GMJob job(id_,Arc::User(uid_),
config_.GmConfig().SessionRoot(id_)+"/"+id_,JOB_STATE_ACCEPTED);
job_.sessiondir,JOB_STATE_ACCEPTED);
#if 0
std::string cred_public;
cred.OutputCertificate(cred_public);
......@@ -901,8 +902,9 @@ bool ARexJob::make_job_id(void) {
bool ARexJob::delete_job_id(void) {
if(!config_) return true;
if(!id_.empty()) {
job_clean_final(GMJob(id_,Arc::User(uid_),
config_.GmConfig().SessionRoot(id_)+"/"+id_),config_.GmConfig());
if(!job_.sessiondir.empty()) // check if session dir was already defined
job_clean_final(GMJob(id_,Arc::User(uid_),
job_.sessiondir),config_.GmConfig());
id_="";
};
return true;
......@@ -930,7 +932,7 @@ std::list<std::string> ARexJob::Jobs(ARexGMConfig& config,Arc::Logger& logger) {
std::string ARexJob::SessionDir(void) {
if(id_.empty()) return "";
return config_.GmConfig().SessionRoot(id_)+"/"+id_;
return job_.sessiondir;
}
std::string ARexJob::LogDir(void) {
......@@ -970,7 +972,7 @@ Arc::FileAccess* ARexJob::CreateFile(const std::string& filename) {
return NULL;
};
int lname = fname.length();
fname = config_.GmConfig().SessionRoot(id_)+"/"+id_+"/"+fname;
fname = job_.sessiondir+"/"+fname;
// First try to create/open file
Arc::FileAccess* fa = Arc::FileAccess::Acquire();
if(!*fa) {
......@@ -1013,7 +1015,7 @@ Arc::FileAccess* ARexJob::OpenFile(const std::string& filename,bool for_read,boo
failure_type_=ARexJobInternalError;
return NULL;
};
fname = config_.GmConfig().SessionRoot(id_)+"/"+id_+"/"+fname;
fname = job_.sessiondir+"/"+fname;
int flags = 0;
if(for_read && for_write) { flags=O_RDWR; }
else if(for_read) { flags=O_RDONLY; }
......@@ -1042,7 +1044,7 @@ Arc::FileAccess* ARexJob::OpenDir(const std::string& dirname) {
return NULL;
};
//if(dname.empty()) return NULL;
dname = config_.GmConfig().SessionRoot(id_)+"/"+id_+"/"+dname;
dname = job_.sessiondir+"/"+dname;
Arc::FileAccess* fa = Arc::FileAccess::Acquire();
if(*fa) {
if(fa->fa_setuid(uid_,gid_)) {
......@@ -1103,8 +1105,8 @@ std::string ARexJob::GetFilePath(const std::string& filename) {
if(id_.empty()) return "";
std::string fname = filename;
if(!normalize_filename(fname)) return "";
if(fname.empty()) config_.GmConfig().SessionRoot(id_)+"/"+id_;
return config_.GmConfig().SessionRoot(id_)+"/"+id_+"/"+fname;
if(fname.empty()) return job_.sessiondir;
return job_.sessiondir+"/"+fname;
}
bool ARexJob::ReportFileComplete(const std::string& filename) {
......
Markdown is supported
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