Page MenuHomeFreeBSD

D55484.diff
No OneTemporary

D55484.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
@@ -64,7 +64,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"));
}
/*

File Metadata

Mime Type
text/plain
Expires
Tue, May 26, 8:30 AM (17 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33527337
Default Alt Text
D55484.diff (1 KB)

Event Timeline