10Sstevel@tonic-gate# 2*12388SJohn.Sonnenschein@Sun.COM# Copyright (c) 2000, 2005 Oracle and/or its affiliates. All rights reserved. 30Sstevel@tonic-gate# 4*12388SJohn.Sonnenschein@Sun.COM 50Sstevel@tonic-gate# 60Sstevel@tonic-gate# test script for Sun::Solaris::Project 70Sstevel@tonic-gate# 80Sstevel@tonic-gate 90Sstevel@tonic-gateuse warnings; 100Sstevel@tonic-gateuse strict; 110Sstevel@tonic-gateuse Data::Dumper; 120Sstevel@tonic-gate$Data::Dumper::Terse = 1; 130Sstevel@tonic-gate$Data::Dumper::Indent = 0; 140Sstevel@tonic-gate 150Sstevel@tonic-gatesub cleanup { 160Sstevel@tonic-gate unlink("/tmp/project.$$.1"); 170Sstevel@tonic-gate unlink("/tmp/project.$$.2"); 180Sstevel@tonic-gate unlink("/tmp/project.$$.3"); 190Sstevel@tonic-gate unlink("/tmp/project.$$.4"); 200Sstevel@tonic-gate unlink("/tmp/project.$$.5"); 210Sstevel@tonic-gate unlink("/tmp/project.$$.1.w"); 220Sstevel@tonic-gate unlink("/tmp/project.$$.2.w"); 230Sstevel@tonic-gate unlink("/tmp/project.$$.3.w"); 240Sstevel@tonic-gate unlink("/tmp/project.$$.4.w"); 250Sstevel@tonic-gate unlink("/tmp/project.$$.5.w"); 260Sstevel@tonic-gate unlink("/tmp/projent.$$"); 270Sstevel@tonic-gate} 280Sstevel@tonic-gate 290Sstevel@tonic-gate# 'use Sun::Solaris::Project;' counts as test 1 300Sstevel@tonic-gateour $test = 1; 310Sstevel@tonic-gateour $intest = 1; 320Sstevel@tonic-gateour $loaded = 0; 330Sstevel@tonic-gate 340Sstevel@tonic-gate# 350Sstevel@tonic-gate# Status reporting utils 360Sstevel@tonic-gate# 370Sstevel@tonic-gate# Expected calling sequence is: 380Sstevel@tonic-gate# start() 390Sstevel@tonic-gate# pass() or fail() 400Sstevel@tonic-gate# start() 410Sstevel@tonic-gate# pass() or fail() 420Sstevel@tonic-gate# ... 430Sstevel@tonic-gate# ... 440Sstevel@tonic-gate# 450Sstevel@tonic-gate# Calling start() twice in a row will fail test. 460Sstevel@tonic-gate# Calling start() and then exiting will fail test. 470Sstevel@tonic-gate# 480Sstevel@tonic-gatesub start 490Sstevel@tonic-gate{ 500Sstevel@tonic-gate if ($intest != 0) { 510Sstevel@tonic-gate fatal("Started new test before finishing previous."); 520Sstevel@tonic-gate } 530Sstevel@tonic-gate $test++; 540Sstevel@tonic-gate $intest = 1; 550Sstevel@tonic-gate print "# Starting Test $test: @_\n" if (@_); 560Sstevel@tonic-gate} 570Sstevel@tonic-gate 580Sstevel@tonic-gatesub pass 590Sstevel@tonic-gate{ 600Sstevel@tonic-gate if ($intest == 0) { 610Sstevel@tonic-gate fatal("pass() without start()"); 620Sstevel@tonic-gate } 630Sstevel@tonic-gate print("ok $test @_\n"); 640Sstevel@tonic-gate $intest = 0; 650Sstevel@tonic-gate} 660Sstevel@tonic-gate 670Sstevel@tonic-gatesub fail 680Sstevel@tonic-gate{ 690Sstevel@tonic-gate if ($intest == 0) { 700Sstevel@tonic-gate fatal("fail() without start()"); 710Sstevel@tonic-gate } 720Sstevel@tonic-gate print("not ok $test @_\n"); 730Sstevel@tonic-gate $intest = 0; 740Sstevel@tonic-gate} 750Sstevel@tonic-gate 760Sstevel@tonic-gatesub fatal 770Sstevel@tonic-gate{ 780Sstevel@tonic-gate print(STDERR "FATAL!\n"); 790Sstevel@tonic-gate print("not ok $test @_\n"); 800Sstevel@tonic-gate exit(1); 810Sstevel@tonic-gate} 820Sstevel@tonic-gate 830Sstevel@tonic-gatesub comment 840Sstevel@tonic-gate{ 850Sstevel@tonic-gate print("# @_\n"); 860Sstevel@tonic-gate} 870Sstevel@tonic-gate 880Sstevel@tonic-gate# 890Sstevel@tonic-gate# Read in a project file and build into the same data structure that we will 900Sstevel@tonic-gate# get if we do the same with the getXXX functions 910Sstevel@tonic-gate# 920Sstevel@tonic-gate 930Sstevel@tonic-gatesub read_pfile 940Sstevel@tonic-gate{ 950Sstevel@tonic-gate my ($fh) = @_; 960Sstevel@tonic-gate my ($line, @a1, @a2); 970Sstevel@tonic-gate while (defined($line = <$fh>)) { 980Sstevel@tonic-gate chomp($line); 990Sstevel@tonic-gate @a2 = split(/:/, $line, 6); 1000Sstevel@tonic-gate $a2[2] = '' if (! defined($a2[2])); 1010Sstevel@tonic-gate $a2[3] = defined($a2[3]) ? [ split(/,/, $a2[3]) ] : []; 1020Sstevel@tonic-gate $a2[4] = defined($a2[4]) ? [ split(/,/, $a2[4]) ] : []; 1030Sstevel@tonic-gate $a2[5] = '' if (! defined($a2[5])); 1040Sstevel@tonic-gate push(@a1, [ @a2 ]); 1050Sstevel@tonic-gate } 1060Sstevel@tonic-gate return(\@a1); 1070Sstevel@tonic-gate} 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate# 1100Sstevel@tonic-gate# Compare two arrays of project structures & check for equivalence. 1110Sstevel@tonic-gate# Converts each into a string using Data::Dumper and then does a string 1120Sstevel@tonic-gate# comparison. Dirty but effective :-) 1130Sstevel@tonic-gate# 1140Sstevel@tonic-gate 1150Sstevel@tonic-gatesub cmp_recs 1160Sstevel@tonic-gate{ 1170Sstevel@tonic-gate my ($a1, $a2) = @_; 1180Sstevel@tonic-gate my $s1 = Dumper($a1); 1190Sstevel@tonic-gate my $s2 = Dumper($a2); 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate # Make sure numbers and quoted numbers compare the same 1220Sstevel@tonic-gate $s1 =~ s/'([+-]?[\d.]+)'/$1/g; 1230Sstevel@tonic-gate $s2 =~ s/'([+-]?[\d.]+)'/$1/g; 1240Sstevel@tonic-gate 1250Sstevel@tonic-gate return($s1 eq $s2); 1260Sstevel@tonic-gate} 1270Sstevel@tonic-gate 1280Sstevel@tonic-gatesub hash2string 1290Sstevel@tonic-gate{ 1300Sstevel@tonic-gate my ($key, $value); 1310Sstevel@tonic-gate my @strings; 1320Sstevel@tonic-gate my $string; 1330Sstevel@tonic-gate my $hash = $_[0]; 1340Sstevel@tonic-gate foreach $key (keys(%$hash)) { 1350Sstevel@tonic-gate push(@strings, "$key => $hash->{$key}"); 1360Sstevel@tonic-gate } 1370Sstevel@tonic-gate $string = "{ " . join(", ", @strings) . " }"; 1380Sstevel@tonic-gate return ($string); 1390Sstevel@tonic-gate} 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate# 1420Sstevel@tonic-gate# Main body of tests starts here. 1430Sstevel@tonic-gate# 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate# Check the module loads. 1460Sstevel@tonic-gateBEGIN { 1470Sstevel@tonic-gate $| = 1; 1480Sstevel@tonic-gate print "1..548\n"; 1490Sstevel@tonic-gate} 1500Sstevel@tonic-gate 1510Sstevel@tonic-gateEND { 1520Sstevel@tonic-gate fail("not ok 1") unless ($loaded); 1530Sstevel@tonic-gate fail("Exited during test!") if ($intest == 1); 1540Sstevel@tonic-gate cleanup(); 1550Sstevel@tonic-gate} 1560Sstevel@tonic-gate 1570Sstevel@tonic-gateuse Sun::Solaris::Project qw(:ALL :PRIVATE); 1580Sstevel@tonic-gate$loaded = 1; 1590Sstevel@tonic-gatepass(); 1600Sstevel@tonic-gate 1610Sstevel@tonic-gatestart("Check the constants."); 1620Sstevel@tonic-gatemy ($fh, $line, $n1, $n2, $n3, $s); 1630Sstevel@tonic-gateopen($fh, "</usr/include/project.h") || fatal($!); 1640Sstevel@tonic-gatewhile (defined($line = <$fh>)) { 1650Sstevel@tonic-gate $n1 = $1 if ($line =~ /#define\s+PROJNAME_MAX\s+(\d+)/); 1660Sstevel@tonic-gate $n2 = $1 if ($line =~ /#define\s+PROJECT_BUFSZ\s+(\d+)/); 1670Sstevel@tonic-gate $s = $1 if ($line =~ /#define\s+PROJF_PATH\s+"([^"]+)"/); 1680Sstevel@tonic-gate} 1690Sstevel@tonic-gateclose($fh); 1700Sstevel@tonic-gateopen($fh, "</usr/include/sys/param.h") || fatal($!); 1710Sstevel@tonic-gatewhile (defined($line = <$fh>)) { 1720Sstevel@tonic-gate $n3 = $1 if ($line =~ /#define\s+MAXUID\s+(\d+)/); 1730Sstevel@tonic-gate} 1740Sstevel@tonic-gateclose($fh); 1750Sstevel@tonic-gateif (! defined($s) || ! defined($n1) || ! defined($n2)) { 1760Sstevel@tonic-gate fail(); 1770Sstevel@tonic-gate} else { 1780Sstevel@tonic-gate if ($n1 == &PROJNAME_MAX && $n2 == &PROJECT_BUFSZ && 1790Sstevel@tonic-gate $n3 == &MAXPROJID && $s eq &PROJF_PATH) { 1800Sstevel@tonic-gate pass(); 1810Sstevel@tonic-gate } else { 1820Sstevel@tonic-gate fail(); 1830Sstevel@tonic-gate } 1840Sstevel@tonic-gate} 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate# 1870Sstevel@tonic-gate# projf_read on various files with various flags. 1880Sstevel@tonic-gate# 1890Sstevel@tonic-gate# This table represents when projf_read should fail given a file 1900Sstevel@tonic-gate# and flags. 1910Sstevel@tonic-gate# 1920Sstevel@tonic-gate# file/flags # {} validate validate,res validate,dup 1930Sstevel@tonic-gate# ################################################################### 1940Sstevel@tonic-gate# parse error # no no no no 1950Sstevel@tonic-gate# dup names # yes no no no 1960Sstevel@tonic-gate# dup ids # yes no no yes 1970Sstevel@tonic-gate# system ids # yes no yes no 1980Sstevel@tonic-gate# all user # yes yes yes yes 1990Sstevel@tonic-gate# 2000Sstevel@tonic-gate 2010Sstevel@tonic-gatemy $flags1 = {}; 2020Sstevel@tonic-gatemy $flags2 = { "validate" => "true" }; 2030Sstevel@tonic-gatemy $flags3 = { "validate" => "true", "res" => 1 }; 2040Sstevel@tonic-gatemy $flags4 = { "validate" => "true", "dup" => 1 }; 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate# Make a temporary project files. 2070Sstevel@tonic-gatemy ($ret, $file1, $file2, $file3, $file4, $file5, $pass); 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate# file1, parse error (extra ":") on group.staff project. 2100Sstevel@tonic-gateopen($file1, "+>/tmp/project.$$.1") || fatal($!); 2110Sstevel@tonic-gateprint $file1 <<EOF; 2120Sstevel@tonic-gatetest1:123:project one:root,bin:adm:attr1=a;attr2=b 2130Sstevel@tonic-gateuser.test2:456:project two:adm,uucp:staff:attr1=p;attr2=q 2140Sstevel@tonic-gategroup.test3:678:project three::root,nobody:root,lp:attr1=y;attr2=z 2150Sstevel@tonic-gatetest4:678:project four:root:root: 2160Sstevel@tonic-gatetest5:679:project five::sys: 2170Sstevel@tonic-gatetest6:690:::: 2180Sstevel@tonic-gateEOF 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate# file2, duplicate project names. 2210Sstevel@tonic-gateopen($file2, "+>/tmp/project.$$.2") || fatal($!); 2220Sstevel@tonic-gateprint $file2 <<EOF; 2230Sstevel@tonic-gatetest1:123:project one:root,bin:adm:attr1=a;attr2=b 2240Sstevel@tonic-gateuser.test2:456:project two:adm,uucp:staff:attr1=p;attr2=q 2250Sstevel@tonic-gategroup.test3:677:project three:root,nobody:root,lp:attr1=y;attr2=z 2260Sstevel@tonic-gatetest1:678:project four:root:root: 2270Sstevel@tonic-gatetest5:679:project five::sys: 2280Sstevel@tonic-gatetest6:690:::: 2290Sstevel@tonic-gateEOF 2300Sstevel@tonic-gate 2310Sstevel@tonic-gate# file3, duplicate project ids. 2320Sstevel@tonic-gateopen($file3, "+>/tmp/project.$$.3") || fatal($!); 2330Sstevel@tonic-gateprint $file3 <<EOF; 2340Sstevel@tonic-gatetest1:123:project one:root,bin:adm:attr1=a;attr2=b 2350Sstevel@tonic-gateuser.test2:456:project two:adm,uucp:staff:attr1=p;attr2=q 2360Sstevel@tonic-gategroup.test3:677:project three:root,nobody:root,lp:attr1=y;attr2=z 2370Sstevel@tonic-gatetest4:678:project four:root:root: 2380Sstevel@tonic-gatetest5:678:project five::sys: 2390Sstevel@tonic-gatetest6:690:::: 2400Sstevel@tonic-gateEOF 2410Sstevel@tonic-gate 2420Sstevel@tonic-gate# file4, system project ids. 2430Sstevel@tonic-gateopen($file4, "+>/tmp/project.$$.4") || fatal($!); 2440Sstevel@tonic-gateprint $file4 <<EOF; 2450Sstevel@tonic-gatesystem:0:::: 2460Sstevel@tonic-gateuser.root:1:::: 2470Sstevel@tonic-gatenoproject:2:::: 2480Sstevel@tonic-gatedefault:3:::: 2490Sstevel@tonic-gategroup.staff:10:::: 2500Sstevel@tonic-gatetest1:123:project one:root,bin:adm:attr1=a;attr2=b 2510Sstevel@tonic-gateuser.test2:456:project two:adm,uucp:staff:attr1=p;attr2=q 2520Sstevel@tonic-gategroup.test3:677:project three:root,nobody:root,lp:attr1=y;attr2=z 2530Sstevel@tonic-gatetest4:678:project four:root:root: 2540Sstevel@tonic-gatetest5:679:project five::sys: 2550Sstevel@tonic-gatetest6:690:::: 2560Sstevel@tonic-gateEOF 2570Sstevel@tonic-gate 2580Sstevel@tonic-gate# file5, all unique user projects. 2590Sstevel@tonic-gateopen($file5, "+>/tmp/project.$$.5") || fatal($!); 2600Sstevel@tonic-gateprint $file5 <<EOF; 2610Sstevel@tonic-gatetest1:123:project one:root,bin:adm:attr1=a;attr2=b 2620Sstevel@tonic-gateuser.test2:456:project two:adm,uucp:staff:attr1=p;attr2=q 2630Sstevel@tonic-gategroup.test3:677:project three:root,nobody:root,lp:attr1=y;attr2=z 2640Sstevel@tonic-gatetest4:678:project four:root:root: 2650Sstevel@tonic-gatetest5:679:project five::sys: 2660Sstevel@tonic-gatetest6:690:::: 2670Sstevel@tonic-gateEOF 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate# 2700Sstevel@tonic-gate# Each test is the file description, input file, filename, flags, and the expected 2710Sstevel@tonic-gate# return value. 2720Sstevel@tonic-gate# 2730Sstevel@tonic-gatemy @read_tests = ( 2740Sstevel@tonic-gate [ "parse error", $file1, "/tmp/project.$$.1", $flags1, 1 ], 2750Sstevel@tonic-gate [ "parse error", $file1, "/tmp/project.$$.1", $flags2, 1 ], 2760Sstevel@tonic-gate [ "parse error", $file1, "/tmp/project.$$.1", $flags3, 1 ], 2770Sstevel@tonic-gate [ "parse error", $file1, "/tmp/project.$$.1", $flags4, 1 ], 2780Sstevel@tonic-gate [ "dup names", $file2, "/tmp/project.$$.2", $flags1, 0 ], 2790Sstevel@tonic-gate [ "dup names", $file2, "/tmp/project.$$.2", $flags2, 1 ], 2800Sstevel@tonic-gate [ "dup names", $file2, "/tmp/project.$$.2", $flags3, 1 ], 2810Sstevel@tonic-gate [ "dup names", $file2, "/tmp/project.$$.2", $flags4, 1 ], 2820Sstevel@tonic-gate [ "dup ids", $file3, "/tmp/project.$$.3", $flags1, 0 ], 2830Sstevel@tonic-gate [ "dup ids", $file3, "/tmp/project.$$.3", $flags2, 1 ], 2840Sstevel@tonic-gate [ "dup ids", $file3, "/tmp/project.$$.3", $flags3, 1 ], 2850Sstevel@tonic-gate [ "dup ids", $file3, "/tmp/project.$$.3", $flags4, 0 ], 2860Sstevel@tonic-gate [ "sys ids", $file4, "/tmp/project.$$.4", $flags1, 0 ], 2870Sstevel@tonic-gate [ "sys ids", $file4, "/tmp/project.$$.4", $flags2, 1 ], 2880Sstevel@tonic-gate [ "sys ids", $file4, "/tmp/project.$$.4", $flags3, 0 ], 2890Sstevel@tonic-gate [ "sys ids", $file4, "/tmp/project.$$.4", $flags4, 1 ], 2900Sstevel@tonic-gate [ "unique users", $file5, "/tmp/project.$$.5", $flags1, 0 ], 2910Sstevel@tonic-gate [ "unique users", $file5, "/tmp/project.$$.5", $flags2, 0 ], 2920Sstevel@tonic-gate [ "unique users", $file5, "/tmp/project.$$.5", $flags3, 0 ], 2930Sstevel@tonic-gate [ "unique users", $file5, "/tmp/project.$$.5", $flags4, 0 ] 2940Sstevel@tonic-gate); 2950Sstevel@tonic-gate 2960Sstevel@tonic-gatemy $projents; 2970Sstevel@tonic-gatemy @goodprojents; 2980Sstevel@tonic-gatemy $read_test; 2990Sstevel@tonic-gatemy $desc; 3000Sstevel@tonic-gatemy $file; 3010Sstevel@tonic-gatemy $filename; 3020Sstevel@tonic-gatemy $flags; 3030Sstevel@tonic-gatemy $flagstring; 3040Sstevel@tonic-gatemy $exp; 3050Sstevel@tonic-gatemy $error; 3060Sstevel@tonic-gate 3070Sstevel@tonic-gate# Do projf_read tests. 3080Sstevel@tonic-gateforeach $read_test (@read_tests) { 3090Sstevel@tonic-gate 3100Sstevel@tonic-gate ($desc, $file, $filename, $flags, $exp) = @$read_test; 3110Sstevel@tonic-gate $flagstring = hash2string($flags); 3120Sstevel@tonic-gate start("projf_read(): $desc, flags: $flagstring, file: $filename"); 3130Sstevel@tonic-gate 3140Sstevel@tonic-gate seek($file, 0, 0); 3150Sstevel@tonic-gate 3160Sstevel@tonic-gate ($ret, $projents) = projf_read($file, $flags); 3170Sstevel@tonic-gate # check return is expected result 3180Sstevel@tonic-gate if ($ret != $exp) { 3190Sstevel@tonic-gate fail("Expected $exp, Returned $ret"); 3200Sstevel@tonic-gate if ($ret) { 3210Sstevel@tonic-gate foreach $error (@$projents) { 3220Sstevel@tonic-gate comment("# " . join(", ", @$error));; 3230Sstevel@tonic-gate } 3240Sstevel@tonic-gate } 3250Sstevel@tonic-gate next; 3260Sstevel@tonic-gate } 3270Sstevel@tonic-gate # verify either projents or error messages were returned 3280Sstevel@tonic-gate if (!(@$projents)) { 3290Sstevel@tonic-gate fail("Missing projents or error messages"); 3300Sstevel@tonic-gate next; 3310Sstevel@tonic-gate } 3320Sstevel@tonic-gate pass(); 3330Sstevel@tonic-gate 3340Sstevel@tonic-gate # Save projents from successful reads for testing projf_write. 3350Sstevel@tonic-gate if ($ret == 0) { 3360Sstevel@tonic-gate push(@goodprojents, [$desc, $flags, $projents, $filename]); 3370Sstevel@tonic-gate } 3380Sstevel@tonic-gate} 3390Sstevel@tonic-gate 3400Sstevel@tonic-gateclose($file1); 3410Sstevel@tonic-gateclose($file2); 3420Sstevel@tonic-gateclose($file3); 3430Sstevel@tonic-gateclose($file4); 3440Sstevel@tonic-gateclose($file5); 3450Sstevel@tonic-gate 3460Sstevel@tonic-gate# Test projf_write, write each successfully read file. 3470Sstevel@tonic-gate 3480Sstevel@tonic-gatemy @write_tests; 3490Sstevel@tonic-gatemy $write_test; 3500Sstevel@tonic-gate 3510Sstevel@tonic-gateforeach $write_test (@goodprojents) { 3520Sstevel@tonic-gate 3530Sstevel@tonic-gate ($desc, $flags, $projents, $filename) = @$write_test; 3540Sstevel@tonic-gate $flagstring = hash2string($flags); 3550Sstevel@tonic-gate start("projf_write(): $desc, flags: $flagstring, file: $filename"); 3560Sstevel@tonic-gate 3570Sstevel@tonic-gate open($fh, ">$filename.w") || fatal($!); 3580Sstevel@tonic-gate 3590Sstevel@tonic-gate projf_write($fh, $projents); 3600Sstevel@tonic-gate close($fh); 3610Sstevel@tonic-gate system("cmp -s $filename $filename.w") == 0 ? pass() : 3620Sstevel@tonic-gate fail("Written file $filename.w does not match file $filename"); 3630Sstevel@tonic-gate} 3640Sstevel@tonic-gate 3650Sstevel@tonic-gate# Tests for projent_parse and projent_validate. 3660Sstevel@tonic-gate 3670Sstevel@tonic-gatemy @projent_tests; 3680Sstevel@tonic-gatemy $projent_test; 3690Sstevel@tonic-gate 3700Sstevel@tonic-gate# 3710Sstevel@tonic-gate# Tests, in format: 3720Sstevel@tonic-gate# 3730Sstevel@tonic-gate# [ parse_result_expected, validate_result_expected, flags, project-line ] 3740Sstevel@tonic-gate# 3750Sstevel@tonic-gate@projent_tests = ( 3760Sstevel@tonic-gate 3770Sstevel@tonic-gate# positive 3780Sstevel@tonic-gate 3790Sstevel@tonic-gate [ 0, 0, { "res" => 1 }, "system:0::::" ], 3800Sstevel@tonic-gate [ 0, 0, { "res" => 1 }, "user.root:1::::" ], 3810Sstevel@tonic-gate [ 0, 0, { "res" => 1 }, "noproject:2::::" ], 3820Sstevel@tonic-gate [ 0, 0, { "res" => 1 }, "default:3::::" ], 3830Sstevel@tonic-gate [ 0, 0, { "res" => 1 }, "group.staff:10::::" ], 3840Sstevel@tonic-gate [ 0, 0, {}, "long:100::::" . "a" x 2048 ], 3850Sstevel@tonic-gate [ 0, 0, {}, "Validname:101::::" ], 3860Sstevel@tonic-gate [ 0, 0, {}, "Validname2:102::::" ], 3870Sstevel@tonic-gate [ 0, 0, {}, "valid3name:103::::" ], 3880Sstevel@tonic-gate [ 0, 0, {}, "VALIDNAME:104::::" ], 3890Sstevel@tonic-gate [ 0, 0, {}, "VALIDNAME5:105::::" ], 3900Sstevel@tonic-gate [ 0, 0, {}, "vAlid5name:106::::" ], 3910Sstevel@tonic-gate [ 0, 0, {}, "valid.name:107::::" ], 3920Sstevel@tonic-gate [ 0, 0, {}, "valid8.NAME:108::::" ], 3930Sstevel@tonic-gate [ 0, 0, {}, "Valid_name9:109::::" ], 3940Sstevel@tonic-gate [ 0, 0, {}, "V_alid.name10:110::::" ], 3950Sstevel@tonic-gate [ 0, 0, {}, "valid12345678901234567890123456789012345678901234567890123456789:111::::" ], 3960Sstevel@tonic-gate [ 0, 0, {}, "projid:2147483647::::" ], 3970Sstevel@tonic-gate [ 0, 0, {}, "comment:111: this is ! & my crazy !@#$%^&*()_+|~`\=-][ 0, 0, {},}{';\"/.,?>< comment:::" ], 3980Sstevel@tonic-gate [ 0, 0, {}, "user1:112::*::" ], 3990Sstevel@tonic-gate [ 0, 0, {}, "user2:113::!*::" ], 4000Sstevel@tonic-gate [ 0, 0, {}, "user3:114::root::" ], 4010Sstevel@tonic-gate [ 0, 0, {}, "user4:115::!root::" ], 4020Sstevel@tonic-gate [ 0, 0, {}, "user5:116::*,!sys::" ], 4030Sstevel@tonic-gate [ 0, 0, {}, "user6:117::!*,daemon::" ], 4040Sstevel@tonic-gate [ 0, 0, {}, "user7:118::root,sys,daemon,bin::" ], 4050Sstevel@tonic-gate [ 0, 0, {}, "user8:119::root,!sys,daemon,!bin::" ], 4060Sstevel@tonic-gate [ 0, 0, { "allowspaces" => 1 }, "user9:116::*, !sys::" ], 4070Sstevel@tonic-gate [ 0, 0, { "allowspaces" => 1 }, "user10:117::!* ,daemon::" ], 4080Sstevel@tonic-gate [ 0, 0, { "allowspaces" => 1 }, "user11:118::root ,sys ,daemon, bin::" ], 4090Sstevel@tonic-gate [ 0, 0, { "allowspaces" => 1 }, "user12:119::root, !sys, daemon ,!bin::" ], 4100Sstevel@tonic-gate [ 0, 0, {}, "group1:120:::*:" ], 4110Sstevel@tonic-gate [ 0, 0, {}, "group2:121:::!*:" ], 4120Sstevel@tonic-gate [ 0, 0, {}, "group3:122:::root:" ], 4130Sstevel@tonic-gate [ 0, 0, {}, "group4:123:::!root:" ], 4140Sstevel@tonic-gate [ 0, 0, {}, "group5:124:::*,!sys:" ], 4150Sstevel@tonic-gate [ 0, 0, {}, "group6:125:::!*,daemon:" ], 4160Sstevel@tonic-gate [ 0, 0, {}, "group7:126:::root,sys,daemon,bin:" ], 4170Sstevel@tonic-gate [ 0, 0, {}, "group8:127:::root,!sys,daemon,!bin:" ], 4180Sstevel@tonic-gate [ 0, 0, { "allowspaces" => 1 }, "group9:124:::*, !sys:" ], 4190Sstevel@tonic-gate [ 0, 0, { "allowspaces" => 1 }, "group10:125:::!* ,daemon:" ], 4200Sstevel@tonic-gate [ 0, 0, { "allowspaces" => 1 }, "group11:126:::root, sys ,daemon, bin:" ], 4210Sstevel@tonic-gate [ 0, 0, { "allowspaces" => 1 }, "group12:127:::root ,!sys, daemon ,!bin:" ], 4220Sstevel@tonic-gate [ 0, 0, {}, "group9:128:::sys:" ], 4230Sstevel@tonic-gate [ 0, 0, {}, "attrib1:129::::one" ], 4240Sstevel@tonic-gate [ 0, 0, {}, "attrib2:130::::One" ], 4250Sstevel@tonic-gate [ 0, 0, {}, "attrib3:131::::ONE" ], 4260Sstevel@tonic-gate [ 0, 0, {}, "attrib4:132::::attrib10" ], 4270Sstevel@tonic-gate [ 0, 0, {}, "attrib5:133::::attrib.attrib=" ], 4280Sstevel@tonic-gate [ 0, 0, {}, "attrib6:134::::attib_" ], 4290Sstevel@tonic-gate [ 0, 0, {}, "attrib7:135::::a10-._attib" ], 4300Sstevel@tonic-gate [ 0, 0, {}, "attrib8:136::::SUNW,attrib" ], 4310Sstevel@tonic-gate [ 0, 0, {}, "attrib9:137::::A,A10=" ], 4320Sstevel@tonic-gate [ 0, 0, {}, "attrib10:138::::FIVEE,name" ], 4330Sstevel@tonic-gate [ 0, 0, {}, "attrib11:139::::one;two" ], 4340Sstevel@tonic-gate [ 0, 0, {}, "attrib12:140::::one=1;two=four" ], 4350Sstevel@tonic-gate [ 0, 0, {}, "attrib13:141::::one;two=;three=four" ], 4360Sstevel@tonic-gate [ 0, 0, {}, "value1:142::::one=foo,bar" ], 4370Sstevel@tonic-gate [ 0, 0, {}, "value2:143::::one=,bar," ], 4380Sstevel@tonic-gate [ 0, 0, {}, "value3:144::::one=(foo,bar)" ], 4390Sstevel@tonic-gate [ 0, 0, {}, "value4:145::::one=(foo,bar,baz),boo" ], 4400Sstevel@tonic-gate [ 0, 0, {}, "value5:146::::one;two=bar,(baz),foo,((baz)),(,)" ], 4410Sstevel@tonic-gate [ 0, 0, {}, "value6:147::::one=100/200" ], 4420Sstevel@tonic-gate [ 0, 0, {}, "value7:148::::two=.-_/=" ], 4430Sstevel@tonic-gate [ 0, 0, {}, "value8:149::::name=one=two" ], 4440Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "value9:150::::task.max-lwps=(priv,1000M,deny,signal=SIGHUP),(priv,1000k,deny,signal=SIGKILL)" ], 4450Sstevel@tonic-gate [ 0, 0, {}, "comma1:151::,::" ], 4460Sstevel@tonic-gate [ 0, 0, {}, "comma2:152::,,::" ], 4470Sstevel@tonic-gate [ 0, 0, {}, "comma3:153::root,::" ], 4480Sstevel@tonic-gate [ 0, 0, {}, "comma4:154::bin,root,,::" ], 4490Sstevel@tonic-gate [ 0, 0, {}, "comma5:155:::,:" ], 4500Sstevel@tonic-gate [ 0, 0, {}, "comma6:156:::,,:" ], 4510Sstevel@tonic-gate [ 0, 0, {}, "comma7:157:::bin,root,:" ], 4520Sstevel@tonic-gate [ 0, 0, {}, "comma8:158:::root,,:" ], 4530Sstevel@tonic-gate [ 0, 0, {}, "semi1:159::::;" ], 4540Sstevel@tonic-gate [ 0, 0, {}, "semi2:160::::;;" ], 4550Sstevel@tonic-gate [ 0, 0, {}, "semi3:161::::foo=(one,two);" ], 4560Sstevel@tonic-gate [ 0, 0, {}, "semi4:162::::foo;;" ], 4570Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl1:163::::task.max-lwps=(priv,1000,deny,signal=HUP),(priv,1000k,deny,signal=15)" ], 4580Sstevel@tonic-gate [ 0, 0, {}, "rctl1:163::::task.max-lwps=(priv,1000,deny,signal=HUP),(priv,10001,deny,signal=15)" ], 4590Sstevel@tonic-gate [ 0, 0, {}, "rctl2:164::::process.max-port-events=(basic,1000,deny)" ], 4600Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl3:165::::project.max-crypto-memory=(priv,2.2gb,deny)" ], 4610Sstevel@tonic-gate [ 0, 0, {}, "rctl3:165::::project.max-crypto-memory=(priv,10,deny)" ], 4620Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl4:166::::project.max-crypto-memory=(privileged,100m,deny)" ], 4630Sstevel@tonic-gate [ 0, 0, {}, "rctl4:166::::project.max-crypto-memory=(privileged,100,deny)" ], 4640Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl5:167::::project.max-crypto-memory=(priv,1000m,deny)" ], 4650Sstevel@tonic-gate [ 0, 0, {}, "rctl5:167::::project.max-crypto-memory=(priv,1000,deny)" ], 4660Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl6:168::::project.max-crypto-memory=(priv,1000k,deny)" ], 4670Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl6:168::::project.max-crypto-memory=(priv,1000m,deny)" ], 4680Sstevel@tonic-gate [ 0, 0, {}, "rctl7:169::::process.max-msg-messages=(priv,10,deny)" ], 4690Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl8:170::::process.max-msg-qbytes=(priv,10000kb,deny)" ], 4700Sstevel@tonic-gate [ 0, 0, {}, "rctl8:170::::process.max-msg-qbytes=(priv,10000,deny)" ], 4710Sstevel@tonic-gate [ 0, 0, {}, "rctl9:171::::process.max-sem-ops=(priv,10000000,deny)" ], 4720Sstevel@tonic-gate [ 0, 0, {}, "rctl10:172::::process.max-sem-nsems=(basic,1,deny)" ], 4730Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl11:173::::process.max-address-space=(priv,2GB,deny)" ], 4740Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl12:174::::process.max-file-descriptor=(basic,1K,deny),(basic,2K,deny)" ], 4750Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl13:175::::process.max-core-size=(priv,10Mb,deny),(priv,2GB,deny)" ], 4760Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl14:176::::process.max-stack-size=(priv,1.8Gb,deny),(priv,100MB,deny)" ], 4770Sstevel@tonic-gate [ 0, 0, {}, "rctl15:177::::process.max-data-size=(priv,1010100101,deny)" ], 4780Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl16:178::::process.max-file-size=(priv,100mb,deny,signal=SIGXFSZ),(priv,1000mb,deny,signal=31)" ], 4790Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl17:179::::process.max-cpu-time=(priv,1t,signal=XCPU),(priv,100ms,sig=30)" ], 4800Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl18:180::::task.max-cpu-time=(priv,1M,sig=SIGKILL)" ], 4810Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl19:181::::task.max-lwps=(basic,10,signal=1),(priv,100,deny,signal=KILL)" ], 4820Sstevel@tonic-gate [ 0, 0, {}, "rctl20:182::::project.max-device-locked-memory=(priv,1000,deny,sig=TERM)" ], 4830Sstevel@tonic-gate [ 0, 0, {}, "rctl21:183::::project.max-port-ids=(priv,100,deny)" ], 4840Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl22:184::::project.max-shm-memory=(priv,1000mb,deny)" ], 4850Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl23:185::::project.max-shm-ids=(priv,1k,deny,signal=SIGSTOP)" ], 4860Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl24:186::::project.max-msg-ids=(priv,1m,deny,signal=XRES)" ], 4870Sstevel@tonic-gate [ 0, 0, {}, "rctl25:187::::project.max-sem-ids=(priv,10,deny,signal=ABRT)" ], 4880Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl26:188::::project.cpu-shares=(priv,63k,none)" ], 4890Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl27:189::::zone.cpu-shares=(priv,20k,none)" ], 4900Sstevel@tonic-gate [ 0, 0, {}, "rctl28:190::::zone.cpu-shares=(priv,100,none)" ], 4910Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl29:191::::project.max-shm-memory=(priv,200G,deny)" ], 4920Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl30:192::::project.max-shm-memory=(priv,200Gb,deny)" ], 4930Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl31:193::::project.max-shm-memory=(priv,2000B,deny)" ], 4940Sstevel@tonic-gate [ 0, 0, {}, "rctl32:194::::project.max-shm-memory=(priv,2000,deny)" ], 4950Sstevel@tonic-gate [ 0, 0, {}, "rctl33:195::::task.max-cpu-time=(priv,2000,none)" ], 4960Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl34:196::::task.max-cpu-time=(priv,2000s,none)" ], 4970Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl35:197::::task.max-cpu-time=(priv,20.1ps,none)" ], 4980Sstevel@tonic-gate [ 0, 0, { "allowunits" => 1 }, "rctl36:198::::task.max-cpu-time=(priv,20T,none)" ], 4990Sstevel@tonic-gate 5000Sstevel@tonic-gate# negative 5010Sstevel@tonic-gate 5020Sstevel@tonic-gate [ 0, 1, {}, "system:0::::" ], 5030Sstevel@tonic-gate [ 0, 1, {}, "user.root:1::::" ], 5040Sstevel@tonic-gate [ 0, 1, {}, "noproject:2::::" ], 5050Sstevel@tonic-gate [ 0, 1, {}, "default:3::::" ], 5060Sstevel@tonic-gate [ 0, 1, {}, "group.staff:10::::" ], 5070Sstevel@tonic-gate [ 0, 1, {}, "long:100::::" . "a" x 4096 ], 5080Sstevel@tonic-gate [ 1, 0, {}, "extrafields:101:::::" ], 5090Sstevel@tonic-gate [ 1, 0, {}, "missingfields:102:::" ], 5100Sstevel@tonic-gate [ 1, 0, {}, "_invalidname:103::::" ], 5110Sstevel@tonic-gate [ 1, 0, {}, "10invlidname:104::::" ], 5120Sstevel@tonic-gate [ 1, 0, {}, "invalid%name:105::::" ], 5130Sstevel@tonic-gate [ 1, 0, {}, "invalid/name:106::::" ], 5140Sstevel@tonic-gate [ 1, 0, {}, ".invalidname:107::::" ], 5150Sstevel@tonic-gate [ 1, 0, {}, "=invalidName:108::::" ], 5160Sstevel@tonic-gate [ 1, 0, {}, "invalid=name:109::::" ], 5170Sstevel@tonic-gate [ 1, 0, {}, "invalid/name:110::::" ], 5180Sstevel@tonic-gate [ 1, 0, {}, "/invalidname:111::::" ], 5190Sstevel@tonic-gate [ 1, 0, {}, "/invalidname:112::::" ], 5200Sstevel@tonic-gate [ 1, 0, {}, "invalidname*:113::::" ], 5210Sstevel@tonic-gate [ 1, 0, {}, "invalid?name:114::::" ], 5220Sstevel@tonic-gate [ 1, 0, {}, ":115:invalid name comment:::" ], 5230Sstevel@tonic-gate [ 1, 0, {}, "invalid!name:116::::" ], 5240Sstevel@tonic-gate [ 1, 0, {}, "invalidname!:117::::" ], 5250Sstevel@tonic-gate [ 1, 0, {}, "invalid12345678901234567890123456789012345678901234567890123456789:118::::" ], 5260Sstevel@tonic-gate [ 1, 0, {}, "projid:-1::::" ], 5270Sstevel@tonic-gate [ 1, 0, {}, "projid:abc::::" ], 5280Sstevel@tonic-gate [ 1, 0, {}, "projid:2147483648::::" ], 5290Sstevel@tonic-gate [ 1, 0, {}, "projid:::::" ], 5300Sstevel@tonic-gate [ 1, 0, {}, "user1:118::*!::" ], 5310Sstevel@tonic-gate [ 1, 0, {}, "user2:119::10user::" ], 5320Sstevel@tonic-gate [ 0, 1, {}, "user3:120::NOLOWER::" ], 5330Sstevel@tonic-gate [ 0, 1, {}, "user4:121::toooolong::" ], 5340Sstevel@tonic-gate [ 1, 0, {}, "user5:122::root!::" ], 5350Sstevel@tonic-gate [ 1, 0, {}, "user6:123::root;sys::" ], 5360Sstevel@tonic-gate [ 0, 1, {}, "user7:124::sys,NOLOWER::" ], 5370Sstevel@tonic-gate [ 1, 0, {}, "user8:125::sys/bin,root::" ], 5380Sstevel@tonic-gate [ 1, 0, {}, "user9:116::*, !sys::" ], 5390Sstevel@tonic-gate [ 1, 0, {}, "user10:117::!* ,daemon::" ], 5400Sstevel@tonic-gate [ 1, 0, {}, "user11:118::root ,sys ,daemon, bin::" ], 5410Sstevel@tonic-gate [ 1, 0, {}, "user12:119::root, !sys, daemon ,!bin::" ], 5420Sstevel@tonic-gate [ 1, 0, {}, "group1:126:::*!:" ], 5430Sstevel@tonic-gate [ 0, 1, {}, "group2:127:::oneUpper:" ], 5440Sstevel@tonic-gate [ 0, 1, {}, "group3:128:::NOLOWER:" ], 5450Sstevel@tonic-gate [ 0, 1, {}, "group4:129:::toooolong:" ], 5460Sstevel@tonic-gate [ 1, 0, {}, "group5:130:::root!:" ], 5470Sstevel@tonic-gate [ 1, 0, {}, "group6:131:::root;sys:" ], 5480Sstevel@tonic-gate [ 0, 1, {}, "group7:132:::sys,NOLOWER:" ], 5490Sstevel@tonic-gate [ 1, 0, {}, "group8:133:::sys-bin,root:" ], 5500Sstevel@tonic-gate [ 1, 0, {}, "group9:124:::*, !sys:" ], 5510Sstevel@tonic-gate [ 1, 0, {}, "group10:125:::!* ,daemon:" ], 5520Sstevel@tonic-gate [ 1, 0, {}, "group11:126:::root, sys ,daemon, bin:" ], 5530Sstevel@tonic-gate [ 1, 0, {}, "group12:127:::root ,!sys, daemon ,!bin:" ], 5540Sstevel@tonic-gate [ 1, 0, {}, "attrib1:134::::10" ], 5550Sstevel@tonic-gate [ 1, 0, {}, "attrib2:135::::_foo=" ], 5560Sstevel@tonic-gate [ 1, 0, {}, "attrib3:136::::,foo" ], 5570Sstevel@tonic-gate [ 1, 0, {}, "attrib4:137::::sun,foo" ], 5580Sstevel@tonic-gate [ 1, 0, {}, "attrib6:139::::!attrib" ], 5590Sstevel@tonic-gate [ 1, 0, {}, "attrib7:140::::_attrib" ], 5600Sstevel@tonic-gate [ 1, 0, {}, "attrib8:141::::attib,attrib" ], 5610Sstevel@tonic-gate [ 1, 0, {}, "attrib9:142::::attrib/attrib" ], 5620Sstevel@tonic-gate [ 1, 0, {}, "attrib10:143::::one;two,three" ], 5630Sstevel@tonic-gate [ 1, 0, {}, "attrib11:144::::one=two;three/" ], 5640Sstevel@tonic-gate [ 1, 0, {}, "value1:145::::one=foo%" ], 5650Sstevel@tonic-gate [ 1, 0, {}, "value2:146::::one= two" ], 5660Sstevel@tonic-gate [ 1, 0, {}, "value3:147::::var=foo?" ], 5670Sstevel@tonic-gate [ 1, 0, {}, "value4:148::::name=value;name=value2)" ], 5680Sstevel@tonic-gate [ 1, 0, {}, "value5:149::::(foo)" ], 5690Sstevel@tonic-gate [ 1, 0, {}, "value6:150::::name=(foo,bar" ], 5700Sstevel@tonic-gate [ 1, 0, {}, "value7:151::::name=(value)(value)" ], 5710Sstevel@tonic-gate [ 1, 0, {}, "value8:152::::name=)" ], 5720Sstevel@tonic-gate [ 1, 0, {}, "value9:153::::name=value,(value value)" ], 5730Sstevel@tonic-gate [ 1, 0, {}, "value10:154::::name=(value(value))" ], 5740Sstevel@tonic-gate [ 1, 0, {}, "value11:155::::name=(value)value" ], 5750Sstevel@tonic-gate [ 1, 0, {}, "value11:156::::name=va?lue" ], 5760Sstevel@tonic-gate [ 1, 0, {}, "value12:157::::name=(value,value))" ], 5770Sstevel@tonic-gate [ 1, 0, {}, "value13:158::::name=(value),value)" ], 5780Sstevel@tonic-gate [ 1, 0, {}, "space1 :159::::" ], 5790Sstevel@tonic-gate [ 1, 0, {}, " space2:160::::" ], 5800Sstevel@tonic-gate [ 1, 0, {}, "space3: 161::::" ], 5810Sstevel@tonic-gate [ 1, 0, {}, "space4:162 ::::" ], 5820Sstevel@tonic-gate [ 1, 0, {}, "space 5:163::::" ], 5830Sstevel@tonic-gate [ 1, 0, {}, "space6:1 64::::" ], 5840Sstevel@tonic-gate [ 1, 0, {}, "space7:165:: root::" ], 5850Sstevel@tonic-gate [ 1, 0, {}, "space8:166::root ::" ], 5860Sstevel@tonic-gate [ 1, 0, {}, "space9:167::daemon, root::" ], 5870Sstevel@tonic-gate [ 1, 0, {}, "space10:168::bin root::" ], 5880Sstevel@tonic-gate [ 1, 0, {}, "space11:169::daemon ,root::" ], 5890Sstevel@tonic-gate [ 1, 0, {}, "space12 :170::::" ], 5900Sstevel@tonic-gate [ 1, 0, {}, " space13:171::::" ], 5910Sstevel@tonic-gate [ 1, 0, {}, "space14: 172::::" ], 5920Sstevel@tonic-gate [ 1, 0, {}, "space15:173 ::::" ], 5930Sstevel@tonic-gate [ 1, 0, {}, "space 16:174::::" ], 5940Sstevel@tonic-gate [ 1, 0, {}, "space17:1 75::::" ], 5950Sstevel@tonic-gate [ 1, 0, {}, "space18:176::: root:" ], 5960Sstevel@tonic-gate [ 1, 0, {}, "space19:177:::root :" ], 5970Sstevel@tonic-gate [ 1, 0, {}, "space20:178:::daemon, root:" ], 5980Sstevel@tonic-gate [ 1, 0, {}, "space21:179:::bin root:" ], 5990Sstevel@tonic-gate [ 1, 0, {}, "space22:180:::daemon ,root:" ], 6000Sstevel@tonic-gate [ 1, 0, {}, "space23:181:::: foo" ], 6010Sstevel@tonic-gate [ 1, 0, {}, "space34:182::::foo =one" ], 6020Sstevel@tonic-gate [ 1, 0, {}, "space35:183::::foo= (one)" ], 6030Sstevel@tonic-gate [ 1, 0, {}, "space36:184::::foo=(one, two)" ], 6040Sstevel@tonic-gate [ 1, 0, {}, "space37:185::::foo=(one ,two)" ], 6050Sstevel@tonic-gate [ 1, 0, {}, "space38:186::::foo=( one)" ], 6060Sstevel@tonic-gate [ 1, 0, {}, "space39:187::::foo=(one )" ], 6070Sstevel@tonic-gate [ 1, 0, {}, "space40:188::::foo=(one) ,two" ], 6080Sstevel@tonic-gate [ 1, 0, {}, "space41:189::::foo=one, (two)" ], 6090Sstevel@tonic-gate [ 1, 0, {}, "comma1:190::,root,bin::" ], 6100Sstevel@tonic-gate [ 1, 0, {}, "comma2:191::root,,bin::" ], 6110Sstevel@tonic-gate [ 1, 0, {}, "comma3:192::,,root,bin::" ], 6120Sstevel@tonic-gate [ 1, 0, {}, "comma4:193:::,root,bin:" ], 6130Sstevel@tonic-gate [ 1, 0, {}, "comma5:194:::root,,bin:" ], 6140Sstevel@tonic-gate [ 1, 0, {}, "comma6:195:::,,root,bin:" ], 6150Sstevel@tonic-gate [ 1, 0, {}, "semi1:196::::;foo" ], 6160Sstevel@tonic-gate [ 1, 0, {}, "semi2:197::::foo;;bar=1" ], 6170Sstevel@tonic-gate [ 1, 0, {}, "semi3:198::::;;bar=(10)" ], 6180Sstevel@tonic-gate [ 0, 1, {}, "rctl1:199::::task.max-lwps=," ], 6190Sstevel@tonic-gate [ 0, 1, {}, "rctl2:200::::task.max-lwps=" ], 6200Sstevel@tonic-gate [ 0, 1, {}, "rctl3:201::::task.max-lwps=priv" ], 6210Sstevel@tonic-gate [ 0, 1, {}, "rctl4:202::::task.max-lwps=priv,1000" ], 6220Sstevel@tonic-gate [ 0, 1, {}, "rctl5:203::::task.max-lwps=priv,1000,deny" ], 6230Sstevel@tonic-gate [ 0, 1, {}, "rctl6:204::::task.max-lwps=(priv)" ], 6240Sstevel@tonic-gate [ 0, 1, {}, "rctl7:205::::task.max-lwps=(priv,1000)" ], 6250Sstevel@tonic-gate [ 0, 1, {}, "rctl8:206::::task.max-lwps=(foo,100,deny)" ], 6260Sstevel@tonic-gate [ 0, 1, {}, "rctl9:207::::task.max-lwps=(priv,foo,none)" ], 6270Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl9:207::::task.max-lwps=(priv,foo,none)" ], 6280Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl10:208::::task.max-lwps=(priv,100foo,none)" ], 6290Sstevel@tonic-gate [ 0, 1, {}, "rctl11:209::::task.max-lwps=(priv,1000,foo)" ], 6300Sstevel@tonic-gate [ 0, 1, { "allowunits" => 1 }, "rctl12:210::::task.max-lwps=(priv,1000k,deny,signal)" ], 6310Sstevel@tonic-gate [ 0, 1, {}, "rctl13:211::::task.max-lwps=(priv,1000,deny,signal=)" ], 6320Sstevel@tonic-gate [ 0, 1, {}, "rctl14:212::::task.max-lwps=(priv,1000,deny,signal=foo)" ], 6330Sstevel@tonic-gate [ 0, 1, {}, "rctl15:213::::task.max-lwps=(priv,1000,deny,signal=1fo)" ], 6340Sstevel@tonic-gate [ 0, 1, {}, "rctl16:214::::task.max-lwps=(priv,1000,deny,signal=100)" ], 6350Sstevel@tonic-gate [ 0, 1, {}, "rctl17:215::::task.max-lwps=(priv,1000,deny,signal=SIG)" ], 6360Sstevel@tonic-gate [ 0, 1, {}, "rctl18:216::::task.max-lwps=(priv,1000,deny,signal=SIG1)" ], 6370Sstevel@tonic-gate [ 0, 1, {}, "rctl19:217::::task.max-lwps=(priv,1000,deny,signal=SIGhup)" ], 6380Sstevel@tonic-gate [ 0, 1, {}, "rctl20:218::::task.max-lwps=(priv,1000,deny,signal=SIGHU)" ], 6390Sstevel@tonic-gate [ 0, 1, {}, "rctl21:219::::task.max-lwps=(priv,1000,deny,signal=SIGHUPP)" ], 6400Sstevel@tonic-gate [ 0, 1, {}, "rctl22:220::::task.max-lwps=(priv,1000,deny,signal=SIGURG)" ], 6410Sstevel@tonic-gate [ 0, 1, {}, "rctl23:221::::task.max-lwps=(priv,1000,deny,signal=SIGXCPU)" ], 6420Sstevel@tonic-gate [ 0, 1, {}, "rctl24:222::::task.max-lwps=(priv,1000,deny,signal=SIGKILL,10)" ], 6430Sstevel@tonic-gate [ 0, 1, {}, "rctl25:223::::task.max-lwps=(priv,1000,deny,signal=SIGKILL,foo)" ], 6440Sstevel@tonic-gate [ 0, 1, {}, "rctl26:224::::process.max-port-events=(priv,1000,none)" ], 6450Sstevel@tonic-gate [ 0, 1, { "allowunits" => 1 }, "rctl27:225::::process.max-address-space=(basic,1024mb,deny,signal=TERM)" ], 6460Sstevel@tonic-gate [ 0, 1, {}, "rctl28:226::::process.max-cpu-time=(basic,3600,deny)" ], 6470Sstevel@tonic-gate [ 0, 1, {}, "rctl29:227::::task.max-lwps=()" ], 6480Sstevel@tonic-gate [ 0, 1, {}, "rctl30:228::::task.max-lwps=((priv),deny)" ], 6490Sstevel@tonic-gate [ 0, 1, {}, "rctl31:229::::task.max-lwps=((priv,1000,deny))" ], 6500Sstevel@tonic-gate [ 0, 1, {}, "rctl32:230::::task.max-lwps=(priv,((1000,2000,1000)),deny)" ], 6510Sstevel@tonic-gate [ 0, 1, {}, "rctl33:231::::task.max-lwps=(,,,)" ], 6520Sstevel@tonic-gate [ 0, 1, {}, "rctl34:232::::task.max-lwps=(priv,1000,(deny))" ], 6530Sstevel@tonic-gate [ 0, 1, {}, "rctl35:233::::task.max-lwps=(priv,1000,deny),foo" ], 6540Sstevel@tonic-gate [ 0, 1, {}, "rctl36:234::::task.max-lwps=(priv,1000,deny),(priv,1000)" ], 6550Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl37:235::::project.max-msg-ids=(priv,15EB,deny)" ], 6560Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl38:236::::process.max-address-space=(priv,16.1EB,deny)" ], 6570Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl39:237::::process.max-address-space=(priv,18000000000gb,deny)" ], 6580Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl40:238::::zone.cpu-shares=(priv,10kb,none)" ], 6590Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl41:239::::zone.cpu-shares=(priv,10Ks,none)" ], 6600Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl42:240::::zone.cpu-shares=(priv,10s,none)" ], 6610Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl43:241::::zone.cpu-shares=(priv,100000b,none)" ], 6620Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl44:242::::project.max-shm-memory=(priv,200Ts,deny)" ], 6630Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl45:243::::project.max-shm-memory=(priv,200s,deny)" ], 6640Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl46:244::::task.max-cpu-time=(priv,20B,none)" ], 6650Sstevel@tonic-gate [ 1, 0, { "allowunits" => 1 }, "rctl47:245::::task.max-cpu-time=(priv,20Kb,none)" ], 6660Sstevel@tonic-gate [ 0, 1, { "allowunits" => 1 }, "rctl48:246::::project.cpu-shares=(priv,100k,none)" ], 6670Sstevel@tonic-gate [ 0, 1, {}, "rctl147:150::::task.max-lwps=(priv,1000M,deny,signal=SIGHUP),(priv,1000k,deny,signal=SIGKILL)" ], 6680Sstevel@tonic-gate [ 0, 1, {}, "rctl148:163::::task.max-lwps=(priv,1000,deny,signal=HUP),(priv,1000k,deny,signal=15)" ], 6690Sstevel@tonic-gate [ 0, 1, {}, "rctl3:165::::project.max-crypto-memory=(priv,10eb,deny)" ], 6700Sstevel@tonic-gate [ 0, 1, {}, "rctl4:166::::project.max-crypto-memory=(privileged,100p,deny)" ], 6710Sstevel@tonic-gate [ 0, 1, {}, "rctl5:167::::project.max-crypto-memory=(priv,1000t,deny)" ], 6720Sstevel@tonic-gate [ 0, 1, {}, "rctl6:168::::project.max-crypto-memory=(priv,1000g,deny)" ], 6730Sstevel@tonic-gate [ 0, 1, {}, "rctl7:169::::process.max-msg-messages=(priv,10m,deny)" ], 6740Sstevel@tonic-gate [ 0, 1, {}, "rctl8:170::::process.max-msg-qbytes=(priv,10000kb,deny)" ], 6750Sstevel@tonic-gate [ 0, 1, {}, "rctl11:173::::process.max-address-space=(priv,10EB,deny)" ], 6760Sstevel@tonic-gate [ 0, 1, {}, "rctl12:174::::process.max-file-descriptor=(basic,1K,deny),(basic,2K,deny)" ], 6770Sstevel@tonic-gate [ 0, 1, {}, "rctl13:175::::process.max-core-size=(priv,1Eb,deny),(priv,10PB,deny)" ], 6780Sstevel@tonic-gate [ 0, 1, {}, "rctl14:176::::process.max-stack-size=(priv,10Tb,deny),(priv,10TB,deny)" ], 6790Sstevel@tonic-gate [ 0, 1, {}, "rctl16:178::::process.max-file-size=(priv,100mb,deny,signal=SIGXFSZ),(priv,1000mb,deny,signal=31)" ], 6800Sstevel@tonic-gate [ 0, 1, {}, "rctl17:179::::process.max-cpu-time=(priv,1t,signal=XCPU),(priv,100ms,sig=30)" ], 6810Sstevel@tonic-gate [ 0, 1, {}, "rctl18:180::::task.max-cpu-time=(priv,1M,sig=SIGKILL)" ], 6820Sstevel@tonic-gate [ 0, 1, {}, "rctl22:184::::project.max-shm-memory=(priv,1000mb,deny)" ], 6830Sstevel@tonic-gate [ 0, 1, {}, "rctl23:185::::project.max-shm-ids=(priv,1k,deny,signal=SIGSTOP)" ], 6840Sstevel@tonic-gate [ 0, 1, {}, "rctl24:186::::project.max-msg-ids=(priv,1m,deny,signal=XRES)" ], 6850Sstevel@tonic-gate [ 0, 1, {}, "rctl26:188::::project.cpu-shares=(priv,63k,none)" ], 6860Sstevel@tonic-gate [ 0, 1, {}, "rctl27:189::::zone.cpu-shares=(priv,20k,none)" ], 6870Sstevel@tonic-gate [ 0, 1, {}, "rctl29:191::::project.max-shm-memory=(priv,200G,deny)" ], 6880Sstevel@tonic-gate [ 0, 1, {}, "rctl30:192::::project.max-shm-memory=(priv,200Gb,deny)" ], 6890Sstevel@tonic-gate [ 0, 1, {}, "rctl31:193::::project.max-shm-memory=(priv,2000B,deny)" ], 6900Sstevel@tonic-gate [ 0, 1, {}, "rctl34:196::::task.max-cpu-time=(priv,2000s,none)" ], 6910Sstevel@tonic-gate [ 0, 1, {}, "rctl35:197::::task.max-cpu-time=(priv,20.1ps,none)" ], 6920Sstevel@tonic-gate [ 0, 1, {}, "rctl36:198::::task.max-cpu-time=(priv,20T,none)" ], 6930Sstevel@tonic-gate); 6940Sstevel@tonic-gate 6950Sstevel@tonic-gatemy $parse_exp; 6960Sstevel@tonic-gatemy $parse_ret; 6970Sstevel@tonic-gatemy $validate_exp; 6980Sstevel@tonic-gatemy $validate_ret; 6990Sstevel@tonic-gatemy $project; 7000Sstevel@tonic-gatemy $projent; 7010Sstevel@tonic-gatemy $errors; 7020Sstevel@tonic-gate 7030Sstevel@tonic-gateforeach $projent_test ( @projent_tests) { 7040Sstevel@tonic-gate 7050Sstevel@tonic-gate ($parse_exp, $validate_exp, $flags, $project) = @$projent_test; 7060Sstevel@tonic-gate $flagstring = hash2string($flags); 7070Sstevel@tonic-gate start("projent_parse(): flags: $flagstring, project: $project"); 7080Sstevel@tonic-gate ($ret, $projent) = projent_parse($project, $flags); 7090Sstevel@tonic-gate if ($ret != $parse_exp) { 7100Sstevel@tonic-gate fail("Expected $parse_exp, Returned $ret"); 7110Sstevel@tonic-gate if ($ret) { 7120Sstevel@tonic-gate foreach $error (@$projent) { 7130Sstevel@tonic-gate comment("# " . join(", ", @$error)); 7140Sstevel@tonic-gate } 7150Sstevel@tonic-gate } 7160Sstevel@tonic-gate next; 7170Sstevel@tonic-gate } 7180Sstevel@tonic-gate pass(); 7190Sstevel@tonic-gate 7200Sstevel@tonic-gate # projent_validate() can only be successfully parsed projents 7210Sstevel@tonic-gate if ($ret) { 7220Sstevel@tonic-gate next; 7230Sstevel@tonic-gate } 7240Sstevel@tonic-gate 7250Sstevel@tonic-gate start("projent_validate(): flags: $flagstring, project: $project"); 7260Sstevel@tonic-gate ($ret, $errors) = projent_validate($projent, $flags); 7270Sstevel@tonic-gate if ($ret != $validate_exp) { 7280Sstevel@tonic-gate fail("Expected $validate_exp, Returned $ret"); 7290Sstevel@tonic-gate if ($ret) { 7300Sstevel@tonic-gate foreach $error (@$errors) { 7310Sstevel@tonic-gate comment("# " . join(", ", @$error)); 7320Sstevel@tonic-gate } 7330Sstevel@tonic-gate } 7340Sstevel@tonic-gate next; 7350Sstevel@tonic-gate } 7360Sstevel@tonic-gate pass(); 7370Sstevel@tonic-gate} 7380Sstevel@tonic-gate 7390Sstevel@tonic-gatemy $pf1; 7400Sstevel@tonic-gatemy $pf2; 7410Sstevel@tonic-gatemy $fh1; 7420Sstevel@tonic-gatemy $fh2; 7430Sstevel@tonic-gatemy @lines; 7440Sstevel@tonic-gate 7450Sstevel@tonic-gate# get projects and make local copy 7460Sstevel@tonic-gateopen($fh1, "/usr/bin/getent project |") || fatal($!); 7470Sstevel@tonic-gateopen($fh2, ">/tmp/projent.$$") || fatal($!); 7480Sstevel@tonic-gate@lines = <$fh1>; 7490Sstevel@tonic-gateprint $fh2 @lines; 7500Sstevel@tonic-gateclose($fh1); 7510Sstevel@tonic-gateclose($fh2); 7520Sstevel@tonic-gate 7530Sstevel@tonic-gateopen($fh1, "</tmp/projent.$$") || fatal($!); 7540Sstevel@tonic-gate$pf1 = read_pfile($fh1); 7550Sstevel@tonic-gateclose($fh1); 7560Sstevel@tonic-gate 7570Sstevel@tonic-gate 7580Sstevel@tonic-gatestart("Test getprojid"); 7590Sstevel@tonic-gate($s) = `/usr/xpg4/bin/id -p` =~ /projid=(\d+)/; 7600Sstevel@tonic-gatedefined($s) && $s == getprojid() ? pass() : fail(); 7610Sstevel@tonic-gate 7620Sstevel@tonic-gatestart("Test fgetprojent"); 7630Sstevel@tonic-gate$pf2 = []; 7640Sstevel@tonic-gateopen($fh, "</tmp/projent.$$") || fatal($!); 7650Sstevel@tonic-gatewhile (my @proj = fgetprojent($fh)) { 7660Sstevel@tonic-gate push(@$pf2, [ @proj ]); 7670Sstevel@tonic-gate} 7680Sstevel@tonic-gateclose($fh); 7690Sstevel@tonic-gatecmp_recs($pf1, $pf2) ? pass() : fail(); 7700Sstevel@tonic-gate 7710Sstevel@tonic-gatemy %pf_byname = map({ $_->[0] => $_} @$pf1); 7720Sstevel@tonic-gatemy %pf_byid = map({ $_->[1] => $_} @$pf1); 7730Sstevel@tonic-gatemy (%h, @a1, @a2, $k, $v); 7740Sstevel@tonic-gate 7750Sstevel@tonic-gatestart("Test getprojent. Don't assume anything about the order it returns stuff in"); 7760Sstevel@tonic-gate%h = %pf_byname; 7770Sstevel@tonic-gate$pass = 1; 7780Sstevel@tonic-gate@a2 = (); 7790Sstevel@tonic-gatewhile (@a1 = getprojent()) { 7800Sstevel@tonic-gate @a2 = @a1 if (! scalar(@a2)); 7810Sstevel@tonic-gate if (exists($h{$a1[0]})) { 7820Sstevel@tonic-gate $pass = 0 if (! cmp_recs(\@a1, $h{$a1[0]})); 7830Sstevel@tonic-gate delete($h{$a1[0]}); 7840Sstevel@tonic-gate } else { 7850Sstevel@tonic-gate $pass = 0; 7860Sstevel@tonic-gate } 7870Sstevel@tonic-gate} 7880Sstevel@tonic-gate$pass && ! %h ? pass() : fail(); 7890Sstevel@tonic-gate 7900Sstevel@tonic-gatestart("Test getprojent when at end"); 7910Sstevel@tonic-gate@a1 = getprojent(); 7920Sstevel@tonic-gatecmp_recs(\@a1, []) ? pass() : fail(); 7930Sstevel@tonic-gate 7940Sstevel@tonic-gate 7950Sstevel@tonic-gatestart("Test endprojent/getprojent"); 7960Sstevel@tonic-gateendprojent(); 7970Sstevel@tonic-gate@a1 = getprojent(); 7980Sstevel@tonic-gatecmp_recs(\@a1, \@a2) ? pass() : fail(); 7990Sstevel@tonic-gate 8000Sstevel@tonic-gatestart("Test setprojent/getprojent"); 8010Sstevel@tonic-gatesetprojent(); 8020Sstevel@tonic-gate@a1 = getprojent(); 8030Sstevel@tonic-gatecmp_recs(\@a1, \@a2) ? pass() : fail(); 8040Sstevel@tonic-gatesetprojent(); 8050Sstevel@tonic-gate 8060Sstevel@tonic-gatestart("Test getprojbyname"); 8070Sstevel@tonic-gate$pass = 1; 8080Sstevel@tonic-gatewhile (($k, $v) = each(%pf_byname)) { 8090Sstevel@tonic-gate @a1 = getprojbyname($k); 8100Sstevel@tonic-gate $pass = 0 if (! cmp_recs(\@a1, $v)); 8110Sstevel@tonic-gate} 8120Sstevel@tonic-gate$pass ? pass() : fail(); 8130Sstevel@tonic-gate 8140Sstevel@tonic-gatestart("Test getprojbyid"); 8150Sstevel@tonic-gate$pass = 1; 8160Sstevel@tonic-gatewhile (($k, $v) = each(%pf_byid)) { 8170Sstevel@tonic-gate @a1 = getprojbyid($k); 8180Sstevel@tonic-gate $pass = 0 if (! cmp_recs(\@a1, $v)); 8190Sstevel@tonic-gate} 8200Sstevel@tonic-gate$pass ? pass() : fail(); 8210Sstevel@tonic-gate 8220Sstevel@tonic-gatestart("Test getprojidbyname"); 8230Sstevel@tonic-gate$pass = 1; 8240Sstevel@tonic-gatewhile (($k, $v) = each(%pf_byname)) { 8250Sstevel@tonic-gate $pass = 0 if (getprojidbyname($k) != $v->[1]); 8260Sstevel@tonic-gate} 8270Sstevel@tonic-gate$pass ? pass() : fail(); 8280Sstevel@tonic-gate 8290Sstevel@tonic-gatestart("Test getdefaultproj"); 8300Sstevel@tonic-gatemy $username = getpwuid($>); 8310Sstevel@tonic-gatemy $projid; 8320Sstevel@tonic-gate$s = `/usr/bin/id -p` ; 8330Sstevel@tonic-gate($projid) = $s =~ /projid=\d+\(([^)]+)\)/; 8340Sstevel@tonic-gatedefined($projid) && $projid eq getdefaultproj($username) ? pass() : fail(); 8350Sstevel@tonic-gate 8360Sstevel@tonic-gatestart("test inproj"); 8370Sstevel@tonic-gate$s = `/usr/bin/projects`; 8380Sstevel@tonic-gate($s) = split(/\s+/, $s); 8390Sstevel@tonic-gateinproj($username, $s) ? pass() : fail(); 8400Sstevel@tonic-gate 8410Sstevel@tonic-gateexit(0); 842