]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/sys/audit/file-attribute-modify.c
Update OpenSSL to 1.1.1.
[FreeBSD/FreeBSD.git] / tests / sys / audit / file-attribute-modify.c
1 /*-
2  * Copyright (c) 2018 Aniket Pandey
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
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.
12  *
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
23  * SUCH DAMAGE.
24  *
25  * $FreeBSD$
26  */
27
28 #include <sys/types.h>
29 #include <sys/extattr.h>
30 #include <sys/file.h>
31 #include <sys/mman.h>
32 #include <sys/stat.h>
33 #include <sys/time.h>
34
35 #include <atf-c.h>
36 #include <fcntl.h>
37 #include <stdint.h>
38 #include <unistd.h>
39
40 #include "utils.h"
41
42 static pid_t pid;
43 static uid_t uid = -1;
44 static gid_t gid = -1;
45 static int filedesc, retval;
46 static struct pollfd fds[1];
47 static mode_t mode = 0777;
48 static char extregex[80];
49 static char buff[] = "ezio";
50 static const char *auclass = "fm";
51 static const char *name = "authorname";
52 static const char *path = "fileforaudit";
53 static const char *errpath = "adirhasnoname/fileforaudit";
54 static const char *successreg = "fileforaudit.*return,success";
55 static const char *failurereg = "fileforaudit.*return,failure";
56
57
58 ATF_TC_WITH_CLEANUP(flock_success);
59 ATF_TC_HEAD(flock_success, tc)
60 {
61         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
62                                         "flock(2) call");
63 }
64
65 ATF_TC_BODY(flock_success, tc)
66 {
67         pid = getpid();
68         snprintf(extregex, sizeof(extregex), "flock.*%d.*return,success", pid);
69
70         /* File needs to exist to call flock(2) */
71         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
72         FILE *pipefd = setup(fds, auclass);
73         ATF_REQUIRE_EQ(0, flock(filedesc, LOCK_SH));
74         check_audit(fds, extregex, pipefd);
75         close(filedesc);
76 }
77
78 ATF_TC_CLEANUP(flock_success, tc)
79 {
80         cleanup();
81 }
82
83
84 ATF_TC_WITH_CLEANUP(flock_failure);
85 ATF_TC_HEAD(flock_failure, tc)
86 {
87         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
88                                         "flock(2) call");
89 }
90
91 ATF_TC_BODY(flock_failure, tc)
92 {
93         const char *regex = "flock.*return,failure : Bad file descriptor";
94         FILE *pipefd = setup(fds, auclass);
95         ATF_REQUIRE_EQ(-1, flock(-1, LOCK_SH));
96         check_audit(fds, regex, pipefd);
97 }
98
99 ATF_TC_CLEANUP(flock_failure, tc)
100 {
101         cleanup();
102 }
103
104
105 ATF_TC_WITH_CLEANUP(fcntl_success);
106 ATF_TC_HEAD(fcntl_success, tc)
107 {
108         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
109                                         "fcntl(2) call");
110 }
111
112 ATF_TC_BODY(fcntl_success, tc)
113 {
114         int flagstatus;
115         /* File needs to exist to call fcntl(2) */
116         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
117         FILE *pipefd = setup(fds, auclass);
118
119         /* Retrieve the status flags of 'filedesc' and store it in flagstatus */
120         ATF_REQUIRE((flagstatus = fcntl(filedesc, F_GETFL, 0)) != -1);
121         snprintf(extregex, sizeof(extregex),
122                         "fcntl.*return,success,%d", flagstatus);
123         check_audit(fds, extregex, pipefd);
124         close(filedesc);
125 }
126
127 ATF_TC_CLEANUP(fcntl_success, tc)
128 {
129         cleanup();
130 }
131
132
133 ATF_TC_WITH_CLEANUP(fcntl_failure);
134 ATF_TC_HEAD(fcntl_failure, tc)
135 {
136         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
137                                         "fcntl(2) call");
138 }
139
140 ATF_TC_BODY(fcntl_failure, tc)
141 {
142         const char *regex = "fcntl.*return,failure : Bad file descriptor";
143         FILE *pipefd = setup(fds, auclass);
144         ATF_REQUIRE_EQ(-1, fcntl(-1, F_GETFL, 0));
145         check_audit(fds, regex, pipefd);
146 }
147
148 ATF_TC_CLEANUP(fcntl_failure, tc)
149 {
150         cleanup();
151 }
152
153
154 ATF_TC_WITH_CLEANUP(fsync_success);
155 ATF_TC_HEAD(fsync_success, tc)
156 {
157         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
158                                         "fsync(2) call");
159 }
160
161 ATF_TC_BODY(fsync_success, tc)
162 {
163         pid = getpid();
164         snprintf(extregex, sizeof(extregex), "fsync.*%d.*return,success", pid);
165
166         /* File needs to exist to call fsync(2) */
167         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
168         FILE *pipefd = setup(fds, auclass);
169         ATF_REQUIRE_EQ(0, fsync(filedesc));
170         check_audit(fds, extregex, pipefd);
171         close(filedesc);
172 }
173
174 ATF_TC_CLEANUP(fsync_success, tc)
175 {
176         cleanup();
177 }
178
179
180 ATF_TC_WITH_CLEANUP(fsync_failure);
181 ATF_TC_HEAD(fsync_failure, tc)
182 {
183         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
184                                         "fsync(2) call");
185 }
186
187 ATF_TC_BODY(fsync_failure, tc)
188 {
189         const char *regex = "fsync.*return,failure : Bad file descriptor";
190         FILE *pipefd = setup(fds, auclass);
191         /* Failure reason: Invalid file descriptor */
192         ATF_REQUIRE_EQ(-1, fsync(-1));
193         check_audit(fds, regex, pipefd);
194 }
195
196 ATF_TC_CLEANUP(fsync_failure, tc)
197 {
198         cleanup();
199 }
200
201
202 ATF_TC_WITH_CLEANUP(chmod_success);
203 ATF_TC_HEAD(chmod_success, tc)
204 {
205         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
206                                         "chmod(2) call");
207 }
208
209 ATF_TC_BODY(chmod_success, tc)
210 {
211         /* File needs to exist to call chmod(2) */
212         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
213         FILE *pipefd = setup(fds, auclass);
214         ATF_REQUIRE_EQ(0, chmod(path, mode));
215         check_audit(fds, successreg, pipefd);
216         close(filedesc);
217 }
218
219 ATF_TC_CLEANUP(chmod_success, tc)
220 {
221         cleanup();
222 }
223
224
225 ATF_TC_WITH_CLEANUP(chmod_failure);
226 ATF_TC_HEAD(chmod_failure, tc)
227 {
228         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
229                                         "chmod(2) call");
230 }
231
232 ATF_TC_BODY(chmod_failure, tc)
233 {
234         FILE *pipefd = setup(fds, auclass);
235         /* Failure reason: file does not exist */
236         ATF_REQUIRE_EQ(-1, chmod(errpath, mode));
237         check_audit(fds, failurereg, pipefd);
238 }
239
240 ATF_TC_CLEANUP(chmod_failure, tc)
241 {
242         cleanup();
243 }
244
245
246 ATF_TC_WITH_CLEANUP(fchmod_success);
247 ATF_TC_HEAD(fchmod_success, tc)
248 {
249         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
250                                         "fchmod(2) call");
251 }
252
253 ATF_TC_BODY(fchmod_success, tc)
254 {
255         pid = getpid();
256         snprintf(extregex, sizeof(extregex), "fchmod.*%d.*return,success", pid);
257
258         /* File needs to exist to call fchmod(2) */
259         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
260         FILE *pipefd = setup(fds, auclass);
261         ATF_REQUIRE_EQ(0, fchmod(filedesc, mode));
262         check_audit(fds, extregex, pipefd);
263         close(filedesc);
264 }
265
266 ATF_TC_CLEANUP(fchmod_success, tc)
267 {
268         cleanup();
269 }
270
271
272 ATF_TC_WITH_CLEANUP(fchmod_failure);
273 ATF_TC_HEAD(fchmod_failure, tc)
274 {
275         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
276                                         "fchmod(2) call");
277 }
278
279 ATF_TC_BODY(fchmod_failure, tc)
280 {
281         const char *regex = "fchmod.*return,failure : Bad file descriptor";
282         FILE *pipefd = setup(fds, auclass);
283         /* Failure reason: Invalid file descriptor */
284         ATF_REQUIRE_EQ(-1, fchmod(-1, mode));
285         check_audit(fds, regex, pipefd);
286 }
287
288 ATF_TC_CLEANUP(fchmod_failure, tc)
289 {
290         cleanup();
291 }
292
293
294 ATF_TC_WITH_CLEANUP(lchmod_success);
295 ATF_TC_HEAD(lchmod_success, tc)
296 {
297         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
298                                         "lchmod(2) call");
299 }
300
301 ATF_TC_BODY(lchmod_success, tc)
302 {
303         /* Symbolic link needs to exist to call lchmod(2) */
304         ATF_REQUIRE_EQ(0, symlink("symlink", path));
305         FILE *pipefd = setup(fds, auclass);
306         ATF_REQUIRE_EQ(0, lchmod(path, mode));
307         check_audit(fds, successreg, pipefd);
308 }
309
310 ATF_TC_CLEANUP(lchmod_success, tc)
311 {
312         cleanup();
313 }
314
315
316 ATF_TC_WITH_CLEANUP(lchmod_failure);
317 ATF_TC_HEAD(lchmod_failure, tc)
318 {
319         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
320                                         "lchmod(2) call");
321 }
322
323 ATF_TC_BODY(lchmod_failure, tc)
324 {
325         FILE *pipefd = setup(fds, auclass);
326         /* Failure reason: file does not exist */
327         ATF_REQUIRE_EQ(-1, lchmod(errpath, mode));
328         check_audit(fds, failurereg, pipefd);
329 }
330
331 ATF_TC_CLEANUP(lchmod_failure, tc)
332 {
333         cleanup();
334 }
335
336
337 ATF_TC_WITH_CLEANUP(fchmodat_success);
338 ATF_TC_HEAD(fchmodat_success, tc)
339 {
340         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
341                                         "fchmodat(2) call");
342 }
343
344 ATF_TC_BODY(fchmodat_success, tc)
345 {
346         /* File needs to exist to call fchmodat(2) */
347         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
348         FILE *pipefd = setup(fds, auclass);
349         ATF_REQUIRE_EQ(0, fchmodat(AT_FDCWD, path, mode, 0));
350         check_audit(fds, successreg, pipefd);
351         close(filedesc);
352 }
353
354 ATF_TC_CLEANUP(fchmodat_success, tc)
355 {
356         cleanup();
357 }
358
359
360 ATF_TC_WITH_CLEANUP(fchmodat_failure);
361 ATF_TC_HEAD(fchmodat_failure, tc)
362 {
363         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
364                                         "fchmodat(2) call");
365 }
366
367 ATF_TC_BODY(fchmodat_failure, tc)
368 {
369         FILE *pipefd = setup(fds, auclass);
370         /* Failure reason: file does not exist */
371         ATF_REQUIRE_EQ(-1, fchmodat(AT_FDCWD, errpath, mode, 0));
372         check_audit(fds, failurereg, pipefd);
373 }
374
375 ATF_TC_CLEANUP(fchmodat_failure, tc)
376 {
377         cleanup();
378 }
379
380
381 ATF_TC_WITH_CLEANUP(chown_success);
382 ATF_TC_HEAD(chown_success, tc)
383 {
384         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
385                                         "chown(2) call");
386 }
387
388 ATF_TC_BODY(chown_success, tc)
389 {
390         /* File needs to exist to call chown(2) */
391         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
392         FILE *pipefd = setup(fds, auclass);
393         ATF_REQUIRE_EQ(0, chown(path, uid, gid));
394         check_audit(fds, successreg, pipefd);
395         close(filedesc);
396 }
397
398 ATF_TC_CLEANUP(chown_success, tc)
399 {
400         cleanup();
401 }
402
403
404 ATF_TC_WITH_CLEANUP(chown_failure);
405 ATF_TC_HEAD(chown_failure, tc)
406 {
407         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
408                                         "chown(2) call");
409 }
410
411 ATF_TC_BODY(chown_failure, tc)
412 {
413         FILE *pipefd = setup(fds, auclass);
414         /* Failure reason: file does not exist */
415         ATF_REQUIRE_EQ(-1, chown(errpath, uid, gid));
416         check_audit(fds, failurereg, pipefd);
417 }
418
419 ATF_TC_CLEANUP(chown_failure, tc)
420 {
421         cleanup();
422 }
423
424
425 ATF_TC_WITH_CLEANUP(fchown_success);
426 ATF_TC_HEAD(fchown_success, tc)
427 {
428         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
429                                         "fchown(2) call");
430 }
431
432 ATF_TC_BODY(fchown_success, tc)
433 {
434         pid = getpid();
435         snprintf(extregex, sizeof(extregex), "fchown.*%d.*return,success", pid);
436
437         /* File needs to exist to call fchown(2) */
438         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
439         FILE *pipefd = setup(fds, auclass);
440         ATF_REQUIRE_EQ(0, fchown(filedesc, uid, gid));
441         check_audit(fds, extregex, pipefd);
442         close(filedesc);
443 }
444
445 ATF_TC_CLEANUP(fchown_success, tc)
446 {
447         cleanup();
448 }
449
450
451 ATF_TC_WITH_CLEANUP(fchown_failure);
452 ATF_TC_HEAD(fchown_failure, tc)
453 {
454         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
455                                         "fchown(2) call");
456 }
457
458 ATF_TC_BODY(fchown_failure, tc)
459 {
460         const char *regex = "fchown.*return,failure : Bad file descriptor";
461         FILE *pipefd = setup(fds, auclass);
462         /* Failure reason: Invalid file descriptor */
463         ATF_REQUIRE_EQ(-1, fchown(-1, uid, gid));
464         check_audit(fds, regex, pipefd);
465 }
466
467 ATF_TC_CLEANUP(fchown_failure, tc)
468 {
469         cleanup();
470 }
471
472
473 ATF_TC_WITH_CLEANUP(lchown_success);
474 ATF_TC_HEAD(lchown_success, tc)
475 {
476         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
477                                         "lchown(2) call");
478 }
479
480 ATF_TC_BODY(lchown_success, tc)
481 {
482         /* Symbolic link needs to exist to call lchown(2) */
483         ATF_REQUIRE_EQ(0, symlink("symlink", path));
484         FILE *pipefd = setup(fds, auclass);
485         ATF_REQUIRE_EQ(0, lchown(path, uid, gid));
486         check_audit(fds, successreg, pipefd);
487 }
488
489 ATF_TC_CLEANUP(lchown_success, tc)
490 {
491         cleanup();
492 }
493
494
495 ATF_TC_WITH_CLEANUP(lchown_failure);
496 ATF_TC_HEAD(lchown_failure, tc)
497 {
498         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
499                                         "lchown(2) call");
500 }
501
502 ATF_TC_BODY(lchown_failure, tc)
503 {
504         FILE *pipefd = setup(fds, auclass);
505         /* Failure reason: Symbolic link does not exist */
506         ATF_REQUIRE_EQ(-1, lchown(errpath, uid, gid));
507         check_audit(fds, failurereg, pipefd);
508 }
509
510 ATF_TC_CLEANUP(lchown_failure, tc)
511 {
512         cleanup();
513 }
514
515
516 ATF_TC_WITH_CLEANUP(fchownat_success);
517 ATF_TC_HEAD(fchownat_success, tc)
518 {
519         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
520                                         "fchownat(2) call");
521 }
522
523 ATF_TC_BODY(fchownat_success, tc)
524 {
525         /* File needs to exist to call fchownat(2) */
526         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
527         FILE *pipefd = setup(fds, auclass);
528         ATF_REQUIRE_EQ(0, fchownat(AT_FDCWD, path, uid, gid, 0));
529         check_audit(fds, successreg, pipefd);
530         close(filedesc);
531 }
532
533 ATF_TC_CLEANUP(fchownat_success, tc)
534 {
535         cleanup();
536 }
537
538
539 ATF_TC_WITH_CLEANUP(fchownat_failure);
540 ATF_TC_HEAD(fchownat_failure, tc)
541 {
542         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
543                                         "fchownat(2) call");
544 }
545
546 ATF_TC_BODY(fchownat_failure, tc)
547 {
548         FILE *pipefd = setup(fds, auclass);
549         /* Failure reason: file does not exist */
550         ATF_REQUIRE_EQ(-1, fchownat(AT_FDCWD, errpath, uid, gid, 0));
551         check_audit(fds, failurereg, pipefd);
552 }
553
554 ATF_TC_CLEANUP(fchownat_failure, tc)
555 {
556         cleanup();
557 }
558
559
560 ATF_TC_WITH_CLEANUP(chflags_success);
561 ATF_TC_HEAD(chflags_success, tc)
562 {
563         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
564                                         "chflags(2) call");
565 }
566
567 ATF_TC_BODY(chflags_success, tc)
568 {
569         /* File needs to exist to call chflags(2) */
570         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
571         FILE *pipefd = setup(fds, auclass);
572         ATF_REQUIRE_EQ(0, chflags(path, UF_OFFLINE));
573         check_audit(fds, successreg, pipefd);
574         close(filedesc);
575 }
576
577 ATF_TC_CLEANUP(chflags_success, tc)
578 {
579         cleanup();
580 }
581
582
583 ATF_TC_WITH_CLEANUP(chflags_failure);
584 ATF_TC_HEAD(chflags_failure, tc)
585 {
586         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
587                                         "chflags(2) call");
588 }
589
590 ATF_TC_BODY(chflags_failure, tc)
591 {
592         FILE *pipefd = setup(fds, auclass);
593         /* Failure reason: file does not exist */
594         ATF_REQUIRE_EQ(-1, chflags(errpath, UF_OFFLINE));
595         check_audit(fds, failurereg, pipefd);
596 }
597
598 ATF_TC_CLEANUP(chflags_failure, tc)
599 {
600         cleanup();
601 }
602
603
604 ATF_TC_WITH_CLEANUP(fchflags_success);
605 ATF_TC_HEAD(fchflags_success, tc)
606 {
607         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
608                                         "fchflags(2) call");
609 }
610
611 ATF_TC_BODY(fchflags_success, tc)
612 {
613         pid = getpid();
614         snprintf(extregex, sizeof(extregex), "fchflags.*%d.*ret.*success", pid);
615         /* File needs to exist to call fchflags(2) */
616         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
617
618         FILE *pipefd = setup(fds, auclass);
619         ATF_REQUIRE_EQ(0, fchflags(filedesc, UF_OFFLINE));
620         check_audit(fds, extregex, pipefd);
621         close(filedesc);
622 }
623
624 ATF_TC_CLEANUP(fchflags_success, tc)
625 {
626         cleanup();
627 }
628
629
630 ATF_TC_WITH_CLEANUP(fchflags_failure);
631 ATF_TC_HEAD(fchflags_failure, tc)
632 {
633         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
634                                         "fchflags(2) call");
635 }
636
637 ATF_TC_BODY(fchflags_failure, tc)
638 {
639         const char *regex = "fchflags.*return,failure : Bad file descriptor";
640         FILE *pipefd = setup(fds, auclass);
641         /* Failure reason: Invalid file descriptor */
642         ATF_REQUIRE_EQ(-1, fchflags(-1, UF_OFFLINE));
643         check_audit(fds, regex, pipefd);
644 }
645
646 ATF_TC_CLEANUP(fchflags_failure, tc)
647 {
648         cleanup();
649 }
650
651
652 ATF_TC_WITH_CLEANUP(lchflags_success);
653 ATF_TC_HEAD(lchflags_success, tc)
654 {
655         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
656                                         "lchflags(2) call");
657 }
658
659 ATF_TC_BODY(lchflags_success, tc)
660 {
661         /* Symbolic link needs to exist to call lchflags(2) */
662         ATF_REQUIRE_EQ(0, symlink("symlink", path));
663         FILE *pipefd = setup(fds, auclass);
664         ATF_REQUIRE_EQ(0, lchflags(path, UF_OFFLINE));
665         check_audit(fds, successreg, pipefd);
666 }
667
668 ATF_TC_CLEANUP(lchflags_success, tc)
669 {
670         cleanup();
671 }
672
673
674 ATF_TC_WITH_CLEANUP(lchflags_failure);
675 ATF_TC_HEAD(lchflags_failure, tc)
676 {
677         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
678                                         "lchflags(2) call");
679 }
680
681 ATF_TC_BODY(lchflags_failure, tc)
682 {
683         FILE *pipefd = setup(fds, auclass);
684         /* Failure reason: Symbolic link does not exist */
685         ATF_REQUIRE_EQ(-1, lchflags(errpath, UF_OFFLINE));
686         check_audit(fds, failurereg, pipefd);
687 }
688
689 ATF_TC_CLEANUP(lchflags_failure, tc)
690 {
691         cleanup();
692 }
693
694
695 ATF_TC_WITH_CLEANUP(chflagsat_success);
696 ATF_TC_HEAD(chflagsat_success, tc)
697 {
698         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
699                                         "chflagsat(2) call");
700 }
701
702 ATF_TC_BODY(chflagsat_success, tc)
703 {
704         /* File needs to exist to call chflagsat(2) */
705         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
706         FILE *pipefd = setup(fds, auclass);
707         ATF_REQUIRE_EQ(0, chflagsat(AT_FDCWD, path, SF_IMMUTABLE, 0));
708         check_audit(fds, successreg, pipefd);
709         close(filedesc);
710 }
711
712 ATF_TC_CLEANUP(chflagsat_success, tc)
713 {
714         cleanup();
715 }
716
717
718 ATF_TC_WITH_CLEANUP(chflagsat_failure);
719 ATF_TC_HEAD(chflagsat_failure, tc)
720 {
721         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
722                                         "chflagsat(2) call");
723 }
724
725 ATF_TC_BODY(chflagsat_failure, tc)
726 {
727         FILE *pipefd = setup(fds, auclass);
728         /* Failure reason: file does not exist */
729         ATF_REQUIRE_EQ(-1, chflagsat(AT_FDCWD, errpath, SF_IMMUTABLE, 0));
730         check_audit(fds, failurereg, pipefd);
731 }
732
733 ATF_TC_CLEANUP(chflagsat_failure, tc)
734 {
735         cleanup();
736 }
737
738
739 ATF_TC_WITH_CLEANUP(utimes_success);
740 ATF_TC_HEAD(utimes_success, tc)
741 {
742         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
743                                         "utimes(2) call");
744 }
745
746 ATF_TC_BODY(utimes_success, tc)
747 {
748         /* File needs to exist to call utimes(2) */
749         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
750         FILE *pipefd = setup(fds, auclass);
751         ATF_REQUIRE_EQ(0, utimes(path, NULL));
752         check_audit(fds, successreg, pipefd);
753         close(filedesc);
754 }
755
756 ATF_TC_CLEANUP(utimes_success, tc)
757 {
758         cleanup();
759 }
760
761
762 ATF_TC_WITH_CLEANUP(utimes_failure);
763 ATF_TC_HEAD(utimes_failure, tc)
764 {
765         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
766                                         "utimes(2) call");
767 }
768
769 ATF_TC_BODY(utimes_failure, tc)
770 {
771         FILE *pipefd = setup(fds, auclass);
772         /* Failure reason: file does not exist */
773         ATF_REQUIRE_EQ(-1, utimes(errpath, NULL));
774         check_audit(fds, failurereg, pipefd);
775 }
776
777 ATF_TC_CLEANUP(utimes_failure, tc)
778 {
779         cleanup();
780 }
781
782
783 ATF_TC_WITH_CLEANUP(futimes_success);
784 ATF_TC_HEAD(futimes_success, tc)
785 {
786         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
787                                         "futimes(2) call");
788 }
789
790 ATF_TC_BODY(futimes_success, tc)
791 {
792         pid = getpid();
793         snprintf(extregex, sizeof(extregex), "futimes.*%d.*ret.*success", pid);
794
795         /* File needs to exist to call futimes(2) */
796         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
797         FILE *pipefd = setup(fds, auclass);
798         ATF_REQUIRE_EQ(0, futimes(filedesc, NULL));
799         check_audit(fds, extregex, pipefd);
800         close(filedesc);
801 }
802
803 ATF_TC_CLEANUP(futimes_success, tc)
804 {
805         cleanup();
806 }
807
808
809 ATF_TC_WITH_CLEANUP(futimes_failure);
810 ATF_TC_HEAD(futimes_failure, tc)
811 {
812         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
813                                         "futimes(2) call");
814 }
815
816 ATF_TC_BODY(futimes_failure, tc)
817 {
818         const char *regex = "futimes.*return,failure : Bad file descriptor";
819         FILE *pipefd = setup(fds, auclass);
820         /* Failure reason: Invalid file descriptor */
821         ATF_REQUIRE_EQ(-1, futimes(-1, NULL));
822         check_audit(fds, regex, pipefd);
823 }
824
825 ATF_TC_CLEANUP(futimes_failure, tc)
826 {
827         cleanup();
828 }
829
830
831 ATF_TC_WITH_CLEANUP(lutimes_success);
832 ATF_TC_HEAD(lutimes_success, tc)
833 {
834         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
835                                         "lutimes(2) call");
836 }
837
838 ATF_TC_BODY(lutimes_success, tc)
839 {
840         /* Symbolic link needs to exist to call lutimes(2) */
841         ATF_REQUIRE_EQ(0, symlink("symlink", path));
842         FILE *pipefd = setup(fds, auclass);
843         ATF_REQUIRE_EQ(0, lutimes(path, NULL));
844         check_audit(fds, successreg, pipefd);
845 }
846
847 ATF_TC_CLEANUP(lutimes_success, tc)
848 {
849         cleanup();
850 }
851
852
853 ATF_TC_WITH_CLEANUP(lutimes_failure);
854 ATF_TC_HEAD(lutimes_failure, tc)
855 {
856         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
857                                         "lutimes(2) call");
858 }
859
860 ATF_TC_BODY(lutimes_failure, tc)
861 {
862         FILE *pipefd = setup(fds, auclass);
863         /* Failure reason: symbolic link does not exist */
864         ATF_REQUIRE_EQ(-1, lutimes(errpath, NULL));
865         check_audit(fds, failurereg, pipefd);
866 }
867
868 ATF_TC_CLEANUP(lutimes_failure, tc)
869 {
870         cleanup();
871 }
872
873
874 ATF_TC_WITH_CLEANUP(futimesat_success);
875 ATF_TC_HEAD(futimesat_success, tc)
876 {
877         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
878                                         "futimesat(2) call");
879 }
880
881 ATF_TC_BODY(futimesat_success, tc)
882 {
883         /* File needs to exist to call futimesat(2) */
884         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
885         FILE *pipefd = setup(fds, auclass);
886         ATF_REQUIRE_EQ(0, futimesat(AT_FDCWD, path, NULL));
887         check_audit(fds, successreg, pipefd);
888         close(filedesc);
889 }
890
891 ATF_TC_CLEANUP(futimesat_success, tc)
892 {
893         cleanup();
894 }
895
896
897 ATF_TC_WITH_CLEANUP(futimesat_failure);
898 ATF_TC_HEAD(futimesat_failure, tc)
899 {
900         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
901                                         "futimesat(2) call");
902 }
903
904 ATF_TC_BODY(futimesat_failure, tc)
905 {
906         FILE *pipefd = setup(fds, auclass);
907         /* Failure reason: file does not exist */
908         ATF_REQUIRE_EQ(-1, futimesat(AT_FDCWD, errpath, NULL));
909         check_audit(fds, failurereg, pipefd);
910 }
911
912 ATF_TC_CLEANUP(futimesat_failure, tc)
913 {
914         cleanup();
915 }
916
917
918 ATF_TC_WITH_CLEANUP(mprotect_success);
919 ATF_TC_HEAD(mprotect_success, tc)
920 {
921         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
922                                         "mprotect(2) call");
923 }
924
925 ATF_TC_BODY(mprotect_success, tc)
926 {
927         pid = getpid();
928         snprintf(extregex, sizeof(extregex), "mprotect.*%d.*ret.*success", pid);
929
930         FILE *pipefd = setup(fds, auclass);
931         ATF_REQUIRE_EQ(0, mprotect(NULL, 0, PROT_NONE));
932         check_audit(fds, extregex, pipefd);
933 }
934
935 ATF_TC_CLEANUP(mprotect_success, tc)
936 {
937         cleanup();
938 }
939
940
941 ATF_TC_WITH_CLEANUP(mprotect_failure);
942 ATF_TC_HEAD(mprotect_failure, tc)
943 {
944         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
945                                         "mprotect(2) call");
946 }
947
948 ATF_TC_BODY(mprotect_failure, tc)
949 {
950         const char *regex = "mprotect.*return,failure : Invalid argument";
951         FILE *pipefd = setup(fds, auclass);
952         ATF_REQUIRE_EQ(-1, mprotect((void *)SIZE_MAX, -1, PROT_NONE));
953         check_audit(fds, regex, pipefd);
954 }
955
956 ATF_TC_CLEANUP(mprotect_failure, tc)
957 {
958         cleanup();
959 }
960
961 /*
962  * undelete(2) only works on whiteout files in union file system. Hence, no
963  * test case for successful invocation.
964  */
965
966 ATF_TC_WITH_CLEANUP(undelete_failure);
967 ATF_TC_HEAD(undelete_failure, tc)
968 {
969         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
970                                         "undelete(2) call");
971 }
972
973 ATF_TC_BODY(undelete_failure, tc)
974 {
975         pid = getpid();
976         snprintf(extregex, sizeof(extregex), "undelete.*%d.*ret.*failure", pid);
977
978         FILE *pipefd = setup(fds, auclass);
979         /* Failure reason: File does not exist */
980         ATF_REQUIRE_EQ(-1, undelete(errpath));
981         check_audit(fds, extregex, pipefd);
982 }
983
984 ATF_TC_CLEANUP(undelete_failure, tc)
985 {
986         cleanup();
987 }
988
989
990 ATF_TC_WITH_CLEANUP(extattr_set_file_success);
991 ATF_TC_HEAD(extattr_set_file_success, tc)
992 {
993         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
994                                         "extattr_set_file(2) call");
995 }
996
997 ATF_TC_BODY(extattr_set_file_success, tc)
998 {
999         /* File needs to exist to call extattr_set_file(2) */
1000         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
1001         /* Prepare the regex to be checked in the audit record */
1002         snprintf(extregex, sizeof(extregex),
1003                 "extattr_set_file.*%s.*%s.*return,success", path, name);
1004
1005         FILE *pipefd = setup(fds, auclass);
1006         ATF_REQUIRE_EQ(sizeof(buff), extattr_set_file(path,
1007                 EXTATTR_NAMESPACE_USER, name, buff, sizeof(buff)));
1008         check_audit(fds, extregex, pipefd);
1009         close(filedesc);
1010 }
1011
1012 ATF_TC_CLEANUP(extattr_set_file_success, tc)
1013 {
1014         cleanup();
1015 }
1016
1017
1018 ATF_TC_WITH_CLEANUP(extattr_set_file_failure);
1019 ATF_TC_HEAD(extattr_set_file_failure, tc)
1020 {
1021         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
1022                                         "extattr_set_file(2) call");
1023 }
1024
1025 ATF_TC_BODY(extattr_set_file_failure, tc)
1026 {
1027         /* Prepare the regex to be checked in the audit record */
1028         snprintf(extregex, sizeof(extregex),
1029                 "extattr_set_file.*%s.*%s.*failure", path, name);
1030
1031         FILE *pipefd = setup(fds, auclass);
1032         /* Failure reason: file does not exist */
1033         ATF_REQUIRE_EQ(-1, extattr_set_file(path,
1034                 EXTATTR_NAMESPACE_USER, name, NULL, 0));
1035         check_audit(fds, extregex, pipefd);
1036 }
1037
1038 ATF_TC_CLEANUP(extattr_set_file_failure, tc)
1039 {
1040         cleanup();
1041 }
1042
1043
1044 ATF_TC_WITH_CLEANUP(extattr_set_fd_success);
1045 ATF_TC_HEAD(extattr_set_fd_success, tc)
1046 {
1047         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
1048                                         "extattr_set_fd(2) call");
1049 }
1050
1051 ATF_TC_BODY(extattr_set_fd_success, tc)
1052 {
1053         /* File needs to exist to call extattr_set_fd(2) */
1054         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
1055
1056         /* Prepare the regex to be checked in the audit record */
1057         snprintf(extregex, sizeof(extregex),
1058                 "extattr_set_fd.*%s.*return,success", name);
1059
1060         FILE *pipefd = setup(fds, auclass);
1061         ATF_REQUIRE_EQ(sizeof(buff), extattr_set_fd(filedesc,
1062                 EXTATTR_NAMESPACE_USER, name, buff, sizeof(buff)));
1063         check_audit(fds, extregex, pipefd);
1064         close(filedesc);
1065 }
1066
1067 ATF_TC_CLEANUP(extattr_set_fd_success, tc)
1068 {
1069         cleanup();
1070 }
1071
1072
1073 ATF_TC_WITH_CLEANUP(extattr_set_fd_failure);
1074 ATF_TC_HEAD(extattr_set_fd_failure, tc)
1075 {
1076         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
1077                                         "extattr_set_fd(2) call");
1078 }
1079
1080 ATF_TC_BODY(extattr_set_fd_failure, tc)
1081 {
1082         /* Prepare the regex to be checked in the audit record */
1083         snprintf(extregex, sizeof(extregex),
1084         "extattr_set_fd.*%s.*return,failure : Bad file descriptor", name);
1085
1086         FILE *pipefd = setup(fds, auclass);
1087         /* Failure reason: Invalid file descriptor */
1088         ATF_REQUIRE_EQ(-1, extattr_set_fd(-1,
1089                 EXTATTR_NAMESPACE_USER, name, NULL, 0));
1090         check_audit(fds, extregex, pipefd);
1091 }
1092
1093 ATF_TC_CLEANUP(extattr_set_fd_failure, tc)
1094 {
1095         cleanup();
1096 }
1097
1098
1099 ATF_TC_WITH_CLEANUP(extattr_set_link_success);
1100 ATF_TC_HEAD(extattr_set_link_success, tc)
1101 {
1102         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
1103                                         "extattr_set_link(2) call");
1104 }
1105
1106 ATF_TC_BODY(extattr_set_link_success, tc)
1107 {
1108         /* Symbolic link needs to exist to call extattr_set_link(2) */
1109         ATF_REQUIRE_EQ(0, symlink("symlink", path));
1110         /* Prepare the regex to be checked in the audit record */
1111         snprintf(extregex, sizeof(extregex),
1112                 "extattr_set_link.*%s.*%s.*return,success", path, name);
1113
1114         FILE *pipefd = setup(fds, auclass);
1115         ATF_REQUIRE_EQ(sizeof(buff), extattr_set_link(path,
1116                 EXTATTR_NAMESPACE_USER, name, buff, sizeof(buff)));
1117
1118         check_audit(fds, extregex, pipefd);
1119 }
1120
1121 ATF_TC_CLEANUP(extattr_set_link_success, tc)
1122 {
1123         cleanup();
1124 }
1125
1126
1127 ATF_TC_WITH_CLEANUP(extattr_set_link_failure);
1128 ATF_TC_HEAD(extattr_set_link_failure, tc)
1129 {
1130         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
1131                                         "extattr_set_link(2) call");
1132 }
1133
1134 ATF_TC_BODY(extattr_set_link_failure, tc)
1135 {
1136         /* Prepare the regex to be checked in the audit record */
1137         snprintf(extregex, sizeof(extregex),
1138                 "extattr_set_link.*%s.*%s.*failure", path, name);
1139         FILE *pipefd = setup(fds, auclass);
1140         /* Failure reason: symbolic link does not exist */
1141         ATF_REQUIRE_EQ(-1, extattr_set_link(path,
1142                 EXTATTR_NAMESPACE_USER, name, NULL, 0));
1143         check_audit(fds, extregex, pipefd);
1144 }
1145
1146 ATF_TC_CLEANUP(extattr_set_link_failure, tc)
1147 {
1148         cleanup();
1149 }
1150
1151
1152 ATF_TC_WITH_CLEANUP(extattr_delete_file_success);
1153 ATF_TC_HEAD(extattr_delete_file_success, tc)
1154 {
1155         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
1156                                         "extattr_delete_file(2) call");
1157 }
1158
1159 ATF_TC_BODY(extattr_delete_file_success, tc)
1160 {
1161         /* File needs to exist to call extattr_delete_file(2) */
1162         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
1163         ATF_REQUIRE_EQ(sizeof(buff), extattr_set_file(path,
1164                 EXTATTR_NAMESPACE_USER, name, buff, sizeof(buff)));
1165
1166         FILE *pipefd = setup(fds, auclass);
1167         ATF_REQUIRE((retval = extattr_delete_file(path,
1168                 EXTATTR_NAMESPACE_USER, name)) != -1);
1169         /* Prepare the regex to be checked in the audit record */
1170         snprintf(extregex, sizeof(extregex),
1171         "extattr_delete_file.*%s.*return,success,%d", path, retval);
1172         check_audit(fds, extregex, pipefd);
1173         close(filedesc);
1174 }
1175
1176 ATF_TC_CLEANUP(extattr_delete_file_success, tc)
1177 {
1178         cleanup();
1179 }
1180
1181
1182 ATF_TC_WITH_CLEANUP(extattr_delete_file_failure);
1183 ATF_TC_HEAD(extattr_delete_file_failure, tc)
1184 {
1185         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
1186                                         "extattr_delete_file(2) call");
1187 }
1188
1189 ATF_TC_BODY(extattr_delete_file_failure, tc)
1190 {
1191         /* Prepare the regex to be checked in the audit record */
1192         snprintf(extregex, sizeof(extregex),
1193                 "extattr_delete_file.*%s.*return,failure", path);
1194
1195         FILE *pipefd = setup(fds, auclass);
1196         /* Failure reason: file does not exist */
1197         ATF_REQUIRE_EQ(-1, extattr_delete_file(path,
1198                 EXTATTR_NAMESPACE_USER, name));
1199         check_audit(fds, extregex, pipefd);
1200 }
1201
1202 ATF_TC_CLEANUP(extattr_delete_file_failure, tc)
1203 {
1204         cleanup();
1205 }
1206
1207
1208 ATF_TC_WITH_CLEANUP(extattr_delete_fd_success);
1209 ATF_TC_HEAD(extattr_delete_fd_success, tc)
1210 {
1211         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
1212                                         "extattr_delete_fd(2) call");
1213 }
1214
1215 ATF_TC_BODY(extattr_delete_fd_success, tc)
1216 {
1217         /* File needs to exist to call extattr_delete_fd(2) */
1218         ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
1219         ATF_REQUIRE_EQ(sizeof(buff), extattr_set_file(path,
1220                 EXTATTR_NAMESPACE_USER, name, buff, sizeof(buff)));
1221
1222         FILE *pipefd = setup(fds, auclass);
1223         ATF_REQUIRE((retval = extattr_delete_fd(filedesc,
1224                 EXTATTR_NAMESPACE_USER, name)) != -1);
1225         /* Prepare the regex to be checked in the audit record */
1226         snprintf(extregex, sizeof(extregex),
1227                 "extattr_delete_fd.*return,success,%d", retval);
1228         check_audit(fds, extregex, pipefd);
1229         close(filedesc);
1230 }
1231
1232 ATF_TC_CLEANUP(extattr_delete_fd_success, tc)
1233 {
1234         cleanup();
1235 }
1236
1237
1238 ATF_TC_WITH_CLEANUP(extattr_delete_fd_failure);
1239 ATF_TC_HEAD(extattr_delete_fd_failure, tc)
1240 {
1241         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
1242                                         "extattr_delete_fd(2) call");
1243 }
1244
1245 ATF_TC_BODY(extattr_delete_fd_failure, tc)
1246 {
1247         /* Prepare the regex to be checked in the audit record */
1248         snprintf(extregex, sizeof(extregex),
1249                 "extattr_delete_fd.*return,failure : Bad file descriptor");
1250
1251         FILE *pipefd = setup(fds, auclass);
1252         /* Failure reason: Invalid file descriptor */
1253         ATF_REQUIRE_EQ(-1, extattr_delete_fd(-1, EXTATTR_NAMESPACE_USER, name));
1254         check_audit(fds, extregex, pipefd);
1255 }
1256
1257 ATF_TC_CLEANUP(extattr_delete_fd_failure, tc)
1258 {
1259         cleanup();
1260 }
1261
1262
1263 ATF_TC_WITH_CLEANUP(extattr_delete_link_success);
1264 ATF_TC_HEAD(extattr_delete_link_success, tc)
1265 {
1266         atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
1267                                         "extattr_delete_link(2) call");
1268 }
1269
1270 ATF_TC_BODY(extattr_delete_link_success, tc)
1271 {
1272         /* Symbolic link needs to exist to call extattr_delete_link(2) */
1273         ATF_REQUIRE_EQ(0, symlink("symlink", path));
1274         ATF_REQUIRE_EQ(sizeof(buff), extattr_set_link(path,
1275                 EXTATTR_NAMESPACE_USER, name, buff, sizeof(buff)));
1276
1277         FILE *pipefd = setup(fds, auclass);
1278         ATF_REQUIRE((retval = extattr_delete_link(path,
1279                 EXTATTR_NAMESPACE_USER, name)) != -1);
1280         /* Prepare the regex to be checked in the audit record */
1281         snprintf(extregex, sizeof(extregex),
1282         "extattr_delete_link.*%s.*return,success,%d", path, retval);
1283         check_audit(fds, extregex, pipefd);
1284 }
1285
1286 ATF_TC_CLEANUP(extattr_delete_link_success, tc)
1287 {
1288         cleanup();
1289 }
1290
1291
1292 ATF_TC_WITH_CLEANUP(extattr_delete_link_failure);
1293 ATF_TC_HEAD(extattr_delete_link_failure, tc)
1294 {
1295         atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
1296                                         "extattr_delete_link(2) call");
1297 }
1298
1299 ATF_TC_BODY(extattr_delete_link_failure, tc)
1300 {
1301         /* Prepare the regex to be checked in the audit record */
1302         snprintf(extregex, sizeof(extregex),
1303                 "extattr_delete_link.*%s.*failure", path);
1304         FILE *pipefd = setup(fds, auclass);
1305         /* Failure reason: symbolic link does not exist */
1306         ATF_REQUIRE_EQ(-1, extattr_delete_link(path,
1307                 EXTATTR_NAMESPACE_USER, name));
1308         check_audit(fds, extregex, pipefd);
1309 }
1310
1311 ATF_TC_CLEANUP(extattr_delete_link_failure, tc)
1312 {
1313         cleanup();
1314 }
1315
1316
1317 ATF_TP_ADD_TCS(tp)
1318 {
1319         ATF_TP_ADD_TC(tp, flock_success);
1320         ATF_TP_ADD_TC(tp, flock_failure);
1321         ATF_TP_ADD_TC(tp, fcntl_success);
1322         ATF_TP_ADD_TC(tp, fcntl_failure);
1323         ATF_TP_ADD_TC(tp, fsync_success);
1324         ATF_TP_ADD_TC(tp, fsync_failure);
1325
1326         ATF_TP_ADD_TC(tp, chmod_success);
1327         ATF_TP_ADD_TC(tp, chmod_failure);
1328         ATF_TP_ADD_TC(tp, fchmod_success);
1329         ATF_TP_ADD_TC(tp, fchmod_failure);
1330         ATF_TP_ADD_TC(tp, lchmod_success);
1331         ATF_TP_ADD_TC(tp, lchmod_failure);
1332         ATF_TP_ADD_TC(tp, fchmodat_success);
1333         ATF_TP_ADD_TC(tp, fchmodat_failure);
1334
1335         ATF_TP_ADD_TC(tp, chown_success);
1336         ATF_TP_ADD_TC(tp, chown_failure);
1337         ATF_TP_ADD_TC(tp, fchown_success);
1338         ATF_TP_ADD_TC(tp, fchown_failure);
1339         ATF_TP_ADD_TC(tp, lchown_success);
1340         ATF_TP_ADD_TC(tp, lchown_failure);
1341         ATF_TP_ADD_TC(tp, fchownat_success);
1342         ATF_TP_ADD_TC(tp, fchownat_failure);
1343
1344         ATF_TP_ADD_TC(tp, chflags_success);
1345         ATF_TP_ADD_TC(tp, chflags_failure);
1346         ATF_TP_ADD_TC(tp, fchflags_success);
1347         ATF_TP_ADD_TC(tp, fchflags_failure);
1348         ATF_TP_ADD_TC(tp, lchflags_success);
1349         ATF_TP_ADD_TC(tp, lchflags_failure);
1350         ATF_TP_ADD_TC(tp, chflagsat_success);
1351         ATF_TP_ADD_TC(tp, chflagsat_failure);
1352
1353         ATF_TP_ADD_TC(tp, utimes_success);
1354         ATF_TP_ADD_TC(tp, utimes_failure);
1355         ATF_TP_ADD_TC(tp, futimes_success);
1356         ATF_TP_ADD_TC(tp, futimes_failure);
1357         ATF_TP_ADD_TC(tp, lutimes_success);
1358         ATF_TP_ADD_TC(tp, lutimes_failure);
1359         ATF_TP_ADD_TC(tp, futimesat_success);
1360         ATF_TP_ADD_TC(tp, futimesat_failure);
1361
1362         ATF_TP_ADD_TC(tp, mprotect_success);
1363         ATF_TP_ADD_TC(tp, mprotect_failure);
1364         ATF_TP_ADD_TC(tp, undelete_failure);
1365
1366         ATF_TP_ADD_TC(tp, extattr_set_file_success);
1367         ATF_TP_ADD_TC(tp, extattr_set_file_failure);
1368         ATF_TP_ADD_TC(tp, extattr_set_fd_success);
1369         ATF_TP_ADD_TC(tp, extattr_set_fd_failure);
1370         ATF_TP_ADD_TC(tp, extattr_set_link_success);
1371         ATF_TP_ADD_TC(tp, extattr_set_link_failure);
1372
1373         ATF_TP_ADD_TC(tp, extattr_delete_file_success);
1374         ATF_TP_ADD_TC(tp, extattr_delete_file_failure);
1375         ATF_TP_ADD_TC(tp, extattr_delete_fd_success);
1376         ATF_TP_ADD_TC(tp, extattr_delete_fd_failure);
1377         ATF_TP_ADD_TC(tp, extattr_delete_link_success);
1378         ATF_TP_ADD_TC(tp, extattr_delete_link_failure);
1379
1380         return (atf_no_error());
1381 }