Page MenuHomeFreeBSD

D55484.id172585.diff
No OneTemporary

D55484.id172585.diff

diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c
--- a/lib/libc/stdlib/system.c
+++ b/lib/libc/stdlib/system.c
@@ -65,7 +65,7 @@
pid_t pid;
if (command == NULL) /* just checking... */
- return(1);
+ return (eaccess(_PATH_BSHELL, X_OK) == 0);
/*
* If we are the first concurrent instance, ignore SIGINT and
diff --git a/lib/libc/tests/stdlib/system_test.c b/lib/libc/tests/stdlib/system_test.c
--- a/lib/libc/tests/stdlib/system_test.c
+++ b/lib/libc/tests/stdlib/system_test.c
@@ -57,10 +57,20 @@
ATF_TC_HEAD(system_null, tc)
{
atf_tc_set_md_var(tc, "descr", "system(NULL)");
+ atf_tc_set_md_var(tc, "require.user", "root");
}
ATF_TC_BODY(system_null, tc)
{
+ /* First, test in a normal environment */
ATF_REQUIRE_EQ(1, system(NULL));
+
+ /* Now enter an empty chroot */
+ ATF_REQUIRE_EQ(0, chroot("."));
+ ATF_REQUIRE_EQ(0, chdir("/"));
+
+ /* Test again with no shell available */
+ ATF_REQUIRE_EQ(0, system(NULL));
+ ATF_REQUIRE_EQ(W_EXITCODE(127, 0), system("true"));
}
static void *

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 8, 8:13 PM (16 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29415786
Default Alt Text
D55484.id172585.diff (1 KB)

Event Timeline