7e4d093f54
The following steps are used to execute the tests using the standard test interface: Classic sudo ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_SUBJECTS="" TEST_ARTIFACTS=$PWD/artifacts ansible-playbook --tags classic tests.yml https://src.fedoraproject.org/rpms/libsemanage/pull-request/2
63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <semanage/semanage.h>
|
|
|
|
#include "functions.c"
|
|
|
|
int main (int argc, char **argv) {
|
|
semanage_handle_t *sh;
|
|
semanage_seuser_t *user;
|
|
int result;
|
|
const char *name;
|
|
|
|
if (argc < 3)
|
|
exit(2);
|
|
|
|
sh = get_handle(argv[1]);
|
|
|
|
user = test_get_seuser(sh, "first");
|
|
|
|
if (strcmp(argv[2], "NULL") == 0)
|
|
name = NULL;
|
|
else
|
|
name = argv[2];
|
|
|
|
const char *old_name = semanage_seuser_get_sename(user);
|
|
printf("semanage_seuser_get_sename(%p): %s\n",
|
|
(void *) user, old_name);
|
|
|
|
if (old_name == NULL) {
|
|
perror("semanage_seuser_get_sename");
|
|
exit(2);
|
|
}
|
|
|
|
if (strcmp(old_name, name) == 0) {
|
|
printf("New name is the same\n");
|
|
exit(2);
|
|
}
|
|
|
|
result = semanage_seuser_set_sename(sh, user, name);
|
|
printf("semanage_seuser_set_sename(%p, %p, %s): %d\n",
|
|
(void *) sh, (void *) user, name, result);
|
|
|
|
if (result < 0) {
|
|
perror("semanage_seuser_set_sename");
|
|
exit(1);
|
|
}
|
|
|
|
const char *new_name = semanage_seuser_get_sename(user);
|
|
printf("semanage_seuser_get_sename(%p): %s\n",
|
|
(void *) user, new_name);
|
|
|
|
if (strcmp(new_name, name) != 0) {
|
|
perror("semanage_seuser_get_sename");
|
|
exit(1);
|
|
}
|
|
|
|
destroy_handle(sh, argv[1]);
|
|
|
|
exit(0);
|
|
}
|