|
Last change
on this file was 2036, checked in by bird, 20 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | #include <errno.h>
|
|---|
| 2 | #include <stdio.h>
|
|---|
| 3 | #include <unistd.h>
|
|---|
| 4 | #include <sys/stat.h>
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 | static void prepare (int argc, char *argv[]);
|
|---|
| 8 | static int do_test (void);
|
|---|
| 9 | #define PREPARE(argc, argv) prepare (argc, argv)
|
|---|
| 10 | #define TEST_FUNCTION do_test ()
|
|---|
| 11 | #include "../test-skeleton.c"
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 | static char *copy;
|
|---|
| 15 |
|
|---|
| 16 | static void
|
|---|
| 17 | prepare (int argc, char *argv[])
|
|---|
| 18 | {
|
|---|
| 19 | char *buf;
|
|---|
| 20 | int off;
|
|---|
| 21 | asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
|
|---|
| 22 | if (buf == NULL)
|
|---|
| 23 | {
|
|---|
| 24 | puts ("asprintf failed");
|
|---|
| 25 | exit (1);
|
|---|
| 26 | }
|
|---|
| 27 | if (system (buf) != 0)
|
|---|
| 28 | {
|
|---|
| 29 | puts ("system failed");
|
|---|
| 30 | exit (1);
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | /* Make it not executable. */
|
|---|
| 34 | copy = buf + off;
|
|---|
| 35 | if (chmod (copy, 0666) != 0)
|
|---|
| 36 | {
|
|---|
| 37 | puts ("chmod failed");
|
|---|
| 38 | exit (1);
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | add_temp_file (copy);
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | static int
|
|---|
| 46 | do_test (void)
|
|---|
| 47 | {
|
|---|
| 48 | char *argv[] = { copy, NULL };
|
|---|
| 49 | char *envp[] = { (char *) "FOO=BAR", NULL };
|
|---|
| 50 |
|
|---|
| 51 | errno = 0;
|
|---|
| 52 | execve (copy, argv, envp);
|
|---|
| 53 |
|
|---|
| 54 | if (errno != EACCES)
|
|---|
| 55 | {
|
|---|
| 56 | printf ("errno = %d (%m), expected EACCES\n", errno);
|
|---|
| 57 | return 1;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | return 0;
|
|---|
| 61 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.