@@ -530,17 +530,11 @@ FileSelect GetSelectConstraints(const EvalContext *ctx, const Promise *pp)
530
530
u_long fplus , fminus ;
531
531
int entries = false;
532
532
533
- s .name = (Rlist * ) PromiseGetConstraintAsRval (pp , "leaf_name" , RVAL_TYPE_LIST );
534
- s .path = (Rlist * ) PromiseGetConstraintAsRval (pp , "path_name" , RVAL_TYPE_LIST );
535
- s .filetypes = (Rlist * ) PromiseGetConstraintAsRval (pp , "file_types" , RVAL_TYPE_LIST );
536
- s .issymlinkto = (Rlist * ) PromiseGetConstraintAsRval (pp , "issymlinkto" , RVAL_TYPE_LIST );
537
-
533
+ // get constraint permissions
538
534
s .perms = PromiseGetConstraintAsList (ctx , "search_mode" , pp );
539
535
540
536
for (rp = s .perms ; rp != NULL ; rp = rp -> next )
541
537
{
542
- plus = 0 ;
543
- minus = 0 ;
544
538
value = RlistScalarValue (rp );
545
539
546
540
if (!ParseModeString (value , & plus , & minus ))
@@ -550,25 +544,17 @@ FileSelect GetSelectConstraints(const EvalContext *ctx, const Promise *pp)
550
544
}
551
545
}
552
546
547
+ // get constraint bsdflags
553
548
s .bsdflags = PromiseGetConstraintAsList (ctx , "search_bsdflags" , pp );
554
549
555
- fplus = 0 ;
556
- fminus = 0 ;
557
-
550
+ // cannot fail, ParseFlagString always returns true
558
551
if (!ParseFlagString (s .bsdflags , & fplus , & fminus ))
559
552
{
560
553
Log (LOG_LEVEL_ERR , "Problem validating a BSD flag string" );
561
554
PromiseRef (LOG_LEVEL_ERR , pp );
562
555
}
563
556
564
- if ((s .name ) || (s .path ) || (s .filetypes ) || (s .issymlinkto ) || (s .perms ) || (s .bsdflags ))
565
- {
566
- entries = true;
567
- }
568
-
569
- s .owners = (Rlist * ) PromiseGetConstraintAsRval (pp , "search_owners" , RVAL_TYPE_LIST );
570
- s .groups = (Rlist * ) PromiseGetConstraintAsRval (pp , "search_groups" , RVAL_TYPE_LIST );
571
-
557
+ // get constraint search_size
572
558
value = PromiseGetConstraintAsRval (pp , "search_size" , RVAL_TYPE_SCALAR );
573
559
if (value )
574
560
{
@@ -581,6 +567,7 @@ FileSelect GetSelectConstraints(const EvalContext *ctx, const Promise *pp)
581
567
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
582
568
}
583
569
570
+ // get constraint creation time
584
571
value = PromiseGetConstraintAsRval (pp , "ctime" , RVAL_TYPE_SCALAR );
585
572
if (value )
586
573
{
@@ -593,6 +580,7 @@ FileSelect GetSelectConstraints(const EvalContext *ctx, const Promise *pp)
593
580
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
594
581
}
595
582
583
+ // get constraint access time
596
584
value = PromiseGetConstraintAsRval (pp , "atime" , RVAL_TYPE_SCALAR );
597
585
if (value )
598
586
{
@@ -604,6 +592,8 @@ FileSelect GetSelectConstraints(const EvalContext *ctx, const Promise *pp)
604
592
PromiseRef (LOG_LEVEL_ERR , pp );
605
593
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
606
594
}
595
+
596
+ // get constraint modification time
607
597
value = PromiseGetConstraintAsRval (pp , "mtime" , RVAL_TYPE_SCALAR );
608
598
if (value )
609
599
{
@@ -616,19 +606,29 @@ FileSelect GetSelectConstraints(const EvalContext *ctx, const Promise *pp)
616
606
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
617
607
}
618
608
609
+ // get constraints owners, groups, exec_regex, exec_program, file types, name, path
610
+ s .owners = (Rlist * ) PromiseGetConstraintAsRval (pp , "search_owners" , RVAL_TYPE_LIST );
611
+ s .groups = (Rlist * ) PromiseGetConstraintAsRval (pp , "search_groups" , RVAL_TYPE_LIST );
619
612
s .exec_regex = PromiseGetConstraintAsRval (pp , "exec_regex" , RVAL_TYPE_SCALAR );
620
613
s .exec_program = PromiseGetConstraintAsRval (pp , "exec_program" , RVAL_TYPE_SCALAR );
614
+ s .filetypes = (Rlist * ) PromiseGetConstraintAsRval (pp , "file_types" , RVAL_TYPE_LIST );
615
+ s .name = (Rlist * ) PromiseGetConstraintAsRval (pp , "leaf_name" , RVAL_TYPE_LIST );
616
+ s .path = (Rlist * ) PromiseGetConstraintAsRval (pp , "path_name" , RVAL_TYPE_LIST );
617
+ s .issymlinkto = (Rlist * ) PromiseGetConstraintAsRval (pp , "issymlinkto" , RVAL_TYPE_LIST );
621
618
622
- if ((s .owners ) || (s .min_size ) || (s .exec_regex ) || (s .exec_program ))
619
+ // check if file_result is needed
620
+ if ((s .owners ) || (s .groups ) || (s .exec_regex ) || (s .exec_program ) || (s .filetypes )
621
+ || (s .name ) || (s .path ) || (s .issymlinkto ) || (s .perms ) || (s .bsdflags ))
623
622
{
624
623
entries = true;
625
624
}
626
625
626
+ // get constraint file_result
627
627
if ((s .result = PromiseGetConstraintAsRval (pp , "file_result" , RVAL_TYPE_SCALAR )) == NULL )
628
628
{
629
- if (! entries )
629
+ if (entries )
630
630
{
631
- Log (LOG_LEVEL_ERR , "file_select body missing its a file_result return value" );
631
+ Log (LOG_LEVEL_ERR , "file_select body missing its file_result return value" );
632
632
}
633
633
}
634
634
@@ -1319,10 +1319,8 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1319
1319
char * value ;
1320
1320
int entries = 0 ;
1321
1321
1322
- p .owner = PromiseGetConstraintAsList (ctx , "process_owner" , pp );
1323
-
1322
+ // get constraint process ID
1324
1323
value = PromiseGetConstraintAsRval (pp , "pid" , RVAL_TYPE_SCALAR );
1325
-
1326
1324
if (value )
1327
1325
{
1328
1326
entries ++ ;
@@ -1333,8 +1331,9 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1333
1331
PromiseRef (LOG_LEVEL_ERR , pp );
1334
1332
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1335
1333
}
1336
- value = PromiseGetConstraintAsRval (pp , "ppid" , RVAL_TYPE_SCALAR );
1337
1334
1335
+ // get constraint parent process ID
1336
+ value = PromiseGetConstraintAsRval (pp , "ppid" , RVAL_TYPE_SCALAR );
1338
1337
if (value )
1339
1338
{
1340
1339
entries ++ ;
@@ -1345,8 +1344,9 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1345
1344
PromiseRef (LOG_LEVEL_ERR , pp );
1346
1345
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1347
1346
}
1348
- value = PromiseGetConstraintAsRval (pp , "pgid" , RVAL_TYPE_SCALAR );
1349
1347
1348
+ // get constraint process group ID
1349
+ value = PromiseGetConstraintAsRval (pp , "pgid" , RVAL_TYPE_SCALAR );
1350
1350
if (value )
1351
1351
{
1352
1352
entries ++ ;
@@ -1357,8 +1357,9 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1357
1357
PromiseRef (LOG_LEVEL_ERR , pp );
1358
1358
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1359
1359
}
1360
- value = PromiseGetConstraintAsRval (pp , "rsize" , RVAL_TYPE_SCALAR );
1361
1360
1361
+ // get constraint resident set size
1362
+ value = PromiseGetConstraintAsRval (pp , "rsize" , RVAL_TYPE_SCALAR );
1362
1363
if (value )
1363
1364
{
1364
1365
entries ++ ;
@@ -1369,6 +1370,8 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1369
1370
PromiseRef (LOG_LEVEL_ERR , pp );
1370
1371
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1371
1372
}
1373
+
1374
+ // get constraint VM size
1372
1375
value = PromiseGetConstraintAsRval (pp , "vsize" , RVAL_TYPE_SCALAR );
1373
1376
if (value )
1374
1377
{
@@ -1380,6 +1383,8 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1380
1383
PromiseRef (LOG_LEVEL_ERR , pp );
1381
1384
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1382
1385
}
1386
+
1387
+ // get constraint cumulated CPU time
1383
1388
value = PromiseGetConstraintAsRval (pp , "ttime_range" , RVAL_TYPE_SCALAR );
1384
1389
if (value )
1385
1390
{
@@ -1391,6 +1396,8 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1391
1396
PromiseRef (LOG_LEVEL_ERR , pp );
1392
1397
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1393
1398
}
1399
+
1400
+ // get constraint start time
1394
1401
value = PromiseGetConstraintAsRval (pp , "stime_range" , RVAL_TYPE_SCALAR );
1395
1402
if (value )
1396
1403
{
@@ -1403,10 +1410,7 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1403
1410
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1404
1411
}
1405
1412
1406
- p .status = PromiseGetConstraintAsRval (pp , "status" , RVAL_TYPE_SCALAR );
1407
- p .command = PromiseGetConstraintAsRval (pp , "command" , RVAL_TYPE_SCALAR );
1408
- p .tty = PromiseGetConstraintAsRval (pp , "tty" , RVAL_TYPE_SCALAR );
1409
-
1413
+ // get constraint priority
1410
1414
value = PromiseGetConstraintAsRval (pp , "priority" , RVAL_TYPE_SCALAR );
1411
1415
if (value )
1412
1416
{
@@ -1418,6 +1422,8 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1418
1422
PromiseRef (LOG_LEVEL_ERR , pp );
1419
1423
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1420
1424
}
1425
+
1426
+ // get constraint threads
1421
1427
value = PromiseGetConstraintAsRval (pp , "threads" , RVAL_TYPE_SCALAR );
1422
1428
if (value )
1423
1429
{
@@ -1430,16 +1436,24 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1430
1436
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1431
1437
}
1432
1438
1439
+ // get constraints owner, status, command and tty
1440
+ p .owner = PromiseGetConstraintAsList (ctx , "process_owner" , pp );
1441
+ p .status = PromiseGetConstraintAsRval (pp , "status" , RVAL_TYPE_SCALAR );
1442
+ p .command = PromiseGetConstraintAsRval (pp , "command" , RVAL_TYPE_SCALAR );
1443
+ p .tty = PromiseGetConstraintAsRval (pp , "tty" , RVAL_TYPE_SCALAR );
1444
+
1445
+ // check if file_result is needed
1433
1446
if ((p .owner ) || (p .status ) || (p .command ) || (p .tty ))
1434
1447
{
1435
1448
entries = true;
1436
1449
}
1437
1450
1451
+ // get constraint process_result
1438
1452
if ((p .process_result = PromiseGetConstraintAsRval (pp , "process_result" , RVAL_TYPE_SCALAR )) == NULL )
1439
1453
{
1440
1454
if (entries )
1441
1455
{
1442
- Log (LOG_LEVEL_ERR , "process_select body missing its a process_result return value" );
1456
+ Log (LOG_LEVEL_ERR , "process_select body missing its process_result return value" );
1443
1457
}
1444
1458
}
1445
1459
0 commit comments