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)  

ruleAdmin.cpp
Go to the documentation of this file.
1 
3 #include "rodsServer.hpp"
4 #include "reGlobalsExtern.hpp"
5 #include "reDefines.h"
6 #include <sys/time.h>
7 
8 
9 #define MY_SERVER_CONFIG_DIR "/projects/misc/doct/dgtg/irods/RODS/server/config"
10 
11 
12 
13 
14 #define LF 10
15 #define CR 13
16 #define MAX_TOKEN 500
17 #define MAX_ENTRIES 5000
18 #define MYSRBBUFSIZE 2000000
19 #define QSIZE MYSRBBUFSIZE
20 #define HUGE_STRING 5000
21 
22 typedef struct {
23  char name[100];
24  int size;
25  char *val;
26  char *fstr;
27 } entry;
28 
29 char *fixstr1;
30 int heading = 0;
31 
32 typedef struct {
34  char cookieStr[MAX_TOKEN];
35  int op;
36  int m; /* m is the number of the last entry which usually stores session ID # */
37 } paramIn;
38 
39 typedef paramIn *inStruct;
40 int
41 showRules( paramIn *Sentries );
42 int
43 performAction( paramIn *Sentries );
44 
45 int
46 webErrorExit( char *msg, int status ) {
47  if ( !heading ) {
48  printf( "Content-type: text/html%c%c", 10, 10 );
49  fflush( stdout );
50  printf( "<html>" );
51  printf( "<body>" );
52  }
53  printf( "<B><FONT COLOR=#DC143C>Error: %s: %i</B>\n", msg, status );
54  printf( "</body></html>" );
55  exit( -1 );
56 }
57 
58 char x2c( char *what ) {
59  char digit;
60 
61  digit = ( what[0] >= 'A' ? ( ( what[0] & 0xdf ) - 'A' ) + 10 : ( what[0] - '0' ) );
62  digit *= 16;
63  digit += ( what[1] >= 'A' ? ( ( what[1] & 0xdf ) - 'A' ) + 10 : ( what[1] - '0' ) );
64  return digit;
65 }
66 
67 void unescape_url( char *url ) {
68  int x, y;
69 
70  for ( x = 0, y = 0; url[y]; ++x, ++y ) {
71  if ( ( ( url[x] = url[y] ) == '%' ) && isxdigit( url[y + 1] ) && isxdigit( url[y + 2] ) ) {
72  url[x] = x2c( &url[y + 1] );
73  y += 2;
74  }
75  }
76  url[x] = '\0';
77 }
78 
79 
80 void plustospace( char *str ) {
81  int x;
82 
83  for ( x = 0; str[x]; x++ ) if ( str[x] == '+' ) {
84  str[x] = ' ';
85  }
86 }
87 
88 int
89 getBoundary( char **stquery, char *boundary ) {
90  char *tmp1;
91 
92  tmp1 = *stquery;
93  while ( *tmp1 != '\n' ) {
94  tmp1++;
95  }
96  tmp1--;
97  *tmp1 = '\0';
98  strcpy( boundary, *stquery );
99  *tmp1 = '\n';
100 }
101 
102 char*
103 findBoundary( char *inStr, char *bound, int length ) {
104  int i, j;
105  void *tmpPtr, *tmpPtr1;
106  j = strlen( bound );
107  tmpPtr = ( void * ) inStr;
108  while ( length > 0 ) {
110  tmpPtr1 = memchr( tmpPtr, bound[0], length );
112  if ( tmpPtr1 == NULL ) {
113  return NULL;
114  }
115  if ( memcmp( tmpPtr1, ( void * ) bound, j ) == 0 ) {
116  return tmpPtr1;
117  }
118  length = length - ( int )( ( char * )tmpPtr1 - ( char * ) tmpPtr ) + 1;
119  tmpPtr = ( void * )( ( char * ) tmpPtr1 + 1 );
120  }
121  return NULL;
122 
123 }
124 int
125 getmultipartword( entry *iEntry, char **stquery, char *boundary, int length ) {
126  char *inS, *tmp1, *tmp2, *endStr;
127  int i, j, k;
128 
129  if ( strlen( *stquery ) < ( 2 * strlen( boundary ) ) ) {
130  return 1;
131  }
132 
133  if ( ( tmp1 = strstr( ( char * ) * stquery, boundary ) ) == NULL ) {
134  webErrorExit( "No Beginning Boundary Found In Field:", 0 );
135  }
136  if ( ( endStr = findBoundary( ( char * )( tmp1 + 1 ), boundary, length ) ) == NULL ) {
137  webErrorExit( "No Ending Boundary Found In Field:", 0 );
138  }
139  *( endStr - 2 ) = '\0'; /* why are we doing this ?? */
140 
141  if ( ( tmp2 = strstr( tmp1, "name=\"" ) ) == NULL ) {
142  webErrorExit( "No Name Found In Field", 0 );
143  }
144  tmp2 += 6;
145  tmp1 = strchr( tmp2, '\"' );
146  *tmp1 = '\0';
147  tmp1++;
148  strcpy( iEntry->name, tmp2 );
149  if ( ( int )( strstr( tmp1, "filename" ) != NULL &&
150  strstr( tmp1, "filename" ) - tmp1 ) < 5 ) {
151  /* this is a file - skip two lines*/
152  while ( *tmp1 != '\n' ) {
153  tmp1++;
154  }
155  tmp1++;
156  while ( *tmp1 != '\n' ) {
157  tmp1++;
158  }
159  tmp1++;
161  if ( strstr( iEntry->name, "filename" ) != NULL ) {
162  tmp1++;
163  tmp1++;
164  }
166  iEntry->size = ( int )( endStr - tmp1 );
167  iEntry->fstr = NULL;
168  iEntry->val = ( char * ) malloc( iEntry->size );
169  memcpy( iEntry->val, tmp1, iEntry->size );
170  iEntry->size -= 2;
171  }
172  else {
177  iEntry->val = ( char * ) malloc( strlen( tmp1 ) + 3 );
178  iEntry->fstr = NULL;
179  strcpy( iEntry->val, tmp1 );
180  iEntry->size = strlen( iEntry->val );
181  }
182  *stquery = endStr;
183 
184  return 0;
185 }
186 int
187 mybgets( char inbuf[], char buffer[], int j ) {
188  char ch;
189  int i = 0;
190  ch = inbuf[j];
191  j++;
192  if ( ch == '\0' ) {
193  return -1;
194  }
195  while ( ch != '\n' ) {
196  buffer[i] = ch;
197  ++i;
198  ch = inbuf[j];
199  j++;
200  if ( ch == '\0' ) {
201  return -1;
202  }
203  }
204  buffer[i] = '\0';
205  return j;
206 }
207 
208 
209 char
210 myfgets( FILE *infile, char buffer[] ) {
211  char ch;
212  int i = 0;
213  ch = getc( infile );
214  if ( ch == EOF ) {
215  return ch;
216  }
217  while ( ch != '\n' ) {
218  buffer[i] = ch;
219  ++i;
220  ch = getc( infile );
221  }
222  buffer[i] = '\0';
223 
224  return '1';
225 }
226 
227 
228 
229 
230 
231 
232 void getword( char *word, char *line, char stop ) {
233  int x = 0, y;
234 
235  for ( x = 0; ( ( line[x] ) && ( line[x] != stop ) ); x++ ) {
236  word[x] = line[x];
237  }
238 
239  word[x] = '\0';
240  if ( line[x] ) {
241  ++x;
242  }
243  y = 0;
244 
245  while ( line[y++] = line[x++] ) {
246  ;
247  }
248 }
249 
250 char *makeword( char *line, char stop ) {
251  int x = 0, y;
252  char *word = ( char * ) malloc( sizeof( char ) * ( strlen( line ) + 1 ) );
253 
254  for ( x = 0; ( ( line[x] ) && ( line[x] != stop ) ); x++ ) {
255  word[x] = line[x];
256  }
257 
258  word[x] = '\0';
259  if ( line[x] ) {
260  ++x;
261  }
262  y = 0;
263 
264  while ( line[y++] = line[x++] ) {
265  ;
266  }
267  return word;
268 }
269 
270 char *fmakeword( FILE *f, char stop, int *cl ) {
271  int wsize;
272  char *word;
273  int ll;
274 
275  wsize = 102400;
276  ll = 0;
277  word = ( char * ) malloc( sizeof( char ) * ( wsize + 1 ) );
278 
279  while ( 1 ) {
280  word[ll] = ( char )fgetc( f );
281  printf( "%c", word[ll] );
282  if ( ll == wsize ) {
283  word[ll + 1] = '\0';
284  wsize += 102400;
285  // JMC cppcheck - realloc failure check
286  char* tmp_ch = 0;
287  tmp_ch = ( char * )realloc( word, sizeof( char ) * ( wsize + 1 ) );
288  if ( !tmp_ch ) {
289  rodsLog( LOG_ERROR, "fmakeword :: realloc failed" );
290  }
291  else {
292  word = tmp_ch;
293  }
294  }
295  --( *cl );
296  if ( ( word[ll] == stop ) || ( feof( f ) ) || ( !( *cl ) ) ) {
297  if ( word[ll] != stop ) {
298  ll++;
299  }
300  word[ll] = '\0';
301  return word;
302  }
303  ++ll;
304  }
305 }
306 
307 
308 int rind( char *s, char c ) {
309  int x;
310  for ( x = strlen( s ) - 1; x != -1; x-- )
311  if ( s[x] == c ) {
312  return x;
313  }
314  return -1;
315 }
316 
317 int getline( char *s, int n, FILE *f ) {
318  int i = 0;
319 
320  while ( 1 ) {
321  s[i] = ( char )fgetc( f );
322 
323  if ( s[i] == CR ) {
324  s[i] = fgetc( f );
325  }
326 
327  if ( ( s[i] == 0x4 ) || ( s[i] == LF ) || ( i == ( n - 1 ) ) ) {
328  s[i] = '\0';
329  return feof( f ) ? 1 : 0;
330  }
331  ++i;
332  }
333 }
334 
335 void send_fd( FILE *f, FILE *fd ) {
336  int num_chars = 0;
337  char c;
338 
339  while ( 1 ) {
340  c = fgetc( f );
341  if ( feof( f ) ) {
342  return;
343  }
344  fputc( c, fd );
345  }
346 }
347 
348 /* reads values entered in html form and stores them in the inStruct previously defined */
349 
350 int getEntries( inStruct Sentries ) {
351  int x;
352  char *stquery, *tmpq, *tmpStr, *tmpStr1, *tmpPtr;
353  char reqMethod[100];
354  int msgLength;
355  char contentType[100];
356  char boundary[MAX_TOKEN];
357  int i;
358 
359 
360  putenv( "HOME=/" );
361 
362 
363  if ( getenv( "CONTENT_TYPE" ) != NULL ) {
364  strcpy( contentType, getenv( "CONTENT_TYPE" ) );
365  }
366  else {
367  strcpy( contentType, "" );
368  }
369  if ( getenv( "REQUEST_METHOD" ) != NULL ) {
370  strcpy( reqMethod, getenv( "REQUEST_METHOD" ) );
371  }
372  else {
373  strcpy( reqMethod, "" );
374  }
375  if ( getenv( "HTTP_COOKIE" ) != NULL ) {
376  strcpy( Sentries->cookieStr, getenv( "HTTP_COOKIE" ) );
377  }
378 
379  else {
380  strcpy( Sentries->cookieStr, "" );
381  }
382  if ( strstr( Sentries->cookieStr, "*" ) != NULL ||
383  strstr( Sentries->cookieStr, ".." ) != NULL ||
384  strstr( Sentries->cookieStr, "?" ) != NULL ||
385  strstr( Sentries->cookieStr, "/" ) != NULL ||
386  strstr( Sentries->cookieStr, "\\" ) != NULL ) {
387 
388  Sentries->op = -1;
389  return 1;
390 
391 
392  }
393 
394 
395  if ( !strcmp( reqMethod, "POST" ) || !strcmp( reqMethod, "post" ) ) {
396  msgLength = atoi( getenv( "CONTENT_LENGTH" ) ) + 10;
397  stquery = malloc( msgLength );
398  if ( fread( stquery, 1, msgLength, stdin ) != ( msgLength - 10 ) ) {
399  webErrorExit( "short fread", 0 );
400  }
401  stquery[msgLength] = '\0';
402  }
403  else {
404  stquery = malloc( QSIZE );
405  if ( getenv( "QUERY_STRING" ) != NULL ) {
406  strcpy( stquery, getenv( "QUERY_STRING" ) );
407  }
408  else {
409  strcpy( stquery, "" );
410  }
411  }
412 
413  if ( strstr( contentType, "multipart/form-data" ) != NULL ) {
414 
415  i = msgLength - 10;
416  getBoundary( &stquery, boundary );
417 
418  for ( x = 0; *stquery != '\0'; x++ ) {
419  if ( x == MAX_ENTRIES ) {
420  webErrorExit( "MaxEntries Exceeded", x );
421  }
422  Sentries->m = x;
423 
424  tmpPtr = stquery;
425  if ( getmultipartword( &Sentries->entries[x], &stquery, boundary, i ) != 0 ) {
426  break;
427  }
428  i -= stquery - tmpPtr;
429 
430  }
431  Sentries->m--;
432  }
433  else {
434 
437  fixstr1 = malloc( 10 );
438  free( fixstr1 );
439 
441  for ( x = 0; stquery[0] != '\0'; x++ ) {
442  if ( x == MAX_ENTRIES ) {
443  webErrorExit( "MaxEntries Exceeded", x );
444  }
445  Sentries->m = x;
446  Sentries->entries[x].val = malloc( HUGE_STRING );
447  getword( Sentries->entries[x].val, stquery, '&' );
448  plustospace( Sentries->entries[x].val );
449  unescape_url( Sentries->entries[x].val );
450  char* wd = ( char * ) makeword( Sentries->entries[x].val, '=' ); // JMC cppcheck - leak
451  sprintf( Sentries->entries[x].name, wd );
452  free( wd ); // JMC cppcheck - leak
453  }
454  }
455 
456  return 0;
457 
458 }
459 
460 
461 
462 int main( int argc, char **argv ) {
463 
464  inStruct Sentries = ( paramIn* )malloc( sizeof( paramIn ) );
465 
466 
476 
478  getEntries( Sentries );
479 
480 
516  if ( !strcmp( Sentries->entries[0].val, "showRules" ) ) {
517  showRules( Sentries );
518  }
519  else if ( !strcmp( Sentries->entries[0].val, "applyRule" ) ) {
520  performAction( Sentries );
521  }
522  free( Sentries );
523  return 0;
524 }
525 
526 int
527 showRules( inStruct Sentries ) {
528  int n, i, j;
529  char ruleCondition[MAX_RULE_LENGTH];
530  char ruleAction[MAX_RULE_LENGTH];
531  char ruleRecovery[MAX_RULE_LENGTH];
532  char ruleHead[MAX_ACTION_SIZE];
533  char ruleBase[MAX_ACTION_SIZE];
534  char *actionArray[MAX_ACTION_IN_RULE];
535  char *recoveryArray[MAX_ACTION_IN_RULE];
536  char configDirEV[200];
538  char oldRuleBase[MAX_ACTION_SIZE];
539  strcpy( ruleSet, "" );
540  strcpy( oldRuleBase, "" );
541  fprintf( stdout, "Content-type: text/html%c%c", 10, 10 );
542  fflush( stdout );
543  fprintf( stdout, "<HTML>\n<HEAD>\n<TITLE>iRODS Rule Administration</TITLE>\n</HEAD>\n<BODY bgcolor=#FFFFFF>\n" );
544  fprintf( stdout, "<CENTER> <B><FONT COLOR=#FF0000>iRODS Rule Base</FONT></B></CENTER>\n" );
545  fflush( stdout );
546 
547  /* sprintf(configDirEV,"irodsConfigDir=/scratch/s1/sekar/irods/RODS/server/config");
548  sprintf(configDirEV,"irodsConfigDir=/misc/www/projects/srb-secure/cgi-bin");
549  putenv(configDirEV);
550  */
551 
552 
553  for ( i = 0; i <= Sentries->m; i++ ) {
554  if ( !strcmp( Sentries->entries[i].name, "ruleSet" ) ) {
555  if ( strlen( Sentries->entries[i].val ) > 0 ) {
556  if ( ruleSet[0] != '\0' ) {
557  strcat( ruleSet, "," );
558  }
559  rstrcat( ruleSet, Sentries->entries[i].val, 999 );
560  }
561  }
562  else if ( !strcmp( Sentries->entries[i].name, "configDir" ) ) {
563  if ( strlen( Sentries->entries[i].val ) > 0 ) {
564  snprintf( configDirEV, 199, "irodsConfigDir=%s", Sentries->entries[i].val );
565  }
566  else {
567  sprintf( configDirEV, "irodsConfigDir=%s", MY_SERVER_CONFIG_DIR );
568  }
569  putenv( configDirEV );
570  }
571  }
572  if ( ruleSet[0] == '\0' ) {
573  strcpy( ruleSet, "core" );
574  }
575  fprintf( stdout, "<CENTER> <B><FONT COLOR=#0000FF>[%s]</FONT></B></CENTER>\n", ruleSet );
576  fflush( stdout );
577 
578  initRuleStruct( NULL, ruleSet, "core", "core" );
579  fprintf( stdout, "<TABLE>\n" );
580  for ( j = 0 ; j < coreRuleStrct.MaxNumOfRules; j++ ) {
581  getRule( j + 1000 , ruleBase, ruleHead, ruleCondition, ruleAction, ruleRecovery, MAX_RULE_LENGTH );
582  if ( strcmp( oldRuleBase, ruleBase ) ) {
583  if ( strlen( oldRuleBase ) > 0 ) {
584  fprintf( stdout, "<TR><TD COLSPAN=6><HR NOSHADE COLOR=#00FF00 SIZE=4></TD></TR>" );
585  }
586  strcpy( oldRuleBase, ruleBase );
587  }
588  n = getActionRecoveryList( ruleAction, ruleRecovery, actionArray, recoveryArray );
589  fprintf( stdout, "<TR><TD><BR>&nbsp;%i</TD><TD><BR>&nbsp;<FONT COLOR=#0000FF>ON</FONT></TD><TD COLSPAN=3><BR>&nbsp;<FONT COLOR=#FF0000>%s.</FONT><FONT COLOR=#0000FF>%s</FONT></TD></TR>\n", j, ruleBase, ruleHead );
590  if ( strlen( ruleCondition ) != 0 ) {
591  fprintf( stdout, "<TR><TD></TD><TD></TD><TD VALIGN=TOP>IF &nbsp;</TD><TD COLSPAN=3 VALIGN=TOP><FONT COLOR=#FF0000>%s</FONT></TD></TR>\n", ruleCondition );
592  }
593  for ( i = 0; i < n; i++ ) {
594  if ( i == 0 )
595  fprintf( stdout, "<TR><TD></TD><TD></TD><TD VALIGN=TOP>DO &nbsp;</TD><TD VALIGN=TOP>%s</TD><TD NOWRAP>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD><TD VALIGN=TOP>[%s]</TD></TR>\n",
596  actionArray[i], recoveryArray[i] );
597  else
598  fprintf( stdout, "<TR><TD></TD><TD></TD><TD VALIGN=TOP>AND &nbsp;</TD><TD VALIGN=TOP>%s</TD><TD NOWRAP>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD><TD VALIGN=TOP>[%s]</TD></TR>\n",
599  actionArray[i], recoveryArray[i] );
600  }
601  }
602  fprintf( stdout, "</TABLE>\n" );
603  fprintf( stdout, "</BODY>\n</HTML>\n" );
604  return 0;
605 }
606 
607 int
608 performAction( inStruct Sentries ) {
609  int status;
610  int c, i, j;
611  int uFlag = 0;;
612  char tmpStr[100];
613  ruleExecInfo_t rei;
614  char action[100];
615  char *t1;
616  char *args[MAX_NUM_OF_ARGS_IN_ACTION];
617  char configDirEV[200];
618  char retestflagEV[200];
619  char reloopbackflagEV[200];
620 
622  hrtime_t ht1, ht2, ht3;
623 
624  bzero( &rei, sizeof( ruleExecInfo_t ) ); /* June 17. 2009 */
625  /*
626  sprintf(configDirEV,"irodsConfigDir=/scratch/s1/sekar/irods/RODS/server/config");
627  sprintf(configDirEV,"irodsConfigDir=/misc/www/projects/srb-secure/cgi-bin");
628  putenv(configDirEV);
629  */
630  sprintf( retestflagEV, "RETESTFLAG=%i", HTML_TEST_1 );
631  putenv( retestflagEV );
632  sprintf( reloopbackflagEV, "RELOOPBACKFLAG=%i", LOOP_BACK_1 );
633  putenv( reloopbackflagEV );
634 
635  fprintf( stdout, "Content-type: text/html%c%c", 10, 10 );
636  fflush( stdout );
637  fprintf( stdout, "<HTML>\n<HEAD>\n<TITLE>iRODS Rule Administration</TITLE>\n</HEAD>\n<BODY bgcolor=#FFFFFF>\n" );
638  fprintf( stdout, "<CENTER> <B><FONT COLOR=#FF0000>iRODS Rule Application</FONT></B></CENTER>\n" );
639  fflush( stdout );
640 
641  rei.doi = mallocAndZero( sizeof( dataObjInfo_t ) );
642  rei.uoip = mallocAndZero( sizeof( userInfo_t ) );
643  rei.uoic = mallocAndZero( sizeof( userInfo_t ) );
644  rei.coi = mallocAndZero( sizeof( collInfo_t ) );
645  rei.uoio = mallocAndZero( sizeof( userInfo_t ) );
646  rei.next = NULL;
647 
648  strcpy( rei.doi->objPath, "" );
649  strcpy( rei.doi->rescName, "" );
650  strcpy( rei.doi->dataType, "" );
651  strcpy( rei.uoic->authInfo.host, "" );
652  rei.doi->dataSize = 100;
653 
654 
655  rei.condInputData = NULL;
656 
657  rei.rsComm = NULL;
658  strcpy( ruleSet, "" );
659 
660  for ( i = 0; i <= Sentries->m; i++ ) {
661 
662  if ( !strcmp( Sentries->entries[i].name, "action" ) ) {
663  strcpy( action, Sentries->entries[i].val );
664  fprintf( stdout, "<FONT COLOR=#0000FF>Action:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
665  Sentries->entries[i].val );
666  }
667  else if ( !strcmp( Sentries->entries[i].name, "objPath" ) ) {
668  strcpy( rei.doi->objPath, Sentries->entries[i].val );
669  fprintf( stdout, "<FONT COLOR=#0000FF>$objPath:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
670  Sentries->entries[i].val );
671  }
672  else if ( !strcmp( Sentries->entries[i].name, "rescName" ) ) {
673  strcpy( rei.doi->rescName, Sentries->entries[i].val );
674  fprintf( stdout, "<FONT COLOR=#0000FF>$rescName:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
675  Sentries->entries[i].val );
676  }
677  else if ( !strcmp( Sentries->entries[i].name, "dataSize" ) ) {
678  rei.doi->dataSize = atol( Sentries->entries[i].val );
679  fprintf( stdout, "<FONT COLOR=#0000FF>$dataSize:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
680  Sentries->entries[i].val );
681  }
682  else if ( !strcmp( Sentries->entries[i].name, "dataType" ) ) {
683  strcpy( rei.doi->dataType, Sentries->entries[i].val );
684  fprintf( stdout, "<FONT COLOR=#0000FF>$dataType:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
685  Sentries->entries[i].val );
686  }
687  else if ( !strcmp( Sentries->entries[i].name, "dataOwner" ) ) {
688  strcpy( rei.doi->dataOwnerName, Sentries->entries[i].val );
689  if ( ( t1 = strstr( rei.doi->dataOwnerName, "|" ) ) != NULL ) {
690  *t1 = '\0';
691  strcpy( rei.doi->dataOwnerZone, ( char * )( t1 + 1 ) );
692  }
693  else {
694  strcpy( rei.doi->dataOwnerZone, "" );
695  }
696  fprintf( stdout, "<FONT COLOR=#0000FF>$dataOwner:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
697  Sentries->entries[i].val );
698  }
699  else if ( !strcmp( Sentries->entries[i].name, "dataUser" ) ) {
700  strcpy( rei.uoic->userName, Sentries->entries[i].val );
701  if ( ( t1 = strstr( rei.uoic->userName, "|" ) ) != NULL ) {
702  *t1 = '\0';
703  strcpy( rei.uoic->rodsZone, ( char * )( t1 + 1 ) );
704  }
705  else {
706  strcpy( rei.uoic->rodsZone, "" );
707  }
708  fprintf( stdout, "<FONT COLOR=#0000FF>$dataUser:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
709  Sentries->entries[i].val );
710  }
711  else if ( !strcmp( Sentries->entries[i].name, "dataAccess" ) ) {
712  strcpy( rei.doi->dataAccess, Sentries->entries[i].val );
713  fprintf( stdout, "<FONT COLOR=#0000FF>$dataAccess:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
714  Sentries->entries[i].val );
715  }
716  else if ( !strcmp( Sentries->entries[i].name, "hostClient" ) ) {
717  strcpy( rei.uoic->authInfo.host, Sentries->entries[i].val );
718  fprintf( stdout, "<FONT COLOR=#0000FF>$hostClient:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
719  Sentries->entries[i].val );
720  }
721  else if ( !strcmp( Sentries->entries[i].name, "proxyUser" ) ) {
722  strcpy( rei.uoip->userName, Sentries->entries[i].val );
723  if ( ( t1 = strstr( rei.uoip->userName, "|" ) ) != NULL ) {
724  *t1 = '\0';
725  strcpy( rei.uoip->rodsZone, ( char * )( t1 + 1 ) );
726  }
727  else {
728  strcpy( rei.uoio->rodsZone, "" );
729  }
730  fprintf( stdout, "<FONT COLOR=#0000FF>$otherUser:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
731  Sentries->entries[i].val );
732  }
733  else if ( !strcmp( Sentries->entries[i].name, "otherUser" ) ) {
734  strcpy( rei.uoic->userName, Sentries->entries[i].val );
735  if ( ( t1 = strstr( rei.uoio->userName, "|" ) ) != NULL ) {
736  *t1 = '\0';
737  strcpy( rei.uoio->rodsZone, ( char * )( t1 + 1 ) );
738  }
739  else {
740  strcpy( rei.uoio->rodsZone, "" );
741  }
742  fprintf( stdout, "<FONT COLOR=#0000FF>$otherUser:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
743  Sentries->entries[i].val );
744  }
745  else if ( !strcmp( Sentries->entries[i].name, "otherUserType" ) ) {
746  strcpy( rei.uoio->userType, Sentries->entries[i].val );
747  fprintf( stdout, "<FONT COLOR=#0000FF>$otherUserType:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
748  Sentries->entries[i].val );
749  }
750  else if ( !strcmp( Sentries->entries[i].name, "ruleSet" ) ) {
751  if ( strlen( Sentries->entries[i].val ) > 0 ) {
752  if ( ruleSet[0] != '\0' ) {
753  strcat( ruleSet, "," );
754  }
755  rstrcat( ruleSet, Sentries->entries[i].val, 999 );
756  }
757  }
758  else if ( !strcmp( Sentries->entries[i].name, "retestflag" ) ) {
759  sprintf( retestflagEV, "RETESTFLAG=%s", Sentries->entries[i].val );
760  putenv( retestflagEV );
761  fprintf( stdout, "<FONT COLOR=#0000FF>Trace Status</FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
762  Sentries->entries[i].val );
763  }
764  else if ( !strcmp( Sentries->entries[i].name, "configDir" ) ) {
765  if ( strlen( Sentries->entries[i].val ) > 0 ) {
766  snprintf( configDirEV, 199, "irodsConfigDir=%s", Sentries->entries[i].val );
767  }
768  else {
769  sprintf( configDirEV, "irodsConfigDir=%s", MY_SERVER_CONFIG_DIR );
770  }
771  putenv( configDirEV );
772  }
773 
774  /*
775  else if (!strcmp(Sentries->entries[i].name,"")){
776  strcpy(,Sentries->entries[i].val);
777  fprintf(stdout,"<FONT COLOR=#0000FF></FONT> <FONT COLOR=#FF0000>%s</FONT><BR>\n",
778  Sentries->entries[i].val);
779  }
780  */
781  }
782  fprintf( stdout, "<FONT COLOR=#0000FF>Rule Set:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR><HR>\n", ruleSet );
783  strcpy( rei.ruleSet, ruleSet );
784  /* fprintf(stdout,"<PRE>\n");fflush(stdout);*/
785  ht1 = gethrtime();
786  initRuleStruct( NULL, ruleSet, "core", "core" );
787  ht2 = gethrtime();
788 
789  i = applyRuleArgPA( action, args, 0, NULL, &rei, SAVE_REI );
790  ht3 = gethrtime();
791 
793  fprintf( stdout, "Rule Initialization Time = %.2f millisecs\n", ( float )( ht2 - ht1 ) / 1000000 );
794  fprintf( stdout, "Rule Execution Time = %.2f millisecs\n", ( float )( ht3 - ht1 ) / 1000000 );
795  }
797  fprintf( stdout, "<BR>Rule Initialization Time = %.2f millisecs<BR>\n", ( float )( ht2 - ht1 ) / 1000000 );
798  fprintf( stdout, "Rule Execution Time = %.2f millisecs<BR>\n", ( float )( ht3 - ht1 ) / 1000000 );
799  }
800 
801  if ( i != 0 ) {
802  rodsLogError( LOG_ERROR, i, "<BR>Rule Application Failed:" );
803  /* fprintf(stdout,"</PRE>\n</body>\n</HTML>\n");*/
804  return -1;
805  }
806  /* fprintf(stdout,"</PRE>\n</body>\n</HTML>\n");*/
807 
808  return 0;
809 }
810 
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
NULL
#define NULL
Definition: rodsDef.h:70
COMMAND_TEST_MSI
#define COMMAND_TEST_MSI
Definition: reDefines.h:35
rstrcat
char * rstrcat(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:75
makeword
char * makeword(char *line, char stop)
Definition: ruleAdmin.cpp:250
LF
#define LF
Definition: ruleAdmin.cpp:14
COMMAND_TEST_1
#define COMMAND_TEST_1
Definition: reDefines.h:33
paramIn::entries
entry entries[5000]
Definition: ruleAdmin.cpp:33
unescape_url
void unescape_url(char *url)
Definition: ruleAdmin.cpp:67
send_fd
void send_fd(FILE *f, FILE *fd)
Definition: ruleAdmin.cpp:335
userInfo_t
Definition: rodsUser.h:65
getword
void getword(char *word, char *line, char stop)
Definition: ruleAdmin.cpp:232
paramIn::op
int op
Definition: ruleAdmin.cpp:35
userInfo_t::userName
char userName[64]
Definition: rodsUser.h:66
MAX_ENTRIES
#define MAX_ENTRIES
Definition: ruleAdmin.cpp:17
LOOP_BACK_1
#define LOOP_BACK_1
Definition: reDefines.h:36
heading
int heading
Definition: ruleAdmin.cpp:30
DataObjInfo::dataOwnerZone
char dataOwnerZone[64]
Definition: objInfo.h:139
RuleExecInfo::coi
collInfo_t * coi
Definition: irods_re_structs.hpp:32
authInfo_t::host
char host[64]
Definition: rodsUser.h:45
DataObjInfo::dataType
char dataType[64]
Definition: objInfo.h:133
MAX_ACTION_IN_RULE
#define MAX_ACTION_IN_RULE
Definition: reDefines.h:23
reDefines.h
getEntries
int getEntries(inStruct Sentries)
Definition: ruleAdmin.cpp:350
entry::name
char name[100]
Definition: ruleAdmin.cpp:23
RuleExecInfo::doi
dataObjInfo_t * doi
Definition: irods_re_structs.hpp:28
rodsServer.hpp
reGlobalsExtern.hpp
getmultipartword
int getmultipartword(entry *iEntry, char **stquery, char *boundary, int length)
Definition: ruleAdmin.cpp:125
paramIn::m
int m
Definition: ruleAdmin.cpp:36
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
generate_iadmin_commands_for_41_to_42_upgrade.name
name
Definition: generate_iadmin_commands_for_41_to_42_upgrade.py:23
stop
irods::error stop(irods::default_re_ctx &_u, const std::string &)
Definition: libirods_rule_engine_plugin-cpp_default_policy.cpp:892
getRule
int getRule(int ri, char *ruleBase, char *ruleHead, char *ruleCondition, char *ruleAction, char *ruleRecovery, int rSize)
Definition: nre.reLib1.cpp:1007
run_tests.action
action
Definition: run_tests.py:114
MAX_ACTION_SIZE
#define MAX_ACTION_SIZE
Definition: reDefines.h:22
CollInfo
Definition: objInfo.h:177
mallocAndZero
void * mallocAndZero(int s)
Definition: reStruct.cpp:13
manual_cleanup.entries
entries
Definition: manual_cleanup.py:30
RuleExecInfo::rsComm
rsComm_t * rsComm
Definition: irods_re_structs.hpp:22
getBoundary
int getBoundary(char **stquery, char *boundary)
Definition: ruleAdmin.cpp:89
webErrorExit
int webErrorExit(char *msg, int status)
Definition: ruleAdmin.cpp:46
fixstr1
char * fixstr1
Definition: ruleAdmin.cpp:29
RuleExecInfo::condInputData
keyValPair_t * condInputData
Definition: irods_re_structs.hpp:34
x2c
char x2c(char *what)
Definition: ruleAdmin.cpp:58
MAX_TOKEN
#define MAX_TOKEN
Definition: ruleAdmin.cpp:16
SAVE_REI
#define SAVE_REI
Definition: rodsDef.h:104
ruleStruct_t::MaxNumOfRules
int MaxNumOfRules
Definition: reGlobalsExtern.hpp:92
RuleExecInfo::uoip
userInfo_t * uoip
Definition: irods_re_structs.hpp:31
DataObjInfo::dataOwnerName
char dataOwnerName[64]
Definition: objInfo.h:138
QSIZE
#define QSIZE
Definition: ruleAdmin.cpp:19
HTML_TEST_1
#define HTML_TEST_1
Definition: reDefines.h:32
getline
int getline(char *s, int n, FILE *f)
Definition: ruleAdmin.cpp:317
findBoundary
char * findBoundary(char *inStr, char *bound, int length)
Definition: ruleAdmin.cpp:103
plustospace
void plustospace(char *str)
Definition: ruleAdmin.cpp:80
MAX_NUM_OF_ARGS_IN_ACTION
#define MAX_NUM_OF_ARGS_IN_ACTION
Definition: irods_re_structs.hpp:13
MAX_RULE_LENGTH
#define MAX_RULE_LENGTH
Definition: reDefines.h:19
applyRuleArgPA
int applyRuleArgPA(const char *action, const char *args[20], int argc, msParamArray_t *inMsParamArray, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: nre.reLib1.cpp:169
irods.pypyodbc.buffer
buffer
Definition: pypyodbc.py:46
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
userInfo_t::rodsZone
char rodsZone[64]
Definition: rodsUser.h:67
showRules
int showRules(paramIn *Sentries)
HTML_TEST_MSI
#define HTML_TEST_MSI
Definition: reDefines.h:34
RULE_SET_DEF_LENGTH
#define RULE_SET_DEF_LENGTH
Definition: reDefines.h:26
rind
int rind(char *s, char c)
Definition: ruleAdmin.cpp:308
RuleExecInfo::uoio
userInfo_t * uoio
Definition: irods_re_structs.hpp:33
getActionRecoveryList
int getActionRecoveryList(char *ruleAction, char *ruleRecovery, char *actionArray[], char *recoveryArray[])
int
typedef int((*funcPtr)())
userInfo_t::userType
char userType[64]
Definition: rodsUser.h:68
myfgets
char myfgets(FILE *infile, char buffer[])
Definition: ruleAdmin.cpp:210
entry::val
char * val
Definition: ruleAdmin.cpp:25
entry::size
int size
Definition: ruleAdmin.cpp:24
entry::fstr
char * fstr
Definition: ruleAdmin.cpp:26
RuleExecInfo::ruleSet
char ruleSet[10 *(1024+64)]
Definition: irods_re_structs.hpp:37
coreRuleStrct
ruleStruct_t coreRuleStrct
Definition: libirods_rule_engine_plugin-irods_rule_language.cpp:47
RuleExecInfo::uoic
userInfo_t * uoic
Definition: irods_re_structs.hpp:30
HUGE_STRING
#define HUGE_STRING
Definition: ruleAdmin.cpp:20
MY_SERVER_CONFIG_DIR
#define MY_SERVER_CONFIG_DIR
Definition: ruleAdmin.cpp:9
DataObjInfo::dataAccess
char dataAccess[64]
Definition: objInfo.h:152
DataObjInfo::rescName
char rescName[64]
Definition: objInfo.h:131
entry
Definition: ruleAdmin.cpp:22
inStruct
paramIn * inStruct
Definition: ruleAdmin.cpp:39
RuleExecInfo
Definition: irods_re_structs.hpp:18
paramIn::cookieStr
char cookieStr[500]
Definition: ruleAdmin.cpp:34
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
fmakeword
char * fmakeword(FILE *f, char stop, int *cl)
Definition: ruleAdmin.cpp:270
mybgets
int mybgets(char inbuf[], char buffer[], int j)
Definition: ruleAdmin.cpp:187
main
int main(int argc, char **argv)
Definition: ruleAdmin.cpp:462
DataObjInfo::objPath
char objPath[(1024+64)]
Definition: objInfo.h:130
performAction
int performAction(paramIn *Sentries)
userInfo_t::authInfo
authInfo_t authInfo
Definition: rodsUser.h:70
reTestFlag
int reTestFlag
Definition: libirods_rule_engine_plugin-irods_rule_language.cpp:55
initRuleStruct
int initRuleStruct(const char *inst_name, rsComm_t *svrComm, const char *ruleSet, const char *dvmSet, const char *fnmSet)
Definition: nre.reLib1.cpp:325
paramIn
Definition: ruleAdmin.cpp:32
DataObjInfo
Definition: objInfo.h:129
DataObjInfo::dataSize
rodsLong_t dataSize
Definition: objInfo.h:134
RuleExecInfo::next
struct RuleExecInfo * next
Definition: irods_re_structs.hpp:38
irods.pyparsing.line
def line(loc, strg)
Definition: pyparsing.py:728
CR
#define CR
Definition: ruleAdmin.cpp:15
ruleSet
Definition: restructs.hpp:282