build+tests: Correct detection of privilege elevation/drop and the corresponding test case

Change-Id: I005c2846474a00aeeb3e63a1e9761a3f8bc0a572
Refs: #3494, #3632, #3633
diff --git a/tests/core/privilege-helper.t.cpp b/tests/core/privilege-helper.t.cpp
index 6dd1598..84c5f39 100644
--- a/tests/core/privilege-helper.t.cpp
+++ b/tests/core/privilege-helper.t.cpp
@@ -25,8 +25,6 @@
 
 #include "core/privilege-helper.hpp"
 
-#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
-
 #include "tests/test-common.hpp"
 
 namespace nfd {
@@ -36,6 +34,7 @@
 
 BOOST_AUTO_TEST_CASE(DropRaise)
 {
+#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
   if (::geteuid() != 0) {
     BOOST_TEST_MESSAGE("This test case needs to be run as super user, skipping");
     return;
@@ -57,11 +56,12 @@
 
   BOOST_CHECK_NO_THROW(PrivilegeHelper::raise());
   BOOST_CHECK_EQUAL(::geteuid(), 0);
+#else
+  BOOST_TEST_MESSAGE("Skipping test, since drop/raise privileges is not supported on this platform");
+#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
 }
 
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace tests
 } // namespace nfd
-
-#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
diff --git a/wscript b/wscript
index 5d1b35d..d169a5a 100644
--- a/wscript
+++ b/wscript
@@ -85,11 +85,14 @@
 int
 main(int, char**)
 {
+  char buffer[100];
   ::sysconf(_SC_GETGR_R_SIZE_MAX);
   group grp;
-  getgrnam_r("nogroup", &grp, nullptr, 0, nullptr);
+  group* grpRes;
+  getgrnam_r("nogroup", &grp, buffer, 100, &grpRes);
   passwd pwd;
-  getpwnam_r("nobody", &pwd, nullptr, 0, nullptr);
+  passwd* pwdRes;
+  getpwnam_r("nobody", &pwd, buffer, 100, &pwdRes);
 
   int ret = setegid(grp.gr_gid);
   ret = seteuid(pwd.pw_uid);