@@ -530,11 +530,7 @@ 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 )
@@ -550,25 +546,20 @@ FileSelect GetSelectConstraints(const EvalContext *ctx, const Promise *pp)
550
546
}
551
547
}
552
548
549
+ // get constraint bsdflags
553
550
s .bsdflags = PromiseGetConstraintAsList (ctx , "search_bsdflags" , pp );
554
551
555
552
fplus = 0 ;
556
553
fminus = 0 ;
557
554
555
+ // cannot fail, ParseFlagString always returns true
558
556
if (!ParseFlagString (s .bsdflags , & fplus , & fminus ))
559
557
{
560
558
Log (LOG_LEVEL_ERR , "Problem validating a BSD flag string" );
561
559
PromiseRef (LOG_LEVEL_ERR , pp );
562
560
}
563
561
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
-
562
+ // get constraint search_size
572
563
value = PromiseGetConstraintAsRval (pp , "search_size" , RVAL_TYPE_SCALAR );
573
564
if (value )
574
565
{
@@ -581,6 +572,7 @@ FileSelect GetSelectConstraints(const EvalContext *ctx, const Promise *pp)
581
572
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
582
573
}
583
574
575
+ // get constraint creation time
584
576
value = PromiseGetConstraintAsRval (pp , "ctime" , RVAL_TYPE_SCALAR );
585
577
if (value )
586
578
{
@@ -593,6 +585,7 @@ FileSelect GetSelectConstraints(const EvalContext *ctx, const Promise *pp)
593
585
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
594
586
}
595
587
588
+ // get constraint access time
596
589
value = PromiseGetConstraintAsRval (pp , "atime" , RVAL_TYPE_SCALAR );
597
590
if (value )
598
591
{
@@ -604,6 +597,8 @@ FileSelect GetSelectConstraints(const EvalContext *ctx, const Promise *pp)
604
597
PromiseRef (LOG_LEVEL_ERR , pp );
605
598
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
606
599
}
600
+
601
+ // get constraint modification time
607
602
value = PromiseGetConstraintAsRval (pp , "mtime" , RVAL_TYPE_SCALAR );
608
603
if (value )
609
604
{
@@ -616,14 +611,24 @@ FileSelect GetSelectConstraints(const EvalContext *ctx, const Promise *pp)
616
611
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
617
612
}
618
613
614
+ // get constraints owners, groups, exec_regex, exec_program, file types, name, path
615
+ s .owners = (Rlist * ) PromiseGetConstraintAsRval (pp , "search_owners" , RVAL_TYPE_LIST );
616
+ s .groups = (Rlist * ) PromiseGetConstraintAsRval (pp , "search_groups" , RVAL_TYPE_LIST );
619
617
s .exec_regex = PromiseGetConstraintAsRval (pp , "exec_regex" , RVAL_TYPE_SCALAR );
620
618
s .exec_program = PromiseGetConstraintAsRval (pp , "exec_program" , RVAL_TYPE_SCALAR );
619
+ s .filetypes = (Rlist * ) PromiseGetConstraintAsRval (pp , "file_types" , RVAL_TYPE_LIST );
620
+ s .name = (Rlist * ) PromiseGetConstraintAsRval (pp , "leaf_name" , RVAL_TYPE_LIST );
621
+ s .path = (Rlist * ) PromiseGetConstraintAsRval (pp , "path_name" , RVAL_TYPE_LIST );
622
+ s .issymlinkto = (Rlist * ) PromiseGetConstraintAsRval (pp , "issymlinkto" , RVAL_TYPE_LIST );
621
623
622
- if ((s .owners ) || (s .min_size ) || (s .exec_regex ) || (s .exec_program ))
624
+ // check if file_result is needed
625
+ if ((s .owners ) || (s .min_size ) || (s .exec_regex ) || (s .exec_program ) || (s .filetypes )
626
+ || (s .name ) || (s .path ) || (s .issymlinkto ) || (s .perms ) || (s .bsdflags ))
623
627
{
624
628
entries = true;
625
629
}
626
630
631
+ // get constraint file_result
627
632
if ((s .result = PromiseGetConstraintAsRval (pp , "file_result" , RVAL_TYPE_SCALAR )) == NULL )
628
633
{
629
634
if (!entries )
@@ -1319,10 +1324,8 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1319
1324
char * value ;
1320
1325
int entries = 0 ;
1321
1326
1322
- p .owner = PromiseGetConstraintAsList (ctx , "process_owner" , pp );
1323
-
1327
+ // get constraint process ID
1324
1328
value = PromiseGetConstraintAsRval (pp , "pid" , RVAL_TYPE_SCALAR );
1325
-
1326
1329
if (value )
1327
1330
{
1328
1331
entries ++ ;
@@ -1333,8 +1336,9 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1333
1336
PromiseRef (LOG_LEVEL_ERR , pp );
1334
1337
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1335
1338
}
1336
- value = PromiseGetConstraintAsRval (pp , "ppid" , RVAL_TYPE_SCALAR );
1337
1339
1340
+ // get constraint parent process ID
1341
+ value = PromiseGetConstraintAsRval (pp , "ppid" , RVAL_TYPE_SCALAR );
1338
1342
if (value )
1339
1343
{
1340
1344
entries ++ ;
@@ -1345,8 +1349,9 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1345
1349
PromiseRef (LOG_LEVEL_ERR , pp );
1346
1350
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1347
1351
}
1348
- value = PromiseGetConstraintAsRval (pp , "pgid" , RVAL_TYPE_SCALAR );
1349
1352
1353
+ // get constraint process group ID
1354
+ value = PromiseGetConstraintAsRval (pp , "pgid" , RVAL_TYPE_SCALAR );
1350
1355
if (value )
1351
1356
{
1352
1357
entries ++ ;
@@ -1357,8 +1362,9 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1357
1362
PromiseRef (LOG_LEVEL_ERR , pp );
1358
1363
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1359
1364
}
1360
- value = PromiseGetConstraintAsRval (pp , "rsize" , RVAL_TYPE_SCALAR );
1361
1365
1366
+ // get constraint resident set size
1367
+ value = PromiseGetConstraintAsRval (pp , "rsize" , RVAL_TYPE_SCALAR );
1362
1368
if (value )
1363
1369
{
1364
1370
entries ++ ;
@@ -1369,6 +1375,8 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1369
1375
PromiseRef (LOG_LEVEL_ERR , pp );
1370
1376
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1371
1377
}
1378
+
1379
+ // get constraint VM size
1372
1380
value = PromiseGetConstraintAsRval (pp , "vsize" , RVAL_TYPE_SCALAR );
1373
1381
if (value )
1374
1382
{
@@ -1380,6 +1388,8 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1380
1388
PromiseRef (LOG_LEVEL_ERR , pp );
1381
1389
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1382
1390
}
1391
+
1392
+ // get constraint cumulated CPU time
1383
1393
value = PromiseGetConstraintAsRval (pp , "ttime_range" , RVAL_TYPE_SCALAR );
1384
1394
if (value )
1385
1395
{
@@ -1391,6 +1401,8 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1391
1401
PromiseRef (LOG_LEVEL_ERR , pp );
1392
1402
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1393
1403
}
1404
+
1405
+ // get constraint start time
1394
1406
value = PromiseGetConstraintAsRval (pp , "stime_range" , RVAL_TYPE_SCALAR );
1395
1407
if (value )
1396
1408
{
@@ -1403,10 +1415,7 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1403
1415
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1404
1416
}
1405
1417
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
-
1418
+ // get constraint priority
1410
1419
value = PromiseGetConstraintAsRval (pp , "priority" , RVAL_TYPE_SCALAR );
1411
1420
if (value )
1412
1421
{
@@ -1418,6 +1427,8 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1418
1427
PromiseRef (LOG_LEVEL_ERR , pp );
1419
1428
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1420
1429
}
1430
+
1431
+ // get constraint threads
1421
1432
value = PromiseGetConstraintAsRval (pp , "threads" , RVAL_TYPE_SCALAR );
1422
1433
if (value )
1423
1434
{
@@ -1430,11 +1441,19 @@ ProcessSelect GetProcessFilterConstraints(const EvalContext *ctx, const Promise
1430
1441
FatalError (ctx , "Could not make sense of integer range [%s]" , value );
1431
1442
}
1432
1443
1444
+ // get constraints owner, status, command and tty
1445
+ p .owner = PromiseGetConstraintAsList (ctx , "process_owner" , pp );
1446
+ p .status = PromiseGetConstraintAsRval (pp , "status" , RVAL_TYPE_SCALAR );
1447
+ p .command = PromiseGetConstraintAsRval (pp , "command" , RVAL_TYPE_SCALAR );
1448
+ p .tty = PromiseGetConstraintAsRval (pp , "tty" , RVAL_TYPE_SCALAR );
1449
+
1450
+ // check if file_result is needed
1433
1451
if ((p .owner ) || (p .status ) || (p .command ) || (p .tty ))
1434
1452
{
1435
1453
entries = true;
1436
1454
}
1437
1455
1456
+ // get constraint process_result
1438
1457
if ((p .process_result = PromiseGetConstraintAsRval (pp , "process_result" , RVAL_TYPE_SCALAR )) == NULL )
1439
1458
{
1440
1459
if (entries )
0 commit comments