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)  

initServer.cpp
Go to the documentation of this file.
1 
4 /* initServer.cpp - Server initialization routines
5  */
6 
7 #include "rcMisc.h"
8 #include "initServer.hpp"
9 #include "rodsConnect.h"
10 #include "rodsConnect.h"
11 #include "procLog.h"
12 #include "resource.hpp"
13 #include "rsGlobalExtern.hpp"
14 #include "rcGlobalExtern.h"
15 #include "genQuery.h"
16 #include "rsIcatOpr.hpp"
17 #include "miscServerFunct.hpp"
18 #include "getRemoteZoneResc.h"
19 #include "getRescQuota.h"
20 #include "physPath.hpp"
21 #include "rsLog.hpp"
22 #include "sockComm.h"
23 #include "irods_stacktrace.hpp"
24 #include "rsGenQuery.hpp"
25 #include "rsExecCmd.hpp"
26 
30 #include "irods_log.hpp"
31 #include "irods_exception.hpp"
32 #include "irods_threads.hpp"
34 #include "irods_random.hpp"
35 
36 #include <vector>
37 #include <set>
38 #include <string>
39 #include <fstream>
40 
41 #include <boost/filesystem.hpp>
42 #include <boost/format.hpp>
43 #include <boost/optional.hpp>
44 #include <boost/system/error_code.hpp>
45 
46 static time_t LastBrokenPipeTime = 0;
47 static int BrokenPipeCnt = 0;
48 
49 
51  argv0 = argv[0];
52  argv0_size = strlen(argv[0]);
53 }
54 
55 int
56 //initServerInfo( rsComm_t *rsComm ) {
57 initServerInfo( int processType, rsComm_t * rsComm) {
58  int status = 0;
59 
60  try {
61  const auto& zone_name = irods::get_server_property<const std::string>(irods::CFG_ZONE_NAME);
62  const auto zone_port = irods::get_server_property<const int>( irods::CFG_ZONE_PORT);
63 
64  /* que the local zone */
65  status = queZone(
66  zone_name.c_str(),
67  zone_port, NULL, NULL );
68  if ( status < 0 ) {
69  rodsLog(
70  LOG_DEBUG,
71  "initServerInfo - queZone failed %d",
72  status );
73  // do not error out
74  }
75  } catch ( const irods::exception& e ) {
77  return e.code();
78  }
79 
81  if ( status < 0 ) {
83  "initServerInfo: initHostConfigByFile error, status = %d",
84  status );
85  return status;
86  }
87 
89  if ( status < 0 ) {
91  "initServerInfo: initLocalServerHost error, status = %d",
92  status );
93  return status;
94  }
95 
97  if ( status < 0 ) {
99  "initServerInfo: initRcatServerHostByFile error, status = %d",
100  status );
101  return status;
102  }
103 
104  std::string svc_role;
105  irods::error ret = get_catalog_service_role(svc_role);
106  if(!ret.ok()) {
107  irods::log(PASS(ret));
108  return ret.code();
109  }
110 
111  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
112  status = connectRcat();
113  if ( status < 0 ) {
114  rodsLog(
116  "initServerInfo: connectRcat failed, status = %d",
117  status );
118 
119  return status;
120  }
121  }
122 
123  status = initZone( rsComm );
124  if ( status < 0 ) {
126  "initServerInfo: initZone error, status = %d",
127  status );
128  return status;
129  }
130 
131  if (processType) {
132  ret = resc_mgr.init_from_catalog( rsComm );
133  if ( !ret.ok() ) {
134  irods::error log_err = PASSMSG( "init_from_catalog failed", ret );
135  irods::log( log_err );
136  return ret.code();
137  }
138  }
139 
140  return status;
141 }
142 
143 int
145 
147  memset( ServerHostHead, 0, sizeof( rodsServerHost_t ) );
148 
151 
153 
154  queHostName( ServerHostHead, "localhost", 0 );
155  char myHostName[MAX_NAME_LEN];
156  status = gethostname( myHostName, MAX_NAME_LEN );
157  if ( status < 0 ) {
158  status = SYS_GET_HOSTNAME_ERR - errno;
160  "initLocalServerHost: gethostname error, status = %d",
161  status );
162  return status;
163  }
165  if ( status < 0 ) {
166  return status;
167  }
168 
170  if ( status < 0 ) {
171  /* some configuration may not be able to resolve myHostName. So don't
172  * exit. Just print out warning */
174  "initLocalServerHost: queAddr error, status = %d",
175  status );
176  status = 0;
177  }
178 
179  if ( ProcessType == SERVER_PT ) {
181  }
182 
183  return status;
184 }
185 
186 int
188  std::string prop_str;
189  try {
190  snprintf( KerberosName, sizeof( KerberosName ), "%s", irods::get_server_property<const std::string>(irods::CFG_KERBEROS_NAME_KW).c_str());
191  } catch ( const irods::exception& e ) {}
192 
193  try {
194  rodsHostAddr_t addr;
195  memset( &addr, 0, sizeof( addr ) );
196  rodsServerHost_t* tmp_host = 0;
197  snprintf( addr.hostAddr, sizeof( addr.hostAddr ), "%s", boost::any_cast<const std::string&>(irods::get_server_property<const std::vector<boost::any>>(irods::CFG_CATALOG_PROVIDER_HOSTS_KW)[0]).c_str() );
198  int rem_flg = resolveHost(
199  &addr,
200  &tmp_host );
201  if ( rem_flg < 0 ) {
203  "initRcatServerHostByFile: resolveHost error for %s, status = %d",
204  addr.hostAddr,
205  rem_flg );
206  return rem_flg;
207  }
208  tmp_host->rcatEnabled = LOCAL_ICAT;
209 
210  } catch ( const irods::exception& e ) {
212  return e.code();
213  }
214 
215  // re host
216  // xmsg host
217  try {
218  rodsHostAddr_t addr;
219  memset( &addr, 0, sizeof( addr ) );
220  rodsServerHost_t* tmp_host = 0;
221  snprintf( addr.hostAddr, sizeof( addr.hostAddr ), "%s", irods::get_server_property<const std::string>(irods::CFG_IRODS_XMSG_HOST_KW).c_str() );
222  int rem_flg = resolveHost(
223  &addr,
224  &tmp_host );
225  if ( rem_flg < 0 ) {
227  "initRcatServerHostByFile: resolveHost error for %s, status = %d",
228  addr.hostAddr,
229  rem_flg );
230  return rem_flg;
231  }
232  tmp_host->xmsgHostFlag = 1;
233  } catch ( const irods::exception& e ) {}
234 
235  // slave icat host
236 
237  try {
238  snprintf( localSID, sizeof( localSID ), "%s", irods::get_server_property<const std::string>(irods::CFG_ZONE_KEY_KW).c_str() );
239  } catch ( const irods::exception& e ) {
240  try {
241  snprintf( localSID, sizeof( localSID ), "%s", irods::get_server_property<const std::string>(LOCAL_ZONE_SID_KW).c_str() );
242  } catch ( const irods::exception& e ) {
244  return e.code();
245  }
246  }
247 
248  // try for new federation config
249  try {
250  for ( const auto& el : irods::get_server_property< const std::vector<boost::any> > ( irods::CFG_FEDERATION_KW ) ) {
251  try {
252  const auto& federation = boost::any_cast<const std::unordered_map<std::string, boost::any>&>(el);
253  try {
254  const auto& fed_zone_key = boost::any_cast< std::string >(federation.at(irods::CFG_ZONE_KEY_KW));
255  const auto& fed_zone_name = boost::any_cast< std::string >(federation.at(irods::CFG_ZONE_NAME_KW));
256  const auto& fed_zone_negotiation_key = boost::any_cast< std::string >(federation.at(irods::CFG_NEGOTIATION_KEY_KW));
257  // store in remote_SID_key_map
258  remote_SID_key_map[fed_zone_name] = std::make_pair( fed_zone_key, fed_zone_negotiation_key );
259  }
260  catch ( boost::bad_any_cast& _e ) {
261  rodsLog(
262  LOG_ERROR,
263  "initRcatServerHostByFile - failed to cast federation entry to string" );
264  continue;
265  } catch ( const std::out_of_range& ) {
266  rodsLog(
267  LOG_ERROR,
268  "%s - federation object did not contain required keys",
269  __PRETTY_FUNCTION__);
270  continue;
271  }
272  } catch ( const boost::bad_any_cast& ) {
273  rodsLog(
274  LOG_ERROR,
275  "%s - failed to cast array member to federation object",
276  __PRETTY_FUNCTION__);
277  continue;
278  }
279 
280  }
281  } catch ( const irods::exception& ) {
282  // try the old remote sid config
283  try {
284  for ( const auto& rem_sid : irods::get_server_property< std::vector< std::string > > ( REMOTE_ZONE_SID_KW ) ) {
285  // legacy format should be zone_name-SID
286  size_t pos = rem_sid.find( "-" );
287  if ( pos == std::string::npos ) {
288  rodsLog( LOG_ERROR, "initRcatServerHostByFile - Unable to parse remote SID %s", rem_sid.c_str() );
289  }
290  else {
291  // store in remote_SID_key_map
292  std::string fed_zone_name = rem_sid.substr( 0, pos );
293  std::string fed_zone_key = rem_sid.substr( pos + 1 );
294  // use our negotiation key for the old configuration
295  try {
296  const auto& neg_key = irods::get_server_property<const std::string>(irods::CFG_NEGOTIATION_KEY_KW);
297  remote_SID_key_map[fed_zone_name] = std::make_pair( fed_zone_key, neg_key );
298  } catch ( const irods::exception& e ) {
300  return e.code();
301  }
302  }
303  }
304  } catch ( const irods::exception& ) {}
305 
306  } // else
307 
308  return 0;
309 }
310 
311 int
312 initZone( rsComm_t *rsComm ) {
313  if (ZoneInfoHead && (strlen(ZoneInfoHead->zoneName) > 0)
315  return 0;
316  }
317 
318  rodsServerHost_t *tmpRodsServerHost;
319  rodsServerHost_t *masterServerHost = NULL;
320  rodsServerHost_t *slaveServerHost = NULL;
321  genQueryInp_t genQueryInp;
322  genQueryOut_t *genQueryOut = NULL;
323  int status, i;
324  sqlResult_t *zoneName, *zoneType, *zoneConn, *zoneComment;
325  char *tmpZoneName, *tmpZoneType, *tmpZoneConn;//, *tmpZoneComment;
326 
327  boost::optional<const std::string&> zone_name;
328  try {
329  zone_name.reset(irods::get_server_property<const std::string>(irods::CFG_ZONE_NAME));
330  } catch ( const irods::exception& e ) {
332  return e.code();
333  }
334 
335  /* configure the local zone first or rsGenQuery would not work */
336 
337  tmpRodsServerHost = ServerHostHead;
338  while ( tmpRodsServerHost != NULL ) {
339  if ( tmpRodsServerHost->rcatEnabled == LOCAL_ICAT ) {
340  tmpRodsServerHost->zoneInfo = ZoneInfoHead;
341  masterServerHost = tmpRodsServerHost;
342  }
343  else if ( tmpRodsServerHost->rcatEnabled == LOCAL_SLAVE_ICAT ) {
344  tmpRodsServerHost->zoneInfo = ZoneInfoHead;
345  slaveServerHost = tmpRodsServerHost;
346  }
347  tmpRodsServerHost = tmpRodsServerHost->next;
348  }
349  ZoneInfoHead->masterServerHost = masterServerHost;
350  ZoneInfoHead->slaveServerHost = slaveServerHost;
351 
352  memset( &genQueryInp, 0, sizeof( genQueryInp ) );
353  addInxIval( &genQueryInp.selectInp, COL_ZONE_NAME, 1 );
354  addInxIval( &genQueryInp.selectInp, COL_ZONE_TYPE, 1 );
355  addInxIval( &genQueryInp.selectInp, COL_ZONE_CONNECTION, 1 );
356  addInxIval( &genQueryInp.selectInp, COL_ZONE_COMMENT, 1 );
357  genQueryInp.maxRows = MAX_SQL_ROWS;
358 
359  status = rsGenQuery( rsComm, &genQueryInp, &genQueryOut );
360 
361  clearGenQueryInp( &genQueryInp );
362 
363  if ( status < 0 ) {
364  freeGenQueryOut( &genQueryOut );
366  "initZone: rsGenQuery error, status = %d", status );
367  return status;
368  }
369 
370  if ( genQueryOut == NULL ) {
372  "initZone: NULL genQueryOut" );
373  return CAT_NO_ROWS_FOUND;
374  }
375 
376  if ( ( zoneName = getSqlResultByInx( genQueryOut, COL_ZONE_NAME ) ) == NULL ) {
378  "initZone: getSqlResultByInx for COL_ZONE_NAME failed" );
379  return UNMATCHED_KEY_OR_INDEX;
380  }
381 
382  if ( ( zoneType = getSqlResultByInx( genQueryOut, COL_ZONE_TYPE ) ) == NULL ) {
384  "initZone: getSqlResultByInx for COL_ZONE_TYPE failed" );
385  return UNMATCHED_KEY_OR_INDEX;
386  }
387 
388  if ( ( zoneConn = getSqlResultByInx( genQueryOut, COL_ZONE_CONNECTION ) ) == NULL ) {
390  "initZone: getSqlResultByInx for COL_ZONE_CONNECTION failed" );
391  return UNMATCHED_KEY_OR_INDEX;
392  }
393 
394  if ( ( zoneComment = getSqlResultByInx( genQueryOut, COL_ZONE_COMMENT ) ) == NULL ) {
396  "initZone: getSqlResultByInx for COL_ZONE_COMMENT failed" );
397  return UNMATCHED_KEY_OR_INDEX;
398  }
399 
400  for ( i = 0; i < genQueryOut->rowCnt; i++ ) {
401  rodsHostAddr_t addr;
402 
403  tmpZoneName = &zoneName->value[zoneName->len * i];
404  tmpZoneType = &zoneType->value[zoneType->len * i];
405  tmpZoneConn = &zoneConn->value[zoneConn->len * i];
406  //tmpZoneComment = &zoneComment->value[zoneComment->len * i];
407  if ( strcmp( tmpZoneType, "local" ) == 0 ) {
408  if ( strcmp( zone_name->c_str(), tmpZoneName ) != 0 ) {
410  "initZone: zoneName in env %s does not match %s in icat ",
411  zone_name->c_str(), tmpZoneName );
412  }
413  /* fillin rodsZone if it is not defined */
414  if ( strlen( rsComm->proxyUser.rodsZone ) == 0 ) {
415  rstrcpy( rsComm->proxyUser.rodsZone, tmpZoneName, NAME_LEN );
416  }
417  if ( strlen( rsComm->clientUser.rodsZone ) == 0 ) {
418  rstrcpy( rsComm->clientUser.rodsZone, tmpZoneName, NAME_LEN );
419  }
420  continue;
421  }
422  else if ( strlen( tmpZoneConn ) <= 0 ) {
424  "initZone: connection info for zone %s not configured",
425  tmpZoneName );
426  continue;
427  }
428 
429  memset( &addr, 0, sizeof( addr ) );
430  /* assume address:port */
431  parseHostAddrStr( tmpZoneConn, &addr );
432  if ( addr.portNum == 0 ) {
433  addr.portNum = ZoneInfoHead->portNum;
434  }
435  rstrcpy( addr.zoneName, tmpZoneName, NAME_LEN ); // JMC - bacport 4562
436  status = resolveHost( &addr, &tmpRodsServerHost );
437  if ( status < 0 ) {
439  "initZone: resolveHost error for %s for zone %s. status = %d",
440  addr.hostAddr, tmpZoneName, status );
441  continue;
442  }
443  if ( tmpRodsServerHost->rcatEnabled == LOCAL_ICAT ) {
445  "initZone: address %s for remote zone %s already in use",
446  tmpZoneConn, tmpZoneName );
447  continue;
448  }
449 
450  tmpRodsServerHost->rcatEnabled = REMOTE_ICAT;
451  /* REMOTE_ICAT is always on a remote host even if it is one the same
452  * host, but will be on different port */
453  tmpRodsServerHost->localFlag = REMOTE_HOST; // JMC - bacport 4562
454  queZone( tmpZoneName, addr.portNum, tmpRodsServerHost, NULL );
455  }
456 
457  freeGenQueryOut( &genQueryOut );
458 
459  return 0;
460 }
461 
462 int
463 initAgent( int processType, rsComm_t *rsComm ) {
464 
465  initProcLog();
466 
467  int status = initServerInfo( 1, rsComm );
468  if ( status < 0 ) {
470  "initAgent: initServerInfo error, status = %d",
471  status );
472  return status;
473  }
474 
475  initL1desc();
477  status = initFileDesc();
478  if ( status < 0 ) {
480  "initAgent: initFileDesc error, status = %d",
481  status );
482  return status;
483  }
484 
485  ruleExecInfo_t rei;
486  memset( &rei, 0, sizeof( rei ) );
487  rei.rsComm = rsComm;
488 
489  if ( ProcessType == AGENT_PT ) {
490  status = applyRule( "acChkHostAccessControl", NULL, &rei,
491  NO_SAVE_REI );
492 
493  if ( status < 0 ) {
495  "initAgent: acChkHostAccessControl error, status = %d",
496  status );
497  return status;
498  }
499  }
500 
501  /* Initialize the global quota */
502 
504  GlobalQuotaOverrun = 0;
506 
507  if ( rsComm->reconnFlag == RECONN_TIMEOUT ) {
508  rsComm->reconnSock = svrSockOpenForInConn( rsComm, &rsComm->reconnPort,
509  &rsComm->reconnAddr, SOCK_STREAM );
510  if ( rsComm->reconnSock < 0 ) {
511  rsComm->reconnPort = 0;
512  rsComm->reconnAddr = NULL;
513  }
514  else {
515  rsComm->cookie = ( int )( irods::getRandom<unsigned int>() >> 1 );
516  }
517  try {
518  rsComm->thread_ctx->lock = new boost::mutex;
519  rsComm->thread_ctx->cond = new boost::condition_variable;
520  rsComm->thread_ctx->reconnThr = new boost::thread( reconnManager, rsComm );
521  }
522  catch ( boost::thread_resource_error& ) {
523  rodsLog( LOG_ERROR, "boost encountered thread_resource_error." );
525  }
526  }
528 
530  ThisComm = rsComm;
531 
532  /* use a tmp myComm is needed to get the permission right for the call */
533  rsComm_t myComm = *rsComm;
535  rei.rsComm = &myComm;
536 
537  status = applyRule( "acSetPublicUserPolicy", NULL, &rei, NO_SAVE_REI );
538 
539  if ( status < 0 ) {
541  "initAgent: acSetPublicUserPolicy error, status = %d",
542  status );
543  return status;
544  }
545 
546  return status;
547 }
548 
549 void
551  std::string svc_role;
552  irods::error ret = get_catalog_service_role(svc_role);
553  if(!ret.ok()) {
554  irods::log(PASS(ret));
555  }
556 
557  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
558  disconnectRcat();
559  }
560 
561  if ( InitialState == INITIAL_DONE ) {
562  /* close all opened descriptors */
564  /* close any opened server to server connection */
566  }
567  irods::re_plugin_globals->global_re_mgr.call_stop_operations();
568 }
569 
570 void
572 #if 0
573  // RTS - rodsLog calls in signal handlers are unsafe - #3326
575  "Agent exiting with status = %d", status );
576 #endif
577 
578  cleanup();
579 
580  if ( status >= 0 ) {
581  exit( 0 );
582  }
583  else {
584  exit( 1 );
585  }
586 }
587 
588 void
589 signalExit( int ) {
590 #if 0
591  // RTS - rodsLog calls in signal handlers are unsafe - #3326
593  "caught a signal and exiting\n" );
594 #endif
596 }
597 
598 void
600  time_t curTime;
601 
602  if ( ThisComm == NULL || ThisComm->reconnSock <= 0 ) {
604  "caught a broken pipe signal and exiting" );
606  }
607  else {
608  curTime = time( 0 );
609  if ( curTime - LastBrokenPipeTime < BROKEN_PIPE_INT ) {
610  BrokenPipeCnt ++;
613  "caught a broken pipe signal and exiting" );
615  }
616  }
617  else {
618  BrokenPipeCnt = 1;
619  }
620  LastBrokenPipeTime = curTime;
622  "caught a broken pipe signal. Attempt to reconnect" );
623  signal( SIGPIPE, ( void ( * )( int ) ) rsPipeSignalHandler );
624 
625  }
626 }
627 
630 
631  // =-=-=-=-=-=-=-
632  // request fully qualified path to the config file
633  std::string cfg_file;
636  cfg_file );
637  if ( !ret.ok() ) {
638  rodsLog(
639  LOG_NOTICE,
640  "config file [%s] not found",
642  return 0;
643  }
644 
646  ret = cfg.load( cfg_file );
647  if ( !ret.ok() ) {
648  irods::log( PASS( ret ) );
649  return ret.code();
650  }
651 
652  try {
653  for ( const auto& el : cfg.get< const std::vector< boost::any > > ("host_entries") ) {
654  try {
655  const auto& host_entry = boost::any_cast<const std::unordered_map<std::string, boost::any>&>(el);
656  const auto& address_type = boost::any_cast<const std::string&>(host_entry.at("address_type"));
657  const auto& addresses = boost::any_cast<const std::vector<boost::any>&>(host_entry.at("addresses"));
658 
659  rodsServerHost_t* svr_host = ( rodsServerHost_t* )malloc( sizeof( rodsServerHost_t ) );
660  memset( svr_host, 0, sizeof( rodsServerHost_t ) );
661 
662  if ( "remote" == address_type ) {
663  svr_host->localFlag = REMOTE_HOST;
664  }
665  else if ( "local" == address_type ) {
666  svr_host->localFlag = LOCAL_HOST;
667 
668  }
669  else {
670  free( svr_host );
671  rodsLog(
672  LOG_ERROR,
673  "unsupported address type [%s]",
674  address_type.c_str() );
675  continue;
676  }
677 
678  // local zone
679  svr_host->zoneInfo = ZoneInfoHead;
680  if ( queRodsServerHost(
682  svr_host ) < 0 ) {
683  rodsLog(
684  LOG_ERROR,
685  "queRodsServerHost failed" );
686  }
687 
688  for ( const auto& el : addresses ) {
689  try {
690  if ( queHostName(
691  svr_host,
692  boost::any_cast<const std::string&>(
693  boost::any_cast<const std::unordered_map<std::string, boost::any>&>(el
694  ).at("address")
695  ).c_str(),
696  0 ) < 0 ) {
697  rodsLog( LOG_ERROR, "queHostName failed" );
698  }
699 
700  } catch ( const boost::bad_any_cast& e ) {
701  irods::log( ERROR( INVALID_ANY_CAST, e.what() ) );
702  continue;
703  } catch ( const std::out_of_range& e ) {
704  irods::log( ERROR( KEY_NOT_FOUND, e.what() ) );
705  }
706 
707  } // for addr_idx
708  } catch ( const boost::bad_any_cast& e ) {
709  irods::log( ERROR( INVALID_ANY_CAST, e.what() ) );
710  continue;
711  } catch ( const std::out_of_range& e ) {
712  irods::log( ERROR( KEY_NOT_FOUND, e.what() ) );
713  }
714 
715  } // for i
716  } catch ( const irods::exception& e ) {
718  return e.code();
719  }
720 
721 
722  return 0;
723 
724 } // initHostConfigByFile
725 
726 int
727 initRsComm( rsComm_t *rsComm ) {
728  memset( rsComm, 0, sizeof( rsComm_t ) );
729 
730  if ( int status = getRodsEnv( &rsComm->myEnv ) ) {
731  irods::log( ERROR( status, "getRodsEnv failed in initRsComm" ) );
732  return status;
733  }
734 
735  try {
736  const auto& zone_name = irods::get_server_property<const std::string>(irods::CFG_ZONE_NAME);
737  const auto& zone_user = irods::get_server_property<const std::string>(irods::CFG_ZONE_USER);
738  const auto& zone_auth_scheme = irods::get_server_property<const std::string>(irods::CFG_ZONE_AUTH_SCHEME);
739 
740  /* fill in the proxyUser info from server_config. clientUser
741  * has to come from the rei */
742  rstrcpy( rsComm->proxyUser.userName, zone_user.c_str(), NAME_LEN );
743  rstrcpy( rsComm->proxyUser.rodsZone, zone_name.c_str(), NAME_LEN );
745  zone_auth_scheme.c_str(), NAME_LEN );
746  rstrcpy( rsComm->clientUser.userName, zone_user.c_str(), NAME_LEN );
747  rstrcpy( rsComm->clientUser.rodsZone, zone_name.c_str(), NAME_LEN );
749  zone_auth_scheme.c_str(), NAME_LEN );
750  /* assume LOCAL_PRIV_USER_AUTH */
751  rsComm->clientUser.authInfo.authFlag =
753  } catch ( const irods::exception& e ) {
755  return e.code();
756  }
757 
758  return 0;
759 }
760 
761 void
762 daemonize( int runMode, int logFd ) {
763  if ( runMode == SINGLE_PASS ) {
764  return;
765  }
766 
767  if ( runMode == STANDALONE_SERVER ) {
768  if ( fork() ) {
769  exit( 0 );
770  }
771 
772  if ( setsid() < 0 ) {
773  fprintf( stderr, "daemonize" );
774  perror( "cannot create a new session." );
775  exit( 1 );
776  }
777  }
778 
779  close( 0 );
780  close( 1 );
781  close( 2 );
782 
783  ( void ) dup2( logFd, 0 );
784  ( void ) dup2( logFd, 1 );
785  ( void ) dup2( logFd, 2 );
786  close( logFd );
787 }
788 
789 /* logFileOpen - Open the logFile for the reServer.
790  *
791  * Input - None
792  * OutPut - the log file descriptor
793  */
794 
795 int
796 logFileOpen( int runMode, const char *logDir, const char *logFileName ) {
797  char *logFile = NULL;
798 #ifdef SYSLOG
799  int logFd = 0;
800 #else
801  int logFd;
802 #endif
803 
804  if ( runMode == SINGLE_PASS && logDir == NULL ) {
805  return 1;
806  }
807 
808  if ( logFileName == NULL ) {
809  fprintf( stderr, "logFileOpen: NULL input logFileName\n" );
811  }
812 
813  getLogfileName( &logFile, logDir, logFileName );
814  if ( NULL == logFile ) { // JMC cppcheck - nullptr
815  fprintf( stderr, "logFileOpen: unable to open log file" );
816  return -1;
817  }
818 
819 #ifndef SYSLOG
820  logFd = open( logFile, O_CREAT | O_WRONLY | O_APPEND, 0666 );
821 #endif
822  if ( logFd < 0 ) {
823  fprintf( stderr, "logFileOpen: Unable to open %s. errno = %d\n",
824  logFile, errno );
825  free( logFile );
826  return -1 * errno;
827  }
828 
829  free( logFile );
830  return logFd;
831 }
832 
833 int
835  char *tmpStr;
836  static char tmpStr2[LONG_NAME_LEN];
837  /* always use NATIVE_PROT as a client. e.g., server to server comm */
838  snprintf( tmpStr2, LONG_NAME_LEN, "%s=%d", IRODS_PROT, NATIVE_PROT );
839  putenv( tmpStr2 );
840 
841  if ( startupPack != NULL ) {
842  rsComm->connectCnt = startupPack->connectCnt;
843  rsComm->irodsProt = startupPack->irodsProt;
844  rsComm->reconnFlag = startupPack->reconnFlag;
846  NAME_LEN );
847  if ( strcmp( startupPack->proxyUser, PUBLIC_USER_NAME ) == 0 ) {
849  }
851  NAME_LEN );
853  NAME_LEN );
854  if ( strcmp( startupPack->clientUser, PUBLIC_USER_NAME ) == 0 ) {
856  }
858  NAME_LEN );
860  NAME_LEN );
862  NAME_LEN );
864  }
865  else { /* have to depend on env variable */
866  tmpStr = getenv( SP_NEW_SOCK );
867  if ( tmpStr == NULL ) {
869  "initRsCommWithStartupPack: env %s does not exist",
870  SP_NEW_SOCK );
872  }
873  rsComm->sock = atoi( tmpStr );
874 
875  tmpStr = getenv( SP_CONNECT_CNT );
876  if ( tmpStr == NULL ) {
878  "initRsCommWithStartupPack: env %s does not exist",
879  SP_CONNECT_CNT );
881  }
882  rsComm->connectCnt = atoi( tmpStr ) + 1;
883 
884  tmpStr = getenv( SP_PROTOCOL );
885  if ( tmpStr == NULL ) {
887  "initRsCommWithStartupPack: env %s does not exist",
888  SP_PROTOCOL );
890  }
891  rsComm->irodsProt = ( irodsProt_t )atoi( tmpStr );
892 
893  if (rsComm->irodsProt != NATIVE_PROT && rsComm->irodsProt != XML_PROT) {
894  rodsLog( LOG_NOTICE, "initRsCommWithStartupPack: Invalid protocol value.");
896  }
897 
898  tmpStr = getenv( SP_RECONN_FLAG );
899  if ( tmpStr == NULL ) {
901  "initRsCommWithStartupPack: env %s does not exist",
902  SP_RECONN_FLAG );
904  }
905  rsComm->reconnFlag = atoi( tmpStr );
906 
907  tmpStr = getenv( SP_PROXY_USER );
908  if ( tmpStr == NULL ) {
910  "initRsCommWithStartupPack: env %s does not exist",
911  SP_PROXY_USER );
913  }
914  rstrcpy( rsComm->proxyUser.userName, tmpStr, NAME_LEN );
915  if ( strcmp( tmpStr, PUBLIC_USER_NAME ) == 0 ) {
917  }
918 
919  tmpStr = getenv( SP_PROXY_RODS_ZONE );
920  if ( tmpStr == NULL ) {
922  "initRsCommWithStartupPack: env %s does not exist",
925  }
926  rstrcpy( rsComm->proxyUser.rodsZone, tmpStr, NAME_LEN );
927 
928  tmpStr = getenv( SP_CLIENT_USER );
929  if ( tmpStr == NULL ) {
931  "initRsCommWithStartupPack: env %s does not exist",
932  SP_CLIENT_USER );
934  }
935  rstrcpy( rsComm->clientUser.userName, tmpStr, NAME_LEN );
936  if ( strcmp( tmpStr, PUBLIC_USER_NAME ) == 0 ) {
938  }
939 
940  tmpStr = getenv( SP_CLIENT_RODS_ZONE );
941  if ( tmpStr == NULL ) {
943  "initRsCommWithStartupPack: env %s does not exist",
946  }
947  rstrcpy( rsComm->clientUser.rodsZone, tmpStr, NAME_LEN );
948 
949  tmpStr = getenv( SP_REL_VERSION );
950  if ( tmpStr == NULL ) {
952  "getstartupPackFromEnv: env %s does not exist",
953  SP_REL_VERSION );
955  }
956  rstrcpy( rsComm->cliVersion.relVersion, tmpStr, NAME_LEN );
957 
958  tmpStr = getenv( SP_API_VERSION );
959  if ( tmpStr == NULL ) {
961  "initRsCommWithStartupPack: env %s does not exist",
962  SP_API_VERSION );
964  }
965  rstrcpy( rsComm->cliVersion.apiVersion, tmpStr, NAME_LEN );
966 
967  tmpStr = getenv( SP_OPTION );
968  if ( tmpStr == NULL ) {
970  "initRsCommWithStartupPack: env %s does not exist",
971  SP_OPTION );
972  }
973  else {
974  rstrcpy( rsComm->option, tmpStr, LONG_NAME_LEN );
975  }
976  }
977  if ( rsComm->sock != 0 ) {
978  /* remove error messages from xmsLog */
979  setLocalAddr( rsComm->sock, &rsComm->localAddr );
980  setRemoteAddr( rsComm->sock, &rsComm->remoteAddr );
981  }
982 
983  tmpStr = inet_ntoa( rsComm->remoteAddr.sin_addr );
984  if ( tmpStr == NULL || *tmpStr == '\0' ) {
985  tmpStr = "UNKNOWN";
986  }
987  rstrcpy( rsComm->clientAddr, tmpStr, NAME_LEN );
988 
989  return 0;
990 }
991 
992 std::set<std::string>
993 construct_controlled_user_set(const std::unordered_map<std::string, boost::any>& controlled_user_connection_list) {
994  std::set<std::string> user_set;
995  try {
996  for ( const auto& user : boost::any_cast<const std::vector<boost::any>&>(controlled_user_connection_list.at("users")) ) {
997  user_set.insert(boost::any_cast<const std::string&>(user));
998  }
999  } catch ( const boost::bad_any_cast& e ) {
1000  THROW( INVALID_ANY_CAST, "controlled_user_connection_list must contain a list of string values at key \"users\"" );
1001  } catch ( const std::out_of_range& e ) {
1002  THROW( KEY_NOT_FOUND, "controlled_user_connection_list must contain a list of string values at key \"users\"" );
1003  }
1004  return user_set;
1005 }
1006 
1007 int
1008 chkAllowedUser( const char *userName, const char *rodsZone ) {
1009 
1010  if ( userName == NULL || rodsZone == NULL ) {
1012  }
1013 
1014  if ( strlen( userName ) == 0 ) {
1015  /* XXXXXXXXXX userName not yet defined. allow it for now */
1016  return 0;
1017  }
1018  boost::optional<const std::unordered_map<std::string, boost::any>&> controlled_user_connection_list;
1019  try {
1020  controlled_user_connection_list.reset(irods::get_server_property<const std::unordered_map<std::string, boost::any> >("controlled_user_connection_list"));
1021  } catch ( const irods::exception& e ) {
1022  if ( e.code() == KEY_NOT_FOUND ) {
1023  return 0;
1024  }
1025  return e.code();
1026  }
1027  const auto user_and_zone = (boost::format("%s#%s") % userName % rodsZone).str();
1028  try {
1029  const auto& control_type = boost::any_cast<const std::string&>(controlled_user_connection_list->at("control_type"));
1030  static const auto controlled_user_set = construct_controlled_user_set(*controlled_user_connection_list);
1031  if ( control_type == "whitelist" ) {
1032  if ( controlled_user_set.count( user_and_zone ) == 0 ) {
1034  }
1035  }
1036  else if ( control_type == "blacklist" ) {
1037  if ( controlled_user_set.count( user_and_zone ) != 0 ) {
1039  }
1040  }
1041  else {
1042  rodsLog(LOG_ERROR, "controlled_user_connection_list must specify \"whitelist\" or \"blacklist\"");
1043  return -1;
1044  }
1045  } catch ( const irods::exception& e ) {
1046  irods::log(e);
1047  return e.code();
1048  } catch ( const std::out_of_range& e ) {
1049  rodsLog( LOG_ERROR, "%s", e.what());
1050  return KEY_NOT_FOUND;
1051  } catch ( const boost::bad_any_cast& e ) {
1052  rodsLog( LOG_ERROR, "%s", e.what());
1053  return INVALID_ANY_CAST;
1054  }
1055  return 0;
1056 
1057 }
1058 
1059 int
1061  try {
1062  const auto& zone_name = irods::get_server_property<const std::string>(irods::CFG_ZONE_NAME);
1063  const auto& zone_user = irods::get_server_property<const std::string>(irods::CFG_ZONE_USER);
1064 
1065  rstrcpy( rsComm->proxyUser.userName, zone_user.c_str(), NAME_LEN );
1066  rstrcpy( rsComm->clientUser.userName, zone_user.c_str(), NAME_LEN );
1067 
1068  rstrcpy( rsComm->proxyUser.rodsZone, zone_name.c_str(), NAME_LEN );
1069  rstrcpy( rsComm->clientUser.rodsZone, zone_name.c_str(), NAME_LEN );
1070  } catch ( const irods::exception& e ) {
1072  return e.code();
1073  }
1074 
1075  return 0;
1076 }
1077 
1078 int
1080  irodsPosition_t position ) {
1081  if ( agentProc == NULL || agentProcHead == NULL ) {
1082  return USER__NULL_INPUT_ERR;
1083  }
1084 
1085  if ( *agentProcHead == NULL ) {
1086  *agentProcHead = agentProc;
1087  agentProc->next = NULL;
1088  return 0;
1089  }
1090 
1091  if ( position == TOP_POS ) {
1092  agentProc->next = *agentProcHead;
1093  *agentProcHead = agentProc;
1094  }
1095  else {
1096  agentProc_t *tmpAgentProc = *agentProcHead;
1097  while ( tmpAgentProc->next != NULL ) {
1098  tmpAgentProc = tmpAgentProc->next;
1099  }
1100  tmpAgentProc->next = agentProc;
1101  agentProc->next = NULL;
1102  }
1103  return 0;
1104 }
1105 
1106 // =-=-=-=-=-=-=-
1107 // JMC - backport 4612
1108 int
1109 purgeLockFileDir( int chkLockFlag ) {
1110  char lockFilePath[MAX_NAME_LEN * 2];
1111  struct dirent *myDirent;
1112  struct stat statbuf;
1113  int status;
1114  int savedStatus = 0;
1115  struct flock myflock;
1116  uint purgeTime;
1117 
1118  std::string lock_dir;
1120  LOCK_FILE_DIR,
1121  lock_dir );
1122  if ( !ret.ok() ) {
1123  irods::log( PASS( ret ) );
1124  return ret.code();
1125  }
1126 
1127  DIR *dirPtr = opendir( lock_dir.c_str() );
1128  if ( dirPtr == NULL ) {
1129  rodsLog( LOG_ERROR,
1130  "purgeLockFileDir: opendir error for %s, errno = %d",
1131  lock_dir.c_str(), errno );
1132  return UNIX_FILE_OPENDIR_ERR - errno;
1133  }
1134  bzero( &myflock, sizeof( myflock ) );
1135  myflock.l_whence = SEEK_SET;
1136  purgeTime = time( 0 ) - LOCK_FILE_PURGE_TIME;
1137  while ( ( myDirent = readdir( dirPtr ) ) != NULL ) {
1138  if ( strcmp( myDirent->d_name, "." ) == 0 ||
1139  strcmp( myDirent->d_name, ".." ) == 0 ) {
1140  continue;
1141  }
1142  snprintf( lockFilePath, MAX_NAME_LEN, "%-s/%-s",
1143  lock_dir.c_str(), myDirent->d_name );
1144  if ( chkLockFlag ) {
1145  int myFd;
1146  myFd = open( lockFilePath, O_RDWR | O_CREAT, 0644 );
1147  if ( myFd < 0 ) {
1148  savedStatus = FILE_OPEN_ERR - errno;
1149  rodsLogError( LOG_ERROR, savedStatus,
1150  "purgeLockFileDir: open error for %s", lockFilePath );
1151  continue;
1152  }
1153  myflock.l_type = F_WRLCK;
1154  int error_code = fcntl( myFd, F_GETLK, &myflock );
1155  if ( error_code != 0 ) {
1156  rodsLog( LOG_ERROR, "fcntl failed in purgeLockFileDir with error code %d", error_code );
1157  }
1158  close( myFd );
1159  /* some process is locking it */
1160  if ( myflock.l_type != F_UNLCK ) {
1161  continue;
1162  }
1163  }
1164  status = stat( lockFilePath, &statbuf );
1165 
1166  if ( status != 0 ) {
1167  rodsLog( LOG_ERROR,
1168  "purgeLockFileDir: stat error for %s, errno = %d",
1169  lockFilePath, errno );
1170  savedStatus = UNIX_FILE_STAT_ERR - errno;
1171  boost::system::error_code err;
1172  boost::filesystem::remove( boost::filesystem::path( lockFilePath ), err );
1173  continue;
1174  }
1175  if ( chkLockFlag && ( int )purgeTime < statbuf.st_mtime ) {
1176  continue;
1177  }
1178  if ( ( statbuf.st_mode & S_IFREG ) == 0 ) {
1179  continue;
1180  }
1181  boost::system::error_code err;
1182  boost::filesystem::remove( boost::filesystem::path( lockFilePath ), err );
1183  }
1184  closedir( dirPtr );
1185 
1186  return savedStatus;
1187 }
1188 
1189 // =-=-=-=-=-=-=-
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
LOCAL_ICAT
#define LOCAL_ICAT
Definition: rodsConnect.h:52
initZone
int initZone(rsComm_t *rsComm)
Definition: initServer.cpp:312
MAX_SQL_ROWS
#define MAX_SQL_ROWS
Definition: rodsGenQuery.h:16
matchHostConfig
int matchHostConfig(rodsServerHost_t *myRodsServerHost)
Definition: rodsConnect.cpp:302
chkAllowedUser
int chkAllowedUser(const char *userName, const char *rodsZone)
Definition: initServer.cpp:1008
construct_controlled_user_set
std::set< std::string > construct_controlled_user_set(const std::unordered_map< std::string, boost::any > &controlled_user_connection_list)
Definition: initServer.cpp:993
LastBrokenPipeTime
static time_t LastBrokenPipeTime
Definition: initServer.cpp:46
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
rsComm_t
Definition: rcConnect.h:145
STANDALONE_SERVER
#define STANDALONE_SERVER
Definition: rodsConnect.h:60
irods::get_full_path_for_config_file
error get_full_path_for_config_file(const std::string &, std::string &)
Definition: irods_get_full_path_for_config_file.cpp:20
SYS_INTERNAL_NULL_INPUT_ERR
@ SYS_INTERNAL_NULL_INPUT_ERR
Definition: rodsErrorTable.h:92
rodsServerHost::localFlag
int localFlag
Definition: rodsConnect.h:68
getRemoteZoneResc.h
setRemoteAddr
int setRemoteAddr(int sock, struct sockaddr_in *remoteAddr)
Definition: sockComm.cpp:1034
getRodsEnv
int getRodsEnv(rodsEnv *myRodsEnv)
Definition: getRodsEnv.cpp:112
irods_server_properties.hpp
THROW
#define THROW(_code, _msg)
Definition: irods_exception.hpp:68
irods::CFG_FEDERATION_KW
const std::string CFG_FEDERATION_KW("federation")
rsLog.hpp
myHostName
char myHostName[(1024+64)]
Definition: nre.reHelpers1.cpp:45
SYS_USER_NOT_ALLOWED_TO_CONN
@ SYS_USER_NOT_ALLOWED_TO_CONN
Definition: rodsErrorTable.h:78
queRodsServerHost
int queRodsServerHost(rodsServerHost_t **rodsServerHostHead, rodsServerHost_t *myRodsServerHost)
Definition: rodsConnect.cpp:212
UNMATCHED_KEY_OR_INDEX
@ UNMATCHED_KEY_OR_INDEX
Definition: rodsErrorTable.h:244
rsComm_t::irodsProt
irodsProt_t irodsProt
Definition: rcConnect.h:146
irods::CFG_CATALOG_PROVIDER_HOSTS_KW
const std::string CFG_CATALOG_PROVIDER_HOSTS_KW("catalog_provider_hosts")
queHostName
int queHostName(rodsServerHost_t *rodsServerHost, const char *myHostName, int topFlag)
Definition: rodsConnect.cpp:177
AGENT_PT
#define AGENT_PT
Definition: rodsDef.h:79
irods::CFG_ZONE_NAME_KW
const std::string CFG_ZONE_NAME_KW("zone_name")
userInfo_t::userName
char userName[64]
Definition: rodsUser.h:66
startupPack::clientRodsZone
char clientRodsZone[64]
Definition: rodsDef.h:241
irods_get_full_path_for_config_file.hpp
MAX_BROKEN_PIPE_CNT
#define MAX_BROKEN_PIPE_CNT
Definition: rodsConnect.h:22
LOG_SYS_FATAL
#define LOG_SYS_FATAL
Definition: rodsLog.h:55
irods::CFG_ZONE_USER
const std::string CFG_ZONE_USER("zone_user")
rodsServerHost::rcatEnabled
int rcatEnabled
Definition: rodsConnect.h:65
SP_CLIENT_RODS_ZONE
#define SP_CLIENT_RODS_ZONE
Definition: rodsDef.h:260
irods_stacktrace.hpp
irods::resource_manager::init_from_catalog
error init_from_catalog(rsComm_t *)
Definition: irods_resource_manager.cpp:217
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
resc_mgr
irods::resource_manager resc_mgr
Definition: irods_resource_manager.cpp:31
rsComm_t::connectCnt
int connectCnt
Definition: rcConnect.h:148
authInfo_t::authScheme
char authScheme[64]
Definition: rodsUser.h:41
NO_SAVE_REI
#define NO_SAVE_REI
Definition: rodsDef.h:103
thread_context::cond
boost::condition_variable * cond
Definition: irods_threads.hpp:13
thread_context::reconnThr
boost::thread * reconnThr
Definition: irods_threads.hpp:11
irods_exception.hpp
startupPack::relVersion
char relVersion[64]
Definition: rodsDef.h:242
irods::CFG_ZONE_KEY_KW
const std::string CFG_ZONE_KEY_KW("zone_key")
GenQueryInp
Definition: rodsGenQuery.h:24
irods::configuration_parser::get
T & get(const std::string &_key)
Definition: irods_configuration_parser.hpp:76
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
XML_PROT
@ XML_PROT
Definition: rodsDef.h:149
cleanup
void cleanup()
Definition: initServer.cpp:550
rcMisc.h
ServerHostHead
rodsServerHost_t * ServerHostHead
Definition: irods_server_globals.cpp:21
PUBLIC_USER_AUTH
#define PUBLIC_USER_AUTH
Definition: rodsUser.h:32
rsComm_t::option
char option[256]
Definition: rcConnect.h:156
irods_threads.hpp
SP_PROXY_USER
#define SP_PROXY_USER
Definition: rodsDef.h:257
LONG_NAME_LEN
#define LONG_NAME_LEN
Definition: rodsDef.h:57
setLocalAddr
int setLocalAddr(int sock, struct sockaddr_in *localAddr)
Definition: sockComm.cpp:1057
SP_NEW_SOCK
#define SP_NEW_SOCK
Definition: rodsDef.h:252
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
SP_CONNECT_CNT
#define SP_CONNECT_CNT
Definition: rodsDef.h:254
zoneInfo::zoneName
char zoneName[64]
Definition: rodsConnect.h:75
LOCK_FILE_DIR
#define LOCK_FILE_DIR
Definition: physPath.hpp:26
BROKEN_PIPE_INT
#define BROKEN_PIPE_INT
Definition: rodsConnect.h:23
rsComm_t::thread_ctx
struct thread_context * thread_ctx
Definition: rcConnect.h:171
irods_resource_backport.hpp
irods::get_full_path_for_unmoved_configs
error get_full_path_for_unmoved_configs(const std::string &, std::string &)
Definition: irods_get_full_path_for_config_file.cpp:43
REMOTE_ZONE_SID_KW
#define REMOTE_ZONE_SID_KW
Definition: rodsConnect.h:85
LOCAL_SLAVE_ICAT
#define LOCAL_SLAVE_ICAT
Definition: rodsConnect.h:53
rodsServerHost::next
struct rodsServerHost * next
Definition: rodsConnect.h:71
irods::CFG_KERBEROS_NAME_KW
const std::string CFG_KERBEROS_NAME_KW("kerberos_name")
initL1desc
int initL1desc()
Definition: objDesc.cpp:33
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
SYS_CAUGHT_SIGNAL
@ SYS_CAUGHT_SIGNAL
Definition: rodsErrorTable.h:75
manual_cleanup.zone_name
zone_name
Definition: manual_cleanup.py:16
initRsComm
int initRsComm(rsComm_t *rsComm)
Definition: initServer.cpp:727
rcGlobalExtern.h
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
rsComm_t::cookie
int cookie
Definition: rcConnect.h:169
ZoneInfoHead
zoneInfo_t * ZoneInfoHead
Definition: irods_server_globals.cpp:23
rodsConnect.h
queZone
int queZone(const char *zoneName, int portNum, rodsServerHost_t *masterServerHost, rodsServerHost_t *slaveServerHost)
Definition: rodsConnect.cpp:233
REMOTE_ICAT
#define REMOTE_ICAT
Definition: rodsConnect.h:54
irods::CFG_NEGOTIATION_KEY_KW
const std::string CFG_NEGOTIATION_KEY_KW("negotiation_key")
localSID
char localSID[50]
Definition: irods_server_globals.cpp:58
GenQueryInp::selectInp
inxIvalPair_t selectInp
Definition: rodsGenQuery.h:53
LocalServerHost
rodsServerHost_t * LocalServerHost
Definition: irods_server_globals.cpp:20
GenQueryInp::maxRows
int maxRows
Definition: rodsGenQuery.h:25
SYS_GETSTARTUP_PACK_ERR
@ SYS_GETSTARTUP_PACK_ERR
Definition: rodsErrorTable.h:76
COL_ZONE_TYPE
#define COL_ZONE_TYPE
Definition: rodsGenQuery.h:124
initHostConfigByFile
int initHostConfigByFile()
Definition: initServer.cpp:629
HOST_CONFIG_FILE
#define HOST_CONFIG_FILE
Definition: rodsConnect.h:7
ProcessType
int ProcessType
Definition: rcGlobal.cpp:16
COL_ZONE_CONNECTION
#define COL_ZONE_CONNECTION
Definition: rodsGenQuery.h:125
RuleExecInfo::rsComm
rsComm_t * rsComm
Definition: irods_re_structs.hpp:22
rsComm_t::myEnv
rodsEnv myEnv
Definition: rcConnect.h:154
disconnectRcat
int disconnectRcat()
Definition: rsIcatOpr.cpp:68
logFileOpen
int logFileOpen(int runMode, const char *logDir, const char *logFileName)
Definition: initServer.cpp:796
RECONN_TIMEOUT
#define RECONN_TIMEOUT
Definition: rcConnect.h:36
SP_OPTION
#define SP_OPTION
Definition: rodsDef.h:263
LOCK_FILE_PURGE_TIME
#define LOCK_FILE_PURGE_TIME
Definition: rodsConnect.h:25
startupPack::clientUser
char clientUser[64]
Definition: rodsDef.h:240
irodsProt_t
irodsProt_t
Definition: rodsDef.h:147
version_t::apiVersion
char apiVersion[64]
Definition: rodsDef.h:289
rsGlobalExtern.hpp
printServerHost
int printServerHost(rodsServerHost_t *myServerHost)
Definition: rodsConnect.cpp:475
connectRcat
int connectRcat()
Definition: rsIcatOpr.cpp:16
rsComm_t::reconnSock
int reconnSock
Definition: rcConnect.h:165
irods::error::code
long long code() const
Definition: irods_error.cpp:194
irods::CFG_IRODS_XMSG_HOST_KW
const std::string CFG_IRODS_XMSG_HOST_KW("xmsg_host")
startupPack::proxyRodsZone
char proxyRodsZone[64]
Definition: rodsDef.h:239
reconnManager
void reconnManager(rsComm_t *rsComm)
Definition: miscServerFunct.cpp:2173
GlobalQuotaOverrun
rodsLong_t GlobalQuotaOverrun
Definition: irods_server_globals.cpp:63
purgeLockFileDir
int purgeLockFileDir(int chkLockFlag)
Definition: initServer.cpp:1109
initRcatServerHostByFile
int initRcatServerHostByFile()
Definition: initServer.cpp:187
initLocalServerHost
int initLocalServerHost()
Definition: initServer.cpp:144
getSqlResultByInx
sqlResult_t * getSqlResultByInx(genQueryOut_t *genQueryOut, int attriInx)
Definition: rcMisc.cpp:1387
RESC_QUOTA_UNINIT
#define RESC_QUOTA_UNINIT
Definition: getRescQuota.h:9
LOG_DEBUG
#define LOG_DEBUG
Definition: rodsLog.h:23
agentProc::next
struct agentProc * next
Definition: rodsConnect.h:34
rsComm_t::proxyUser
userInfo_t proxyUser
Definition: rcConnect.h:152
IRODS_PROT
#define IRODS_PROT
Definition: rodsDef.h:248
rsComm_t::reconnFlag
int reconnFlag
Definition: rcConnect.h:164
InformationRequiredToSafelyRenameProcess::argv0
char * argv0
Definition: initServer.hpp:17
irods::CFG_SERVICE_ROLE_PROVIDER
const std::string CFG_SERVICE_ROLE_PROVIDER("provider")
HostConfigHead
rodsServerHost_t * HostConfigHead
Definition: irods_server_globals.cpp:22
UNIX_FILE_OPENDIR_ERR
@ UNIX_FILE_OPENDIR_ERR
Definition: rodsErrorTable.h:312
irods::configuration_parser
Definition: irods_configuration_parser.hpp:20
irods::configuration_parser::load
error load(const std::string &)
Definition: irods_configuration_parser.cpp:72
genQuery.h
rsComm_t::remoteAddr
struct sockaddr_in remoteAddr
Definition: rcConnect.h:150
SP_REL_VERSION
#define SP_REL_VERSION
Definition: rodsDef.h:261
signalExit
void signalExit(int)
Definition: initServer.cpp:589
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
terminate_irods_processes.e
e
Definition: terminate_irods_processes.py:19
getRescQuota.h
COL_ZONE_NAME
#define COL_ZONE_NAME
Definition: rodsGenQuery.h:123
startupPack::reconnFlag
int reconnFlag
Definition: rodsDef.h:236
rsComm_t::reconnPort
int reconnPort
Definition: rcConnect.h:166
addInxIval
int addInxIval(inxIvalPair_t *inxIvalPair, int inx, int value)
Definition: rcMisc.cpp:883
RescQuotaPolicy
int RescQuotaPolicy
Definition: irods_server_globals.cpp:64
INVALID_ANY_CAST
@ INVALID_ANY_CAST
Definition: rodsErrorTable.h:771
KEY_NOT_FOUND
@ KEY_NOT_FOUND
Definition: rodsErrorTable.h:749
GlobalQuotaLimit
rodsLong_t GlobalQuotaLimit
Definition: irods_server_globals.cpp:62
rsComm_t::reconnAddr
char * reconnAddr
Definition: rcConnect.h:168
disconnectAllSvrToSvrConn
int disconnectAllSvrToSvrConn()
Definition: rodsConnect.cpp:762
GenQueryOut
Definition: rodsGenQuery.h:67
SP_RECONN_FLAG
#define SP_RECONN_FLAG
Definition: rodsDef.h:256
LOCAL_PRIV_USER_AUTH
#define LOCAL_PRIV_USER_AUTH
Definition: rodsUser.h:36
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
queAgentProc
int queAgentProc(agentProc_t *agentProc, agentProc_t **agentProcHead, irodsPosition_t position)
Definition: initServer.cpp:1079
initExecCmdMutex
int initExecCmdMutex()
Definition: rsExecCmd.cpp:29
rodsServerHost::xmsgHostFlag
int xmsgHostFlag
Definition: rodsConnect.h:67
userInfo_t::rodsZone
char rodsZone[64]
Definition: rodsUser.h:67
startupPack::proxyUser
char proxyUser[64]
Definition: rodsDef.h:238
zoneInfo::portNum
int portNum
Definition: rodsConnect.h:76
remote_SID_key_map
irods::lookup_table< std::pair< std::string, std::string > > remote_SID_key_map
Definition: irods_server_globals.cpp:59
GenQueryOut::rowCnt
int rowCnt
Definition: rodsGenQuery.h:68
setRsCommFromRodsEnv
int setRsCommFromRodsEnv(rsComm_t *rsComm)
Definition: initServer.cpp:1060
agentProc
Definition: rodsConnect.h:29
physPath.hpp
irods::log
void log(const error &)
Definition: irods_log.cpp:13
SP_PROTOCOL
#define SP_PROTOCOL
Definition: rodsDef.h:255
rsIcatOpr.hpp
BrokenPipeCnt
static int BrokenPipeCnt
Definition: initServer.cpp:47
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
rsComm_t::clientUser
userInfo_t clientUser
Definition: rcConnect.h:153
startupPack::apiVersion
char apiVersion[64]
Definition: rodsDef.h:243
cleanupAndExit
void cleanupAndExit(int status)
Definition: initServer.cpp:571
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
SYS_GET_HOSTNAME_ERR
@ SYS_GET_HOSTNAME_ERR
Definition: rodsErrorTable.h:85
irods::error
Definition: irods_error.hpp:23
startupPack::irodsProt
irodsProt_t irodsProt
Definition: rodsDef.h:235
initAgent
int initAgent(int processType, rsComm_t *rsComm)
Definition: initServer.cpp:463
miscServerFunct.hpp
int
typedef int((*funcPtr)())
InitialState
int InitialState
Definition: irods_server_globals.cpp:44
getLogfileName
void getLogfileName(char **logFile, const char *logDir, const char *logFileName)
Definition: rsLog.cpp:45
SP_CLIENT_USER
#define SP_CLIENT_USER
Definition: rodsDef.h:259
SqlResult::value
char * value
Definition: rodsGenQuery.h:64
version_t::relVersion
char relVersion[64]
Definition: rodsDef.h:288
ThisComm
rsComm_t * ThisComm
Definition: irods_server_globals.cpp:45
irods::experimental::filesystem::client::remove
auto remove(rcComm_t &_comm, const path &_p, remove_options _opts=remove_options::none) -> bool
Definition: filesystem.cpp:699
startupPack::option
char option[256]
Definition: rodsDef.h:244
startupPack::connectCnt
int connectCnt
Definition: rodsDef.h:237
get_catalog_service_role
irods::error get_catalog_service_role(std::string &_role)
Definition: miscServerFunct.cpp:3153
rodsServerHost
Definition: rodsConnect.h:62
procLog.h
rodsHostAddr_t::hostAddr
char hostAddr[256]
Definition: rodsDef.h:297
CAT_NO_ROWS_FOUND
@ CAT_NO_ROWS_FOUND
Definition: rodsErrorTable.h:423
SqlResult
Definition: rodsGenQuery.h:61
PUBLIC_USER_NAME
#define PUBLIC_USER_NAME
Definition: rodsDef.h:130
SP_API_VERSION
#define SP_API_VERSION
Definition: rodsDef.h:262
InformationRequiredToSafelyRenameProcess::InformationRequiredToSafelyRenameProcess
InformationRequiredToSafelyRenameProcess(char **argv)
Definition: initServer.cpp:50
irods::CFG_ZONE_AUTH_SCHEME
const std::string CFG_ZONE_AUTH_SCHEME("zone_auth_scheme")
LOCAL_ZONE_SID_KW
#define LOCAL_ZONE_SID_KW
Definition: rodsConnect.h:84
RuleExecInfo
Definition: irods_re_structs.hpp:18
InformationRequiredToSafelyRenameProcess::argv0_size
size_t argv0_size
Definition: initServer.hpp:18
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
initRsCommWithStartupPack
int initRsCommWithStartupPack(rsComm_t *rsComm, startupPack_t *startupPack)
Definition: initServer.cpp:834
SERVER_PT
#define SERVER_PT
Definition: rodsDef.h:78
rodsServerHost::zoneInfo
void * zoneInfo
Definition: rodsConnect.h:70
rsPipeSignalHandler
void rsPipeSignalHandler(int)
Definition: initServer.cpp:599
startupPack
Definition: rodsDef.h:234
applyRule
int applyRule(char *inAction, msParamArray_t *inMsParamArray, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:65
resource.hpp
irods::exception
Definition: irods_exception.hpp:15
SqlResult::len
int len
Definition: rodsGenQuery.h:63
zoneInfo::slaveServerHost
rodsServerHost_t * slaveServerHost
Definition: rodsConnect.h:78
initFileDesc
int initFileDesc()
Definition: fileOpr.cpp:25
NATIVE_PROT
@ NATIVE_PROT
Definition: rodsDef.h:148
irods_configuration_parser.hpp
sockComm.h
FILE_OPEN_ERR
@ FILE_OPEN_ERR
Definition: rodsErrorTable.h:494
queAddr
int queAddr(rodsServerHost_t *rodsServerHost, char *myHostName)
Definition: rodsConnect.cpp:143
SINGLE_PASS
#define SINGLE_PASS
Definition: rodsConnect.h:58
initServerInfo
int initServerInfo(int processType, rsComm_t *rsComm)
Definition: initServer.cpp:57
INITIAL_DONE
#define INITIAL_DONE
Definition: rodsConnect.h:19
initServer.hpp
rsGenQuery.hpp
irods_random.hpp
userInfo_t::authInfo
authInfo_t authInfo
Definition: rodsUser.h:70
UNIX_FILE_STAT_ERR
@ UNIX_FILE_STAT_ERR
Definition: rodsErrorTable.h:306
irods::CFG_ZONE_NAME
const std::string CFG_ZONE_NAME("zone_name")
SP_PROXY_RODS_ZONE
#define SP_PROXY_RODS_ZONE
Definition: rodsDef.h:258
parseHostAddrStr
int parseHostAddrStr(char *hostAddr, rodsHostAddr_t *addr)
Definition: rcMisc.cpp:3552
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
rsComm_t::clientAddr
char clientAddr[64]
Definition: rcConnect.h:151
rsComm_t::cliVersion
version_t cliVersion
Definition: rcConnect.h:155
rodsHostAddr_t::portNum
int portNum
Definition: rodsDef.h:299
freeGenQueryOut
int freeGenQueryOut(genQueryOut_t **genQueryOut)
Definition: rcMisc.cpp:1133
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
irods::CFG_ZONE_PORT
const std::string CFG_ZONE_PORT("zone_port")
authInfo_t::authFlag
int authFlag
Definition: rodsUser.h:42
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irodsPosition_t
irodsPosition_t
Definition: rodsDef.h:160
initSpecCollDesc
int initSpecCollDesc()
Definition: objDesc.cpp:68
COL_ZONE_COMMENT
#define COL_ZONE_COMMENT
Definition: rodsGenQuery.h:126
svrSockOpenForInConn
int svrSockOpenForInConn(rsComm_t *rsComm, int *portNum, char **addr, int proto)
Definition: miscServerFunct.cpp:2368
SYS_THREAD_RESOURCE_ERR
@ SYS_THREAD_RESOURCE_ERR
Definition: rodsErrorTable.h:214
rsComm_t::sock
int sock
Definition: rcConnect.h:147
clearGenQueryInp
void clearGenQueryInp(void *voidInp)
Definition: rcMisc.cpp:1118
rsGenQuery
int rsGenQuery(rsComm_t *rsComm, genQueryInp_t *genQueryInp, genQueryOut_t **genQueryOut)
Definition: rsGenQuery.cpp:604
thread_context::lock
boost::mutex * lock
Definition: irods_threads.hpp:12
rsComm_t::localAddr
struct sockaddr_in localAddr
Definition: rcConnect.h:149
irods::re_plugin_globals
std::unique_ptr< struct irods::global_re_plugin_mgr > re_plugin_globals
Definition: irods_re_plugin.cpp:16
rodsHostAddr_t::zoneName
char zoneName[64]
Definition: rodsDef.h:298
TOP_POS
@ TOP_POS
Definition: rodsDef.h:162
irods_log.hpp
closeAllL1desc
int closeAllL1desc(rsComm_t *rsComm)
Definition: objDesc.cpp:108
KerberosName
char KerberosName[(1024+64)]
Definition: irods_server_globals.cpp:40
initProcLog
int initProcLog()
Definition: procLog.cpp:26
resolveHost
int resolveHost(rodsHostAddr_t *addr, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:375
rodsHostAddr_t
Definition: rodsDef.h:296
USER__NULL_INPUT_ERR
@ USER__NULL_INPUT_ERR
Definition: rodsErrorTable.h:247
rsExecCmd.hpp
daemonize
void daemonize(int runMode, int logFd)
Definition: initServer.cpp:762