From owner-p4-projects@FreeBSD.ORG Tue Jul 3 07:50:41 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4A7C216A46D; Tue, 3 Jul 2007 07:50:41 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D25EE16A468 for ; Tue, 3 Jul 2007 07:50:40 +0000 (UTC) (envelope-from zhouzhouyi@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id C1F5613C43E for ; Tue, 3 Jul 2007 07:50:40 +0000 (UTC) (envelope-from zhouzhouyi@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l637oer8098118 for ; Tue, 3 Jul 2007 07:50:40 GMT (envelope-from zhouzhouyi@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l637oe69098109 for perforce@freebsd.org; Tue, 3 Jul 2007 07:50:40 GMT (envelope-from zhouzhouyi@FreeBSD.org) Date: Tue, 3 Jul 2007 07:50:40 GMT Message-Id: <200707030750.l637oe69098109@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zhouzhouyi@FreeBSD.org using -f From: Zhouyi ZHOU To: Perforce Change Reviews Cc: Subject: PERFORCE change 122751 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jul 2007 07:50:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=122751 Change 122751 by zhouzhouyi@zhouzhouyi_mactest on 2007/07/03 07:50:04 adjustment for better handling of configuration file and unmatched case warning Affected files ... .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/mactest.c#6 edit .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/misc.sh#4 edit .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/open/00.t#3 edit .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/signal/01.t#2 edit Differences ... ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/mactest.c#6 (text+ko) ==== @@ -227,7 +227,7 @@ usage(void) { - fprintf(stderr, "usage: mactest -m label_string syscall args ...\n"); + fprintf(stderr, "usage: mactest -m label_string -f macconf_file syscall args ...\n"); exit(1); } @@ -607,19 +607,23 @@ struct syscall_desc *scall; unsigned int n,nread; const char *label_string = NULL; + const char *macconf_file = NULL; int pid,pid1; int error; int mactestpipefd, logfd; char buf[2048]; int ch; + int notgood = 0; - - while ((ch = getopt(argc, argv, "m:")) != -1) { + while ((ch = getopt(argc, argv, "m:f:")) != -1) { switch(ch) { case 'm': label_string = optarg; break; + case 'f': + macconf_file = optarg; + break; default: usage(); } @@ -632,8 +636,12 @@ usage(); } + if (macconf_file == NULL){ + fprintf(stderr, "must supply macconf_file\n"); + usage(); + } + - if (mac_is_present(NULL) == 1) { mac_t label; @@ -688,7 +696,7 @@ yyparse(); fclose(inputfile); record_from_log = mactestlog_record_chain; - if ((inputfile = fopen("mactest.conf", "r")) == NULL){ + if ((inputfile = fopen(macconf_file, "r")) == NULL){ fprintf(stderr, "mactest.conf do not exists!\n"); exit(1); } @@ -729,7 +737,8 @@ if (iterator) record_from_conf = record_from_conf->next; else{ - fprintf(stderr, "missing ...\n"); + notgood = 1; + fprintf(stderr, "\n missing ...\n"); struct modes_or_flags *iterator1, *tmp1; struct labelstrings *iterator2, *tmp2; @@ -766,12 +775,14 @@ } fprintf(stderr, "\n"); } - exit(1); + record_from_conf = record_from_conf->next; } } } - - exit(0); + if (notgood) + exit(1); + else + exit(0); } static const char * ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/misc.sh#4 (text+ko) ==== @@ -39,19 +39,21 @@ } -mactestnotexpectanyerror() +mactestexpect() { - + e="${1}" + shift ${mactest} $* 2>${tmp_file} 1>>${tmp_file} r=`cat ${tmp_file}` - echo "${r}" | egrep '^''0''$' >/dev/null 2>&1 - if [ $? -eq 0 ] && [ ${#r} -eq 1 ] ; then + echo "${r}" | egrep '^'${e}'$' >/dev/null 2>&1 + if [ $? -eq 0 ] && [ ${#r} -eq ${#e} ]; then echo "ok ${ntest}" else echo ${r} echo "not ok ${ntest}" fi ntest=`expr $ntest + 1` + rm ${tmp_file} } ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/open/00.t#3 (text+ko) ==== @@ -6,7 +6,7 @@ dir=`dirname $0` . ${dir}/../misc.sh -echo "1..2" +echo "1..4" n0=`namegen` n1=`namegen` @@ -23,29 +23,76 @@ if [ "${mac_mls_support}" != "" ] && [ "${mac_biba_support}" != "" ] ; then dvplabel=`getfmac ".."| sed 's/\(\.\.:\ \)\([a-z\,\/]*\)/\2/`; + +############################################################# +#case mkdir: #examine the label of its parent directory - echo "pid = -1 mac_test_check_vnode_lookup: biba/high(low-high),mls/9(low-high) ${dvplabel}" > ${mactest_conf} + echo -n "pid = -1 mac_test_check_vnode_lookup:" > ${mactest_conf} + echo "biba/high(low-high),mls/8(low-high) ${dvplabel}" >> ${mactest_conf} + #check the label of its parent directory - echo "pid = -1 mac_test_check_vnode_create: biba/high(low-high),mls/9(low-high) ${dvplabel}" >> ${mactest_conf} + echo -n "pid = -1 mac_test_check_vnode_create:" >> ${mactest_conf} + echo "biba/high(low-high),mls/8(low-high) ${dvplabel}" >> ${mactest_conf} + #init the label of currently created vnode echo "pid = -1 mac_test_init_vnode_label" >> ${mactest_conf} + #associate the extattr of newly created vnode - echo "pid = -1 mac_test_create_vnode_extattr: biba/high(low-high),mls/9(low-high) * ${dvplabel} biba/high,mls/9" >> ${mactest_conf} - mactestnotexpectanyerror -m "mls/9(low-high)" mkdir ${n1} 0755 - rm ${mactest_conf} + echo -n "pid = -1 mac_test_create_vnode_extattr:" >> ${mactest_conf} + echo "biba/high(low-high),mls/8(low-high) * ${dvplabel} biba/high,mls/8" >> ${mactest_conf} + mactestexpect 0 -m "mls/8(low-high)" -f ${mactest_conf} mkdir ${n1} 0755 + +############################################################# +#case creative open: cd ${n1} - echo "pid = -1 mac_test_check_vnode_lookup with cr_label and dvplabel:biba/high(low-high),mls/9(low-high) biba/high,mls/9" > ${mactest_conf} - echo "pid = -1 mac_test_check_vnode_create with cr_label and dvplabel:biba/high(low-high),mls/9(low-high) biba/high,mls/9" >> ${mactest_conf} + echo -n "pid = -1 mac_test_check_vnode_lookup:" > ${mactest_conf} + echo "biba/high(low-high),mls/9(low-high) biba/high,mls/8" >> ${mactest_conf} + + echo -n "pid = -1 mac_test_check_vnode_create:" >> ${mactest_conf} + echo "biba/high(low-high),mls/9(low-high) biba/high,mls/8" >> ${mactest_conf} + echo "pid = -1 mac_test_init_vnode_label" >> ${mactest_conf} - echo "pid = -1 mac_test_create_vnode_extattr with cr_label mplabel dvplabel and vplabel:biba/high(low-high),mls/9(low-high) biba/high,mls/low biba/high,mls/9 biba/high,mls/9" >> ${mactest_conf} - echo "pid = -1 mac_test_check_vnode_open with acc_mode and cr_label and vplabel#VWRITE :biba/high(low-high),mls/9(low-high) biba/high,mls/9" >> ${mactest_conf} - mv ${mactest_conf} "mactest.conf" - mactestnotexpectanyerror -m "mls/9(low-high)" open ${n0} O_CREAT,O_WRONLY 0755 - rm "mactest.conf" + + echo -n "pid = -1 mac_test_create_vnode_extattr:" >> ${mactest_conf} + echo "biba/high(low-high),mls/9(low-high) biba/high,mls/low biba/high,mls/8 biba/high,mls/9" >> ${mactest_conf} + + echo -n "pid = -1 mac_test_check_vnode_open#VWRITE :" >> ${mactest_conf} + echo "biba/high(low-high),mls/9(low-high) biba/high,mls/9" >> ${mactest_conf} + + mactestexpect 0 -m "mls/9(low-high)" -f ${mactest_conf} open ${n0} O_CREAT,O_WRONLY 0755 + + + +############################################################# +#case lstat: +#dvplabel is mls/8 + echo -n "pid = -1 mac_test_check_vnode_lookup with cr_label and dvplabel:" > ${mactest_conf} + echo "biba/high(low-high),mls/high(low-high) biba/high,mls/8" >> ${mactest_conf} + +#no file label + echo -n "pid = -1 mac_test_check_vnode_stat with cred label, file label and vplabel:" >> ${mactest_conf} + echo "biba/high(low-high),mls/high(low-high) NULL biba/high,mls/9" >> ${mactest_conf} + mactestexpect regular,0755 -m "mls/high" -f ${mactest_conf} lstat ${n0} type,mode + + +############################################################# +#case unlink: +#This case will show complex of access control for mls directory structure +#dvplabel is mls/8 + echo -n "pid = -1 mac_test_check_vnode_lookup with cr_label and dvplabel:" > ${mactest_conf} + echo "biba/high(low-high),mls/6(low-high) biba/high,mls/8" >> ${mactest_conf} + +#the hook for delete + echo -n "pid = -1 mac_test_check_vnode_delete with cr_label dvplabel and vplabel:" >> ${mactest_conf} + echo "biba/high(low-high),mls/6(low-high) biba/high,mls/8 biba/high,mls/9" >> ${mactest_conf} + echo "pid = -1 mac_test_destroy_vnode_label" >> ${mactest_conf} + mactestexpect 0 -m "mls/6" -f ${mactest_conf} unlink ${n0} cd .. + +#cleanup: rm -fr ${n1} fi ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/signal/01.t#2 (text+ko) ==== @@ -7,7 +7,6 @@ dir=`dirname $0` . ${dir}/../misc.sh -mactest_conf="mactest.conf" #turn off all the switches @@ -23,13 +22,12 @@ maccmdnotexpectanyerror "mls/3(2-7)" ${macproc} -w 100 -f "${pid_file}" getmacprocpid - echo "pid = -1 mac_test_check_proc_signal with cr_label and proc label: biba/high(low-high),mls/9(low-high) biba/high(low-high),mls/3(2-7)" > ${mactest_conf} + echo "pid = -1 mac_test_check_proc_signal with cr_label and proc label: biba/high(low-high),mls/9(low-high) mls/3(2-7),biba/high(low-high)" > ${mactest_conf} - mactestnotexpectanyerror -m "mls/9" kill ${pid} 9 + mactestexpect 0 -m "mls/9" -f ${mactest_conf} kill ${pid} 9 rm ${mactest_conf} rm ${pid_file} - rm ${tmp_file} fi