1 /*
2 * Copyright (c) 2002-2003, Intel Corporation. All rights reserved.
3 * Created by: salwan.searty REMOVE-THIS AT intel DOT com
4 * This file is licensed under the GPL license. For the full content
5 * of this license, see the COPYING file at the top level of this
6 * source tree.
7
8 This program tests the assertion that if the user id of the sending process
9 doesn't match the user id of the receiving process (pid), then the kill function
10 will fail with errno set to EPERM.
11
12 */
13
14 #include <signal.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <errno.h>
18 #include <unistd.h>
19 #include <sys/types.h>
20 #include "posixtest.h"
21
main(void)22 int main(void)
23 {
24 /* this is added incase user is root. If user is normal user, then it
25 * has no effect on the tests */
26 setuid(1);
27
28 if (kill(1, 0) != -1) {
29 printf
30 ("Test FAILED: kill() succeeded even though this program's user id did not match the recieving process's user id\n");
31 return PTS_FAIL;
32 }
33
34 if (EPERM != errno) {
35 printf("Test FAILED: EPERM error not received\n");
36 return PTS_FAIL;
37 }
38
39 printf("Test PASSED\n");
40 return PTS_PASS;
41 }
42