From: Martin R. <mr...@us...> - 2005-04-20 16:09:28
|
Update of /cvsroot/ltp/ltp/testcases/kernel/security/selinux-testsuite/tests/wait In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18951/tests/wait Added Files: Makefile selinux_wait.sh selinux_wait_child.c selinux_wait_parent.c Log Message: Moved to the correct directory --- NEW FILE: selinux_wait_child.c --- /* * Copyright (c) 2002 Network Associates Technology, Inc. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * */ int main(void) { exit(0); } --- NEW FILE: selinux_wait_parent.c --- /* * Copyright (c) 2002 Network Associates Technology, Inc. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <signal.h> #include <selinux/selinux.h> #include <selinux/context.h> int main(int argc, char **argv) { int pid, rc, len, status; security_context_t context_s; context_t context; if (argc != 3) { fprintf(stderr, "usage: %s newdomain program\n", argv[0]); exit(-1); } rc = getcon(&context_s); if (rc < 0) { fprintf(stderr, "%s: unable to get my context\n", argv[0]); exit(-1); } context = context_new(context_s); if (!context) { fprintf(stderr, "%s: unable to create context structure\n", argv[0]); exit(-1); } if (context_type_set(context, argv[1])) { fprintf(stderr, "%s: unable to set new type\n", argv[0]); exit(-1); } freecon(context_s); context_s = context_str(context); if (!context_s) { fprintf(stderr, "%s: unable to obtain new context string\n", argv[0]); exit(-1); } rc = setexeccon(context_s); if (rc < 0) { fprintf(stderr, "%s: unable to set exec context to %s\n", argv[0], context_s); exit(-1); } pid = fork(); if (pid < 0) { perror("fork"); exit(-1); } else if (pid == 0) { rc = execv(argv[2], argv+2); perror(argv[3]); exit(1); } pid = wait(&status); if (pid < 0) { perror("wait"); exit(1); } if (WIFEXITED(status)) { exit(WEXITSTATUS(status)); } exit(-1); } --- NEW FILE: Makefile --- TARGETS=selinux_wait_parent selinux_wait_child LDLIBS += -lselinux all: $(TARGETS) install: @set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done ln -f selinux_wait.sh ../../../../../bin/ clean: rm -f $(TARGETS) --- NEW FILE: selinux_wait.sh --- #!/bin/sh # # Copyright (c) 2002 Network Associates Technology, Inc. # Copyright (c) International Business Machines Corp., 2005 # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # setup() { export TCID="setup" export TST_COUNT=0 SAVEPWD=${PWD} cd ${LTPROOT}/testcases/bin CURRENTDIR="." } test01() { TCID="test01" TST_COUNT=1 RC=0 # Verify that test_wait_parent_t can wait on test_wait_child_t. runcon -t test_wait_parent_t -- $CURRENTDIR/selinux_wait_parent test_wait_child_t $CURRENTDIR/selinux_wait_child 2>&1 RC=$? if [ $RC -eq 0 ] then echo "Test #1: wait passed." else echo "Test #1: wait failed." fi return $RC } test02() { TCID="test02" TST_COUNT=2 RC=0 # Verify that test_wait_parent_t cannot wait on test_wait_notchild_t. runcon -t test_wait_parent_t -- $CURRENTDIR/selinux_wait_parent test_wait_notchild_t $CURRENTDIR/selinux_wait_child 2>&1 RC=$? if [ $RC -ne 0 ] then echo "Test #1: wait passed." RC=0 else echo "Test #1: wait failed." RC=1 fi return $RC } cleanup() { cd $SAVEPWD } # Function: main # # Description: - Execute all tests, exit with test status. # # Exit: - zero on success # - non-zero on failure. # RC=0 # Return value from setup, and test functions. setup test01 || exit $RC test02 || exit $RC cleanup exit 0 |