From owner-p4-projects@FreeBSD.ORG Thu Jun 21 09:27:22 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 B3B4816A46B; Thu, 21 Jun 2007 09:27:22 +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 75E5216A400 for ; Thu, 21 Jun 2007 09:27:22 +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 5A75F13C43E for ; Thu, 21 Jun 2007 09:27:22 +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 l5L9RMvn015045 for ; Thu, 21 Jun 2007 09:27:22 GMT (envelope-from zhouzhouyi@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l5L9RMQ0015042 for perforce@freebsd.org; Thu, 21 Jun 2007 09:27:22 GMT (envelope-from zhouzhouyi@FreeBSD.org) Date: Thu, 21 Jun 2007 09:27:22 GMT Message-Id: <200706210927.l5L9RMQ0015042@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 122072 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: Thu, 21 Jun 2007 09:27:23 -0000 http://perforce.freebsd.org/chv.cgi?CH=122072 Change 122072 by zhouzhouyi@zhouzhouyi_mactest on 2007/06/21 09:26:54 Correct the mactestpipe grammer for precise parsing it Affected files ... .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/zhouzhouyi_mactest_soc/sys/security/mac_test/mac_test.c#10 edit .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/zhouzhouyi_mactest_soc/tools/regression/mactest/mactestparser.y#2 edit Differences ... ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/zhouzhouyi_mactest_soc/sys/security/mac_test/mac_test.c#10 (text+ko) ==== @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -1765,7 +1766,7 @@ } sprintf(submitstring, "mac_test_check_sysv_semctl " - "with cmd and cr_label and semaklabel:%s:", + "with cmd and cr_label and semaklabel#%s:", cmdstring); MACTEST_PIPE_SUBMIT_WITHPID(submitstring, strlen(submitstring)); @@ -1809,7 +1810,7 @@ bzero(submitstring, 256); if (submitstring){ sprintf(submitstring, "mac_test_check_sysv_semop " - "with access type and cr_label and semaklabel:%s:", + "with access type and cr_label and semaklabel#%s:", accesstype&SEM_R? (accesstype&SEM_A? "SEM_AR": "SEM_R"): (accesstype&SEM_A? "SEM_A": "NULL")); MACTEST_PIPE_SUBMIT_WITHPID(submitstring, @@ -1835,7 +1836,7 @@ bzero(submitstring, 256); if (submitstring){ sprintf(submitstring, "mac_test_check_sysv_shmat " - "with shmflg and cr_label and shmseglabel:%s:", + "with shmflg and cr_label and shmseglabel#%s:", (shmflg & SHM_RDONLY)? "SHM_RDONLY" : "SHM_RND"); MACTEST_PIPE_SUBMIT_WITHPID(submitstring, strlen(submitstring)); @@ -1883,7 +1884,7 @@ } sprintf(submitstring, "mac_test_check_sysv_shmctl " - "with cmd and cr_label and shmseglabel:%s:", + "with cmd and cr_label and shmseglabel#%s:", cmdstring); MACTEST_PIPE_SUBMIT_WITHPID(submitstring, strlen(submitstring)); @@ -2806,7 +2807,7 @@ if (string == acc_string) strcpy(acc_string, "NULL"); sprintf(submitstring, "mac_test_check_vnode_access " - "with acc_mode and cr_label and vplabel:%s:", + "with acc_mode and cr_label and vplabel#%s:", acc_string); MACTEST_PIPE_SUBMIT_WITHPID(submitstring, strlen(submitstring)); @@ -3112,7 +3113,7 @@ if (string == acc_string) strcpy(acc_string, "NULL"); sprintf(submitstring, "mac_test_check_vnode_open " - "with acc_mode and cr_label and vplabel:%s:", + "with acc_mode and cr_label and vplabel#%s:", acc_string); MACTEST_PIPE_SUBMIT_WITHPID(submitstring, strlen(submitstring)); @@ -3321,6 +3322,9 @@ strlen("mac_test_check_vnode_setextattr " "with cr_label and vplabel:")); MACTEST_PIPE_SUBMIT_LABEL2(cred, cred->cr_label, vnode, vplabel); + if (attrnamespace == EXTATTR_NAMESPACE_SYSTEM && !strcmp(name, "mac_test") + && uio->uio_iov->iov_len && !strncmp(uio->uio_iov->iov_base, "mac_test", 8)) + LABEL_INIT(vplabel, MAGIC_MACTESTPIPE); LABEL_CHECK(cred->cr_label, MAGIC_CRED); LABEL_CHECK(vplabel, MAGIC_VNODE); COUNTER_INC(check_vnode_setextattr); ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/zhouzhouyi_mactest_soc/tools/regression/mactest/mactestparser.y#2 (text+ko) ==== @@ -45,6 +45,7 @@ static int line = 0; size_t strlen_allow_null(const char *s); + char * stringsave = 0; %} @@ -56,12 +57,15 @@ %token PID %token IDENTIFIER %token NUM +%token MAC_TEST %type identifier +%type mac_test %type mactestpipe_records %type mactestpipe_record -%type hook_elements +%type hook_elements %type label_elements %type modflag_elements +%type modflag_and_label_elements %type pid %% /* Grammar rules and actions follow. */ @@ -79,29 +83,32 @@ ; mactestpipe_record: - PID '=' pid identifier '\n' {$$ = new_mactestpipe_record(strdup($4), $3);} - |PID '=' pid identifier hook_elements ':' label_elements '\n' { - $$ = new_mactestpipe_record(strdup($4), $3);} - |PID '=' pid identifier hook_elements ':' modflag_elements ':' label_elements '\n' { - $$ = new_mactestpipe_record(strdup($4), $3);} + PID '=' pid hook_elements '\n' {$$ = new_mactestpipe_record(strdup($4), $3);} + |PID '=' pid hook_elements label_elements '\n' { + $$ = new_mactestpipe_record(stringsave, $3);stringsave = 0;} + |PID '=' pid hook_elements modflag_and_label_elements '\n' { + $$ = new_mactestpipe_record(stringsave, $3);stringsave = 0;} |'\n' {$$ = 0;} ; hook_elements: - identifier {} + mac_test {stringsave = strdup($1);} |hook_elements identifier {} |hook_elements error ; label_elements: - identifier { new_labelstrings(strdup($1));} + ':' identifier { new_labelstrings(strdup($2));} |label_elements identifier { new_labelstrings(strdup($2));} |label_elements error ; +modflag_and_label_elements: + modflag_elements label_elements + ; modflag_elements: - identifier { new_modes_or_flags(strdup($1));} + '#' identifier { new_modes_or_flags(strdup($2));} |modflag_elements identifier { new_modes_or_flags(strdup($2));} |modflag_elements error ; @@ -109,7 +116,9 @@ identifier: IDENTIFIER {} ; - +mac_test: + MAC_TEST {} + ; pid: NUM {} ; @@ -163,11 +172,16 @@ if (c == ':') return ':'; + + if (c == '#') + return '#'; i = 0; buf[i] = c; - while ((c = getchar()) != ' ' && c != '\t' && c != '\n' && c!= EOF && c !=':'){ + while ((c = getchar()) != ' ' && c != '\t' && c != '\n' && c!= EOF && c !=':' + && c != '#') + { i ++; buf[i] = c; @@ -192,6 +206,10 @@ ungetc (c,stdin); } + if (c == '#'){ + ungetc (c,stdin); + } + yylval.namestring = buf; if (!strcmp(buf, "pid")) @@ -199,8 +217,10 @@ if (!strcmp(buf, "=")) - return '='; - + return '='; + + if (!strncmp(buf, "mac_test", 8)) + return MAC_TEST; return IDENTIFIER; }