12 |
|
|
13 |
static int profile_fd = EOF; |
static int profile_fd = EOF; |
14 |
static int domain_fd = EOF; |
static int domain_fd = EOF; |
15 |
|
static int exception_fd = EOF; |
16 |
static const char *policy = ""; |
static const char *policy = ""; |
17 |
static char self_domain[4096] = ""; |
static char self_domain[4096] = ""; |
18 |
|
|
433 |
show_result(bind(fd, (struct sockaddr *) &addr, sizeof(addr)), 0); |
show_result(bind(fd, (struct sockaddr *) &addr, sizeof(addr)), 0); |
434 |
if (fd != EOF) close(fd); |
if (fd != EOF) close(fd); |
435 |
} |
} |
436 |
|
|
437 |
|
filename = "/tmp/rewrite_test"; |
438 |
|
create2(filename); |
439 |
|
policy = "allow_read/write /tmp/rewrite_test"; |
440 |
|
if (write_policy()) { |
441 |
|
char *cp = "deny_rewrite /tmp/rewrite_test\n"; |
442 |
|
write(exception_fd, cp, strlen(cp)); |
443 |
|
policy = "allow_truncate /tmp/rewrite_test"; |
444 |
|
if (write_policy()) { |
445 |
|
int fd; |
446 |
|
|
447 |
|
fd = open(filename, O_RDONLY); |
448 |
|
show_result(fd, 1); |
449 |
|
if (fd != EOF) close(fd); |
450 |
|
|
451 |
|
fd = open(filename, O_WRONLY | O_APPEND); |
452 |
|
show_result(fd, 1); |
453 |
|
if (fd != EOF) close(fd); |
454 |
|
|
455 |
|
fd = open(filename, O_WRONLY); |
456 |
|
show_result(fd, 0); |
457 |
|
if (fd != EOF) close(fd); |
458 |
|
|
459 |
|
fd = open(filename, O_WRONLY | O_TRUNC); |
460 |
|
show_result(fd, 0); |
461 |
|
if (fd != EOF) close(fd); |
462 |
|
|
463 |
|
fd = open(filename, O_WRONLY | O_TRUNC | O_APPEND); |
464 |
|
show_result(fd, 0); |
465 |
|
if (fd != EOF) close(fd); |
466 |
|
|
467 |
|
show_result(truncate(filename, 0), 0); |
468 |
|
|
469 |
|
cp = "255-MAC_FOR_FILE=disabled\n"; |
470 |
|
write(profile_fd, cp, strlen(cp)); |
471 |
|
fd = open(filename, O_WRONLY | O_APPEND); |
472 |
|
cp = "255-MAC_FOR_FILE=enforcing\n"; |
473 |
|
write(profile_fd, cp, strlen(cp)); |
474 |
|
show_result(ftruncate(fd, 0), 0); |
475 |
|
|
476 |
|
show_result(fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_APPEND), 0); |
477 |
|
if (fd != EOF) close(fd); |
478 |
|
|
479 |
|
delete_policy(); |
480 |
|
} |
481 |
|
policy = "allow_read/write /tmp/rewrite_test"; |
482 |
|
delete_policy(); |
483 |
|
cp = "delete deny_rewrite /tmp/rewrite_test\n"; |
484 |
|
write(exception_fd, cp, strlen(cp)); |
485 |
|
} |
486 |
|
unlink2(filename); |
487 |
} |
} |
488 |
|
|
489 |
int main(int argc, char *argv[]) { |
int main(int argc, char *argv[]) { |
491 |
Init(); |
Init(); |
492 |
profile_fd = open(proc_policy_profile, O_WRONLY); |
profile_fd = open(proc_policy_profile, O_WRONLY); |
493 |
domain_fd = open(proc_policy_domain_policy, O_WRONLY); |
domain_fd = open(proc_policy_domain_policy, O_WRONLY); |
494 |
|
exception_fd = open(proc_policy_exception_policy, O_WRONLY); |
495 |
{ |
{ |
496 |
int self_fd = open(proc_policy_self_domain, O_RDONLY); |
int self_fd = open(proc_policy_self_domain, O_RDONLY); |
497 |
memset(self_domain, 0, sizeof(self_domain)); |
memset(self_domain, 0, sizeof(self_domain)); |