Blame tests/semanage-seuser-functions/test_count_local.c
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
#include <stdio.h>
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
#include <stdlib.h>
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
#include <string.h>
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
#include <errno.h>
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
#include <semanage/semanage.h>
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
#include "functions.c"
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
int main (int argc, char **argv) {
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
semanage_handle_t *sh;
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
semanage_seuser_t *seuser;
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
int result;
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
unsigned int response;
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
int num;
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
if (argc < 2)
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
exit(2);
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
sh = get_handle(argv[1]);
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
num = strtol(argv[2], NULL, 10);
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
for (int i = 0; i < num; i++) {
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
seuser = test_get_seuser_nth(sh, i);
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
test_add_local_seuser(sh, seuser);
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
}
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
result = semanage_seuser_count_local(sh, &response);
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
printf("semanage_seuser_count_local(%p, %p): %d, response: %d\n",
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
(void *) sh, (void *) &response, result, response);
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
if (result < 0) {
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
perror("semanage_seuser_count_local");
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
exit(1);
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
}
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
if (argc >= 3)
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
check_result_int(argv[2], response);
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
test_del_local_seuser(sh, seuser);
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
destroy_handle(sh, argv[1]);
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
exit(0);
|
|
![](https://seccdn.libravatar.org/avatar/279c3c15fe92a8dd296bcd0cf8c6e7ee5578149b69b9ab53e88d611c5e59f41f?s=16&d=retro) |
7e4d093 |
}
|