2 * Copyright (c) 2018 Aniket Pandey
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 #include <sys/types.h>
46 typedef struct msgstr msgstr_t;
49 static int msqid, shmid;
50 static struct pollfd fds[1];
51 static struct msqid_ds msgbuff;
52 static struct shmid_ds shmbuff;
53 static char ipcregex[BUFFSIZE];
54 static const char *auclass = "ip";
57 ATF_TC_WITH_CLEANUP(msgget_success);
58 ATF_TC_HEAD(msgget_success, tc)
60 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
64 ATF_TC_BODY(msgget_success, tc)
66 FILE *pipefd = setup(fds, auclass);
67 /* Create a message queue and obtain the corresponding identifier */
68 ATF_REQUIRE((msqid = msgget(IPC_PRIVATE, IPC_CREAT | S_IRUSR)) != -1);
69 /* Check the presence of message queue ID in audit record */
70 snprintf(ipcregex, sizeof(ipcregex),
71 "msgget.*return,success,%d", msqid);
72 check_audit(fds, ipcregex, pipefd);
74 /* Destroy the message queue with ID = msqid */
75 ATF_REQUIRE_EQ(0, msgctl(msqid, IPC_RMID, NULL));
78 ATF_TC_CLEANUP(msgget_success, tc)
84 ATF_TC_WITH_CLEANUP(msgget_failure);
85 ATF_TC_HEAD(msgget_failure, tc)
87 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
91 ATF_TC_BODY(msgget_failure, tc)
93 const char *regex = "msgget.*return,failure.*No such file or directory";
94 FILE *pipefd = setup(fds, auclass);
95 ATF_REQUIRE_EQ(-1, msgget((key_t)(-1), 0));
96 check_audit(fds, regex, pipefd);
99 ATF_TC_CLEANUP(msgget_failure, tc)
105 ATF_TC_WITH_CLEANUP(msgsnd_success);
106 ATF_TC_HEAD(msgsnd_success, tc)
108 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
112 ATF_TC_BODY(msgsnd_success, tc)
114 /* Create a message queue and obtain the corresponding identifier */
115 ATF_REQUIRE((msqid = msgget(IPC_PRIVATE, IPC_CREAT | S_IRUSR)) != -1);
117 /* Initialize a msgstr_t structure to store message */
120 memset(msg.mtext, 0, BUFFSIZE);
122 /* Check the presence of message queue ID in audit record */
123 snprintf(ipcregex, sizeof(ipcregex),
124 "msgsnd.*Message IPC.*%d.*return,success", msqid);
126 FILE *pipefd = setup(fds, auclass);
127 ATF_REQUIRE_EQ(0, msgsnd(msqid, &msg, BUFFSIZE, IPC_NOWAIT));
128 check_audit(fds, ipcregex, pipefd);
130 /* Destroy the message queue with ID = msqid */
131 ATF_REQUIRE_EQ(0, msgctl(msqid, IPC_RMID, NULL));
134 ATF_TC_CLEANUP(msgsnd_success, tc)
140 ATF_TC_WITH_CLEANUP(msgsnd_failure);
141 ATF_TC_HEAD(msgsnd_failure, tc)
143 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
147 ATF_TC_BODY(msgsnd_failure, tc)
149 const char *regex = "msgsnd.*Message IPC.*return,failure : Bad address";
150 FILE *pipefd = setup(fds, auclass);
151 ATF_REQUIRE_EQ(-1, msgsnd(-1, NULL, 0, IPC_NOWAIT));
152 check_audit(fds, regex, pipefd);
155 ATF_TC_CLEANUP(msgsnd_failure, tc)
161 ATF_TC_WITH_CLEANUP(msgrcv_success);
162 ATF_TC_HEAD(msgrcv_success, tc)
164 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
168 ATF_TC_BODY(msgrcv_success, tc)
171 /* Create a message queue and obtain the corresponding identifier */
172 ATF_REQUIRE((msqid = msgget(IPC_PRIVATE, IPC_CREAT | S_IRUSR)) != -1);
174 /* Initialize two msgstr_t structures to store respective messages */
177 memset(msg1.mtext, 0, BUFFSIZE);
179 /* Send a message to the queue with ID = msqid */
180 ATF_REQUIRE_EQ(0, msgsnd(msqid, &msg1, BUFFSIZE, IPC_NOWAIT));
182 FILE *pipefd = setup(fds, auclass);
183 ATF_REQUIRE((recv_bytes = msgrcv(msqid, &msg2,
184 BUFFSIZE, 0, MSG_NOERROR | IPC_NOWAIT)) != -1);
185 /* Check the presence of queue ID and returned bytes in audit record */
186 snprintf(ipcregex, sizeof(ipcregex),
187 "msgrcv.*Message IPC,*%d.*return,success,%zd", msqid, recv_bytes);
188 check_audit(fds, ipcregex, pipefd);
190 /* Destroy the message queue with ID = msqid */
191 ATF_REQUIRE_EQ(0, msgctl(msqid, IPC_RMID, NULL));
194 ATF_TC_CLEANUP(msgrcv_success, tc)
200 ATF_TC_WITH_CLEANUP(msgrcv_failure);
201 ATF_TC_HEAD(msgrcv_failure, tc)
203 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
207 ATF_TC_BODY(msgrcv_failure, tc)
209 const char *regex = "msgrcv.*return,failure : Invalid argument";
210 FILE *pipefd = setup(fds, auclass);
211 ATF_REQUIRE_EQ(-1, msgrcv(-1, NULL, 0, 0, MSG_NOERROR | IPC_NOWAIT));
212 check_audit(fds, regex, pipefd);
215 ATF_TC_CLEANUP(msgrcv_failure, tc)
221 ATF_TC_WITH_CLEANUP(msgctl_rmid_success);
222 ATF_TC_HEAD(msgctl_rmid_success, tc)
224 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
225 "msgctl(2) call for IPC_RMID command");
228 ATF_TC_BODY(msgctl_rmid_success, tc)
230 /* Create a message queue and obtain the corresponding identifier */
231 ATF_REQUIRE((msqid = msgget(IPC_PRIVATE, IPC_CREAT | S_IRUSR)) != -1);
233 FILE *pipefd = setup(fds, auclass);
234 ATF_REQUIRE_EQ(0, msgctl(msqid, IPC_RMID, NULL));
235 /* Check the presence of queue ID and IPC_RMID in audit record */
236 snprintf(ipcregex, sizeof(ipcregex),
237 "msgctl.*IPC_RMID.*%d.*return,success", msqid);
238 check_audit(fds, ipcregex, pipefd);
241 ATF_TC_CLEANUP(msgctl_rmid_success, tc)
247 ATF_TC_WITH_CLEANUP(msgctl_rmid_failure);
248 ATF_TC_HEAD(msgctl_rmid_failure, tc)
250 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
251 "msgctl(2) call for IPC_RMID command");
254 ATF_TC_BODY(msgctl_rmid_failure, tc)
256 const char *regex = "msgctl.*IPC_RMID.*return,failur.*Invalid argument";
257 FILE *pipefd = setup(fds, auclass);
258 ATF_REQUIRE_EQ(-1, msgctl(-1, IPC_RMID, NULL));
259 check_audit(fds, regex, pipefd);
262 ATF_TC_CLEANUP(msgctl_rmid_failure, tc)
268 ATF_TC_WITH_CLEANUP(msgctl_stat_success);
269 ATF_TC_HEAD(msgctl_stat_success, tc)
271 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
272 "msgctl(2) call for IPC_STAT command");
275 ATF_TC_BODY(msgctl_stat_success, tc)
277 /* Create a message queue and obtain the corresponding identifier */
278 ATF_REQUIRE((msqid = msgget(IPC_PRIVATE, IPC_CREAT | S_IRUSR)) != -1);
280 FILE *pipefd = setup(fds, auclass);
281 ATF_REQUIRE_EQ(0, msgctl(msqid, IPC_STAT, &msgbuff));
282 /* Check the presence of queue ID and IPC_STAT in audit record */
283 snprintf(ipcregex, sizeof(ipcregex),
284 "msgctl.*IPC_STAT.*%d.*return,success", msqid);
285 check_audit(fds, ipcregex, pipefd);
287 /* Destroy the message queue with ID = msqid */
288 ATF_REQUIRE_EQ(0, msgctl(msqid, IPC_RMID, NULL));
291 ATF_TC_CLEANUP(msgctl_stat_success, tc)
297 ATF_TC_WITH_CLEANUP(msgctl_stat_failure);
298 ATF_TC_HEAD(msgctl_stat_failure, tc)
300 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
301 "msgctl(2) call for IPC_STAT command");
304 ATF_TC_BODY(msgctl_stat_failure, tc)
306 const char *regex = "msgctl.*IPC_STAT.*return,failur.*Invalid argument";
307 FILE *pipefd = setup(fds, auclass);
308 ATF_REQUIRE_EQ(-1, msgctl(-1, IPC_STAT, &msgbuff));
309 check_audit(fds, regex, pipefd);
312 ATF_TC_CLEANUP(msgctl_stat_failure, tc)
318 ATF_TC_WITH_CLEANUP(msgctl_set_success);
319 ATF_TC_HEAD(msgctl_set_success, tc)
321 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
322 "msgctl(2) call for IPC_SET command");
325 ATF_TC_BODY(msgctl_set_success, tc)
327 /* Create a message queue and obtain the corresponding identifier */
328 ATF_REQUIRE((msqid = msgget(IPC_PRIVATE, IPC_CREAT | S_IRUSR)) != -1);
329 /* Fill up the msgbuff structure to be used with IPC_SET */
330 ATF_REQUIRE_EQ(0, msgctl(msqid, IPC_STAT, &msgbuff));
332 FILE *pipefd = setup(fds, auclass);
333 ATF_REQUIRE_EQ(0, msgctl(msqid, IPC_SET, &msgbuff));
334 /* Check the presence of message queue ID in audit record */
335 snprintf(ipcregex, sizeof(ipcregex),
336 "msgctl.*IPC_SET.*%d.*return,success", msqid);
337 check_audit(fds, ipcregex, pipefd);
339 /* Destroy the message queue with ID = msqid */
340 ATF_REQUIRE_EQ(0, msgctl(msqid, IPC_RMID, NULL));
343 ATF_TC_CLEANUP(msgctl_set_success, tc)
349 ATF_TC_WITH_CLEANUP(msgctl_set_failure);
350 ATF_TC_HEAD(msgctl_set_failure, tc)
352 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
353 "msgctl(2) call for IPC_SET command");
356 ATF_TC_BODY(msgctl_set_failure, tc)
358 const char *regex = "msgctl.*IPC_SET.*return,failure.*Invalid argument";
359 FILE *pipefd = setup(fds, auclass);
360 ATF_REQUIRE_EQ(-1, msgctl(-1, IPC_SET, &msgbuff));
361 check_audit(fds, regex, pipefd);
364 ATF_TC_CLEANUP(msgctl_set_failure, tc)
370 ATF_TC_WITH_CLEANUP(msgctl_illegal_command);
371 ATF_TC_HEAD(msgctl_illegal_command, tc)
373 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
374 "msgctl(2) call for illegal cmd value");
377 ATF_TC_BODY(msgctl_illegal_command, tc)
379 /* Create a message queue and obtain the corresponding identifier */
380 ATF_REQUIRE((msqid = msgget(IPC_PRIVATE, IPC_CREAT | S_IRUSR)) != -1);
382 const char *regex = "msgctl.*illegal command.*failur.*Invalid argument";
383 FILE *pipefd = setup(fds, auclass);
384 ATF_REQUIRE_EQ(-1, msgctl(msqid, -1, &msgbuff));
385 check_audit(fds, regex, pipefd);
387 /* Destroy the message queue with ID = msqid */
388 ATF_REQUIRE_EQ(0, msgctl(msqid, IPC_RMID, NULL));
391 ATF_TC_CLEANUP(msgctl_illegal_command, tc)
397 ATF_TC_WITH_CLEANUP(shmget_success);
398 ATF_TC_HEAD(shmget_success, tc)
400 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
404 ATF_TC_BODY(shmget_success, tc)
406 FILE *pipefd = setup(fds, auclass);
408 shmget(IPC_PRIVATE, 1, IPC_CREAT | S_IRUSR)) != -1);
409 /* Check the presence of shared memory ID in audit record */
410 snprintf(ipcregex, sizeof(ipcregex), "shmget.*ret.*success,%d", shmid);
411 check_audit(fds, ipcregex, pipefd);
413 /* Destroy the shared memory with ID = shmid */
414 ATF_REQUIRE_EQ(0, shmctl(shmid, IPC_RMID, NULL));
417 ATF_TC_CLEANUP(shmget_success, tc)
423 ATF_TC_WITH_CLEANUP(shmget_failure);
424 ATF_TC_HEAD(shmget_failure, tc)
426 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
430 ATF_TC_BODY(shmget_failure, tc)
432 const char *regex = "shmget.*return,failure.*No such file or directory";
433 FILE *pipefd = setup(fds, auclass);
434 ATF_REQUIRE_EQ(-1, shmget((key_t)(-1), 0, 0));
435 check_audit(fds, regex, pipefd);
438 ATF_TC_CLEANUP(shmget_failure, tc)
444 ATF_TC_WITH_CLEANUP(shmat_success);
445 ATF_TC_HEAD(shmat_success, tc)
447 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
451 ATF_TC_BODY(shmat_success, tc)
454 /* Create a shared memory segment and obtain the identifier */
456 shmget(IPC_PRIVATE, 1, IPC_CREAT | S_IRUSR)) != -1);
458 FILE *pipefd = setup(fds, auclass);
459 ATF_REQUIRE((intptr_t)(addr = shmat(shmid, NULL, 0)) != -1);
461 /* Check for shared memory ID and process address in record */
462 snprintf(ipcregex, sizeof(ipcregex), "shmat.*Shared Memory "
463 "IPC.*%d.*return,success", shmid);
464 check_audit(fds, ipcregex, pipefd);
466 /* Destroy the shared memory with ID = shmid */
467 ATF_REQUIRE_EQ(0, shmctl(shmid, IPC_RMID, NULL));
470 ATF_TC_CLEANUP(shmat_success, tc)
476 ATF_TC_WITH_CLEANUP(shmat_failure);
477 ATF_TC_HEAD(shmat_failure, tc)
479 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
483 ATF_TC_BODY(shmat_failure, tc)
485 const char *regex = "shmat.*Shared Memory IPC.*return,failure";
486 FILE *pipefd = setup(fds, auclass);
487 ATF_REQUIRE_EQ(-1, (intptr_t)shmat(-1, NULL, 0));
488 check_audit(fds, regex, pipefd);
491 ATF_TC_CLEANUP(shmat_failure, tc)
497 ATF_TC_WITH_CLEANUP(shmdt_success);
498 ATF_TC_HEAD(shmdt_success, tc)
500 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
504 ATF_TC_BODY(shmdt_success, tc)
508 snprintf(ipcregex, sizeof(ipcregex), "shmdt.*%d.*return,success", pid);
510 /* Create a shared memory segment and obtain the identifier */
512 shmget(IPC_PRIVATE, 1, IPC_CREAT | S_IRUSR)) != -1);
514 /* Attach the shared memory to calling process's address space */
515 ATF_REQUIRE((intptr_t)(addr = shmat(shmid, NULL, 0)) != -1);
517 FILE *pipefd = setup(fds, auclass);
518 ATF_REQUIRE_EQ(0, shmdt(addr));
519 check_audit(fds, ipcregex, pipefd);
521 /* Destroy the shared memory with ID = shmid */
522 ATF_REQUIRE_EQ(0, shmctl(shmid, IPC_RMID, NULL));
525 ATF_TC_CLEANUP(shmdt_success, tc)
531 ATF_TC_WITH_CLEANUP(shmdt_failure);
532 ATF_TC_HEAD(shmdt_failure, tc)
534 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
538 ATF_TC_BODY(shmdt_failure, tc)
540 const char *regex = "shmdt.*return,failure : Invalid argument";
541 FILE *pipefd = setup(fds, auclass);
542 ATF_REQUIRE_EQ(-1, shmdt(NULL));
543 check_audit(fds, regex, pipefd);
546 ATF_TC_CLEANUP(shmdt_failure, tc)
552 ATF_TC_WITH_CLEANUP(shmctl_rmid_success);
553 ATF_TC_HEAD(shmctl_rmid_success, tc)
555 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
556 "shmctl(2) call for IPC_RMID command");
559 ATF_TC_BODY(shmctl_rmid_success, tc)
561 /* Create a shared memory segment and obtain the identifier */
563 shmget(IPC_PRIVATE, 1, IPC_CREAT | S_IRUSR)) != -1);
565 FILE *pipefd = setup(fds, auclass);
566 ATF_REQUIRE_EQ(0, shmctl(shmid, IPC_RMID, NULL));
567 /* Check the presence of shmid and IPC_RMID in audit record */
568 snprintf(ipcregex, sizeof(ipcregex),
569 "shmctl.*IPC_RMID.*%d.*return,success", shmid);
570 check_audit(fds, ipcregex, pipefd);
573 ATF_TC_CLEANUP(shmctl_rmid_success, tc)
579 ATF_TC_WITH_CLEANUP(shmctl_rmid_failure);
580 ATF_TC_HEAD(shmctl_rmid_failure, tc)
582 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
583 "shmctl(2) call for IPC_RMID command");
586 ATF_TC_BODY(shmctl_rmid_failure, tc)
588 const char *regex = "shmctl.*IPC_RMID.*return,fail.*Invalid argument";
589 FILE *pipefd = setup(fds, auclass);
590 ATF_REQUIRE_EQ(-1, shmctl(-1, IPC_RMID, NULL));
591 check_audit(fds, regex, pipefd);
594 ATF_TC_CLEANUP(shmctl_rmid_failure, tc)
600 ATF_TC_WITH_CLEANUP(shmctl_stat_success);
601 ATF_TC_HEAD(shmctl_stat_success, tc)
603 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
604 "shmctl(2) call for IPC_STAT command");
607 ATF_TC_BODY(shmctl_stat_success, tc)
609 /* Create a shared memory segment and obtain the identifier */
611 shmget(IPC_PRIVATE, 1, IPC_CREAT | S_IRUSR)) != -1);
613 FILE *pipefd = setup(fds, auclass);
614 ATF_REQUIRE_EQ(0, shmctl(shmid, IPC_STAT, &shmbuff));
615 /* Check if shared memory ID and IPC_STAT are present in audit record */
616 snprintf(ipcregex, sizeof(ipcregex),
617 "shmctl.*IPC_STAT.*%d.*return,success", shmid);
618 check_audit(fds, ipcregex, pipefd);
620 /* Destroy the shared memory with ID = shmid */
621 ATF_REQUIRE_EQ(0, shmctl(shmid, IPC_RMID, NULL));
624 ATF_TC_CLEANUP(shmctl_stat_success, tc)
630 ATF_TC_WITH_CLEANUP(shmctl_stat_failure);
631 ATF_TC_HEAD(shmctl_stat_failure, tc)
633 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
634 "shmctl(2) call for IPC_STAT command");
637 ATF_TC_BODY(shmctl_stat_failure, tc)
639 const char *regex = "shmctl.*IPC_STAT.*return,fail.*Invalid argument";
640 FILE *pipefd = setup(fds, auclass);
641 ATF_REQUIRE_EQ(-1, shmctl(-1, IPC_STAT, &shmbuff));
642 check_audit(fds, regex, pipefd);
645 ATF_TC_CLEANUP(shmctl_stat_failure, tc)
651 ATF_TC_WITH_CLEANUP(shmctl_set_success);
652 ATF_TC_HEAD(shmctl_set_success, tc)
654 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
655 "shmctl(2) call for IPC_SET command");
658 ATF_TC_BODY(shmctl_set_success, tc)
660 /* Create a shared memory segment and obtain the identifier */
662 shmget(IPC_PRIVATE, 1, IPC_CREAT | S_IRUSR)) != -1);
663 /* Fill up the shmbuff structure to be used with IPC_SET */
664 ATF_REQUIRE_EQ(0, shmctl(shmid, IPC_STAT, &shmbuff));
666 FILE *pipefd = setup(fds, auclass);
667 ATF_REQUIRE_EQ(0, shmctl(shmid, IPC_SET, &shmbuff));
668 /* Check the presence of shared memory ID in audit record */
669 snprintf(ipcregex, sizeof(ipcregex),
670 "shmctl.*IPC_SET.*%d.*return,success", msqid);
671 check_audit(fds, ipcregex, pipefd);
673 /* Destroy the shared memory with ID = shmid */
674 ATF_REQUIRE_EQ(0, shmctl(shmid, IPC_RMID, NULL));
677 ATF_TC_CLEANUP(shmctl_set_success, tc)
683 ATF_TC_WITH_CLEANUP(shmctl_set_failure);
684 ATF_TC_HEAD(shmctl_set_failure, tc)
686 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
687 "shmctl(2) call for IPC_SET command");
690 ATF_TC_BODY(shmctl_set_failure, tc)
692 const char *regex = "shmctl.*IPC_SET.*return,failure.*Invalid argument";
693 FILE *pipefd = setup(fds, auclass);
694 ATF_REQUIRE_EQ(-1, shmctl(-1, IPC_SET, &shmbuff));
695 check_audit(fds, regex, pipefd);
698 ATF_TC_CLEANUP(shmctl_set_failure, tc)
704 ATF_TC_WITH_CLEANUP(shmctl_illegal_command);
705 ATF_TC_HEAD(shmctl_illegal_command, tc)
707 atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
708 "shmctl(2) call for illegal cmd value");
711 ATF_TC_BODY(shmctl_illegal_command, tc)
713 /* Create a shared memory segment and obtain the identifier */
715 shmget(IPC_PRIVATE, 1, IPC_CREAT | S_IRUSR)) != -1);
717 const char *regex = "shmctl.*illegal command.*fail.*Invalid argument";
718 FILE *pipefd = setup(fds, auclass);
719 ATF_REQUIRE_EQ(-1, shmctl(shmid, -1, &shmbuff));
720 check_audit(fds, regex, pipefd);
722 /* Destroy the shared memory with ID = shmid */
723 ATF_REQUIRE_EQ(0, shmctl(shmid, IPC_RMID, NULL));
726 ATF_TC_CLEANUP(shmctl_illegal_command, tc)
734 ATF_TP_ADD_TC(tp, msgget_success);
735 ATF_TP_ADD_TC(tp, msgget_failure);
736 ATF_TP_ADD_TC(tp, msgsnd_success);
737 ATF_TP_ADD_TC(tp, msgsnd_failure);
738 ATF_TP_ADD_TC(tp, msgrcv_success);
739 ATF_TP_ADD_TC(tp, msgrcv_failure);
741 ATF_TP_ADD_TC(tp, msgctl_rmid_success);
742 ATF_TP_ADD_TC(tp, msgctl_rmid_failure);
743 ATF_TP_ADD_TC(tp, msgctl_stat_success);
744 ATF_TP_ADD_TC(tp, msgctl_stat_failure);
745 ATF_TP_ADD_TC(tp, msgctl_set_success);
746 ATF_TP_ADD_TC(tp, msgctl_set_failure);
747 ATF_TP_ADD_TC(tp, msgctl_illegal_command);
749 ATF_TP_ADD_TC(tp, shmget_success);
750 ATF_TP_ADD_TC(tp, shmget_failure);
751 ATF_TP_ADD_TC(tp, shmat_success);
752 ATF_TP_ADD_TC(tp, shmat_failure);
753 ATF_TP_ADD_TC(tp, shmdt_success);
754 ATF_TP_ADD_TC(tp, shmdt_failure);
756 ATF_TP_ADD_TC(tp, shmctl_rmid_success);
757 ATF_TP_ADD_TC(tp, shmctl_rmid_failure);
758 ATF_TP_ADD_TC(tp, shmctl_stat_success);
759 ATF_TP_ADD_TC(tp, shmctl_stat_failure);
760 ATF_TP_ADD_TC(tp, shmctl_set_success);
761 ATF_TP_ADD_TC(tp, shmctl_set_failure);
762 ATF_TP_ADD_TC(tp, shmctl_illegal_command);
764 return (atf_no_error());