10 * Test for dynamic executables with no read permissions. This test relies on
11 * being linked dynamically.
14 main(int argc
, char ** argv
)
16 char *executable
, cp_cmd
[PATH_MAX
+ 9];
19 if (strcmp(argv
[0], "DO CHECK") == 0)
24 /* Make a copy of this binary which is executable-only. */
27 snprintf(cp_cmd
, sizeof(cp_cmd
), "cp ../%s .", executable
);
28 status
= system(cp_cmd
);
29 if (status
< 0 || !WIFEXITED(status
) ||
30 WEXITSTATUS(status
) != EXIT_SUCCESS
) e(0);
32 if (chmod(executable
, S_IXUSR
) != 0) e(0);
34 /* Invoke the changed binary in a child process. */
39 execl(executable
, "DO CHECK", NULL
);
43 if (wait(&status
) <= 0) e(0);
44 if (!WIFEXITED(status
) || WEXITSTATUS(status
) != EXIT_SUCCESS
)