Date: Thu, 21 Jun 2007 09:27:22 GMT From: Zhouyi ZHOU <zhouzhouyi@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 122072 for review Message-ID: <200706210927.l5L9RMQ0015042@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <sys/msg.h> #include <sys/proc.h> #include <sys/vnode.h> +#include <sys/uio.h> #include <sys/sem.h> #include <sys/shm.h> #include <sys/socket.h> @@ -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 <namestring> identifier +%type <namestring> mac_test %type <mtpipetype> mactestpipe_records %type <mtpipetype> mactestpipe_record -%type <itype> hook_elements +%type <namestring> hook_elements %type <itype> label_elements %type <itype> modflag_elements +%type <itype> modflag_and_label_elements %type <itype> 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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706210927.l5L9RMQ0015042>