~ubuntu-branches/ubuntu/trusty/nordugrid-arc/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libs/data-staging/DataDeliveryLocalComm.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2013-11-29 13:39:10 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20131129133910-altaxrfowczzl2ev
Tags: 4.0.0-1
4.0.0 Release (Closes: #715131) (LP: #1049798)

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
        surl = dtr->get_source()->TransferLocations()[0].fullstr();
64
64
      }
65
65
      else {
66
 
        logger_->msg(Arc::ERROR, "DTR %s: No locations defined for %s", dtr_id, dtr->get_source()->str());
 
66
        logger_->msg(Arc::ERROR, "No locations defined for %s", dtr->get_source()->str());
67
67
        return;
68
68
      }
69
69
 
70
70
      if (dtr->get_destination()->TransferLocations().empty()) {
71
 
        logger_->msg(Arc::ERROR, "DTR %s: No locations defined for %s", dtr_id, dtr->get_destination()->str());
 
71
        logger_->msg(Arc::ERROR, "No locations defined for %s", dtr->get_destination()->str());
72
72
        return;
73
73
      }
74
74
      std::string durl = dtr->get_destination()->TransferLocations()[0].fullstr();
83
83
        child_uid = dtr->get_local_user().get_uid();
84
84
        child_gid = dtr->get_local_user().get_gid();
85
85
      }
86
 
      // If child is going to be run under different user ID
87
 
      // we must ensure it will be able to read credentials.
88
 
      tmp_proxy_ = prepare_proxy(dtr->get_usercfg().ProxyPath(), child_uid, child_gid);
89
86
      args.push_back("--surl");
90
87
      args.push_back(surl);
91
88
      args.push_back("--durl");
92
89
      args.push_back(durl);
93
 
      if (!tmp_proxy_.empty()) {
94
 
        args.push_back("--sopt");
95
 
        args.push_back("credential="+tmp_proxy_);
96
 
        args.push_back("--dopt");
97
 
        args.push_back("credential="+tmp_proxy_);
98
 
      } else if(!dtr->get_usercfg().ProxyPath().empty()) {
99
 
        args.push_back("--sopt");
100
 
        args.push_back("credential="+dtr->get_usercfg().ProxyPath());
101
 
        args.push_back("--dopt");
102
 
        args.push_back("credential="+dtr->get_usercfg().ProxyPath());
 
90
      if (!dtr->get_source()->RequiresCredentialsInFile() &&
 
91
          !dtr->get_destination()->RequiresCredentialsInFile() &&
 
92
          !dtr->get_usercfg().CredentialString().empty()) {
 
93
        // If file-based credentials are not required then send through stdin
 
94
        stdin_ = dtr->get_usercfg().CredentialString();
 
95
      } else {
 
96
        // If child is going to be run under different user ID
 
97
        // we must ensure it will be able to read credentials.
 
98
        tmp_proxy_ = prepare_proxy(dtr->get_usercfg().ProxyPath(), child_uid, child_gid);
 
99
        if (!tmp_proxy_.empty()) {
 
100
          args.push_back("--sopt");
 
101
          args.push_back("credential="+tmp_proxy_);
 
102
          args.push_back("--dopt");
 
103
          args.push_back("credential="+tmp_proxy_);
 
104
        } else if(!dtr->get_usercfg().ProxyPath().empty()) {
 
105
          args.push_back("--sopt");
 
106
          args.push_back("credential="+dtr->get_usercfg().ProxyPath());
 
107
          args.push_back("--dopt");
 
108
          args.push_back("credential="+dtr->get_usercfg().ProxyPath());
 
109
        }
103
110
      }
104
111
      if (!dtr->get_usercfg().CACertificatesDirectory().empty()) {
105
112
        args.push_back("--sopt");
120
127
        std::string csum(dtr->get_source()->GetCheckSum());
121
128
        std::string::size_type pos(csum.find(':'));
122
129
        if (pos == std::string::npos || pos == csum.length()-1) {
123
 
          logger_->msg(Arc::WARNING, "DTR %s: Bad checksum format %s", dtr_id, csum);
 
130
          logger_->msg(Arc::WARNING, "Bad checksum format %s", csum);
124
131
        } else {
125
132
          args.push_back("--cstype");
126
133
          args.push_back(csum.substr(0, pos));
141
148
      child_->KeepStdin(false);
142
149
      child_->AssignUserId(child_uid);
143
150
      child_->AssignGroupId(child_gid);
 
151
      child_->AssignStdin(stdin_);
144
152
      // Start child
145
153
      std::string cmd;
146
154
      for(std::list<std::string>::iterator arg = args.begin();arg!=args.end();++arg) {
147
155
        cmd += *arg;
148
156
        cmd += " ";
149
157
      }
150
 
      logger_->msg(Arc::DEBUG, "DTR %s: Running command: %s", dtr_id, cmd);
 
158
      logger_->msg(Arc::DEBUG, "Running command: %s", cmd);
151
159
      if(!child_->Start()) {
152
160
        delete child_;
153
161
        child_=NULL;
185
193
          for(;*start;) {
186
194
            char* end = strchr(start,'\n');
187
195
            if(end) *end = 0;
188
 
            logger_->msg(Arc::INFO, "DTR %s: DataDelivery: %s", dtr_id, start);
 
196
            logger_->msg(Arc::INFO, "DataDelivery: %s", start);
189
197
            if(!end) break;
190
198
            start = end + 1;
191
199
          }
197
205
          } else {
198
206
            status_.commstatus = CommExited;
199
207
            if(child_->Result() != 0) {
200
 
              logger_->msg(Arc::ERROR, "DTR %s: DataStagingDelivery exited with code %i", dtr_id, child_->Result());
 
208
              logger_->msg(Arc::ERROR, "DataStagingDelivery exited with code %i", child_->Result());
201
209
              status_.commstatus = CommFailed;
202
210
            }
203
211
          }
216
224
    // check for stuck child process (no report through comm channel)
217
225
    Arc::Period t = Arc::Time() - last_comm;
218
226
    if (transfer_params.max_inactivity_time > 0 && t >= transfer_params.max_inactivity_time*2) {
219
 
      logger_->msg(Arc::ERROR, "DTR %s: Transfer killed after %i seconds without communication", dtr_id, t.GetPeriod());
 
227
      logger_->msg(Arc::ERROR, "Transfer killed after %i seconds without communication", t.GetPeriod());
220
228
      child_->Kill(1);
221
229
      delete child_;
222
230
      child_ = NULL;