irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

miscServerFunct.cpp
Go to the documentation of this file.
1 
4 /* miscServerFunct.c - misc server functions
5  */
6 
7 #include <sys/wait.h>
8 
9 #include "miscServerFunct.hpp"
10 #include "QUANTAnet_rbudpBase_c.h"
11 #include "QUANTAnet_rbudpSender_c.h"
12 #include "QUANTAnet_rbudpReceiver_c.h"
13 #include "dataObjOpen.h"
14 #include "dataObjLseek.h"
15 #include "rcMisc.h"
16 #include "dataObjOpr.hpp"
17 #include "dataObjClose.h"
18 #include "dataObjWrite.h"
19 #include "dataObjRead.h"
20 #include "modAVUMetadata.h"
21 #include "genQuery.h"
22 #include "rcPortalOpr.h"
23 #include "rcConnect.h"
24 #include "rodsConnect.h"
25 #include "sockComm.h"
26 #include "modAccessControl.h"
27 #include "rsDataObjOpen.hpp"
28 #include "rsDataObjClose.hpp"
29 #include "rsDataObjLseek.hpp"
30 #include "rsDataObjWrite.hpp"
31 #include "rsDataObjRead.hpp"
32 #include "rsGenQuery.hpp"
33 #include "rsModAVUMetadata.hpp"
34 #include "rsModAccessControl.hpp"
35 
36 #include <string>
37 #include <vector>
38 #include <boost/thread/thread.hpp>
39 #include <boost/thread/scoped_thread.hpp>
40 #include <boost/lexical_cast.hpp>
41 #include <openssl/md5.h>
42 
43 
44 #if !defined(solaris_platform)
45 char *__loc1;
46 #endif /* solaris_platform */
47 #include "rsGlobalExtern.hpp"
48 #include "rcGlobalExtern.h"
49 
50 
51 // =-=-=-=-=-=-=-
52 #include "irods_stacktrace.hpp"
56 #include "irods_exception.hpp"
57 #include "irods_serialization.hpp"
60 #include "irods_threads.hpp"
61 #include "irods_lexical_cast.hpp"
63 #include "irods_random.hpp"
65 #include "irods_default_paths.hpp"
67 
68 #include <iomanip>
69 #include <fstream>
70 
71 #include <boost/filesystem.hpp>
72 
73 int
75  rErrMsg_t errMsg;
76  int reconnFlag;
77 
78 
79  if ( rodsServerHost->conn == NULL ) { /* a connection already */
80  if ( getenv( RECONNECT_ENV ) != NULL ) {
81  reconnFlag = RECONN_TIMEOUT;
82  }
83  else {
84  reconnFlag = NO_RECONN;
85  }
87  ( ( zoneInfo_t * ) rodsServerHost->zoneInfo )->portNum,
88  rsComm->myEnv.rodsUserName, rsComm->myEnv.rodsZone,
89  rsComm->clientUser.userName, rsComm->clientUser.rodsZone, &errMsg,
90  rsComm->connectCnt, reconnFlag );
91 
92  if ( rodsServerHost->conn == NULL ) {
93  if ( errMsg.status < 0 ) {
94  return errMsg.status;
95  }
96  else {
97  return SYS_SVR_TO_SVR_CONNECT_FAILED - errno;
98  }
99  }
100  }
101 
102  return rodsServerHost->localFlag;
103 }
104 
105 int
107  int status;
108 
110 
111  if ( status < 0 ) {
112  return status;
113  }
114 
116  if ( status < 0 ) {
118  "svrToSvrConnect: clientLogin to %s failed",
120  return status;
121  }
122  else {
123  return rodsServerHost->localFlag;
124  }
125 }
126 
127 /* setupSrvPortalForParaOpr - Setup the portal on this server for
128  * parallel or RBUDP transfer. It call createSrvPortal to create
129  * the portal socket, malloc the portalOprOut struct, put the
130  * server address, portNumber, etc in this struct. Aslo malloc
131  * the rsComm->portalOpr struct and fill in the struct. This struct
132  * will be used later by the server after sending reply to the client.
133  * If RBUDP_TRANSFER_KW is set in dataOprInp->condInput, RBUDP transfer
134  * is assumed.
135  */
136 
137 int
139  int oprType, portalOprOut_t **portalOprOut ) {
140  portalOprOut_t *myDataObjPutOut = NULL;
141  int portalSock = 0;
142  int proto = 0;
143 
144  if ( getValByKey( &dataOprInp->condInput, RBUDP_TRANSFER_KW ) != NULL ) {
145  proto = SOCK_DGRAM;
146  }
147  else {
148  proto = SOCK_STREAM;
149  }
150 
151  myDataObjPutOut = ( portalOprOut_t * ) malloc( sizeof( portalOprOut_t ) );
152  memset( myDataObjPutOut, 0, sizeof( portalOprOut_t ) );
153 
154  *portalOprOut = myDataObjPutOut;
155 
156  if ( getValByKey( &dataOprInp->condInput, STREAMING_KW ) != NULL ||
157  proto == SOCK_DGRAM ) {
158  /* streaming or udp - use only one thread */
159  myDataObjPutOut->numThreads = 1;
160  }
161  else {
162  myDataObjPutOut->numThreads = getNumThreads( rsComm,
163  dataOprInp->dataSize, dataOprInp->numThreads,
164  &dataOprInp->condInput,
165  //getValByKey (&dataOprInp->condInput, RESC_NAME_KW), NULL);
166  getValByKey( &dataOprInp->condInput, RESC_HIER_STR_KW ), NULL, oprType );
167  }
168 
169  if ( myDataObjPutOut->numThreads == 0 ) {
170  return 0;
171  }
172  else {
173  int port_range_count;
174  try {
175  const auto svr_port_range_start = irods::get_server_property<const int>(irods::CFG_SERVER_PORT_RANGE_START_KW);
176  const auto svr_port_range_end = irods::get_server_property<const int>(irods::CFG_SERVER_PORT_RANGE_END_KW);
177  port_range_count = svr_port_range_end - svr_port_range_start + 1;
178  } catch ( irods::exception& e ) {
179  return e.code();
180  }
181 
182  /* setup the portal - try port_range_count times in case of bind collision */
183  for ( int i = 0; i < port_range_count; ++i ) {
184  portalSock = createSrvPortal( rsComm, &myDataObjPutOut->portList,
185  proto );
186  if ( 0 <= portalSock ) {
187  break;
188  }
189  }
190  if ( portalSock < 0 ) {
192  "setupSrvPortalForParaOpr: createSrvPortal error, status = %d",
193  portalSock );
194  myDataObjPutOut->status = portalSock;
195  return portalSock;
196  }
197  rsComm->portalOpr = ( portalOpr_t * ) malloc( sizeof( portalOpr_t ) );
198  rsComm->portalOpr->oprType = oprType;
199  rsComm->portalOpr->portList = myDataObjPutOut->portList;
200  rsComm->portalOpr->dataOprInp = *dataOprInp;
201  memset( &dataOprInp->condInput, 0, sizeof( dataOprInp->condInput ) );
202  rsComm->portalOpr->dataOprInp.numThreads = myDataObjPutOut->numThreads;
203  }
204 
205  return 0;
206 }
207 
208 /* createSrvPortal - create a server socket portal.
209  * proto can be SOCK_STREAM or SOCK_DGRAM.
210  * if proto == SOCK_DGRAM, create a tcp (control) and a udp socket
211  */
212 
213 int
214 createSrvPortal( rsComm_t *rsComm, portList_t *thisPortList, int proto ) {
215  int lsock = -1;
216  int lport = 0;
217  char *laddr = NULL;
218  int udpsock = -1;
219  int udpport = 0;
220  char *udpaddr = NULL;
221 
222 
223  if ( proto != SOCK_DGRAM && proto != SOCK_STREAM ) {
225  "createSrvPortal: invalid input protocol %d", proto );
227  }
228 
229  if ( ( lsock = svrSockOpenForInConn( rsComm, &lport, &laddr,
230  SOCK_STREAM ) ) < 0 ) {
232  "createSrvPortal: svrSockOpenForInConn failed: status=%d",
233  lsock );
234  return lsock;
235  }
236 
237  thisPortList->sock = lsock;
238  thisPortList->cookie = ( int )( irods::getRandom<unsigned int>() >> 1 );
239  if ( ProcessType == CLIENT_PT ) {
240  rstrcpy( thisPortList->hostAddr, laddr, LONG_NAME_LEN );
241  }
242  else {
243  /* server. try to use what is configured */
244  if ( LocalServerHost != NULL
245  && strcmp( LocalServerHost->hostName->name, "localhost" ) != 0
246  && get_canonical_name( LocalServerHost->hostName->name, thisPortList->hostAddr, LONG_NAME_LEN) == 0 ) {
247  // empty block b/c get_canonical_name does the copy on success
248  } else {
249  rstrcpy( thisPortList->hostAddr, laddr, LONG_NAME_LEN );
250  }
251  }
252  free( laddr );
253  thisPortList->portNum = lport;
254  thisPortList->windowSize = rsComm->windowSize;
255 
256  if ( listen( lsock, SOMAXCONN ) < 0 ) {
258  "setupSrvPortal: listen failed, errno: %d",
259  errno );
260  return SYS_SOCK_LISTEN_ERR;
261  }
262 
263  if ( proto == SOCK_DGRAM ) {
264  if ( ( udpsock = svrSockOpenForInConn( rsComm, &udpport, &udpaddr,
265  SOCK_DGRAM ) ) < 0 ) {
267  "setupSrvPortal- sockOpenForInConn of SOCK_DGRAM failed: stat=%d",
268  udpsock );
269  CLOSE_SOCK( lsock );
270  return udpsock;
271  }
272  else {
273  addUdpPortToPortList( thisPortList, udpport );
274  addUdpSockToPortList( thisPortList, udpsock );
275  }
276  }
277  free( udpaddr );
278 
279  return lsock;
280 }
281 
282 int
283 acceptSrvPortal( rsComm_t *rsComm, portList_t *thisPortList ) {
284  const int sockfd = getTcpSockFromPortList( thisPortList );
285  const int nfds = sockfd + 1;
286  fd_set basemask;
287  struct timeval selectTimeout;
288  int nSelected = 0;
289 
290  selectTimeout.tv_sec = SELECT_TIMEOUT_FOR_CONN;
291  selectTimeout.tv_usec = 0;
292  while ( true ) {
293  FD_ZERO( &basemask );
294  FD_SET( sockfd, &basemask );
295  nSelected = select( nfds, &basemask, ( fd_set * ) NULL, ( fd_set * ) NULL, &selectTimeout );
296  if ( nSelected < 0 ) {
297  if ( errno == EINTR || errno == EAGAIN ) {
298  rodsLog( LOG_ERROR, "acceptSrvPortal: select interrupted, errno = %d", errno );
299  }
300  else {
301  rodsLog( LOG_ERROR, "acceptSrvPortal: select failed, errno = %d", errno );
302  return SYS_SOCK_SELECT_ERR - errno;
303  }
304  }
305  else {
306  break;
307  }
308  }
309  if ( nSelected == 0 ) {
310  rodsLog( LOG_ERROR, "acceptSrvPortal() -- select timed out" );
311  return SYS_SOCK_SELECT_ERR - errno;
312  }
313 
314  const int saved_socket_flags = fcntl( sockfd, F_GETFL );
315  fcntl( sockfd, F_SETFL, saved_socket_flags | O_NONBLOCK );
316  const int myFd = accept( sockfd, 0, 0 );
317  fcntl( sockfd, F_SETFL, saved_socket_flags );
318 
319  if ( myFd < 0 ) {
321  "acceptSrvPortal() -- accept() failed: errno=%d",
322  errno );
323  return SYS_SOCK_ACCEPT_ERR - errno;
324  }
325  else {
326  rodsSetSockOpt( myFd, rsComm->windowSize );
327  }
328 
329  int myCookie;
330  int nbytes = read( myFd, &myCookie, sizeof( myCookie ) );
331  myCookie = ntohl( myCookie );
332  if ( nbytes != sizeof( myCookie ) || myCookie != thisPortList->cookie ) {
334  "acceptSrvPortal: cookie err, bytes read=%d,cookie=%d,inCookie=%d",
335  nbytes, thisPortList->cookie, myCookie );
336  CLOSE_SOCK( myFd );
337  return SYS_PORT_COOKIE_ERR;
338  }
339  return myFd;
340 }
341 
342 int applyRuleForSvrPortal( int sockFd, int oprType, int preOrPost, int load, rsComm_t *rsComm ) {
343  typedef union address {
344  struct sockaddr sa;
345  struct sockaddr_in sa_in;
346  } address_t;
347 
348  address_t local, peer;
349  socklen_t local_len;
350  memset( &local, 0, sizeof( local ) );
351  memset( &peer, 0, sizeof( peer ) );
352  local_len = sizeof( struct sockaddr );
353  int status = getsockname( sockFd, &local.sa, &local_len );
354  if ( status < 0 ) {
355  rodsLog( LOG_ERROR, "applyRuleForSvrPortal: acceptSrvPortal error. errno = %d", errno );
356  return SYS_SOCK_READ_ERR - errno;
357  }
358  local_len = sizeof( struct sockaddr );
359  status = getpeername( sockFd, &peer.sa, &local_len );
360  if ( status < 0 ) {
361  rodsLog( LOG_ERROR, "applyRuleForSvrPortal: acceptSrvPortal error. errno = %d", errno );
362  return SYS_SOCK_READ_ERR - errno;
363  }
364  char lPort[MAX_NAME_LEN];
365  char pPort[MAX_NAME_LEN];
366  char lLoad[MAX_NAME_LEN];
367  char oType[MAX_NAME_LEN];
368  snprintf( oType, MAX_NAME_LEN, "%d", oprType );
369  snprintf( lLoad, MAX_NAME_LEN, "%d", load );
370  char *lAddr = strdup( inet_ntoa( local.sa_in.sin_addr ) );
371  int localPort = ntohs( local.sa_in.sin_port );
372  snprintf( lPort, MAX_NAME_LEN, "%d", localPort );
373  char *pAddr = strdup( inet_ntoa( peer.sa_in.sin_addr ) );
374  int peerPort = ntohs( peer.sa_in.sin_port );
375  snprintf( pPort, MAX_NAME_LEN, "%d", peerPort );
376  const char *args[6] = {oType, lAddr, lPort, pAddr, pPort, lLoad};
377  ruleExecInfo_t rei;
378  memset( &rei, 0, sizeof( rei ) );
379  rei.rsComm = rsComm;
380  int ret = applyRuleArg( ( char * )( preOrPost == 0 ? "acPreProcForServerPortal" : "acPostProcForServerPortal" ), args, 6, &rei,
381  0 );
382  free( lAddr );
383  free( pAddr );
384  return ret;
385 }
386 
387 
388 int
390  portalOpr_t *myPortalOpr;
391  dataOprInp_t *dataOprInp;
392  portList_t *thisPortList;
393  rodsLong_t size0, size1, offset0;
394  int lsock, portalFd;
395  int i;
396  int numThreads;
398  boost::shared_ptr<boost::thread> tid[MAX_NUM_CONFIG_TRAN_THR];
399  int oprType;
400  int flags = 0;
401  int retVal = 0;
402 
403  myPortalOpr = rsComm->portalOpr;
404 
405  if ( myPortalOpr == NULL ) {
406  rodsLog( LOG_NOTICE, "svrPortalPut: NULL myPortalOpr" );
408  }
409 
410  thisPortList = &myPortalOpr->portList;
411  if ( thisPortList == NULL ) {
412  rodsLog( LOG_NOTICE, "svrPortalPut: NULL portList" );
414  }
415 
416  if ( getUdpPortFromPortList( thisPortList ) != 0 ) {
417  /* rbudp transfer */
418  retVal = svrPortalPutGetRbudp( rsComm );
419  return retVal;
420  }
421 
422  oprType = myPortalOpr->oprType;
423  dataOprInp = &myPortalOpr->dataOprInp;
424 
425  if ( getValByKey( &dataOprInp->condInput, STREAMING_KW ) != NULL ) {
426  flags |= STREAMING_FLAG;
427  }
428 
429  numThreads = dataOprInp->numThreads;
430 
431  if ( numThreads <= 0 || numThreads > MAX_NUM_CONFIG_TRAN_THR ) {
433  "svrPortalPut: numThreads %d out of range" );
435  }
436 
437  memset( myInput, 0, sizeof( myInput ) );
438 
439  size0 = dataOprInp->dataSize / numThreads;
440 
441  size1 = dataOprInp->dataSize - size0 * ( numThreads - 1 );
442  offset0 = dataOprInp->offset;
443 
444  lsock = getTcpSockFromPortList( thisPortList );
445 
446  /* accept the first connection */
447  portalFd = acceptSrvPortal( rsComm, thisPortList );
448  if ( portalFd < 0 ) {
450  "svrPortalPut: acceptSrvPortal error. errno = %d",
451  errno );
452 
453  CLOSE_SOCK( lsock );
454 
455  return portalFd;
456  }
457  applyRuleForSvrPortal( portalFd, oprType, 0, size0, rsComm );
458 
459  if ( oprType == PUT_OPR ) {
460  fillPortalTransferInp( &myInput[0], rsComm,
461  portalFd, dataOprInp->destL3descInx, 0, dataOprInp->destRescTypeInx,
462  0, size0, offset0, flags );
463  }
464  else {
465  fillPortalTransferInp( &myInput[0], rsComm,
466  dataOprInp->srcL3descInx, portalFd, dataOprInp->srcRescTypeInx, 0,
467  0, size0, offset0, flags );
468  }
469 
470  if ( numThreads == 1 ) {
471  if ( oprType == PUT_OPR ) {
472  partialDataPut( &myInput[0] );
473  }
474  else {
475  partialDataGet( &myInput[0] );
476  }
477 
478  CLOSE_SOCK( lsock );
479 
480  return myInput[0].status;
481  }
482  else {
483  rodsLong_t mySize = 0;
484  rodsLong_t myOffset = 0;
485 
486  for ( i = 1; i < numThreads; i++ ) {
487  int l3descInx;
488 
489  portalFd = acceptSrvPortal( rsComm, thisPortList );
490  if ( portalFd < 0 ) {
492  "svrPortalPut: acceptSrvPortal error. errno = %d",
493  errno );
494 
495  CLOSE_SOCK( lsock );
496 
497  return portalFd;
498  }
499 
500  myOffset += size0;
501 
502  if ( i < numThreads - 1 ) {
503  mySize = size0;
504  }
505  else {
506  mySize = size1;
507  }
508 
509  applyRuleForSvrPortal( portalFd, oprType, 0, mySize, rsComm );
510 
511  if ( oprType == PUT_OPR ) {
512  /* open the file */
513  l3descInx = l3OpenByHost( rsComm, dataOprInp->destL3descInx, O_WRONLY );
514  fillPortalTransferInp( &myInput[i], rsComm,
515  portalFd, l3descInx, 0,
516  dataOprInp->destRescTypeInx,
517  i, mySize, myOffset, flags );
518  tid[i].reset( new boost::thread( partialDataPut, &myInput[i] ) );
519 
520  }
521  else { /* a get */
522  l3descInx = l3OpenByHost( rsComm, dataOprInp->srcL3descInx, O_RDONLY );
523  fillPortalTransferInp( &myInput[i], rsComm,
524  l3descInx, portalFd, dataOprInp->srcRescTypeInx, 0,
525  i, mySize, myOffset, flags );
526  tid[i].reset( new boost::thread( partialDataGet, &myInput[i] ) );
527  }
528  } // for i
529 
530  /* spawn the first thread. do this last so the file will not be
531  * closed */
532  if ( oprType == PUT_OPR ) {
533  tid[0].reset( new boost::thread( partialDataPut, &myInput[0] ) );
534  }
535  else {
536  tid[0].reset( new boost::thread( partialDataGet, &myInput[0] ) );
537  }
538 
539  for ( i = 0; i < numThreads; i++ ) {
540  if ( tid[i] != 0 ) {
541  tid[i]->join();
542  }
543  if ( myInput[i].status < 0 ) {
544  retVal = myInput[i].status;
545  }
546  } // for i
547  CLOSE_SOCK( lsock );
548  return retVal;
549 
550  } // else
551 }
552 
554  portalTransferInp_t* myInput,
555  rsComm_t* rsComm,
556  int srcFd,
557  int destFd,
558  int srcRescTypeInx,
559  int destRescTypeInx,
560  int threadNum,
562  rodsLong_t offset,
563  int flags ) {
564 
565  if ( myInput == NULL ) {
567  }
568 
569  myInput->rsComm = rsComm;
570  myInput->destFd = destFd;
571  myInput->srcFd = srcFd;
572  myInput->destRescTypeInx = destRescTypeInx;
573  myInput->srcRescTypeInx = srcRescTypeInx;
574  myInput->threadNum = threadNum;
575  myInput->size = size;
576  myInput->offset = offset;
577  myInput->flags = flags;
578 
579  // =-=-=-=-=-=-=-
580  // copy the encryption key over to the
581  // portal input
582  memcpy(
583  myInput->shared_secret,
584  rsComm->shared_secret,
585  NAME_LEN );
586 
587  // =-=-=-=-=-=-=-
588  // copy the encryption environment over to the
589  // portal input
590  myInput->key_size = rsComm->key_size;
591  myInput->salt_size = rsComm->salt_size;
592  myInput->num_hash_rounds = rsComm->num_hash_rounds;
593  snprintf( myInput->encryption_algorithm, sizeof( myInput->encryption_algorithm ),
594  "%s", rsComm->encryption_algorithm );
595  return 0;
596 }
597 
598 
599 void
601  int destL3descInx = 0, srcFd = 0;
602  unsigned char *buf = 0;
603  int bytesWritten = 0;
604  rodsLong_t bytesToGet = 0;
605  rodsLong_t myOffset = 0;
606 
607  if ( myInput == NULL ) {
608  rodsLog( LOG_SYS_FATAL, "partialDataPut: NULL myInput" );
609  return;
610  }
611 
612  // =-=-=-=-=-=-=-
613  // flag to determine if we need to use encryption
614  bool use_encryption_flg =
615  ( myInput->rsComm->negotiation_results ==
617 
618  myInput->status = 0;
619  destL3descInx = myInput->destFd;
620  srcFd = myInput->srcFd;
621 
622  if ( myInput->offset != 0 ) {
623  myOffset = _l3Lseek( myInput->rsComm, destL3descInx,
624  myInput->offset, SEEK_SET );
625  if ( myOffset < 0 ) {
626  myInput->status = myOffset;
628  "_partialDataPut: _objSeek error, status = %d ",
629  myInput->status );
630  if ( myInput->threadNum > 0 ) {
631  _l3Close( myInput->rsComm, destL3descInx );
632  }
633  CLOSE_SOCK( srcFd );
634  return;
635  }
636  }
637 
638  bytesToGet = myInput->size;
639 
640  // =-=-=-=-=-=-=-
641  // create an encryption context, initialization vector
642  int iv_size = 0;
647  irods::buffer_crypt::array_t shared_secret;
648  irods::buffer_crypt crypt(
649  myInput->key_size,
650  myInput->salt_size,
651  myInput->num_hash_rounds,
652  myInput->encryption_algorithm );
653 
654  // =-=-=-=-=-=-=-
655  // compute an iv to determine how large it
656  // is for this implementation
657  if ( use_encryption_flg ) {
658  iv_size = crypt.key_size();
659  shared_secret.assign(
660  &myInput->shared_secret[0],
661  &myInput->shared_secret[iv_size] );
662  }
663 
664  int chunk_size;
665  try {
666  chunk_size = irods::get_advanced_setting<const int>(irods::CFG_TRANS_CHUNK_SIZE_PARA_TRANS) * 1024 * 1024;
667  } catch ( const irods::exception& e ) {
668  irods::log(e);
669  return;
670  }
671 
672  int trans_buff_size = 0;
673  try {
674  trans_buff_size = irods::get_advanced_setting<const int>(irods::CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS) * 1024 * 1024;
675  } catch ( const irods::exception& e ) {
676  irods::log(e);
677  return;
678  }
679 
680  buf = ( unsigned char* )malloc( ( 2 * trans_buff_size ) + sizeof( unsigned char ) );
681 
682  while ( bytesToGet > 0 ) {
683  int toread0;
684  int bytesRead;
685 
686  if ( myInput->flags & STREAMING_FLAG ) {
687  toread0 = bytesToGet;
688  }
689  else if ( bytesToGet > chunk_size ) {
690  toread0 = chunk_size;
691  }
692  else {
693  toread0 = bytesToGet;
694  }
695 
696  myInput->status = sendTranHeader( srcFd, PUT_OPR, myInput->flags,
697  myOffset, toread0 );
698 
699  if ( myInput->status < 0 ) {
701  "partialDataPut: sendTranHeader error. status = %d",
702  myInput->status );
703  if ( myInput->threadNum > 0 ) {
704  _l3Close( myInput->rsComm, destL3descInx );
705  }
706  CLOSE_SOCK( srcFd );
707  free( buf );
708  return;
709  }
710 
711  while ( toread0 > 0 ) {
712  int toread1 = 0;
713 
714  if ( toread0 > trans_buff_size ) {
715  toread1 = trans_buff_size;
716  }
717  else {
718  toread1 = toread0;
719  }
720 
721  // =-=-=-=-=-=-=-
722  // read the incoming size as it might differ due to encryption
723  int new_size = toread1;
724  if ( use_encryption_flg ) {
725  bytesRead = myRead(
726  srcFd,
727  &new_size,
728  sizeof( int ),
729  NULL, NULL );
730  if ( bytesRead != sizeof( int ) ) {
731  rodsLog( LOG_ERROR, "_partialDataPut:Bytes Read != %d", sizeof( int ) );
732  break;
733  }
734  }
735 
736  // =-=-=-=-=-=-=-
737  // now read the provided number of bytes as suggested by the incoming size
738  bytesRead = myRead(
739  srcFd,
740  buf,
741  new_size,
742  NULL, NULL );
743 
744  if ( bytesRead == new_size ) {
745  // =-=-=-=-=-=-=-
746  // if using encryption, strip off the iv
747  // and decrypt before writing
748  int plain_size = bytesRead;
749  if ( use_encryption_flg ) {
750  this_iv.assign(
751  &buf[0],
752  &buf[ iv_size ] );
753  cipher.assign(
754  &buf[ iv_size ],
755  &buf[ new_size ] );
756  irods::error ret = crypt.decrypt(
757  shared_secret,
758  this_iv,
759  cipher,
760  plain );
761  if ( !ret.ok() ) {
762  irods::log( PASS( ret ) );
763  myInput->status = SYS_COPY_LEN_ERR;
764  break;
765  }
766 
767  std::copy(
768  plain.begin(),
769  plain.end(),
770  &buf[0] );
771  plain_size = plain.size();
772 
773  }
774 
775  if ( ( bytesWritten = _l3Write(
776  myInput->rsComm,
777  destL3descInx,
778  buf,
779  plain_size ) ) != ( plain_size ) ) {
781  "_partialDataPut:Bytes written %d don't match read %d",
782  bytesWritten, bytesRead );
783 
784  if ( bytesWritten < 0 ) {
785  myInput->status = bytesWritten;
786  }
787  else {
788  myInput->status = SYS_COPY_LEN_ERR;
789  }
790  break;
791  }
792  bytesToGet -= bytesWritten;
793  toread0 -= bytesWritten;
794  myOffset += bytesWritten;
795 
796  }
797  else if ( bytesRead < 0 ) {
798  myInput->status = bytesRead;
799  break;
800  }
801  else { /* toread > 0 */
803  "_partialDataPut: toread %d bytes, %d bytes read, errno = %d",
804  toread1, bytesRead, errno );
805  myInput->status = SYS_COPY_LEN_ERR;
806  break;
807  }
808 
809  } /* while loop toread0 */
810  if ( myInput->status < 0 ) {
811  break;
812  }
813  } /* while loop bytesToGet */
814 
815  free( buf );
816 
817  applyRuleForSvrPortal( srcFd, PUT_OPR, 1, myOffset - myInput->offset, myInput->rsComm );
818 
819  sendTranHeader( srcFd, DONE_OPR, 0, 0, 0 );
820  if ( myInput->threadNum > 0 ) {
821  _l3Close( myInput->rsComm, destL3descInx );
822  }
823  mySockClose( srcFd );
824 
825  return;
826 }
827 
829  portalTransferInp_t* myInput ) {
830  // =-=-=-=-=-=-=-
831  //
832  int srcL3descInx = 0, destFd = 0;
833  int bytesWritten = 0;
834  rodsLong_t bytesToGet = 0;
835  rodsLong_t myOffset = 0;
836 
837  if ( myInput == NULL ) {
838  rodsLog( LOG_SYS_FATAL, "partialDataGet: NULL myInput" );
839  return;
840  }
841 
842  myInput->status = 0;
843  srcL3descInx = myInput->srcFd;
844  destFd = myInput->destFd;
845 
846  if ( myInput->offset != 0 ) {
847  myOffset = _l3Lseek( myInput->rsComm, srcL3descInx,
848  myInput->offset, SEEK_SET );
849  if ( myOffset < 0 ) {
850  myInput->status = myOffset;
852  "_partialDataGet: _objSeek error, status = %d ",
853  myInput->status );
854  if ( myInput->threadNum > 0 ) {
855  _l3Close( myInput->rsComm, srcL3descInx );
856  }
857  CLOSE_SOCK( destFd );
858  return;
859  }
860  }
861 
862  // =-=-=-=-=-=-=-
863  // flag to determine if we need to use encryption
864  bool use_encryption_flg =
865  ( myInput->rsComm->negotiation_results ==
867 
868  // =-=-=-=-=-=-=-
869  // create an encryption context
870  int iv_size = 0;
874  irods::buffer_crypt::array_t shared_secret;
875  irods::buffer_crypt crypt(
876  myInput->key_size,
877  myInput->salt_size,
878  myInput->num_hash_rounds,
879  myInput->encryption_algorithm );
880 
881  // =-=-=-=-=-=-=-
882  // set iv size
883  if ( use_encryption_flg ) {
884  iv_size = crypt.key_size();
885  shared_secret.assign(
886  &myInput->shared_secret[0],
887  &myInput->shared_secret[iv_size] );
888  }
889 
890  int trans_buff_size = 0;
891  try {
892  trans_buff_size = irods::get_advanced_setting<const int>(irods::CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS) * 1024 * 1024;
893  } catch ( const irods::exception& e ) {
894  irods::log(e);
895  return;
896  }
897 
898  size_t buf_size = ( 2 * trans_buff_size ) * sizeof( unsigned char ) ;
899  unsigned char * buf = ( unsigned char* )malloc( buf_size );
900 
901  bytesToGet = myInput->size;
902 
903  int chunk_size;
904  try {
905  chunk_size = irods::get_advanced_setting<const int>(irods::CFG_TRANS_CHUNK_SIZE_PARA_TRANS) * 1024 * 1024;
906  } catch ( const irods::exception& e ) {
907  irods::log(e);
908  return;
909  }
910 
911  while ( bytesToGet > 0 ) {
912  int toread0;
913  int bytesRead;
914 
915  if ( myInput->flags & STREAMING_FLAG ) {
916  toread0 = bytesToGet;
917  }
918  else if ( bytesToGet > chunk_size ) {
919  toread0 = chunk_size;
920  }
921  else {
922  toread0 = bytesToGet;
923  }
924 
925  myInput->status = sendTranHeader( destFd, GET_OPR, myInput->flags,
926  myOffset, toread0 );
927 
928  if ( myInput->status < 0 ) {
930  "partialDataGet: sendTranHeader error. status = %d",
931  myInput->status );
932  if ( myInput->threadNum > 0 ) {
933  _l3Close( myInput->rsComm, srcL3descInx );
934  }
935  CLOSE_SOCK( destFd );
936  free( buf );
937  return;
938  }
939 
940  while ( toread0 > 0 ) {
941  int toread1;
942 
943  if ( toread0 > trans_buff_size ) {
944  toread1 = trans_buff_size;
945  }
946  else {
947  toread1 = toread0;
948  }
949 
950  bytesRead = _l3Read( myInput->rsComm, srcL3descInx, buf, toread1 );
951 
952 
953  if ( bytesRead == toread1 ) {
954  // =-=-=-=-=-=-=-
955  // compute an iv for this particular transmission and use
956  // it to encrypt this buffer
957  int new_size = bytesRead;
958  if ( use_encryption_flg ) {
959  irods::error ret = crypt.initialization_vector( iv );
960  if ( !ret.ok() ) {
961  ret = PASS( ret );
962  printf( "%s", ret.result().c_str() );
963  break;
964  }
965 
966  // =-=-=-=-=-=-=-
967  // encrypt
968  in_buf.assign(
969  &buf[0],
970  &buf[ bytesRead ] );
971 
972  ret = crypt.encrypt(
973  shared_secret,
974  iv,
975  in_buf,
976  cipher );
977  if ( !ret.ok() ) {
978  ret = PASS( ret );
979  printf( "%s", ret.result().c_str() );
980  break;
981  }
982 
983  // =-=-=-=-=-=-=-
984  // capture the iv with the cipher text
985  memset( buf, 0, buf_size );
986  std::copy(
987  iv.begin(),
988  iv.end(),
989  &buf[0] );
990  std::copy(
991  cipher.begin(),
992  cipher.end(),
993  &buf[iv_size] );
994 
995  new_size = iv_size + cipher.size();
996 
997  // =-=-=-=-=-=-=-
998  // need to send the incoming size as encryption might change
999  // the size of the data from the written values
1000  bytesWritten = myWrite(
1001  destFd,
1002  &new_size,
1003  sizeof( int ),
1004  &bytesWritten );
1005  }
1006 
1007  // =-=-=-=-=-=-=-
1008  // then write the actual buffer
1009  bytesWritten = myWrite(
1010  destFd,
1011  buf,
1012  new_size,
1013  &bytesWritten );
1014 
1015  if ( bytesWritten != new_size ) {
1017  "_partialDataGet:Bytes written %d don't match read %d",
1018  bytesWritten, bytesRead );
1019 
1020  if ( bytesWritten < 0 ) {
1021  myInput->status = bytesWritten;
1022  }
1023  else {
1024  myInput->status = SYS_COPY_LEN_ERR;
1025  }
1026  break;
1027  }
1028 
1029  // =-=-=-=-=-=-=-
1030  // had to change to bytesRead as bytesWritten
1031  // may have changed due to encryption
1032  bytesToGet -= bytesRead;
1033  toread0 -= bytesRead;
1034  myOffset += bytesRead;
1035 
1036  }
1037  else if ( bytesRead < 0 ) {
1038  myInput->status = bytesRead;
1039  break;
1040 
1041  }
1042  else { /* toread > 0 */
1044  "_partialDataGet: toread %d bytes, %d bytes read",
1045  toread1, bytesRead );
1046  myInput->status = SYS_COPY_LEN_ERR;
1047  break;
1048  }
1049  } /* while loop toread0 */
1050  if ( myInput->status < 0 ) {
1051  break;
1052  }
1053  } /* while loop bytesToGet */
1054 
1055  free( buf );
1056 
1057  applyRuleForSvrPortal( destFd, GET_OPR, 1, myOffset - myInput->offset, myInput->rsComm );
1058 
1059  sendTranHeader( destFd, DONE_OPR, 0, 0, 0 );
1060  if ( myInput->threadNum > 0 ) {
1061  _l3Close( myInput->rsComm, srcL3descInx );
1062  }
1063  CLOSE_SOCK( destFd );
1064 
1065  return;
1066 }
1067 
1068 void
1070  transferHeader_t myHeader;
1071  int destL3descInx = 0, srcFd = 0;
1072  unsigned char *buf = 0;
1073  rodsLong_t curOffset = 0;
1074  rodsLong_t myOffset = 0;
1075  int toRead, bytesRead = 0, bytesWritten = 0;
1076 
1077  if ( myInput == NULL ) {
1079  "remToLocPartialCopy: NULL input" );
1080  return;
1081  }
1082 
1083  myInput->status = 0;
1084  destL3descInx = myInput->destFd;
1085  srcFd = myInput->srcFd;
1086  myInput->bytesWritten = 0;
1087 
1088  // =-=-=-=-=-=-=-
1089  // flag to determine if we need to use encryption
1090  bool use_encryption_flg =
1091  ( myInput->rsComm->negotiation_results ==
1093 
1094  // =-=-=-=-=-=-=-
1095  // create an encryption context, initialization vector
1096  int iv_size = 0;
1101  irods::buffer_crypt::array_t shared_secret;
1102  irods::buffer_crypt crypt(
1103  myInput->key_size,
1104  myInput->salt_size,
1105  myInput->num_hash_rounds,
1106  myInput->encryption_algorithm );
1107 
1108  // =-=-=-=-=-=-=-
1109  // compute an iv to determine how large it
1110  // is for this implementation
1111  if ( use_encryption_flg ) {
1112  iv_size = crypt.key_size();
1113  shared_secret.assign(
1114  &myInput->shared_secret[0],
1115  &myInput->shared_secret[iv_size] );
1116  }
1117 
1118  int trans_buff_size;
1119  try {
1120  trans_buff_size = irods::get_advanced_setting<const int>(irods::CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS) * 1024 * 1024;
1121  } catch ( const irods::exception& e ) {
1122  irods::log(e);
1123  return;
1124  }
1125 
1126  buf = ( unsigned char* )malloc( ( 2 * trans_buff_size ) * sizeof( unsigned char ) );
1127 
1128  while ( myInput->status >= 0 ) {
1129  rodsLong_t toGet;
1130 
1131  myInput->status = rcvTranHeader( srcFd, &myHeader );
1132 
1133  if ( myInput->status < 0 ) {
1134  break;
1135  }
1136 
1137  if ( myHeader.oprType == DONE_OPR ) {
1138  break;
1139  }
1140  if ( myHeader.offset != curOffset ) {
1141  curOffset = myHeader.offset;
1142  myOffset = _l3Lseek( myInput->rsComm, destL3descInx,
1143  myHeader.offset, SEEK_SET );
1144  if ( myOffset < 0 ) {
1145  myInput->status = myOffset;
1147  "remToLocPartialCopy: _objSeek error, status = %d ",
1148  myInput->status );
1149  break;
1150  }
1151  }
1152 
1153  toGet = myHeader.length;
1154  while ( toGet > 0 ) {
1155 
1156  if ( toGet > trans_buff_size ) {
1157  toRead = trans_buff_size;
1158  }
1159  else {
1160  toRead = toGet;
1161  }
1162 
1163  // =-=-=-=-=-=-=-
1164  // read the incoming size as it might differ due to encryption
1165  int new_size = toRead;
1166  if ( use_encryption_flg ) {
1167  bytesRead = myRead( srcFd, &new_size, sizeof( int ), NULL, NULL );
1168  if ( bytesRead != sizeof( int ) ) {
1169  rodsLog( LOG_ERROR, "_partialDataPut:Bytes Read != %d", sizeof( int ) );
1170  break;
1171  }
1172  }
1173 
1174  // =-=-=-=-=-=-=-
1175  // now read the provided number of bytes as suggested by the incoming size
1176  bytesRead = myRead( srcFd, buf, new_size, NULL, NULL );
1177  if ( bytesRead != new_size ) {
1178  if ( bytesRead < 0 ) {
1179  myInput->status = bytesRead;
1180  rodsLogError( LOG_ERROR, bytesRead,
1181  "remToLocPartialCopy: copy error for %lld", bytesRead );
1182  }
1183  else if ( ( myInput->flags & NO_CHK_COPY_LEN_FLAG ) == 0 ) {
1184  myInput->status = SYS_COPY_LEN_ERR - errno;
1185  rodsLog( LOG_ERROR,
1186  "remToLocPartialCopy: toGet %lld, bytesRead %d",
1187  toGet, bytesRead );
1188  }
1189  break;
1190  }
1191 
1192  // =-=-=-=-=-=-=-
1193  // if using encryption, strip off the iv
1194  // and decrypt before writing
1195  int plain_size = bytesRead;
1196  if ( use_encryption_flg ) {
1197  this_iv.assign(
1198  &buf[ 0 ],
1199  &buf[ iv_size ] );
1200  cipher.assign(
1201  &buf[ iv_size ],
1202  &buf[ new_size ] );
1203 
1204  irods::error ret = crypt.decrypt(
1205  shared_secret,
1206  this_iv,
1207  cipher,
1208  plain );
1209  if ( !ret.ok() ) {
1210  irods::log( PASS( ret ) );
1211  myInput->status = SYS_COPY_LEN_ERR;
1212  break;
1213  }
1214 
1215  std::copy(
1216  plain.begin(),
1217  plain.end(),
1218  &buf[0] );
1219  plain_size = plain.size();
1220 
1221  }
1222 
1223  bytesWritten = _l3Write(
1224  myInput->rsComm,
1225  destL3descInx,
1226  buf,
1227  plain_size );
1228 
1229  if ( bytesWritten != plain_size ) {
1231  "_partialDataPut:Bytes written %d don't match read %d",
1232  bytesWritten, bytesRead );
1233 
1234  if ( bytesWritten < 0 ) {
1235  myInput->status = bytesWritten;
1236  }
1237  else {
1238  myInput->status = SYS_COPY_LEN_ERR;
1239  }
1240  break;
1241  }
1242 
1243  toGet -= bytesWritten;
1244  }
1245  curOffset += myHeader.length;
1246  myInput->bytesWritten += myHeader.length;
1247  }
1248 
1249  free( buf );
1250  if ( myInput->threadNum > 0 ) {
1251  _l3Close( myInput->rsComm, destL3descInx );
1252  }
1253  CLOSE_SOCK( srcFd );
1254 }
1255 
1256 /* rbudpRemLocCopy - The rbudp version of remLocCopy.
1257  */
1258 
1259 int
1262  dataOprInp_t *dataOprInp;
1263  int oprType;
1264  int veryVerbose, sendRate, packetSize;
1265  char *tmpStr;
1266  int status;
1267 
1268  if ( dataCopyInp == NULL ) {
1270  "rbudpRemLocCopy: NULL dataCopyInp input" );
1272  }
1273  portalOprOut = &dataCopyInp->portalOprOut;
1274  dataOprInp = &dataCopyInp->dataOprInp;
1275  oprType = dataOprInp->oprType;
1276 
1277  if ( getValByKey( &dataOprInp->condInput, VERY_VERBOSE_KW ) != NULL ) {
1278  veryVerbose = 2;
1279  }
1280  else {
1281  veryVerbose = 0;
1282  }
1283 
1284  if ( ( tmpStr = getValByKey( &dataOprInp->condInput,
1285  RBUDP_PACK_SIZE_KW ) ) != NULL ) {
1286  packetSize = atoi( tmpStr );
1287  }
1288  else {
1289  packetSize = DEF_UDP_PACKET_SIZE;
1290  }
1291 
1292  if ( oprType == COPY_TO_LOCAL_OPR ) {
1293  int destL3descInx = dataOprInp->destL3descInx;
1294 
1296  FileDesc[destL3descInx].fd,
1297  veryVerbose, packetSize );
1298 
1299  }
1300  else {
1301  int srcL3descInx = dataOprInp->srcL3descInx;
1302 
1303  if ( ( tmpStr = getValByKey( &dataOprInp->condInput,
1304  RBUDP_SEND_RATE_KW ) ) != NULL ) {
1305  sendRate = atoi( tmpStr );
1306  }
1307  else {
1308  sendRate = DEF_UDP_SEND_RATE;
1309  }
1311  FileDesc[srcL3descInx].fd,
1312  veryVerbose, sendRate, packetSize );
1313  }
1314  return status;
1315 }
1316 
1317 /* remLocCopy - This routine is very similar to rcPartialDataGet.
1318  */
1319 
1320 int
1321 remLocCopy( rsComm_t *rsComm, dataCopyInp_t *dataCopyInp ) {
1323  dataOprInp_t *dataOprInp;
1324  portList_t *myPortList;
1325  int i, sock, myFd;
1326  int numThreads;
1328  int retVal = 0;
1329  rodsLong_t dataSize;
1330  int oprType;
1331 
1332  if ( dataCopyInp == NULL ) {
1334  "remLocCopy: NULL dataCopyInp input" );
1336  }
1337 
1338  portalOprOut = &dataCopyInp->portalOprOut;
1339  numThreads = portalOprOut->numThreads;
1340  if ( numThreads == 0 ) {
1341  retVal = singleRemLocCopy( rsComm, dataCopyInp );
1342  return retVal;
1343  }
1344 
1345  dataOprInp = &dataCopyInp->dataOprInp;
1346  oprType = dataOprInp->oprType;
1347  dataSize = dataOprInp->dataSize;
1348 
1349  if ( getUdpPortFromPortList( &portalOprOut->portList ) != 0 ) {
1350  /* rbudp transfer */
1351  retVal = rbudpRemLocCopy( dataCopyInp );
1352  return retVal;
1353  }
1354 
1355  if ( numThreads > MAX_NUM_CONFIG_TRAN_THR || numThreads <= 0 ) {
1357  "remLocCopy: numThreads %d out of range",
1358  numThreads );
1359  return SYS_INVALID_PORTAL_OPR;
1360  }
1361 
1362 
1363  myPortList = &portalOprOut->portList;
1364 
1365  memset( myInput, 0, sizeof( myInput ) );
1366 
1367  sock = connectToRhostPortal( myPortList->hostAddr,
1368  myPortList->portNum, myPortList->cookie, rsComm->windowSize );
1369  if ( sock < 0 ) {
1370  return sock;
1371  }
1372 
1373  if ( oprType == COPY_TO_LOCAL_OPR ) {
1374  fillPortalTransferInp( &myInput[0], rsComm,
1375  sock, dataOprInp->destL3descInx, 0, dataOprInp->destRescTypeInx,
1376  0, 0, 0, 0 );
1377  }
1378  else {
1379  fillPortalTransferInp( &myInput[0], rsComm,
1380  dataOprInp->srcL3descInx, sock, dataOprInp->srcRescTypeInx, 0,
1381  0, 0, 0, 0 );
1382  }
1383 
1384  if ( numThreads == 1 ) {
1385  if ( getValByKey( &dataOprInp->condInput,
1386  NO_CHK_COPY_LEN_KW ) != NULL ) {
1387  myInput[0].flags = NO_CHK_COPY_LEN_FLAG;
1388  }
1389  if ( oprType == COPY_TO_LOCAL_OPR ) {
1390  remToLocPartialCopy( &myInput[0] );
1391  }
1392  else {
1393  locToRemPartialCopy( &myInput[0] );
1394  }
1395  if ( myInput[0].status < 0 ) {
1396  return myInput[0].status;
1397  }
1398  else {
1399  if ( myInput[0].bytesWritten == dataSize ) {
1400  return 0;
1401  }
1402  else {
1404  "remLocCopy:bytesWritten %lld dataSize %lld mismatch",
1405  myInput[0].bytesWritten, dataSize );
1406  return SYS_COPY_LEN_ERR;
1407  }
1408  }
1409  }
1410  else {
1411  rodsLong_t totalWritten = 0;
1412  std::unique_ptr<boost::scoped_thread<>> tid[MAX_NUM_CONFIG_TRAN_THR];
1413  memset( tid, 0, sizeof( tid ) );
1414 
1415  for ( i = 1; i < numThreads; i++ ) {
1416  sock = connectToRhostPortal( myPortList->hostAddr,
1417  myPortList->portNum, myPortList->cookie, rsComm->windowSize );
1418  if ( sock < 0 ) {
1419  return sock;
1420  }
1421  if ( oprType == COPY_TO_LOCAL_OPR ) {
1422  myFd = l3OpenByHost( rsComm, dataOprInp->destL3descInx, O_WRONLY );
1423  if ( myFd < 0 ) { /* error */
1424  retVal = myFd;
1426  "remLocCopy: cannot open file, status = %d",
1427  myFd );
1428  CLOSE_SOCK( sock );
1429  continue;
1430  }
1431 
1432  fillPortalTransferInp( &myInput[i], rsComm,
1433  sock, myFd, 0, dataOprInp->destRescTypeInx,
1434  i, 0, 0, 0 );
1435 
1436  tid[i] = std::make_unique<boost::scoped_thread<>>( boost::thread( remToLocPartialCopy, &myInput[i] ) );
1437  }
1438  else {
1439  myFd = l3OpenByHost( rsComm, dataOprInp->srcL3descInx, O_RDONLY );
1440  if ( myFd < 0 ) { /* error */
1441  retVal = myFd;
1443  "remLocCopy: cannot open file, status = %d",
1444  myFd );
1445  CLOSE_SOCK( sock );
1446  continue;
1447  }
1448 
1449  fillPortalTransferInp( &myInput[i], rsComm,
1450  myFd, sock, dataOprInp->destRescTypeInx, 0,
1451  i, 0, 0, 0 );
1452 
1453  tid[i] = std::make_unique<boost::scoped_thread<>>( boost::thread( locToRemPartialCopy, &myInput[i] ) );
1454  }
1455  }
1456 
1457  if ( oprType == COPY_TO_LOCAL_OPR ) {
1458  tid[0] = std::make_unique<boost::scoped_thread<>>( boost::thread( remToLocPartialCopy, &myInput[0] ) );
1459  }
1460  else {
1461  tid[0] = std::make_unique<boost::scoped_thread<>>( boost::thread( locToRemPartialCopy, &myInput[0] ) );
1462  }
1463 
1464 
1465  if ( retVal < 0 ) {
1466  return retVal;
1467  }
1468 
1469  for ( i = 0; i < numThreads; i++ ) {
1470  if ( tid[i] != 0 ) {
1471  tid[i]->join();
1472  }
1473  totalWritten += myInput[i].bytesWritten;
1474  if ( myInput[i].status < 0 ) {
1475  retVal = myInput[i].status;
1476  }
1477  }
1478  if ( retVal < 0 ) {
1479  return retVal;
1480  }
1481  else {
1482  if ( dataSize <= 0 || totalWritten == dataSize ) {
1483  return 0;
1484  }
1485  else {
1487  "remLocCopy: totalWritten %lld dataSize %lld mismatch",
1488  totalWritten, dataSize );
1489  return SYS_COPY_LEN_ERR;
1490  }
1491  }
1492  }
1493 }
1494 
1495 int
1496 sameHostCopy( rsComm_t *rsComm, dataCopyInp_t *dataCopyInp ) {
1497  dataOprInp_t *dataOprInp;
1498  int i, out_fd, in_fd;
1499  int numThreads;
1501  int retVal = 0;
1502  rodsLong_t dataSize;
1503  rodsLong_t size0, size1, offset0;
1504 
1505  if ( dataCopyInp == NULL ) {
1507  "sameHostCopy: NULL dataCopyInp input" );
1509  }
1510 
1511  dataOprInp = &dataCopyInp->dataOprInp;
1512 
1513  numThreads = dataOprInp->numThreads;
1514 
1515  dataSize = dataOprInp->dataSize;
1516 
1517  if ( numThreads == 0 ) {
1518  numThreads = 1;
1519  }
1520  else if ( numThreads > MAX_NUM_CONFIG_TRAN_THR || numThreads < 0 ) {
1522  "sameHostCopy: numThreads %d out of range",
1523  numThreads );
1524  return SYS_INVALID_PORTAL_OPR;
1525  }
1526 
1527  memset( myInput, 0, sizeof( myInput ) );
1528 
1529  size0 = dataOprInp->dataSize / numThreads;
1530  size1 = dataOprInp->dataSize - size0 * ( numThreads - 1 );
1531  offset0 = dataOprInp->offset;
1532 
1533  // =-=-=-=-=-=-=-
1534  // JMC :: since this is a local to local xfer and there is no
1535  // :: cookie to share it is set to 0, this may *possibly* be
1536  // :: a security issue.
1537  fillPortalTransferInp( &myInput[0], rsComm,
1538  dataOprInp->srcL3descInx, dataOprInp->destL3descInx,
1539  dataOprInp->srcRescTypeInx, dataOprInp->destRescTypeInx,
1540  0, size0, offset0, 0 );
1541 
1542  if ( numThreads == 1 ) {
1543  if ( getValByKey( &dataOprInp->condInput,
1544  NO_CHK_COPY_LEN_KW ) != NULL ) {
1545  myInput[0].flags = NO_CHK_COPY_LEN_FLAG;
1546  }
1547  sameHostPartialCopy( &myInput[0] );
1548  return myInput[0].status;
1549  }
1550  else {
1551  rodsLong_t totalWritten = 0;
1552  rodsLong_t mySize = 0;
1553  rodsLong_t myOffset = 0;
1554  std::unique_ptr<boost::scoped_thread<>> tid[MAX_NUM_CONFIG_TRAN_THR];
1555  memset( tid, 0, sizeof( tid ) );
1556 
1557  for ( i = 1; i < numThreads; i++ ) {
1558  myOffset += size0;
1559  if ( i < numThreads - 1 ) {
1560  mySize = size0;
1561  }
1562  else {
1563  mySize = size1;
1564  }
1565 
1566  out_fd = l3OpenByHost( rsComm, dataOprInp->destL3descInx, O_WRONLY );
1567  if ( out_fd < 0 ) { /* error */
1568  retVal = out_fd;
1570  "sameHostCopy: cannot open dest file, status = %d",
1571  out_fd );
1572  continue;
1573  }
1574 
1575  in_fd = l3OpenByHost( rsComm, dataOprInp->srcL3descInx, O_RDONLY );
1576  if ( in_fd < 0 ) { /* error */
1577  retVal = in_fd;
1579  "sameHostCopy: cannot open src file, status = %d", in_fd );
1580  continue;
1581  }
1583  &myInput[i], rsComm,
1584  in_fd, out_fd,
1585  dataOprInp->srcRescTypeInx,
1586  dataOprInp->destRescTypeInx,
1587  i, mySize, myOffset, 0 );
1588 
1589  tid[i] = std::make_unique<boost::scoped_thread<>>( boost::thread( sameHostPartialCopy, &myInput[i] ) );
1590  }
1591 
1592  tid[0] = std::make_unique<boost::scoped_thread<>>( boost::thread( sameHostPartialCopy, &myInput[0] ) );
1593 
1594  if ( retVal < 0 ) {
1595  return retVal;
1596  }
1597 
1598  for ( i = 0; i < numThreads; i++ ) {
1599  if ( tid[i] != 0 ) {
1600  tid[i]->join();
1601  }
1602  totalWritten += myInput[i].bytesWritten;
1603  if ( myInput[i].status < 0 ) {
1604  retVal = myInput[i].status;
1605  }
1606  }
1607  if ( retVal < 0 ) {
1608  return retVal;
1609  }
1610  else {
1611  if ( dataSize <= 0 || totalWritten == dataSize ) {
1612  return 0;
1613  }
1614  else {
1616  "sameHostCopy: totalWritten %lld dataSize %lld mismatch",
1617  totalWritten, dataSize );
1618  return SYS_COPY_LEN_ERR;
1619  }
1620  }
1621  }
1622 }
1623 
1624 void
1626  int destL3descInx, srcL3descInx;
1627  void *buf;
1628  rodsLong_t myOffset = 0;
1629  rodsLong_t toCopy;
1630  int bytesRead, bytesWritten;
1631 
1632  if ( myInput == NULL ) {
1634  "onsameHostPartialCopy: NULL input" );
1635  return;
1636  }
1637 
1638  myInput->status = 0;
1639  destL3descInx = myInput->destFd;
1640  srcL3descInx = myInput->srcFd;
1641  myInput->bytesWritten = 0;
1642 
1643  if ( myInput->offset != 0 ) {
1644  myOffset = _l3Lseek( myInput->rsComm, destL3descInx,
1645  myInput->offset, SEEK_SET );
1646  if ( myOffset < 0 ) {
1647  myInput->status = myOffset;
1649  "sameHostPartialCopy: _objSeek error, status = %d ",
1650  myInput->status );
1651  if ( myInput->threadNum > 0 ) {
1652  _l3Close( myInput->rsComm, destL3descInx );
1653  _l3Close( myInput->rsComm, srcL3descInx );
1654  }
1655  return;
1656  }
1657  myOffset = _l3Lseek( myInput->rsComm, srcL3descInx,
1658  myInput->offset, SEEK_SET );
1659  if ( myOffset < 0 ) {
1660  myInput->status = myOffset;
1662  "sameHostPartialCopy: _objSeek error, status = %d ",
1663  myInput->status );
1664  if ( myInput->threadNum > 0 ) {
1665  _l3Close( myInput->rsComm, destL3descInx );
1666  _l3Close( myInput->rsComm, srcL3descInx );
1667  }
1668  return;
1669  }
1670  }
1671 
1672  int trans_buff_size;
1673  try {
1674  trans_buff_size = irods::get_advanced_setting<const int>(irods::CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS) * 1024 * 1024;
1675  } catch ( const irods::exception& e ) {
1676  irods::log(e);
1677  return;
1678  }
1679 
1680  buf = malloc( trans_buff_size );
1681 
1682  toCopy = myInput->size;
1683 
1684  while ( toCopy > 0 ) {
1685  int toRead;
1686 
1687  if ( toCopy > trans_buff_size ) {
1688  toRead = trans_buff_size;
1689  }
1690  else {
1691  toRead = toCopy;
1692  }
1693 
1694  bytesRead = _l3Read( myInput->rsComm, srcL3descInx, buf, toRead );
1695 
1696  if ( bytesRead <= 0 ) {
1697  if ( bytesRead < 0 ) {
1698  myInput->status = bytesRead;
1699  rodsLogError( LOG_ERROR, bytesRead,
1700  "sameHostPartialCopy: copy error for %lld", bytesRead );
1701  }
1702  else if ( ( myInput->flags & NO_CHK_COPY_LEN_FLAG ) == 0 ) {
1703  myInput->status = SYS_COPY_LEN_ERR - errno;
1704  rodsLog( LOG_ERROR,
1705  "sameHostPartialCopy: toCopy %lld, bytesRead %d",
1706  toCopy, bytesRead );
1707  }
1708  break;
1709  }
1710 
1711  bytesWritten = _l3Write( myInput->rsComm, destL3descInx,
1712  buf, bytesRead );
1713 
1714  if ( bytesWritten != bytesRead ) {
1716  "sameHostPartialCopy:Bytes written %d don't match read %d",
1717  bytesWritten, bytesRead );
1718 
1719  if ( bytesWritten < 0 ) {
1720  myInput->status = bytesWritten;
1721  }
1722  else {
1723  myInput->status = SYS_COPY_LEN_ERR;
1724  }
1725  break;
1726  }
1727 
1728  toCopy -= bytesWritten;
1729  myInput->bytesWritten += bytesWritten;
1730  }
1731 
1732  free( buf );
1733  if ( myInput->threadNum > 0 ) {
1734  _l3Close( myInput->rsComm, destL3descInx );
1735  _l3Close( myInput->rsComm, srcL3descInx );
1736  }
1737 }
1738 
1739 void
1741  transferHeader_t myHeader;
1742  int srcL3descInx = 0, destFd = 0;
1743  unsigned char *buf = 0;
1744  rodsLong_t curOffset = 0;
1745  rodsLong_t myOffset = 0;
1746  int toRead = 0, bytesRead = 0, bytesWritten = 0;
1747 
1748  if ( myInput == NULL ) {
1750  "locToRemPartialCopy: NULL input" );
1751  return;
1752  }
1753 
1754  myInput->status = 0;
1755  srcL3descInx = myInput->srcFd;
1756  destFd = myInput->destFd;
1757  myInput->bytesWritten = 0;
1758 
1759  // =-=-=-=-=-=-=-
1760  // flag to determine if we need to use encryption
1761  bool use_encryption_flg =
1762  ( myInput->rsComm->negotiation_results ==
1764 
1765  // =-=-=-=-=-=-=-
1766  // create an encryption context
1767  int iv_size = 0;
1771  irods::buffer_crypt::array_t shared_secret;
1772  irods::buffer_crypt crypt(
1773  myInput->key_size,
1774  myInput->salt_size,
1775  myInput->num_hash_rounds,
1776  myInput->encryption_algorithm );
1777 
1778  // =-=-=-=-=-=-=-
1779  // set iv size
1780  if ( use_encryption_flg ) {
1781  iv_size = crypt.key_size();
1782  shared_secret.assign(
1783  &myInput->shared_secret[0],
1784  &myInput->shared_secret[iv_size] );
1785 
1786  }
1787 
1788  int trans_buff_size;
1789  try {
1790  trans_buff_size = irods::get_advanced_setting<const int>(irods::CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS) * 1024 * 1024;
1791  } catch ( const irods::exception& e ) {
1792  irods::log(e);
1793  return;
1794  }
1795 
1796  buf = ( unsigned char* )malloc( 2 * trans_buff_size * sizeof( unsigned char ) );
1797 
1798  while ( myInput->status >= 0 ) {
1799  rodsLong_t toGet;
1800 
1801  myInput->status = rcvTranHeader( destFd, &myHeader );
1802 
1803  if ( myInput->status < 0 ) {
1804  break;
1805  }
1806 
1807  if ( myHeader.oprType == DONE_OPR ) {
1808  break;
1809  }
1810 
1811  if ( myHeader.offset != curOffset ) {
1812  curOffset = myHeader.offset;
1813  myOffset = _l3Lseek( myInput->rsComm, srcL3descInx,
1814  myHeader.offset, SEEK_SET );
1815  if ( myOffset < 0 ) {
1816  myInput->status = myOffset;
1818  "locToRemPartialCopy: _objSeek error, status = %d ",
1819  myInput->status );
1820  break;
1821  }
1822  }
1823 
1824  toGet = myHeader.length;
1825  while ( toGet > 0 ) {
1826 
1827  if ( toGet > trans_buff_size ) {
1828  toRead = trans_buff_size;
1829  }
1830  else {
1831  toRead = toGet;
1832  }
1833 
1834  bytesRead = _l3Read( myInput->rsComm, srcL3descInx, buf, toRead );
1835 
1836  if ( bytesRead != toRead ) {
1837  if ( bytesRead < 0 ) {
1838  myInput->status = bytesRead;
1839  rodsLogError( LOG_ERROR, bytesRead,
1840  "locToRemPartialCopy: copy error for %lld", bytesRead );
1841  }
1842  else if ( ( myInput->flags & NO_CHK_COPY_LEN_FLAG ) == 0 ) {
1843  myInput->status = SYS_COPY_LEN_ERR - errno;
1844  rodsLog( LOG_ERROR,
1845  "locToRemPartialCopy: toGet %lld, bytesRead %d",
1846  toGet, bytesRead );
1847  }
1848  break;
1849  }
1850 
1851  // =-=-=-=-=-=-=-
1852  // compute an iv for this particular transmission and use
1853  // it to encrypt this buffer
1854  int new_size = bytesRead;
1855  if ( use_encryption_flg ) {
1856  irods::error ret = crypt.initialization_vector( iv );
1857  if ( !ret.ok() ) {
1858  ret = PASS( ret );
1859  printf( "%s", ret.result().c_str() );
1860  break;
1861  }
1862 
1863  // =-=-=-=-=-=-=-
1864  // encrypt
1865  in_buf.assign(
1866  &buf[0],
1867  &buf[ bytesRead ] );
1868 
1869  ret = crypt.encrypt(
1870  shared_secret,
1871  iv,
1872  in_buf,
1873  cipher );
1874  if ( !ret.ok() ) {
1875  ret = PASS( ret );
1876  printf( "%s", ret.result().c_str() );
1877  break;
1878  }
1879 
1880  // =-=-=-=-=-=-=-
1881  // capture the iv with the cipher text
1882  std::copy(
1883  iv.begin(),
1884  iv.end(),
1885  &buf[0] );
1886  std::copy(
1887  cipher.begin(),
1888  cipher.end(),
1889  &buf[iv_size] );
1890 
1891  new_size = iv.size() + cipher.size();
1892 
1893  // =-=-=-=-=-=-=-
1894  // need to send the incoming size as encryption might change
1895  // the size of the data from the written values
1896  bytesWritten = myWrite(
1897  destFd,
1898  &new_size,
1899  sizeof( int ),
1900  &bytesWritten );
1901  }
1902 
1903  bytesWritten = myWrite(
1904  destFd,
1905  buf,
1906  new_size,
1907  NULL );
1908 
1909  if ( bytesWritten != new_size ) {
1911  "_partialDataPut:Bytes written %d don't match read %d",
1912  bytesWritten, bytesRead );
1913 
1914  if ( bytesWritten < 0 ) {
1915  myInput->status = bytesWritten;
1916  }
1917  else {
1918  myInput->status = SYS_COPY_LEN_ERR;
1919  }
1920  break;
1921  }
1922 
1923  toGet -= bytesRead;
1924  }
1925 
1926  curOffset += myHeader.length;
1927  myInput->bytesWritten += myHeader.length;
1928  }
1929 
1930  free( buf );
1931  if ( myInput->threadNum > 0 ) {
1932  _l3Close( myInput->rsComm, srcL3descInx );
1933  }
1934  CLOSE_SOCK( destFd );
1935 }
1936 
1937 /*
1938  Given a zoneName, return the Zone Server ID string (from the
1939  server_config.json file) if defined. If the input zoneName is
1940  null, use the local zone.
1941  Input: zoneName
1942  Output: zoneSID
1943  */
1944 void
1945 getZoneServerId( char *zoneName, char *zoneSID ) {
1946  zoneInfo_t *tmpZoneInfo;
1947  rodsServerHost_t *tmpRodsServerHost;
1948  int zoneNameLen = 0;
1949  char *localZoneName = NULL;
1950 
1951  if ( !zoneSID ) {
1952  rodsLog( LOG_ERROR, "getZoneServerId - input zoneSID is NULL" );
1953  return;
1954  }
1955 
1956  if ( zoneName != NULL ) {
1957  zoneNameLen = strlen( zoneName );
1958  }
1959  if ( zoneNameLen == 0 ) {
1960  strncpy( zoneSID, localSID, MAX_PASSWORD_LEN );
1961  return;
1962  }
1963 
1964  /* get our local zoneName */
1965  tmpZoneInfo = ZoneInfoHead;
1966  while ( tmpZoneInfo != NULL ) {
1967  tmpRodsServerHost = ( rodsServerHost_t * ) tmpZoneInfo->masterServerHost;
1968  if ( tmpRodsServerHost->rcatEnabled == LOCAL_ICAT ) {
1969  localZoneName = tmpZoneInfo->zoneName;
1970  }
1971  tmpZoneInfo = tmpZoneInfo->next;
1972  }
1973 
1974  /* return the local SID if the local zone is the one requested */
1975  if ( localZoneName != NULL ) {
1976  if ( strncmp( localZoneName, zoneName, MAX_NAME_LEN ) == 0 ) {
1977  strncpy( zoneSID, localSID, MAX_PASSWORD_LEN );
1978  return;
1979  }
1980  }
1981 
1982  // retrieve remote SID from map
1983  std::string _zone_sid = remote_SID_key_map[zoneName].first;
1984 
1985  if ( !_zone_sid.empty() ) {
1986  snprintf( zoneSID, MAX_PASSWORD_LEN, "%s", _zone_sid.c_str() );
1987  return;
1988  }
1989 
1990  zoneSID[0] = '\0';
1991  return;
1992 }
1993 
1994 int
1996 
1999  }
2000  if ( rsComm->proxyUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH ) {
2002  }
2003 
2004  return 0;
2005 }
2006 
2007 /* generic functions to return SYS_NOT_SUPPORTED */
2008 
2009 int
2011  return SYS_NOT_SUPPORTED;
2012 }
2013 
2014 rodsLong_t
2016  return ( rodsLong_t ) SYS_NOT_SUPPORTED;
2017 }
2018 
2019 int
2021  portalOpr_t *myPortalOpr;
2022  portList_t *thisPortList;
2023  int lsock;
2024  int tcpSock, udpSockfd;
2025  int udpPortBuf;
2026  int status;
2027 #if defined(aix_platform)
2028  socklen_t laddrlen = sizeof( struct sockaddr );
2029 #else
2030  uint laddrlen = sizeof( struct sockaddr );
2031 #endif
2032  int packetSize;
2033  char *tmpStr;
2034  int verbose;
2035 
2036  myPortalOpr = rsComm->portalOpr;
2037 
2038  if ( myPortalOpr == NULL ) {
2039  rodsLog( LOG_NOTICE, "svrPortalPutGetRbudp: NULL myPortalOpr" );
2041  }
2042 
2043  thisPortList = &myPortalOpr->portList;
2044  if ( thisPortList == NULL ) {
2045  rodsLog( LOG_NOTICE, "svrPortalPutGetRbudp: NULL portList" );
2047  }
2048 
2049  lsock = getTcpSockFromPortList( thisPortList );
2050 
2051  tcpSock = acceptSrvPortal( rsComm, thisPortList );
2052  if ( tcpSock < 0 ) {
2054  "svrPortalPutGetRbudp: acceptSrvPortal error. errno = %d",
2055  errno );
2056  CLOSE_SOCK( lsock );
2057  return tcpSock;
2058  }
2059  else {
2060  CLOSE_SOCK( lsock );
2061  }
2062  status = readn( tcpSock, ( char * ) &udpPortBuf, sizeof( udpPortBuf ) );
2063  if ( status != sizeof( udpPortBuf ) ) {
2064  rodsLog( LOG_ERROR,
2065  "svrPortalPutGetRbudp: readn error. toread %d, bytes read %d ",
2066  sizeof( udpPortBuf ), status );
2067  return SYS_UDP_CONNECT_ERR;
2068  }
2069 
2070  if ( ( tmpStr = getValByKey( &myPortalOpr->dataOprInp.condInput, RBUDP_PACK_SIZE_KW ) ) == NULL ||
2071  ( packetSize = atoi( tmpStr ) ) < 1 ) {
2072  packetSize = DEF_UDP_PACKET_SIZE;
2073  }
2074 
2075  if ( getValByKey( &myPortalOpr->dataOprInp.condInput, VERY_VERBOSE_KW ) !=
2076  NULL ) {
2077  verbose = 2;
2078  }
2079  else {
2080  verbose = 0;
2081  }
2082 
2083  udpSockfd = getUdpSockFromPortList( thisPortList );
2084 
2085  checkbuf( udpSockfd, UDPSOCKBUF, verbose );
2086  if ( myPortalOpr->oprType == PUT_OPR ) {
2087  rbudpReceiver_t rbudpReceiver;
2088  bzero( &rbudpReceiver, sizeof( rbudpReceiver ) );
2089  int destL3descInx = myPortalOpr->dataOprInp.destL3descInx;
2090 
2091  rbudpReceiver.rbudpBase.verbose = verbose;
2092  rbudpReceiver.rbudpBase.udpSockBufSize = UDPSOCKBUF;
2093  rbudpReceiver.rbudpBase.tcpPort = getTcpPortFromPortList( thisPortList );
2094  rbudpReceiver.rbudpBase.tcpSockfd = tcpSock;
2095  rbudpReceiver.rbudpBase.udpSockfd = udpSockfd;
2096  rbudpReceiver.rbudpBase.hasTcpSock = 0;
2097  rbudpReceiver.rbudpBase.udpRemotePort = ntohl( udpPortBuf );
2098  /* use the addr of tcp sock */
2099  if ( getpeername( tcpSock,
2100  ( struct sockaddr * ) &rbudpReceiver.rbudpBase.udpServerAddr,
2101  &laddrlen ) < 0 ) {
2103  "svrPortalPutGetRbudp() - getpeername() failed: errno=%d",
2104  errno );
2105  recvClose( &rbudpReceiver );
2106  return USER_RODS_HOSTNAME_ERR;
2107  }
2108 
2109  rbudpReceiver.rbudpBase.udpServerAddr.sin_port = htons( rbudpReceiver.rbudpBase.udpRemotePort );
2110 
2111  status = getfileByFd(
2112  &rbudpReceiver,
2113  FileDesc[destL3descInx].fd,
2114  packetSize );
2115 
2116  if ( status < 0 ) {
2117  rodsLog( LOG_ERROR,
2118  "svrPortalPutGetRbudp: getfileByFd error for %s",
2119  FileDesc[destL3descInx].fileName );
2121  }
2122  recvClose( &rbudpReceiver );
2123  }
2124  else if ( myPortalOpr->oprType == GET_OPR ) {
2125 
2126  int sendRate;
2127  rbudpSender_t rbudpSender;
2128  int srcL3descInx = myPortalOpr->dataOprInp.srcL3descInx;
2129 
2130  bzero( &rbudpSender, sizeof( rbudpSender ) );
2131  rbudpSender.rbudpBase.verbose = verbose;
2132  rbudpSender.rbudpBase.udpSockBufSize = UDPSOCKBUF;
2133  rbudpSender.rbudpBase.tcpPort = getTcpPortFromPortList( thisPortList );
2134  rbudpSender.rbudpBase.tcpSockfd = tcpSock;
2135  rbudpSender.rbudpBase.udpSockfd = udpSockfd;
2136  rbudpSender.rbudpBase.hasTcpSock = 0;
2137  rbudpSender.rbudpBase.udpRemotePort = ntohl( udpPortBuf );
2138  /* use the addr of tcp sock */
2139  if ( getpeername( tcpSock,
2140  ( struct sockaddr * ) &rbudpSender.rbudpBase.udpServerAddr,
2141  &laddrlen ) < 0 ) {
2143  "svrPortalPutGetRbudp() - getpeername() failed: errno=%d",
2144  errno );
2145  sendClose( &rbudpSender );
2146  return USER_RODS_HOSTNAME_ERR;
2147  }
2148  rbudpSender.rbudpBase.udpServerAddr.sin_port =
2149  htons( rbudpSender.rbudpBase.udpRemotePort );
2150  if ( ( tmpStr = getValByKey( &myPortalOpr->dataOprInp.condInput, RBUDP_SEND_RATE_KW ) ) == NULL ||
2151  ( sendRate = atoi( tmpStr ) ) < 1 ) {
2152  sendRate = DEF_UDP_SEND_RATE;
2153  }
2154 
2155  status = sendfileByFd(
2156  &rbudpSender,
2157  sendRate,
2158  packetSize,
2159  FileDesc[srcL3descInx].fd );
2160 
2161  if ( status < 0 ) {
2162  rodsLog( LOG_ERROR,
2163  "svrPortalPutGetRbudp: sendfile error for %s",
2164  FileDesc[srcL3descInx].fileName );
2166  }
2167  sendClose( &rbudpSender );
2168  }
2169 
2170  return status;
2171 }
2172 void
2174  struct sockaddr_in remoteAddr;
2176  int acceptFailCnt = 0;
2177 
2178  if ( rsComm == NULL || rsComm->reconnSock <= 0 ) {
2179  return;
2180  }
2181 
2182  if ( listen( rsComm->reconnSock, 1 ) < 0 ) {
2183  rodsLog( LOG_ERROR,
2184  "reconnManager: listen failed, errno: %d",
2185  errno );
2186  return;
2187  }
2188 
2189  const int nSockets = rsComm->reconnSock + 1;
2190  fd_set basemask;
2191  FD_ZERO( &basemask );
2192  FD_SET( rsComm->reconnSock, &basemask );
2193 
2194  while ( 1 ) {
2195  int nSelected;
2196  while ( ( nSelected = select( nSockets, &basemask,
2197  ( fd_set * ) NULL, ( fd_set * ) NULL, NULL ) ) < 0 ) {
2198  if ( errno == EINTR ) {
2199  rodsLog( LOG_NOTICE, "reconnManager: select interrupted\n" );
2200  continue;
2201  }
2202  else {
2203  rodsLog( LOG_ERROR, "reconnManager: select failed, errno = %d", errno );
2204  boost::unique_lock< boost::mutex > boost_lock( *rsComm->thread_ctx->lock );
2205  close( rsComm->reconnSock );
2206  rsComm->reconnSock = 0;
2207  boost_lock.unlock();
2208  return;
2209  } // else
2210  } // while select
2211 
2212  /* don't lock it yet until we are done with establishing a connection */
2213  socklen_t len = sizeof( remoteAddr );
2214  bzero( &remoteAddr, sizeof( remoteAddr ) );
2215 
2216  const int saved_socket_flags = fcntl( rsComm->reconnSock, F_GETFL );
2217  fcntl( rsComm->reconnSock, F_SETFL, saved_socket_flags | O_NONBLOCK );
2218  const int newSock = accept( rsComm->reconnSock, ( struct sockaddr * ) &remoteAddr, &len );
2219  fcntl( rsComm->reconnSock, F_SETFL, saved_socket_flags );
2220 
2221  if ( newSock < 0 ) {
2222  acceptFailCnt++;
2223  rodsLog( LOG_ERROR,
2224  "reconnManager: accept for sock %d failed, errno = %d",
2225  rsComm->reconnSock, errno );
2226  if ( acceptFailCnt > MAX_RECON_ERROR_CNT ) {
2227  rodsLog( LOG_ERROR,
2228  "reconnManager: accept failed cnt > 10, reconnManager exit" );
2229  close( rsComm->reconnSock );
2230  rsComm->reconnSock = -1;
2231  rsComm->reconnPort = 0;
2232  return;
2233  }
2234  else {
2235  continue;
2236  }
2237  }
2238 
2239  // =-=-=-=-=-=-=-
2240  // create a network object
2241  irods::network_object_ptr net_obj;
2242  irods::error ret = irods::network_factory( rsComm, net_obj );
2243  if ( !ret.ok() ) {
2244  irods::log( PASS( ret ) );
2245  return;
2246  }
2247 
2248  // =-=-=-=-=-=-=-
2249  // repave sock handle with new socket
2250  net_obj->socket_handle( newSock );
2251 
2252  ret = readReconMsg( net_obj, &reconnMsg );
2253  if ( !ret.ok() ) {
2254  irods::log( PASS( ret ) );
2255  close( newSock );
2256  continue;
2257  }
2258  else if ( reconnMsg->cookie != rsComm->cookie ) {
2259  rodsLog( LOG_ERROR,
2260  "reconnManager: cookie mismatch, got = %d vs %d",
2261  reconnMsg->cookie, rsComm->cookie );
2262  close( newSock );
2263  free( reconnMsg );
2264  continue;
2265  }
2266 
2267  boost::unique_lock<boost::mutex> boost_lock( *rsComm->thread_ctx->lock );
2268  rsComm->clientState = reconnMsg->procState;
2269  rsComm->reconnectedSock = newSock;
2270  /* need to check agentState */
2271  while ( rsComm->agentState == SENDING_STATE ) {
2272  /* have to wait until the agent stop sending */
2273  rsComm->reconnThrState = CONN_WAIT_STATE;
2274  rsComm->thread_ctx->cond->wait( boost_lock );
2275  }
2276 
2277  rsComm->reconnThrState = PROCESSING_STATE;
2278  bzero( reconnMsg, sizeof( reconnMsg_t ) );
2279  reconnMsg->procState = rsComm->agentState;
2280  ret = sendReconnMsg( net_obj, reconnMsg );
2281  free( reconnMsg );
2282  if ( !ret.ok() ) {
2283  irods::log( PASS( ret ) );
2284  close( newSock );
2285  rsComm->reconnectedSock = 0;
2286  boost_lock.unlock();
2287  continue;
2288  }
2289  if ( rsComm->agentState == PROCESSING_STATE ) {
2291  "reconnManager: svrSwitchConnect. cliState = %d,agState=%d",
2292  rsComm->clientState, rsComm->agentState );
2293  svrSwitchConnect( rsComm );
2294  }
2295  boost_lock.unlock();
2296  } // while 1
2297 }
2298 
2299 int
2301  if ( rsComm->reconnSock > 0 ) {
2302  /* handle reconn */
2303  boost::unique_lock<boost::mutex> boost_lock( *rsComm->thread_ctx->lock );
2304  if ( rsComm->reconnThrState == CONN_WAIT_STATE ) {
2305  /* should not be here */
2307  "svrChkReconnAtSendStart: ThrState = CONN_WAIT_STATE, agentState=%d",
2308  rsComm->agentState );
2309  rsComm->agentState = PROCESSING_STATE;
2310  rsComm->thread_ctx->cond->notify_all();
2311  }
2312  svrSwitchConnect( rsComm );
2313  rsComm->agentState = SENDING_STATE;
2314  boost_lock.unlock();
2315  }
2316  return 0;
2317 }
2318 
2319 int
2321  if ( rsComm->reconnSock > 0 ) {
2322  /* handle reconn */
2323  boost::unique_lock<boost::mutex> boost_lock( *rsComm->thread_ctx->lock );
2324  rsComm->agentState = PROCESSING_STATE;
2325  if ( rsComm->reconnThrState == CONN_WAIT_STATE ) {
2326  rsComm->thread_ctx->cond->wait( boost_lock );
2327  }
2328  boost_lock.unlock();
2329  }
2330  return 0;
2331 }
2332 
2333 int
2335  if ( rsComm->reconnSock > 0 ) {
2336  /* handle reconn */
2337  boost::unique_lock< boost::mutex > boost_lock( *rsComm->thread_ctx->lock );
2338  if ( rsComm->reconnThrState == CONN_WAIT_STATE ) {
2339  /* should not be here */
2341  "svrChkReconnAtReadStart: ThrState = CONN_WAIT_STATE, agentState=%d",
2342  rsComm->agentState );
2343  rsComm->agentState = PROCESSING_STATE;
2344  rsComm->thread_ctx->cond->wait( boost_lock );
2345  }
2346  svrSwitchConnect( rsComm );
2347  rsComm->agentState = RECEIVING_STATE;
2348  boost_lock.unlock();
2349  }
2350  return 0;
2351 }
2352 
2353 int
2355  if ( rsComm->reconnSock > 0 ) {
2356  /* handle reconn */
2357  boost::unique_lock< boost::mutex > boost_lock( *rsComm->thread_ctx->lock );
2358  rsComm->agentState = PROCESSING_STATE;
2359  if ( rsComm->reconnThrState == CONN_WAIT_STATE ) {
2360  rsComm->thread_ctx->cond->notify_all();
2361  }
2362  boost_lock.unlock();
2363  }
2364  return 0;
2365 }
2366 
2367 int
2368 svrSockOpenForInConn( rsComm_t *rsComm, int *portNum, char **addr, int proto ) {
2369  int status;
2370 
2371  status = sockOpenForInConn( rsComm, portNum, addr, proto );
2372  if ( status < 0 ) {
2373  return status;
2374  }
2375 
2376  if ( addr != NULL && *addr != NULL &&
2377  ( isLoopbackAddress( *addr ) || strcmp( *addr, "0.0.0.0" ) == 0 ||
2378  strcmp( *addr, "localhost" ) == 0 ) ) {
2379  /* localhost */
2380  char *myaddr;
2381 
2382  myaddr = getLocalSvrAddr();
2383  if ( myaddr != NULL ) {
2384  free( *addr );
2385  *addr = strdup( myaddr );
2386  }
2387  else {
2389  "svrSockOpenForInConn: problem resolving local host addr %s",
2390  *addr );
2391  }
2392  }
2393  return status;
2394 }
2395 
2396 char *
2398  char *myHost;
2399  myHost = _getSvrAddr( LocalServerHost );
2400  return myHost;
2401 }
2402 
2403 char *
2405  hostName_t *tmpHostName;
2406 
2407  if ( rodsServerHost == NULL ) {
2408  return NULL;
2409  }
2410 
2411  tmpHostName = rodsServerHost->hostName;
2412  while ( tmpHostName != NULL ) {
2413  if ( strcmp( tmpHostName->name, "localhost" ) != 0 &&
2414  !isLoopbackAddress( tmpHostName->name ) &&
2415  strcmp( tmpHostName->name, "0.0.0.0" ) != 0 &&
2416  strchr( tmpHostName->name, '.' ) != NULL ) {
2417  return tmpHostName->name;
2418  }
2419  tmpHostName = tmpHostName->next;
2420  }
2421  return NULL;
2422 }
2423 
2424 char *
2426  char *myHost;
2427 
2428  myHost = _getSvrAddr( rodsServerHost );
2429  if ( myHost == NULL ) {
2430  /* use the first one */
2431  myHost = rodsServerHost->hostName->name;
2432  }
2433  return myHost;
2434 }
2435 
2436 int
2437 setLocalSrvAddr( char *outLocalAddr ) {
2438  char *myHost;
2439 
2440  if ( outLocalAddr == NULL ) {
2441  return USER__NULL_INPUT_ERR;
2442  }
2443 
2444  myHost = getSvrAddr( LocalServerHost );
2445 
2446  if ( myHost != NULL ) {
2447  rstrcpy( outLocalAddr, myHost, NAME_LEN );
2448  return 0;
2449  }
2450  else {
2451  return SYS_INVALID_SERVER_HOST;
2452  }
2453 }
2454 
2455 int
2456 forkAndExec( char *av[] ) {
2457  int childPid = 0;
2458  int status = -1;
2459  int childStatus = 0;
2460 
2461  childPid = RODS_FORK();
2462 
2463  if ( childPid == 0 ) {
2464  /* child */
2465  execv( av[0], av );
2466  /* gets here. must be bad */
2467  exit( 1 );
2468  }
2469  else if ( childPid < 0 ) {
2470  rodsLog( LOG_ERROR,
2471  "exectar: RODS_FORK failed. errno = %d", errno );
2472  return SYS_FORK_ERROR;
2473  }
2474 
2475  /* parent */
2476 
2477  status = waitpid( childPid, &childStatus, 0 );
2478  if ( status >= 0 && childStatus != 0 ) {
2479  rodsLog( LOG_ERROR,
2480  "forkAndExec: waitpid status = %d, childStatus = %d",
2481  status, childStatus );
2483  }
2484 
2485  return status;
2486 }
2487 
2488 int
2489 singleRemLocCopy( rsComm_t *rsComm, dataCopyInp_t *dataCopyInp ) {
2490  dataOprInp_t *dataOprInp;
2491  int status = 0;
2492  int oprType;
2493 
2494  if ( dataCopyInp == NULL ) {
2496  "remLocCopy: NULL dataCopyInp input" );
2498  }
2499  dataOprInp = &dataCopyInp->dataOprInp;
2500  oprType = dataOprInp->oprType;
2501 
2502  if ( oprType == COPY_TO_LOCAL_OPR ) {
2503  status = singleRemToLocCopy( rsComm, dataCopyInp );
2504  }
2505  else {
2506  status = singleLocToRemCopy( rsComm, dataCopyInp );
2507  }
2508  return status;
2509 }
2510 
2511 int
2512 singleRemToLocCopy( rsComm_t *rsComm, dataCopyInp_t *dataCopyInp ) {
2513  dataOprInp_t *dataOprInp;
2514  rodsLong_t dataSize;
2515  int l1descInx;
2516  int destL3descInx;
2517  bytesBuf_t dataObjReadInpBBuf;
2518  openedDataObjInp_t dataObjReadInp;
2519  int bytesWritten, bytesRead;
2520  rodsLong_t totalWritten = 0;
2521 
2522  /* a GET type operation */
2523  if ( dataCopyInp == NULL ) {
2525  "singleRemToLocCopy: NULL dataCopyInp input" );
2527  }
2528 
2529  int trans_buff_size;
2530  try {
2531  trans_buff_size = irods::get_advanced_setting<const int>(irods::CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS) * 1024 * 1024;
2532  } catch ( const irods::exception& e ) {
2533  irods::log(e);
2534  return e.code();
2535  }
2536 
2537  dataOprInp = &dataCopyInp->dataOprInp;
2538  l1descInx = dataCopyInp->portalOprOut.l1descInx;
2539  destL3descInx = dataOprInp->destL3descInx;
2540  dataSize = dataOprInp->dataSize;
2541 
2542  bzero( &dataObjReadInp, sizeof( dataObjReadInp ) );
2543  dataObjReadInpBBuf.buf = malloc( trans_buff_size );
2544  dataObjReadInpBBuf.len = dataObjReadInp.len = trans_buff_size;
2545  dataObjReadInp.l1descInx = l1descInx;
2546  while ( ( bytesRead = rsDataObjRead( rsComm, &dataObjReadInp,
2547  &dataObjReadInpBBuf ) ) > 0 ) {
2548  bytesWritten = _l3Write( rsComm, destL3descInx,
2549  dataObjReadInpBBuf.buf, bytesRead );
2550 
2551  if ( bytesWritten != bytesRead ) {
2552  rodsLog( LOG_ERROR,
2553  "singleRemToLocCopy: Read %d bytes, Wrote %d bytes.\n ",
2554  bytesRead, bytesWritten );
2555  free( dataObjReadInpBBuf.buf );
2556  return SYS_COPY_LEN_ERR;
2557  }
2558  else {
2559  totalWritten += bytesWritten;
2560  }
2561  }
2562  free( dataObjReadInpBBuf.buf );
2563  if ( dataSize <= 0 || totalWritten == dataSize ||
2564  getValByKey( &dataOprInp->condInput, NO_CHK_COPY_LEN_KW ) != NULL ) {
2565  return 0;
2566  }
2567  else {
2568  rodsLog( LOG_ERROR,
2569  "singleRemToLocCopy: totalWritten %lld dataSize %lld mismatch",
2570  totalWritten, dataSize );
2571  return SYS_COPY_LEN_ERR;
2572  }
2573 }
2574 
2575 int
2576 singleLocToRemCopy( rsComm_t *rsComm, dataCopyInp_t *dataCopyInp ) {
2577  dataOprInp_t *dataOprInp;
2578  rodsLong_t dataSize;
2579  int l1descInx;
2580  int srcL3descInx;
2581  bytesBuf_t dataObjWriteInpBBuf;
2582  openedDataObjInp_t dataObjWriteInp;
2583  int bytesWritten, bytesRead;
2584  rodsLong_t totalWritten = 0;
2585 
2586  /* a PUT type operation */
2587  if ( dataCopyInp == NULL ) {
2589  "singleRemToLocCopy: NULL dataCopyInp input" );
2591  }
2592 
2593  int trans_buff_size;
2594  try {
2595  trans_buff_size = irods::get_advanced_setting<const int>(irods::CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS) * 1024 * 1024;
2596  } catch ( const irods::exception& e ) {
2597  irods::log(e);
2598  return e.code();
2599  }
2600 
2601  dataOprInp = &dataCopyInp->dataOprInp;
2602  l1descInx = dataCopyInp->portalOprOut.l1descInx;
2603  srcL3descInx = dataOprInp->srcL3descInx;
2604  dataSize = dataOprInp->dataSize;
2605 
2606  bzero( &dataObjWriteInp, sizeof( dataObjWriteInp ) );
2607  dataObjWriteInpBBuf.buf = malloc( trans_buff_size );
2608  dataObjWriteInpBBuf.len = 0;
2609  dataObjWriteInp.l1descInx = l1descInx;
2610 
2611  while ( ( bytesRead = _l3Read( rsComm, srcL3descInx,
2612  dataObjWriteInpBBuf.buf, trans_buff_size ) ) > 0 ) {
2613  dataObjWriteInp.len = dataObjWriteInpBBuf.len = bytesRead;
2614  bytesWritten = rsDataObjWrite( rsComm, &dataObjWriteInp,
2615  &dataObjWriteInpBBuf );
2616  if ( bytesWritten != bytesRead ) {
2617  rodsLog( LOG_ERROR,
2618  "singleLocToRemCopy: Read %d bytes, Wrote %d bytes.\n ",
2619  bytesRead, bytesWritten );
2620  free( dataObjWriteInpBBuf.buf );
2621  return SYS_COPY_LEN_ERR;
2622  }
2623  else {
2624  totalWritten += bytesWritten;
2625  }
2626  }
2627  free( dataObjWriteInpBBuf.buf );
2628  if ( dataSize <= 0 || totalWritten == dataSize ||
2629  getValByKey( &dataOprInp->condInput, NO_CHK_COPY_LEN_KW ) != NULL ) {
2630  return 0;
2631  }
2632  else {
2633  rodsLog( LOG_ERROR,
2634  "singleLocToRemCopy: totalWritten %lld dataSize %lld mismatch",
2635  totalWritten, dataSize );
2636  return SYS_COPY_LEN_ERR;
2637  }
2638 }
2639 
2640 int
2641 singleL1Copy( rsComm_t *rsComm, dataCopyInp_t *dataCopyInp ) {
2642  dataOprInp_t *dataOprInp;
2643  rodsLong_t dataSize;
2644  int srcL1descInx, destL1descInx;
2645  bytesBuf_t dataObjReadInpBBuf;
2646  bytesBuf_t dataObjWriteInpBBuf;
2647  openedDataObjInp_t dataObjReadInp;
2648  openedDataObjInp_t dataObjWriteInp;
2649  int bytesWritten, bytesRead;
2650  rodsLong_t totalWritten = 0;
2651 
2652  if ( dataCopyInp == NULL ) {
2654  "singleL1Copy: NULL dataCopyInp input" );
2656  }
2657 
2658  int trans_buff_size;
2659  try {
2660  trans_buff_size = irods::get_advanced_setting<const int>(irods::CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS) * 1024 * 1024;
2661  } catch ( const irods::exception& e ) {
2662  irods::log(e);
2663  return e.code();
2664  }
2665 
2666  dataOprInp = &dataCopyInp->dataOprInp;
2667  destL1descInx = dataCopyInp->portalOprOut.l1descInx;
2668  srcL1descInx = L1desc[destL1descInx].srcL1descInx;
2669 
2670  dataSize = dataOprInp->dataSize;
2671  bzero( &dataObjReadInp, sizeof( dataObjReadInp ) );
2672  dataObjReadInpBBuf.buf = malloc( trans_buff_size );
2673  dataObjReadInpBBuf.len = dataObjReadInp.len = trans_buff_size;
2674  dataObjReadInp.l1descInx = srcL1descInx;
2675 
2676  bzero( &dataObjWriteInp, sizeof( dataObjWriteInp ) );
2677  dataObjWriteInpBBuf.buf = dataObjReadInpBBuf.buf;
2678  dataObjWriteInpBBuf.len = 0;
2679  dataObjWriteInp.l1descInx = destL1descInx;
2680 
2681  while ( ( bytesRead = rsDataObjRead( rsComm, &dataObjReadInp,
2682  &dataObjReadInpBBuf ) ) > 0 ) {
2683  dataObjWriteInp.len = dataObjWriteInpBBuf.len = bytesRead;
2684  bytesWritten = rsDataObjWrite( rsComm, &dataObjWriteInp,
2685  &dataObjWriteInpBBuf );
2686 
2687  if ( bytesWritten != bytesRead ) {
2688  rodsLog( LOG_ERROR,
2689  "singleL1Copy: Read %d bytes, Wrote %d bytes.\n ",
2690  bytesRead, bytesWritten );
2691  free( dataObjReadInpBBuf.buf );
2692  return SYS_COPY_LEN_ERR;
2693  }
2694  else {
2695  totalWritten += bytesWritten;
2696  }
2697  }
2698  free( dataObjReadInpBBuf.buf );
2699  if ( dataSize <= 0 || totalWritten == dataSize ||
2700  getValByKey( &dataOprInp->condInput, NO_CHK_COPY_LEN_KW ) != NULL ) {
2701  return 0;
2702  }
2703  else {
2704  rodsLog( LOG_ERROR,
2705  "singleL1Copy: totalWritten %lld dataSize %lld mismatch",
2706  totalWritten, dataSize );
2707  return SYS_COPY_LEN_ERR;
2708  }
2709 }
2710 
2711 /* readStartupPack - Read the startup packet from client.
2712  * Note: initServerInfo must be called first because it calls getLocalZoneInfo.
2713  */
2714 
2719  struct timeval* tv ) {
2720  msgHeader_t myHeader;
2721  irods::error ret = readMsgHeader( _ptr, &myHeader, tv );
2722  if ( !ret.ok() ) {
2723  return PASS( ret );
2724  }
2725 
2726  if ( strcmp(myHeader.type, RODS_HEARTBEAT_T) == 0 ) {
2727  *startupPack = static_cast<startupPack_t*>(malloc(sizeof(**startupPack)));
2728  snprintf((*startupPack)->option, sizeof((*startupPack)->option), "%s", RODS_HEARTBEAT_T);
2729  return SUCCESS();
2730  }
2731 
2732  if ( myHeader.msgLen > ( int ) sizeof( startupPack_t ) * 2 ||
2733  myHeader.msgLen <= 0 ) {
2734  std::stringstream msg;
2735  msg << "readStartupPack: problem with myHeader.msgLen = " << myHeader.msgLen;
2736  return ERROR( SYS_HEADER_READ_LEN_ERR, msg.str() );
2737  }
2738 
2739  bytesBuf_t inputStructBBuf, bsBBuf, errorBBuf;
2740  memset( &bsBBuf, 0, sizeof( bytesBuf_t ) );
2741  ret = readMsgBody(
2742  _ptr,
2743  &myHeader,
2744  &inputStructBBuf,
2745  &bsBBuf,
2746  &errorBBuf,
2747  XML_PROT,
2748  tv );
2749  if ( !ret.ok() ) {
2750  return PASS( ret );
2751  }
2752 
2753  /* some sanity check */
2754 
2755  if ( strcmp( myHeader.type, RODS_CONNECT_T ) != 0 ) {
2756  if ( inputStructBBuf.buf != NULL ) {
2757  clearBBuf( &inputStructBBuf );
2758  }
2759  if ( bsBBuf.buf != NULL ) {
2760  clearBBuf( &bsBBuf );
2761  }
2762  if ( errorBBuf.buf != NULL ) {
2763  clearBBuf( &errorBBuf );
2764  }
2765  std::stringstream msg;
2766  msg << "readStartupPack: wrong mag type - " << myHeader.type << ", expect " << RODS_CONNECT_T;
2767  return ERROR( SYS_HEADER_TYPE_LEN_ERR, msg.str() );
2768  }
2769 
2770  if ( myHeader.bsLen != 0 ) {
2771  if ( bsBBuf.buf != NULL ) {
2772  clearBBuf( &bsBBuf );
2773  }
2774  rodsLog( LOG_NOTICE, "readStartupPack: myHeader.bsLen = %d is not 0",
2775  myHeader.bsLen );
2776  }
2777 
2778  if ( myHeader.errorLen != 0 ) {
2779  if ( errorBBuf.buf != NULL ) {
2780  clearBBuf( &errorBBuf );
2781  }
2783  "readStartupPack: myHeader.errorLen = %d is not 0",
2784  myHeader.errorLen );
2785  }
2786 
2787  /* always use XML_PROT for the startup pack */
2788  int status = unpackStruct( inputStructBBuf.buf, ( void ** ) startupPack,
2789  "StartupPack_PI", RodsPackTable, XML_PROT );
2790 
2791  clearBBuf( &inputStructBBuf );
2792 
2793  if ( status < 0 ) {
2794  return ERROR( status, "readStartupPack:unpackStruct error." );
2795  }
2796 
2797  if ( ( *startupPack )->clientUser[0] != '\0' &&
2798  ( *startupPack )->clientRodsZone[0] == '\0' ) {
2799  /* clientRodsZone is not defined */
2800  if ( const char* zoneName = getLocalZoneName() ) {
2801  rstrcpy( ( *startupPack )->clientRodsZone, zoneName, NAME_LEN );
2802  }
2803  }
2804  if ( ( *startupPack )->proxyUser[0] != '\0' &&
2805  ( *startupPack )->proxyRodsZone[0] == '\0' ) {
2806  /* proxyRodsZone is not defined */
2807  if ( const char* zoneName = getLocalZoneName() ) {
2808  rstrcpy( ( *startupPack )->proxyRodsZone, zoneName, NAME_LEN );
2809  }
2810  }
2811 
2812  return CODE( status );
2813 }
2814 
2815 /* initServiceUser - set the username/uid of the unix user to
2816  * run the iRODS daemons as if configured using the
2817  * irodsServiceUser environment variable. Will also
2818  * set effective uid to service user.
2819  */
2820 int
2822  char *serviceUser;
2823  struct passwd *pwent;
2824 
2825  serviceUser = getenv( "irodsServiceUser" );
2826  if ( serviceUser == NULL || getuid() != 0 ) {
2827  /* either the option is not set, or not running */
2828  /* with the necessary root permission. Just return. */
2829  return 0;
2830  }
2831 
2832  /* clear errno before getpwnam to distinguish an error from user */
2833  /* not existing. pwent == NULL && errno == 0 means no entry */
2834  errno = 0;
2835  pwent = getpwnam( serviceUser );
2836  if ( pwent ) {
2837  ServiceUid = pwent->pw_uid;
2838  ServiceGid = pwent->pw_gid;
2839  return changeToServiceUser();
2840  }
2841 
2842  if ( errno ) {
2844  "setServiceUser: error in getpwnam %s, errno = %d",
2845  serviceUser, errno );
2846  return SYS_USER_RETRIEVE_ERR - errno;
2847  }
2848  else {
2850  "setServiceUser: user %s doesn't exist", serviceUser );
2851  return SYS_USER_RETRIEVE_ERR;
2852  }
2853 }
2854 
2855 /* isServiceUserSet - check if the service user has been configured
2856  */
2857 int
2859  if ( ServiceUid ) {
2860  return 1;
2861  }
2862  else {
2863  return 0;
2864  }
2865 }
2866 
2867 /* changeToRootUser - take on root privilege by setting the process
2868  * effective uid to zero.
2869  */
2870 int
2872  int prev_errno, my_errno;
2873 
2874  if ( !isServiceUserSet() ) {
2875  /* not configured ... just return */
2876  return 0;
2877  }
2878 
2879  /* preserve the errno from before. We'll often be */
2880  /* called after a "permission denied" type error, */
2881  /* so we need to preserve this previous error state */
2882  prev_errno = errno;
2883  if ( seteuid( 0 ) == -1 ) {
2884  my_errno = errno;
2885  errno = prev_errno;
2887  "changeToRootUser: can't change to root user id" );
2888  return SYS_USER_NO_PERMISSION - my_errno;
2889  }
2890 
2891  return 0;
2892 }
2893 
2894 /* changeToServiceUser - set the process effective uid to that of the
2895  * configured service user. Normally used to give
2896  * up root permission.
2897  */
2898 int
2900  int prev_errno, my_errno;
2901 
2902  if ( !isServiceUserSet() ) {
2903  /* not configured ... just return */
2904  return 0;
2905  }
2906 
2907  prev_errno = errno;
2908 
2909  if ( setegid( ServiceGid ) == -1 ) {
2910  /* if only setegid fails, log error but continue */
2911  rodsLog( LOG_ERROR, "changeToServiceUser: setegid() failed, errno = %d", errno );
2912  errno = prev_errno;
2913  }
2914 
2915  if ( seteuid( ServiceUid ) == -1 ) {
2916  my_errno = errno;
2917  errno = prev_errno;
2919  "changeToServiceUser: can't change to service user id" );
2920  return SYS_USER_NO_PERMISSION - my_errno;
2921  }
2922 
2923  return 0;
2924 }
2925 
2926 /* changeToUser - set the process effective uid to the provided uid.
2927  * Used to allow the iRODS services the ability to
2928  * perform actions as a particular user.
2929  */
2930 int
2931 changeToUser( uid_t uid ) {
2932  int prev_errno, my_errno;
2933 
2934  if ( !isServiceUserSet() ) {
2935  /* not configured ... just return */
2936  return 0;
2937  }
2938 
2939  prev_errno = errno;
2940  if ( geteuid() != 0 ) {
2941  changeToRootUser();
2942  }
2943  if ( seteuid( uid ) == -1 ) {
2944  my_errno = errno;
2945  errno = prev_errno;
2947  "changeToUser: can't change to user id %d",
2948  uid );
2949  return SYS_USER_NO_PERMISSION - my_errno;
2950  }
2951  errno = prev_errno;
2952 
2953  return 0;
2954 }
2955 
2956 /* dropRootPrivilege - set the process real and effective uid to
2957  * the current effective uid of the process.
2958  * Used, for example, to drop root privilege
2959  * before a call to execl().
2960  */
2961 int
2963  int prev_errno, my_errno;
2964  uid_t new_real_uid;
2965 
2966  if ( !isServiceUserSet() ) {
2967  /* not configured ... just return */
2968  return 0;
2969  }
2970 
2971  prev_errno = errno;
2972 
2973  new_real_uid = geteuid();
2974  if ( new_real_uid == 0 ) {
2975  /* will become the iRODS service user */
2976  new_real_uid = ServiceUid;
2977  }
2978  else {
2979  /* need to set effective uid to root
2980  for the call to setuid() */
2981  changeToRootUser();
2982  }
2983 
2984  if ( setuid( new_real_uid ) == -1 ) {
2985  my_errno = errno;
2986  errno = prev_errno;
2988  "dropRootPrivilege: can't setuid() to uid %d",
2989  new_real_uid );
2990  return SYS_USER_NO_PERMISSION - my_errno;
2991  }
2992 
2993  errno = prev_errno;
2994 
2995  return 0;
2996 }
2997 
2998 /*
2999  check a chlModAVUMetadata argument; returning the type.
3000 */
3001 int
3002 checkModArgType( const char *arg ) {
3003  if ( arg == NULL || strlen( arg ) == 0 ) {
3004  return CAT_INVALID_ARGUMENT;
3005  }
3006  if ( ':' != arg[1] ) {
3007  return 0;
3008  }
3009  switch ( arg[0] ) {
3010  case 'n':
3011  return 1;
3012  case 'v':
3013  return 2;
3014  case 'u':
3015  return 3;
3016  default:
3017  return 0;
3018  }
3019 }
3020 
3022  // Should only ever set the cache salt once
3023  try {
3024  const auto& existing_name = irods::get_server_property<const std::string>( irods::CFG_RE_CACHE_SALT_KW);
3025  rodsLog( LOG_NOTICE, "setRECacheSaltFromEnv: mutex name already set [%s]", existing_name.c_str() );
3026  return SUCCESS();
3027  } catch ( const irods::exception& ) {
3028  const char *p_mutex_salt = std::getenv( SP_RE_CACHE_SALT );
3029  if ( NULL == p_mutex_salt ) {
3030  rodsLog( LOG_ERROR, "setRECacheSaltFromEnv: call to getenv failed" );
3031  return ERROR( SYS_GETENV_ERR, "setRECacheSaltFromEnv: mutex name already set" );
3032  }
3033 
3034  try {
3035  irods::set_server_property<std::string>( irods::CFG_RE_CACHE_SALT_KW, p_mutex_salt );
3036  } catch ( const irods::exception& e ) {
3037  rodsLog( LOG_ERROR, "setRECacheSaltFromEnv: failed to set server_properties" );
3038  return irods::error(e);
3039  }
3040 
3041  return SUCCESS();
3042  }
3043 
3044 } // setRECacheSaltFromEnv
3045 
3047  const std::string& script_language,
3048  const std::string& script_name,
3049  const std::vector<std::string>& args,
3050  std::string& output ) {
3051  output.clear();
3052  std::stringstream exec;
3053  try {
3054  exec << script_language
3055  << " " << irods::get_irods_home_directory().string()
3056  << "/scripts/" << script_name;
3057  } catch (const irods::exception& e) {
3058  irods::log(e);
3059  return ERROR(-1, "failed to get irods home directory");
3060  }
3061  for ( std::vector<std::string>::size_type i = 0; i < args.size(); ++i ) {
3062  exec << " " << args[i];
3063  }
3064 
3065  FILE *fp = popen( exec.str().c_str(), "r" );
3066  if ( fp == NULL ) {
3067  return ERROR( SYS_FORK_ERROR, "popen() failed" );
3068  }
3069 
3070  std::vector<char> buf( 1000 );
3071  const char* fgets_ret = fgets( &buf[0], buf.size(), fp );
3072  if ( fgets_ret == NULL ) {
3073  std::stringstream msg;
3074  msg << "fgets() failed. feof["
3075  << std::feof( fp )
3076  << "] ferror["
3077  << std::ferror( fp ) << "]";
3078  const int pclose_ret = pclose( fp );
3079  msg << " pclose[" << pclose_ret << "]";
3080  return ERROR( FILE_READ_ERR, msg.str() );
3081  }
3082 
3083  const int pclose_ret = pclose( fp );
3084  if ( pclose_ret == -1 ) {
3085  return ERROR( SYS_FORK_ERROR,
3086  "pclose() failed." );
3087  }
3088 
3089  output = &buf[0];
3090  // Remove trailing newline
3091  const std::string::size_type size = output.size();
3092  if ( size > 0 && output[size - 1] == '\n' ) {
3093  output.resize( size - 1 );
3094  }
3095 
3096  return SUCCESS();
3097 
3098 } // get_script_output_single_line
3099 
3101  keyValPair_t& _kvp ) {
3102 
3103  irods::error ret = SUCCESS();
3104 
3105  try {
3106  addKeyVal(&_kvp, irods::CLIENT_USER_NAME_KW.c_str(), irods::get_server_property<const std::string>(irods::CLIENT_USER_NAME_KW).c_str());
3107  } catch ( const irods::exception& e ) {
3108  addKeyVal(&_kvp, irods::CLIENT_USER_NAME_KW.c_str(), "");
3109  }
3110 
3111  try {
3112  addKeyVal(&_kvp, irods::CLIENT_USER_ZONE_KW.c_str(), irods::get_server_property<const std::string>(irods::CLIENT_USER_ZONE_KW).c_str());
3113  } catch ( const irods::exception& e ) {
3114  addKeyVal(&_kvp, irods::CLIENT_USER_ZONE_KW.c_str(), "");
3115  }
3116 
3117  try {
3118  addKeyVal(&_kvp, irods::CLIENT_USER_PRIV_KW.c_str(),
3119  boost::lexical_cast<std::string>(irods::get_server_property<const int>(irods::CLIENT_USER_PRIV_KW)).c_str());
3120  } catch ( boost::bad_lexical_cast& _e ) {
3121  // can't actually fail to cast an int to a string
3122  addKeyVal(&_kvp, irods::CLIENT_USER_PRIV_KW.c_str(), "0");
3123  } catch ( const irods::exception& e ) {
3124  addKeyVal(&_kvp, irods::CLIENT_USER_PRIV_KW.c_str(), "0");
3125  }
3126 
3127  try {
3128  addKeyVal(&_kvp, irods::PROXY_USER_NAME_KW.c_str(), irods::get_server_property<const std::string>(irods::PROXY_USER_NAME_KW).c_str());
3129  } catch ( const irods::exception& e ) {
3130  addKeyVal(&_kvp, irods::PROXY_USER_NAME_KW.c_str(), "");
3131  }
3132 
3133  try {
3134  addKeyVal(&_kvp, irods::PROXY_USER_ZONE_KW.c_str(), irods::get_server_property<const std::string&>(irods::PROXY_USER_ZONE_KW).c_str());
3135  } catch ( const irods::exception& e ) {
3136  addKeyVal(&_kvp, irods::PROXY_USER_ZONE_KW.c_str(), "");
3137  }
3138 
3139  try {
3140  addKeyVal(&_kvp, irods::PROXY_USER_PRIV_KW.c_str(),
3141  boost::lexical_cast<std::string>(irods::get_server_property<const int>(irods::PROXY_USER_PRIV_KW)).c_str());
3142  } catch ( boost::bad_lexical_cast& _e ) {
3143  // can't actually fail to cast an int to a string
3144  addKeyVal(&_kvp, irods::PROXY_USER_PRIV_KW.c_str(), "0");
3145  } catch ( const irods::exception& e ) {
3146  addKeyVal(&_kvp, irods::PROXY_USER_PRIV_KW.c_str(), "0");
3147  }
3148 
3149  return ret;
3150 
3151 } // add_global_re_params_to_kvp
3152 
3154  std::string& _role ) {
3155 
3156  try {
3157  _role = irods::get_server_property<const std::string>(irods::CFG_CATALOG_SERVICE_ROLE);
3158  } catch ( const irods::exception& e ) {
3159  return irods::error(e);
3160  }
3161  return SUCCESS();
3162 
3163 } // get_catalog_service_role
3164 
3166  std::string& _instance_name ) {
3167  try {
3168  _instance_name = boost::any_cast<const std::string&>(boost::any_cast<const std::unordered_map<std::string, boost::any>&>(irods::get_server_property<const std::vector<boost::any>>(std::vector<std::string>{irods::CFG_PLUGIN_CONFIGURATION_KW, irods::PLUGIN_TYPE_RULE_ENGINE})[0]).at(irods::CFG_INSTANCE_NAME_KW));
3169  } catch ( const irods::exception& e ) {
3170  return irods::error(e);
3171  } catch ( const boost::bad_any_cast& e ) {
3172  return ERROR( INVALID_ANY_CAST, e.what() );
3173  } catch ( const std::out_of_range& e ) {
3174  return ERROR( KEY_NOT_FOUND, e.what() );
3175  }
3176 
3177  return SUCCESS();
3178 
3179 } // get_default_rule_plugin_instance
3180 
3182  std::vector< std::string > &_instance_names ) {
3183  try {
3184  const auto& rule_engines = irods::get_server_property<const std::vector<boost::any>>(std::vector<std::string>{irods::CFG_PLUGIN_CONFIGURATION_KW, irods::PLUGIN_TYPE_RULE_ENGINE});
3185  for ( const auto& el : rule_engines ) {
3186  _instance_names.push_back( boost::any_cast< const std::string& >( boost::any_cast< const std::unordered_map<std::string, boost::any>&>( el ).at(irods::CFG_INSTANCE_NAME_KW) ) );
3187  }
3188  } catch ( const irods::exception& e ) {
3189  return irods::error(e);
3190  } catch ( const boost::bad_any_cast& e ) {
3191  return ERROR( INVALID_ANY_CAST, e.what() );
3192  } catch ( const std::out_of_range& e ) {
3193  return ERROR( KEY_NOT_FOUND, e.what() );
3194  }
3195 
3196  return SUCCESS();
3197 }
3198 
3199 void applyMetadataFromKVP(rsComm_t *rsComm, dataObjInp_t *dataObjInp) {
3200  if ( !rsComm ) {
3201  THROW( SYS_INTERNAL_NULL_INPUT_ERR, "null rsComm passed in" );
3202  }
3203  if ( !dataObjInp ) {
3204  THROW( SYS_INTERNAL_NULL_INPUT_ERR, "null dataObjInp passed in" );
3205  }
3206  if ( const char* serialized_metadata = getValByKey( &dataObjInp->condInput, METADATA_INCLUDED_KW ) ) {
3207  std::vector<std::string> deserialized_metadata = irods::deserialize_metadata( serialized_metadata );
3208  for ( size_t i = 0; i + 2 < deserialized_metadata.size(); i += 3 ) {
3209  modAVUMetadataInp_t modAVUMetadataInp;
3210  memset( &modAVUMetadataInp, 0, sizeof( modAVUMetadataInp ) );
3211 
3212  modAVUMetadataInp.arg0 = strdup( "add" );
3213  modAVUMetadataInp.arg1 = strdup( "-d" );
3214  modAVUMetadataInp.arg2 = strdup( dataObjInp->objPath );
3215  modAVUMetadataInp.arg3 = strdup( deserialized_metadata[i].c_str() );
3216  modAVUMetadataInp.arg4 = strdup( deserialized_metadata[i + 1].c_str() );
3217  modAVUMetadataInp.arg5 = strdup( deserialized_metadata[i + 2].c_str() );
3218  int status = rsModAVUMetadata( rsComm, &modAVUMetadataInp );
3219  clearModAVUMetadataInp( &modAVUMetadataInp );
3221  THROW( status, "rsModAVUMetadata failed" );
3222  }
3223  }
3224  }
3225 }
3226 
3227 void applyACLFromKVP(rsComm_t *rsComm, dataObjInp_t *dataObjInp) {
3228  if ( !rsComm ) {
3229  THROW( SYS_INTERNAL_NULL_INPUT_ERR, "null rsComm passed in" );
3230  }
3231  if ( !dataObjInp ) {
3232  THROW( SYS_INTERNAL_NULL_INPUT_ERR, "null dataObjInp passed in" );
3233  }
3234  if ( const char* serialized_acl = getValByKey( &dataObjInp->condInput, ACL_INCLUDED_KW ) ) {
3235  std::vector<std::vector<std::string> > deserialized_acl = irods::deserialize_acl( serialized_acl );
3236  for ( std::vector<std::vector<std::string> >::const_iterator iter = deserialized_acl.begin(); iter != deserialized_acl.end(); ++iter ) {
3237  modAccessControlInp_t modAccessControlInp;
3238  modAccessControlInp.recursiveFlag = 0;
3239  modAccessControlInp.accessLevel = strdup( ( *iter )[0].c_str() );
3240  modAccessControlInp.userName = ( char * )malloc( sizeof( char ) * NAME_LEN );
3241  modAccessControlInp.zone = ( char * )malloc( sizeof( char ) * NAME_LEN );
3242  const int status_parseUserName = parseUserName( ( *iter )[1].c_str(), modAccessControlInp.userName, modAccessControlInp.zone );
3243  if ( status_parseUserName < 0 ) {
3244  THROW( status_parseUserName, "parseUserName failed" );
3245  }
3246  modAccessControlInp.path = strdup( dataObjInp->objPath );
3247  int status = rsModAccessControl( rsComm, &modAccessControlInp );
3248  clearModAccessControlInp( &modAccessControlInp );
3249  if ( status < 0 ) {
3250  THROW( status, "rsModAccessControl failed" );
3251  }
3252  }
3253  }
3254 }
msgHeader::errorLen
int errorLen
Definition: rodsDef.h:213
RBUDP_SEND_RATE_KW
#define RBUDP_SEND_RATE_KW
Definition: rodsKeyWdDef.h:78
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
getValByKey
char * getValByKey(const keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:675
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
LOCAL_ICAT
#define LOCAL_ICAT
Definition: rodsConnect.h:52
OpenedDataObjInp
Definition: dataObjInpOut.h:104
L1desc
l1desc_t L1desc[1026]
Definition: irods_server_globals.cpp:29
dataObjRead.h
msgHeader::bsLen
int bsLen
Definition: rodsDef.h:214
irods::CLIENT_USER_PRIV_KW
const std::string CLIENT_USER_PRIV_KW("client_user_priv")
NULL
#define NULL
Definition: rodsDef.h:70
irods::get_server_property
T & get_server_property(const std::string &_prop)
Definition: irods_server_properties.hpp:118
zoneInfo::masterServerHost
rodsServerHost_t * masterServerHost
Definition: rodsConnect.h:77
RECONNECT_ENV
#define RECONNECT_ENV
Definition: sockComm.h:27
forkAndExec
int forkAndExec(char *av[])
Definition: miscServerFunct.cpp:2456
irods::buffer_crypt::decrypt
irods::error decrypt(const array_t &, const array_t &, const array_t &, array_t &)
Definition: irods_buffer_encryption.cpp:260
rsComm_t
Definition: rcConnect.h:145
applyMetadataFromKVP
void applyMetadataFromKVP(rsComm_t *rsComm, dataObjInp_t *dataObjInp)
Definition: miscServerFunct.cpp:3199
leaf_bundle_t
irods::resource_manager::leaf_bundle_t leaf_bundle_t
Definition: db_plugin.cpp:54
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
myRead
int myRead(int sock, void *buf, int len, int *bytesRead, struct timeval *tv)
Definition: rcMisc.cpp:4651
SYS_INTERNAL_NULL_INPUT_ERR
@ SYS_INTERNAL_NULL_INPUT_ERR
Definition: rodsErrorTable.h:92
rodsServerHost::localFlag
int localFlag
Definition: rodsConnect.h:68
DataOprInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:134
msgHeader
Definition: rodsDef.h:210
remLocCopy
int remLocCopy(rsComm_t *rsComm, dataCopyInp_t *dataCopyInp)
Definition: miscServerFunct.cpp:1321
modAVUMetadataInp_t::arg0
char * arg0
Definition: modAVUMetadata.h:7
SYS_USER_NO_PERMISSION
@ SYS_USER_NO_PERMISSION
Definition: rodsErrorTable.h:186
changeToUser
int changeToUser(uid_t uid)
Definition: miscServerFunct.cpp:2931
rErrMsg_t
Definition: rodsError.h:19
irods::buffer_crypt::array_t
std::vector< unsigned char > array_t
Definition: irods_buffer_encryption.hpp:30
irods_server_properties.hpp
THROW
#define THROW(_code, _msg)
Definition: irods_exception.hpp:68
readMsgBody
irods::error readMsgBody(irods::network_object_ptr, msgHeader_t *, bytesBuf_t *, bytesBuf_t *, bytesBuf_t *, irodsProt_t, struct timeval *)
Definition: sockComm.cpp:236
RODS_HEARTBEAT_T
#define RODS_HEARTBEAT_T
Definition: rodsDef.h:224
rcvTranHeader
int rcvTranHeader(int sock, transferHeader_t *myHeader)
Definition: rcPortalOpr.cpp:65
portalOprOut
Definition: dataObjInpOut.h:114
rsDataObjWrite.hpp
RODS_FORK
#define RODS_FORK()
Definition: rodsDef.h:339
BytesBuf::buf
void * buf
Definition: rodsDef.h:199
rsDataObjOpen.hpp
reconnMsg
Definition: rcConnect.h:49
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
irods::CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS
const std::string CFG_TRANS_BUFFER_SIZE_FOR_PARA_TRANS("transfer_buffer_size_for_parallel_transfer_in_megabytes")
rbudpRemLocCopy
int rbudpRemLocCopy(dataCopyInp_t *dataCopyInp)
Definition: miscServerFunct.cpp:1260
irods::get_irods_home_directory
boost::filesystem::path get_irods_home_directory()
Definition: irods_default_paths.cpp:36
SENDING_STATE
@ SENDING_STATE
Definition: rcConnect.h:44
irods::CLIENT_USER_NAME_KW
const std::string CLIENT_USER_NAME_KW("client_user_name")
setRECacheSaltFromEnv
irods::error setRECacheSaltFromEnv()
Definition: miscServerFunct.cpp:3021
PortalTransferInp::bytesWritten
rodsLong_t bytesWritten
Definition: miscServerFunct.hpp:37
userInfo_t::userName
char userName[64]
Definition: rodsUser.h:66
remToLocPartialCopy
void remToLocPartialCopy(portalTransferInp_t *myInput)
Definition: miscServerFunct.cpp:1069
LOG_SYS_FATAL
#define LOG_SYS_FATAL
Definition: rodsLog.h:55
rodsServerHost::rcatEnabled
int rcatEnabled
Definition: rodsConnect.h:65
modAccessControlInp_t::userName
char * userName
Definition: modAccessControl.h:12
longNoSupport
rodsLong_t longNoSupport(...)
Definition: miscServerFunct.cpp:2015
RBUDP_TRANSFER_KW
#define RBUDP_TRANSFER_KW
Definition: rodsKeyWdDef.h:76
irods_stacktrace.hpp
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
msgHeader::type
char type[128]
Definition: rodsDef.h:211
MAX_RECON_ERROR_CNT
#define MAX_RECON_ERROR_CNT
Definition: miscServerFunct.hpp:26
CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME
@ CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME
Definition: rodsErrorTable.h:424
PortalOpr::dataOprInp
dataOprInp_t dataOprInp
Definition: dataObjInpOut.h:199
OpenedDataObjInp::l1descInx
int l1descInx
Definition: dataObjInpOut.h:105
rsComm_t::connectCnt
int connectCnt
Definition: rcConnect.h:148
irods::CFG_TRANS_CHUNK_SIZE_PARA_TRANS
const std::string CFG_TRANS_CHUNK_SIZE_PARA_TRANS("transfer_chunk_size_for_parallel_transfer_in_megabytes")
thread_context::cond
boost::condition_variable * cond
Definition: irods_threads.hpp:13
sockOpenForInConn
int sockOpenForInConn(rsComm_t *rsComm, int *portNum, char **addr, int proto)
Definition: sockComm.cpp:289
SYS_GETENV_ERR
@ SYS_GETENV_ERR
Definition: rodsErrorTable.h:210
rodsEnv::rodsZone
char rodsZone[64]
Definition: getRodsEnv.h:18
irods::PROXY_USER_NAME_KW
const std::string PROXY_USER_NAME_KW("proxy_user_name")
irods_exception.hpp
DataOprInp::srcL3descInx
int srcL3descInx
Definition: dataObjInpOut.h:125
PortalTransferInp::shared_secret
char shared_secret[64]
Definition: miscServerFunct.hpp:46
rErrMsg_t::status
int status
Definition: rodsError.h:20
sendReconnMsg
irods::error sendReconnMsg(irods::network_object_ptr, reconnMsg_t *)
Definition: sockComm.cpp:1366
applyACLFromKVP
void applyACLFromKVP(rsComm_t *rsComm, dataObjInp_t *dataObjInp)
Definition: miscServerFunct.cpp:3227
modAVUMetadataInp_t::arg2
char * arg2
Definition: modAVUMetadata.h:9
generate_iadmin_commands_for_41_to_42_upgrade.output
output
Definition: generate_iadmin_commands_for_41_to_42_upgrade.py:21
XML_PROT
@ XML_PROT
Definition: rodsDef.h:149
modAccessControl.h
RODS_CONNECT_T
#define RODS_CONNECT_T
Definition: rodsDef.h:223
rcMisc.h
irods::CFG_PLUGIN_CONFIGURATION_KW
const std::string CFG_PLUGIN_CONFIGURATION_KW("plugin_configuration")
singleL1Copy
int singleL1Copy(rsComm_t *rsComm, dataCopyInp_t *dataCopyInp)
Definition: miscServerFunct.cpp:2641
rcConnect.h
rsComm_t::salt_size
int salt_size
Definition: rcConnect.h:189
SP_RE_CACHE_SALT
#define SP_RE_CACHE_SALT
Definition: rodsDef.h:266
irods_threads.hpp
rsComm_t::windowSize
int windowSize
Definition: rcConnect.h:163
DataOprInp::numThreads
int numThreads
Definition: dataObjInpOut.h:124
PUT_OPR
#define PUT_OPR
Definition: dataObjInpOut.h:167
setupSrvPortalForParaOpr
int setupSrvPortalForParaOpr(rsComm_t *rsComm, dataOprInp_t *dataOprInp, int oprType, portalOprOut_t **portalOprOut)
Definition: miscServerFunct.cpp:138
irods_default_paths.hpp
LONG_NAME_LEN
#define LONG_NAME_LEN
Definition: rodsDef.h:57
readReconMsg
irods::error readReconMsg(irods::network_object_ptr, reconnMsg_t **)
Definition: sockComm.cpp:1276
modAccessControlInp_t::accessLevel
char * accessLevel
Definition: modAccessControl.h:11
getUdpPortFromPortList
int getUdpPortFromPortList(portList_t *thisPortList)
Definition: sockComm.cpp:1475
svrToSvrConnect
int svrToSvrConnect(rsComm_t *rsComm, rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:106
ServiceUid
uid_t ServiceUid
Definition: irods_server_globals.cpp:70
rodsSetSockOpt
int rodsSetSockOpt(int sock, int tcp_buffer_size)
Definition: sockComm.cpp:598
addUdpSockToPortList
int addUdpSockToPortList(portList_t *thisPortList, int udpsock)
Definition: sockComm.cpp:1487
SELECT_TIMEOUT_FOR_CONN
#define SELECT_TIMEOUT_FOR_CONN
Definition: rodsDef.h:106
locToRemPartialCopy
void locToRemPartialCopy(portalTransferInp_t *myInput)
Definition: miscServerFunct.cpp:1740
dropRootPrivilege
int dropRootPrivilege()
Definition: miscServerFunct.cpp:2962
dataObjLseek.h
irods::PLUGIN_TYPE_RULE_ENGINE
const std::string PLUGIN_TYPE_RULE_ENGINE("rule_engines")
zoneInfo::zoneName
char zoneName[64]
Definition: rodsConnect.h:75
initServiceUser
int initServiceUser()
Definition: miscServerFunct.cpp:2821
DataCopyInp
Definition: dataCopy.h:7
SYS_PORT_COOKIE_ERR
@ SYS_PORT_COOKIE_ERR
Definition: rodsErrorTable.h:96
rsComm_t::num_hash_rounds
int num_hash_rounds
Definition: rcConnect.h:190
unpackStruct
int unpackStruct(const void *inPackStr, void **outStruct, const char *packInstName, const packInstruct_t *myPackTable, irodsProt_t irodsProt)
Definition: packStruct.cpp:63
rsComm_t::thread_ctx
struct thread_context * thread_ctx
Definition: rcConnect.h:171
STREAMING_KW
#define STREAMING_KW
Definition: rodsKeyWdDef.h:47
isUserPrivileged
int isUserPrivileged(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:1995
changeToServiceUser
int changeToServiceUser()
Definition: miscServerFunct.cpp:2899
readMsgHeader
irods::error readMsgHeader(irods::network_object_ptr, msgHeader_t *, struct timeval *)
Definition: sockComm.cpp:173
list_rule_plugin_instances
irods::error list_rule_plugin_instances(std::vector< std::string > &_instance_names)
Definition: miscServerFunct.cpp:3181
MAX_NUM_CONFIG_TRAN_THR
#define MAX_NUM_CONFIG_TRAN_THR
Definition: rodsDef.h:96
changeToRootUser
int changeToRootUser()
Definition: miscServerFunct.cpp:2871
rcGlobalExtern.h
rsComm_t::reconnectedSock
int reconnectedSock
Definition: rcConnect.h:167
modAVUMetadataInp_t::arg4
char * arg4
Definition: modAVUMetadata.h:11
getLocalSvrAddr
char * getLocalSvrAddr()
Definition: miscServerFunct.cpp:2397
svrSockOpenForInConn
int svrSockOpenForInConn(rsComm_t *rsComm, int *portNum, char **addr, int proto)
Definition: miscServerFunct.cpp:2368
PortalTransferInp::status
int status
Definition: miscServerFunct.hpp:39
SYS_SOCK_ACCEPT_ERR
@ SYS_SOCK_ACCEPT_ERR
Definition: rodsErrorTable.h:71
rsComm_t::clientState
procState_t clientState
Definition: rcConnect.h:174
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
portalOprOut::status
int status
Definition: dataObjInpOut.h:115
rsComm_t::cookie
int cookie
Definition: rcConnect.h:169
modAccessControlInp_t
Definition: modAccessControl.h:9
ZoneInfoHead
zoneInfo_t * ZoneInfoHead
Definition: irods_server_globals.cpp:23
sameHostPartialCopy
void sameHostPartialCopy(portalTransferInp_t *myInput)
Definition: miscServerFunct.cpp:1625
rodsConnect.h
connectToRhostPortal
int connectToRhostPortal(char *rodsHost, int rodsPort, int cookie, int windowSize)
Definition: sockComm.cpp:655
MAX_PASSWORD_LEN
#define MAX_PASSWORD_LEN
Definition: authenticate.h:9
SYS_HEADER_TYPE_LEN_ERR
@ SYS_HEADER_TYPE_LEN_ERR
Definition: rodsErrorTable.h:74
localSID
char localSID[50]
Definition: irods_server_globals.cpp:58
LocalServerHost
rodsServerHost_t * LocalServerHost
Definition: irods_server_globals.cpp:20
GET_OPR
#define GET_OPR
Definition: dataObjInpOut.h:168
createSrvPortal
int createSrvPortal(rsComm_t *rsComm, portList_t *thisPortList, int proto)
Definition: miscServerFunct.cpp:214
acceptSrvPortal
int acceptSrvPortal(rsComm_t *rsComm, portList_t *thisPortList)
Definition: miscServerFunct.cpp:283
rsModAVUMetadata.hpp
rodsEnv::rodsUserName
char rodsUserName[64]
Definition: getRodsEnv.h:9
ProcessType
int ProcessType
Definition: rcGlobal.cpp:16
applyRuleForSvrPortal
int applyRuleForSvrPortal(int sockFd, int oprType, int preOrPost, int load, rsComm_t *rsComm)
Definition: miscServerFunct.cpp:342
RuleExecInfo::rsComm
rsComm_t * rsComm
Definition: irods_re_structs.hpp:22
BytesBuf::len
int len
Definition: rodsDef.h:198
irods::deserialize_acl
std::vector< std::vector< std::string > > deserialize_acl(const std::string &acl)
Definition: irods_serialization.cpp:332
portList_t::portNum
int portNum
Definition: dataObjInpOut.h:30
rsComm_t::myEnv
rodsEnv myEnv
Definition: rcConnect.h:154
PortalTransferInp::encryption_algorithm
char encryption_algorithm[64]
Definition: miscServerFunct.hpp:45
portList_t::windowSize
int windowSize
Definition: dataObjInpOut.h:33
getUdpSockFromPortList
int getUdpSockFromPortList(portList_t *thisPortList)
Definition: sockComm.cpp:1494
partialDataGet
void partialDataGet(portalTransferInp_t *myInput)
Definition: miscServerFunct.cpp:828
irods_serialization.hpp
RECONN_TIMEOUT
#define RECONN_TIMEOUT
Definition: rcConnect.h:36
PortalTransferInp::threadNum
int threadNum
Definition: miscServerFunct.hpp:34
msgHeader::msgLen
int msgLen
Definition: rodsDef.h:212
mySockClose
int mySockClose(int sock)
Definition: sockComm.cpp:1573
SYS_NOT_SUPPORTED
@ SYS_NOT_SUPPORTED
Definition: rodsErrorTable.h:133
svrChkReconnAtSendEnd
int svrChkReconnAtSendEnd(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:2320
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
irods_network_factory.hpp
hostName::next
struct hostName * next
Definition: rodsConnect.h:39
SYS_HEADER_READ_LEN_ERR
@ SYS_HEADER_READ_LEN_ERR
Definition: rodsErrorTable.h:72
rsGlobalExtern.hpp
PROCESSING_STATE
@ PROCESSING_STATE
Definition: rcConnect.h:42
__loc1
char * __loc1
Definition: miscServerFunct.cpp:45
rsComm_t::reconnSock
int reconnSock
Definition: rcConnect.h:165
_l3Close
int _l3Close(rsComm_t *rsComm, int l3descInx)
Definition: rsDataObjClose.cpp:756
RESC_HIER_STR_KW
#define RESC_HIER_STR_KW
Definition: rodsKeyWdDef.h:225
irods::CLIENT_USER_ZONE_KW
const std::string CLIENT_USER_ZONE_KW("client_user_zone")
irods_buffer_encryption.hpp
PortalTransferInp::key_size
int key_size
Definition: miscServerFunct.hpp:42
irods::deserialize_metadata
std::vector< std::string > deserialize_metadata(const std::string &metadata)
Definition: irods_serialization.cpp:313
getNumThreads
int getNumThreads(rsComm_t *rsComm, rodsLong_t dataSize, int inpNumThr, keyValPair_t *condInput, char *destRescName, char *srcRescName, int oprType)
Definition: objDesc.cpp:279
irods::network_factory
irods::error network_factory(rcComm_t *, irods::network_object_ptr &)
Definition: irods_network_factory.cpp:8
_l3Read
int _l3Read(rsComm_t *rsComm, int l3descInx, void *buf, int len)
Definition: rsDataObjRead.cpp:151
PortalOpr
Definition: dataObjInpOut.h:197
RECEIVING_STATE
@ RECEIVING_STATE
Definition: rcConnect.h:43
SYS_SOCK_READ_ERR
@ SYS_SOCK_READ_ERR
Definition: rodsErrorTable.h:181
TransferHeader
Definition: dataObjInpOut.h:208
SYS_COPY_LEN_ERR
@ SYS_COPY_LEN_ERR
Definition: rodsErrorTable.h:95
EXEC_CMD_ERROR
@ EXEC_CMD_ERROR
Definition: rodsErrorTable.h:265
PortalOpr::portList
portList_t portList
Definition: dataObjInpOut.h:200
hostName
Definition: rodsConnect.h:37
rsComm_t::proxyUser
userInfo_t proxyUser
Definition: rcConnect.h:152
SYS_SVR_TO_SVR_CONNECT_FAILED
@ SYS_SVR_TO_SVR_CONNECT_FAILED
Definition: rodsErrorTable.h:90
get_canonical_name
int get_canonical_name(const char *_hostname, char *_buf, size_t _len)
Definition: rcMisc.cpp:4580
myWrite
int myWrite(int sock, void *buf, int len, int *bytesWritten)
Definition: rcMisc.cpp:4610
modAccessControlInp_t::path
char * path
Definition: modAccessControl.h:14
rsDataObjWrite
int rsDataObjWrite(rsComm_t *rsComm, openedDataObjInp_t *dataObjWriteInp, bytesBuf_t *dataObjWriteInpBBuf)
Definition: rsDataObjWrite.cpp:68
CAT_INSUFFICIENT_PRIVILEGE_LEVEL
@ CAT_INSUFFICIENT_PRIVILEGE_LEVEL
Definition: rodsErrorTable.h:445
OpenedDataObjInp::len
int len
Definition: dataObjInpOut.h:106
rsComm_t::negotiation_results
char negotiation_results[(1024+64)]
Definition: rcConnect.h:185
SYS_UDP_TRANSFER_ERR
@ SYS_UDP_TRANSFER_ERR
Definition: rodsErrorTable.h:154
irods::experimental::filesystem::client::copy
auto copy(rcComm_t &_comm, const path &_from, const path &_to, copy_options _options=copy_options::none) -> void
Definition: filesystem.cpp:370
NO_CHK_COPY_LEN_FLAG
#define NO_CHK_COPY_LEN_FLAG
Definition: dataObjInpOut.h:206
reconnManager
void reconnManager(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:2173
VERY_VERBOSE_KW
#define VERY_VERBOSE_KW
Definition: rodsKeyWdDef.h:77
hostName::name
char * name
Definition: rodsConnect.h:38
irods::CS_NEG_USE_SSL
const std::string CS_NEG_USE_SSL("CS_NEG_USE_SSL")
applyRuleArg
int applyRuleArg(const char *action, const char *args[20], int argc, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:95
ACL_INCLUDED_KW
#define ACL_INCLUDED_KW
Definition: rodsKeyWdDef.h:35
DataObjInp
Definition: dataObjInpOut.h:65
rsDataObjClose.hpp
genQuery.h
PortalTransferInp::destFd
int destFd
Definition: miscServerFunct.hpp:30
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
PortalTransferInp::srcFd
int srcFd
Definition: miscServerFunct.hpp:31
terminate_irods_processes.e
e
Definition: terminate_irods_processes.py:19
zoneInfo::next
struct zoneInfo * next
Definition: rodsConnect.h:79
RBUDP_PACK_SIZE_KW
#define RBUDP_PACK_SIZE_KW
Definition: rodsKeyWdDef.h:79
SYS_SOCK_LISTEN_ERR
@ SYS_SOCK_LISTEN_ERR
Definition: rodsErrorTable.h:69
irods::resource_manager::leaf_bundle_t
std::vector< rodsLong_t > leaf_bundle_t
Definition: irods_resource_manager.hpp:84
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
irods::CFG_INSTANCE_NAME_KW
const std::string CFG_INSTANCE_NAME_KW("instance_name")
irods::buffer_crypt
Definition: irods_buffer_encryption.hpp:25
rsComm_t::reconnPort
int reconnPort
Definition: rcConnect.h:166
putFileToPortalRbudp
int putFileToPortalRbudp(portalOprOut_t *portalOprOut, char *locFilePath, int locFd, int veryVerbose, int sendRate, int packetSize)
Definition: rcPortalOpr.cpp:1210
SYS_FORK_ERROR
@ SYS_FORK_ERROR
Definition: rodsErrorTable.h:116
singleRemLocCopy
int singleRemLocCopy(rsComm_t *rsComm, dataCopyInp_t *dataCopyInp)
Definition: miscServerFunct.cpp:2489
COPY_TO_LOCAL_OPR
#define COPY_TO_LOCAL_OPR
Definition: dataObjInpOut.h:170
INVALID_ANY_CAST
@ INVALID_ANY_CAST
Definition: rodsErrorTable.h:771
KEY_NOT_FOUND
@ KEY_NOT_FOUND
Definition: rodsErrorTable.h:749
getFileToPortalRbudp
int getFileToPortalRbudp(portalOprOut_t *portalOprOut, char *locFilePath, int locFd, int veryVerbose, int packetSize)
Definition: rcPortalOpr.cpp:1281
DONE_OPR
#define DONE_OPR
Definition: dataObjInpOut.h:166
CONN_WAIT_STATE
@ CONN_WAIT_STATE
Definition: rcConnect.h:45
portalOprOut::portList
portList_t portList
Definition: dataObjInpOut.h:119
modAVUMetadataInp_t::arg3
char * arg3
Definition: modAVUMetadata.h:10
portList_t
Definition: dataObjInpOut.h:29
LOCAL_PRIV_USER_AUTH
#define LOCAL_PRIV_USER_AUTH
Definition: rodsUser.h:36
irods::buffer_crypt::initialization_vector
irods::error initialization_vector(array_t &)
Definition: irods_buffer_encryption.cpp:134
rsComm_t::reconnThrState
procState_t reconnThrState
Definition: rcConnect.h:175
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
add_global_re_params_to_kvp_for_dynpep
irods::error add_global_re_params_to_kvp_for_dynpep(keyValPair_t &_kvp)
Definition: miscServerFunct.cpp:3100
l1desc::srcL1descInx
int srcL1descInx
Definition: objDesc.hpp:50
CLIENT_PT
#define CLIENT_PT
Definition: rodsDef.h:77
dataObjWrite.h
userInfo_t::rodsZone
char rodsZone[64]
Definition: rodsUser.h:67
getTcpSockFromPortList
int getTcpSockFromPortList(portList_t *thisPortList)
Definition: sockComm.cpp:1501
PortalTransferInp
Definition: miscServerFunct.hpp:28
rsComm_t::key_size
int key_size
Definition: rcConnect.h:188
remote_SID_key_map
irods::lookup_table< std::pair< std::string, std::string > > remote_SID_key_map
Definition: irods_server_globals.cpp:59
svrPortalPutGet
int svrPortalPutGet(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:389
svrSwitchConnect
int svrSwitchConnect(rsComm_t *rsComm)
Definition: sockComm.cpp:1408
irods::buffer_crypt::encrypt
irods::error encrypt(const array_t &, const array_t &, const array_t &, array_t &)
Definition: irods_buffer_encryption.cpp:168
irods::log
void log(const error &)
Definition: irods_log.cpp:13
rsModAVUMetadata
int rsModAVUMetadata(rsComm_t *rsComm, modAVUMetadataInp_t *modAVUMetadataInp)
Definition: rsModAVUMetadata.cpp:13
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
rsComm_t::shared_secret
unsigned char shared_secret[64]
Definition: rcConnect.h:186
modAVUMetadataInp_t
Definition: modAVUMetadata.h:6
reconnMsg::cookie
int cookie
Definition: rcConnect.h:51
isLoopbackAddress
int isLoopbackAddress(const char *ip_address)
Definition: rcConnect.cpp:620
rsComm_t::clientUser
userInfo_t clientUser
Definition: rcConnect.h:153
rcPortalOpr.h
dataObjClose.h
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
rsComm_t::portalOpr
portalOpr_t * portalOpr
Definition: rcConnect.h:159
svrPortalPutGetRbudp
int svrPortalPutGetRbudp(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:2020
RodsPackTable
const packInstruct_t RodsPackTable[]
Definition: rodsPackTable.h:61
BytesBuf
Definition: rodsDef.h:197
rsComm_t::agentState
procState_t agentState
Definition: rcConnect.h:173
irods::error
Definition: irods_error.hpp:23
FILE_READ_ERR
@ FILE_READ_ERR
Definition: rodsErrorTable.h:495
SYS_INVALID_PROTOCOL_TYPE
@ SYS_INVALID_PROTOCOL_TYPE
Definition: rodsErrorTable.h:152
miscServerFunct.hpp
_l3Lseek
rodsLong_t _l3Lseek(rsComm_t *rsComm, int l3descInx, rodsLong_t offset, int whence)
Definition: rsDataObjLseek.cpp:102
int
typedef int((*funcPtr)())
portalOprOut::l1descInx
int l1descInx
Definition: dataObjInpOut.h:116
getLocalZoneName
char * getLocalZoneName()
Definition: rodsConnect.cpp:685
irods_lexical_cast.hpp
TransferHeader::offset
rodsLong_t offset
Definition: dataObjInpOut.h:211
CLOSE_SOCK
#define CLOSE_SOCK
Definition: sockComm.h:36
intNoSupport
int intNoSupport(...)
Definition: miscServerFunct.cpp:2010
svrToSvrConnectNoLogin
int svrToSvrConnectNoLogin(rsComm_t *rsComm, rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:74
get_default_rule_plugin_instance
irods::error get_default_rule_plugin_instance(std::string &_instance_name)
Definition: miscServerFunct.cpp:3165
_l3Write
int _l3Write(rsComm_t *rsComm, int l3descInx, void *buf, int len)
Definition: rsDataObjWrite.cpp:189
STREAMING_FLAG
#define STREAMING_FLAG
Definition: dataObjInpOut.h:205
svrChkReconnAtReadStart
int svrChkReconnAtReadStart(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:2334
irods::CFG_CATALOG_SERVICE_ROLE
const std::string CFG_CATALOG_SERVICE_ROLE("catalog_service_role")
NO_CHK_COPY_LEN_KW
#define NO_CHK_COPY_LEN_KW
Definition: rodsKeyWdDef.h:108
ServiceGid
gid_t ServiceGid
Definition: irods_server_globals.cpp:71
PortalTransferInp::size
rodsLong_t size
Definition: miscServerFunct.hpp:35
SYS_SOCK_SELECT_ERR
@ SYS_SOCK_SELECT_ERR
Definition: rodsErrorTable.h:212
fillPortalTransferInp
int fillPortalTransferInp(portalTransferInp_t *myInput, rsComm_t *rsComm, int srcFd, int destFd, int srcRescTypeInx, int destRescTypeInx, int threadNum, rodsLong_t size, rodsLong_t offset, int flags)
Definition: miscServerFunct.cpp:553
PortalTransferInp::destRescTypeInx
int destRescTypeInx
Definition: miscServerFunct.hpp:32
FileDesc
fileDesc_t FileDesc[1026]
Definition: irods_server_globals.cpp:28
DataCopyInp::portalOprOut
portalOprOut_t portalOprOut
Definition: dataCopy.h:9
PortalTransferInp::offset
rodsLong_t offset
Definition: miscServerFunct.hpp:36
irods_hierarchy_parser.hpp
TransferHeader::length
rodsLong_t length
Definition: dataObjInpOut.h:212
sameHostCopy
int sameHostCopy(rsComm_t *rsComm, dataCopyInp_t *dataCopyInp)
Definition: miscServerFunct.cpp:1496
checkModArgType
int checkModArgType(const char *arg)
Definition: miscServerFunct.cpp:3002
l3OpenByHost
int l3OpenByHost(rsComm_t *rsComm, int l3descInx, int flags)
Definition: rsDataObjOpen.cpp:523
reconnMsg::procState
procState_t procState
Definition: rcConnect.h:52
rsDataObjRead.hpp
clearModAccessControlInp
void clearModAccessControlInp(void *)
Definition: rcMisc.cpp:3505
rsDataObjLseek.hpp
get_catalog_service_role
irods::error get_catalog_service_role(std::string &_role)
Definition: miscServerFunct.cpp:3153
rodsServerHost
Definition: rodsConnect.h:62
DataOprInp::offset
rodsLong_t offset
Definition: dataObjInpOut.h:132
DataOprInp::srcRescTypeInx
int srcRescTypeInx
Definition: dataObjInpOut.h:127
PortalTransferInp::srcRescTypeInx
int srcRescTypeInx
Definition: miscServerFunct.hpp:33
portList_t::sock
int sock
Definition: dataObjInpOut.h:32
irods::network_object_ptr
boost::shared_ptr< network_object > network_object_ptr
Definition: irods_network_object.hpp:78
irods::buffer_crypt::key_size
int key_size()
Definition: irods_buffer_encryption.hpp:77
irods::CFG_SERVER_PORT_RANGE_START_KW
const std::string CFG_SERVER_PORT_RANGE_START_KW("server_port_range_start")
SYS_INVALID_PORTAL_OPR
@ SYS_INVALID_PORTAL_OPR
Definition: rodsErrorTable.h:101
rsDataObjRead
int rsDataObjRead(rsComm_t *rsComm, openedDataObjInp_t *dataObjReadInp, bytesBuf_t *dataObjReadOutBBuf)
Definition: rsDataObjRead.cpp:65
error
int error
Definition: filesystem.cpp:101
RuleExecInfo
Definition: irods_re_structs.hpp:18
modAVUMetadata.h
portalOprOut::numThreads
int numThreads
Definition: dataObjInpOut.h:117
DataOprInp
Definition: dataObjInpOut.h:122
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
modAccessControlInp_t::recursiveFlag
int recursiveFlag
Definition: modAccessControl.h:10
DataOprInp::destL3descInx
int destL3descInx
Definition: dataObjInpOut.h:126
irods_resource_manager.hpp
modAccessControlInp_t::zone
char * zone
Definition: modAccessControl.h:13
rodsServerHost::zoneInfo
void * zoneInfo
Definition: rodsConnect.h:70
startupPack
Definition: rodsDef.h:234
PortalTransferInp::num_hash_rounds
int num_hash_rounds
Definition: miscServerFunct.hpp:44
irods::exception
Definition: irods_exception.hpp:15
PortalTransferInp::rsComm
rsComm_t * rsComm
Definition: miscServerFunct.hpp:29
CAT_INVALID_ARGUMENT
@ CAT_INVALID_ARGUMENT
Definition: rodsErrorTable.h:431
DataCopyInp::dataOprInp
dataOprInp_t dataOprInp
Definition: dataCopy.h:8
irods::CFG_SERVER_PORT_RANGE_END_KW
const std::string CFG_SERVER_PORT_RANGE_END_KW("server_port_range_end")
setLocalSrvAddr
int setLocalSrvAddr(char *outLocalAddr)
Definition: miscServerFunct.cpp:2437
sockComm.h
addUdpPortToPortList
int addUdpPortToPortList(portList_t *thisPortList, int udpport)
Definition: sockComm.cpp:1468
isServiceUserSet
int isServiceUserSet()
Definition: miscServerFunct.cpp:2858
dataObjOpen.h
_getSvrAddr
char * _getSvrAddr(rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:2404
irods::CFG_RE_CACHE_SALT_KW
const std::string CFG_RE_CACHE_SALT_KW("reCacheSalt")
_rcConnect
rcComm_t * _rcConnect(const char *rodsHost, int rodsPort, const char *proxyUserName, const char *proxyRodsZone, const char *clientUserName, const char *clientRodsZone, rErrMsg_t *errMsg, int connectCnt, int reconnFlag)
Definition: rcConnect.cpp:54
size
long long size
Definition: filesystem.cpp:102
rsGenQuery.hpp
irods_random.hpp
DataOprInp::oprType
int oprType
Definition: dataObjInpOut.h:123
userInfo_t::authInfo
authInfo_t authInfo
Definition: rodsUser.h:70
rodsServerHost::hostName
hostName_t * hostName
Definition: rodsConnect.h:63
readStartupPack
irods::error readStartupPack(irods::network_object_ptr _ptr, startupPack_t **startupPack, struct timeval *tv)
Definition: miscServerFunct.cpp:2716
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
dataObjOpr.hpp
clientLogin
int clientLogin(rcComm_t *conn, const char *_context, const char *_scheme_override)
Definition: clientLogin.cpp:222
getTcpPortFromPortList
int getTcpPortFromPortList(portList_t *thisPortList)
Definition: sockComm.cpp:1482
getZoneServerId
void getZoneServerId(char *zoneName, char *zoneSID)
Definition: miscServerFunct.cpp:1945
irods::PROXY_USER_PRIV_KW
const std::string PROXY_USER_PRIV_KW("proxy_user_priv")
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
get_script_output_single_line
irods::error get_script_output_single_line(const std::string &script_language, const std::string &script_name, const std::vector< std::string > &args, std::string &output)
Definition: miscServerFunct.cpp:3046
modAVUMetadataInp_t::arg5
char * arg5
Definition: modAVUMetadata.h:12
SYS_USER_RETRIEVE_ERR
@ SYS_USER_RETRIEVE_ERR
Definition: rodsErrorTable.h:187
rsComm_t::encryption_algorithm
char encryption_algorithm[64]
Definition: rcConnect.h:191
zoneInfo
Definition: rodsConnect.h:74
PortalTransferInp::salt_size
int salt_size
Definition: miscServerFunct.hpp:43
METADATA_INCLUDED_KW
#define METADATA_INCLUDED_KW
Definition: rodsKeyWdDef.h:34
portList_t::cookie
int cookie
Definition: dataObjInpOut.h:31
clearBBuf
int clearBBuf(bytesBuf_t *myBBuf)
Definition: rcMisc.cpp:101
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
KeyValPair
Definition: objInfo.h:120
authInfo_t::authFlag
int authFlag
Definition: rodsUser.h:42
irods::PROXY_USER_ZONE_KW
const std::string PROXY_USER_ZONE_KW("proxy_user_zone")
CODE
#define CODE(code_)
Definition: irods_error.hpp:120
sockCommNetworkInterface.hpp
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
clearModAVUMetadataInp
void clearModAVUMetadataInp(void *voidInp)
Definition: rcMisc.cpp:3516
buf
static char buf[64+50+1]
Definition: rsAuthRequest.cpp:21
NO_RECONN
#define NO_RECONN
Definition: rcConnect.h:34
parseUserName
int parseUserName(const char *fullUserNameIn, char *userName, char *userZone)
Definition: rcMisc.cpp:204
singleRemToLocCopy
int singleRemToLocCopy(rsComm_t *rsComm, dataCopyInp_t *dataCopyInp)
Definition: miscServerFunct.cpp:2512
PortalTransferInp::flags
int flags
Definition: miscServerFunct.hpp:38
rsModAccessControl.hpp
rsModAccessControl
int rsModAccessControl(rsComm_t *rsComm, modAccessControlInp_t *modAccessControlInp)
Definition: rsModAccessControl.cpp:14
svrChkReconnAtSendStart
int svrChkReconnAtSendStart(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:2300
DataOprInp::dataSize
rodsLong_t dataSize
Definition: dataObjInpOut.h:133
thread_context::lock
boost::mutex * lock
Definition: irods_threads.hpp:12
TransferHeader::oprType
int oprType
Definition: dataObjInpOut.h:209
SYS_UDP_CONNECT_ERR
@ SYS_UDP_CONNECT_ERR
Definition: rodsErrorTable.h:153
irods::error::result
std::string result() const
Definition: irods_error.cpp:201
portList_t::hostAddr
char hostAddr[256]
Definition: dataObjInpOut.h:34
DataOprInp::destRescTypeInx
int destRescTypeInx
Definition: dataObjInpOut.h:128
irods_client_server_negotiation.hpp
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32
partialDataPut
void partialDataPut(portalTransferInp_t *myInput)
Definition: miscServerFunct.cpp:600
PortalOpr::oprType
int oprType
Definition: dataObjInpOut.h:198
sendTranHeader
int sendTranHeader(int sock, int oprType, int flags, rodsLong_t offset, rodsLong_t length)
Definition: rcPortalOpr.cpp:36
svrChkReconnAtReadEnd
int svrChkReconnAtReadEnd(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:2354
getSvrAddr
char * getSvrAddr(rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:2425
USER__NULL_INPUT_ERR
@ USER__NULL_INPUT_ERR
Definition: rodsErrorTable.h:247
modAVUMetadataInp_t::arg1
char * arg1
Definition: modAVUMetadata.h:8
singleLocToRemCopy
int singleLocToRemCopy(rsComm_t *rsComm, dataCopyInp_t *dataCopyInp)
Definition: miscServerFunct.cpp:2576
USER_RODS_HOSTNAME_ERR
@ USER_RODS_HOSTNAME_ERR
Definition: rodsErrorTable.h:234