Commit a496932c authored by Aleksandr Konstantinov's avatar Aleksandr Konstantinov
Browse files

Make check for presence of proxy conditional depending on presence of token and input/output files.

parent ca73b68c
Pipeline #10301 passed with stage
in 115 minutes and 32 seconds
......@@ -64,8 +64,10 @@ int RUNMAIN(arccat)(int argc, char **argv) {
return 1;
}
if (!checkproxy(usercfg)) {
return 1;
if(usercfg.OToken().empty()) {
if (!checkproxy(usercfg)) {
return 1;
}
}
if (opt.debug.empty() && !usercfg.Verbosity().empty())
......
......@@ -62,8 +62,10 @@ int RUNMAIN(arcclean)(int argc, char **argv) {
return 1;
}
if (!checkproxy(usercfg)) {
return 1;
if(usercfg.OToken().empty()) {
if (!checkproxy(usercfg)) {
return 1;
}
}
if (opt.debug.empty() && !usercfg.Verbosity().empty())
......
......@@ -63,8 +63,10 @@ int RUNMAIN(arcget)(int argc, char **argv) {
return 1;
}
if (!checkproxy(usercfg)) {
return 1;
if(usercfg.OToken().empty()) {
if (!checkproxy(usercfg)) {
return 1;
}
}
if (opt.debug.empty() && !usercfg.Verbosity().empty())
......
......@@ -61,8 +61,10 @@ int RUNMAIN(arckill)(int argc, char **argv) {
return 1;
}
if (!checkproxy(usercfg)) {
return 1;
if(usercfg.OToken().empty()) {
if (!checkproxy(usercfg)) {
return 1;
}
}
if (opt.debug.empty() && !usercfg.Verbosity().empty())
......
......@@ -65,8 +65,11 @@ int RUNMAIN(arcresub)(int argc, char **argv) {
return 0;
}
if (!checkproxy(usercfg)) {
return 1;
// TODO: proper check for each job must be implemented
if(usercfg.OToken().empty()) {
if (!checkproxy(usercfg)) {
return 1;
}
}
if (opt.debug.empty() && !usercfg.Verbosity().empty())
......
......@@ -51,8 +51,10 @@ int RUNMAIN(arcresume)(int argc, char **argv) {
return 1;
}
if (!checkproxy(usercfg)) {
return 1;
if(usercfg.OToken().empty()) {
if (!checkproxy(usercfg)) {
return 1;
}
}
if (opt.debug.empty() && !usercfg.Verbosity().empty())
......
......@@ -78,10 +78,6 @@ int RUNMAIN(arcsub)(int argc, char **argv) {
return 0;
}
if (!checkproxy(usercfg)) {
return 1;
}
if (opt.debug.empty() && !usercfg.Verbosity().empty())
Arc::Logger::getRootLogger().setThreshold(Arc::istring_to_level(usercfg.Verbosity()));
......@@ -171,6 +167,20 @@ int RUNMAIN(arcsub)(int argc, char **argv) {
}
}
// Check if X.509 credentials are needed for data staging
bool need_proxy = false;
for (std::list<Arc::JobDescription>::iterator jobIt = jobdescriptionlist.begin(); jobIt != jobdescriptionlist.end(); ++jobIt) {
if(jobneedsproxy(*jobIt)) {
need_proxy = true;
break;
}
}
if(need_proxy || usercfg.OToken().empty()) {
if (!checkproxy(usercfg)) {
return 1;
}
}
if ( opt.isARC6TargetSelectionOptions(logger) ) {
// canonicalize endpoint types
if (!opt.canonicalizeARC6InterfaceTypes(logger)) return 1;
......
......@@ -201,8 +201,10 @@ int RUNMAIN(arcsync)(int argc, char **argv) {
if (opt.timeout > 0)
usercfg.Timeout(opt.timeout);
if (!checkproxy(usercfg)) {
return 1;
if(usercfg.OToken().empty()) {
if (!checkproxy(usercfg)) {
return 1;
}
}
if (opt.debug.empty() && !usercfg.Verbosity().empty())
......
......@@ -178,10 +178,6 @@ int RUNMAIN(arctest)(int argc, char **argv) {
return EXIT_SUCCESS;
}
if (!checkproxy(usercfg)) {
return 1;
}
if (opt.timeout > 0)
usercfg.Timeout(opt.timeout);
......@@ -194,6 +190,12 @@ int RUNMAIN(arctest)(int argc, char **argv) {
return 1;
}
if(usercfg.OToken().empty() || jobneedsproxy(testJob)) {
if (!checkproxy(usercfg)) {
return 1;
}
}
// Set user input variables into job description
if (opt.testjobid == 1) {
testJob.Application.Executable.Argument.back() = Arc::tostring(opt.runtime);
......
......@@ -172,6 +172,32 @@ bool checkproxy(const Arc::UserConfig& uc)
return true;
}
static bool urlisinsecure(Arc::URL const & url) {
std::string protocol = url.Protocol();
return protocol.empty() || (protocol == "http") || (protocol == "ftp") || (protocol == "ldap");
}
bool jobneedsproxy(const Arc::JobDescription& job) {
// Check if X.509 credentials are needed for data staging
std::list<Arc::InputFileType> inputFiles = job.DataStaging.InputFiles;
for(std::list<Arc::InputFileType>::iterator fileIt = inputFiles.begin(); fileIt != inputFiles.end(); ++fileIt) {
for(std::list<Arc::SourceType>::iterator sourceIt = fileIt->Sources.begin(); sourceIt != fileIt->Sources.end(); ++sourceIt) {
if(!urlisinsecure(*sourceIt)) {
return true;
}
}
}
std::list<Arc::OutputFileType> outputFiles = job.DataStaging.OutputFiles;
for(std::list<Arc::OutputFileType>::iterator fileIt = outputFiles.begin(); fileIt != outputFiles.end(); ++fileIt) {
for(std::list<Arc::TargetType>::iterator targetIt = fileIt->Targets.begin(); targetIt != fileIt->Targets.end(); ++targetIt) {
if(!urlisinsecure(*targetIt)) {
return true;
}
}
}
return false;
}
void splitendpoints(std::list<std::string>& selected, std::list<std::string>& rejected)
{
// Removes slashes from end of endpoint strings, and put strings with leading '-' into rejected list.
......
......@@ -10,6 +10,7 @@
#include <arc/compute/Endpoint.h>
#include <arc/compute/Job.h>
#include <arc/compute/JobInformationStorage.h>
#include <arc/compute/JobDescription.h>
struct termios;
......@@ -111,6 +112,8 @@ void showplugins(const std::string& program, const std::list<std::string>& types
bool checkproxy(const Arc::UserConfig& uc);
bool jobneedsproxy(const Arc::JobDescription& job);
void splitendpoints(std::list<std::string>& selected, std::list<std::string>& rejected);
/**
......
......@@ -604,6 +604,9 @@ static int runmain(int argc, char *argv[]) {
}
if (info) {
if(!usercfg.OToken().empty()) {
std::cout << Arc::IString("Bearer token is available. It is preferred for job submission.") << std::endl;
}
std::vector<Arc::VOMSACInfo> voms_attributes;
bool res = false;
......
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