Hi, I have noticed failures under testcases/open_posix_testsuite/conformance/interfaces/mlock/12-1.c and testcases/open_posix_testsuite/conformance/interfaces/mlock/speculative/12-1.c and fixed as per man page mlock()
EPERM: (Linux 2.6.9 and later) the caller was not privileged (CAP_IPC_LOCK) and its RLIMIT_MEMLOCK soft resource limit was 0. Please find the patch below and as attachment. Best regards Naresh Kamboju Signed-off-by: Naresh Kamboju < [email protected] > diff -Naurb a/testcases/open_posix_testsuite/conformance/interfaces/mlock/12-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mlock/12-1.c --- a/testcases/open_posix_testsuite/conformance/interfaces/mlock/12-1.c 2005-06-03 22:00:32.000000000 +0530 +++ b/testcases/open_posix_testsuite/conformance/interfaces/mlock/12-1.c 2009-06-12 17:18:00.000000000 +0530 @@ -8,7 +8,8 @@ * GNU General Public License for more details. * * Test that the mlock() function sets errno = EPERM if the calling process - * does not have the appropriate privilege to perform the requested operation. + * does not have the appropriate privilege to perform the requested operation + * (Linux 2.6.9 and later) and its RLIMIT_MEMLOCK soft resource limit set to 0. */ #define _XOPEN_SOURCE 600 @@ -21,6 +22,7 @@ #include <sys/types.h> #include <pwd.h> #include <string.h> +#include <sys/resource.h> #include "posixtest.h" #define BUFSIZE 8 @@ -29,6 +31,9 @@ int set_nonroot() { struct passwd *pw; + struct rlimit rlim; + int ret=0; + setpwent(); /* search for the first user which is non root */ while((pw = getpwent()) != NULL) @@ -40,6 +45,18 @@ return 1; } + /* + * mlock() + * EPERM: + * (Linux 2.6.9 and later) the caller was not privileged (CAP_IPC_LOCK) + * and its RLIMIT_MEMLOCK soft resource limit was 0. + */ + + rlim.rlim_cur = 0; + rlim.rlim_max = 0; + if ((ret = setrlimit(RLIMIT_MEMLOCK,&rlim)) != 0) + printf("Failed at setrlimit() return %d \n", ret); + if(seteuid(pw->pw_uid) != 0) { if(errno == EPERM) { printf("You don't have permission to change your UID.\n"); diff -Naurb a/testcases/open_posix_testsuite/conformance/interfaces/mlock/speculative/12-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mlock/speculative/12-1.c --- a/testcases/open_posix_testsuite/conformance/interfaces/mlock/speculative/12-1.c 2007-07-26 17:32:13.000000000 +0530 +++ b/testcases/open_posix_testsuite/conformance/interfaces/mlock/speculative/12-1.c 2009-06-12 17:18:24.000000000 +0530 @@ -8,7 +8,8 @@ * GNU General Public License for more details. * * Test that the mlock() function sets errno = EPERM if the calling process - * does not have the appropriate privilege to perform the requested operation. + * does not have the appropriate privilege to perform the requested operation + * (Linux 2.6.9 and later) and its RLIMIT_MEMLOCK soft resource limit set to 0. */ #define _XOPEN_SOURCE 600 @@ -21,6 +22,7 @@ #include <sys/types.h> #include <pwd.h> #include <string.h> +#include <sys/resource.h> #include "posixtest.h" #define BUFSIZE 8 @@ -29,6 +31,9 @@ int set_nonroot() { struct passwd *pw; + struct rlimit rlim; + int ret=0; + setpwent(); /* search for the first user which is non root */ while((pw = getpwent()) != NULL) @@ -40,6 +45,18 @@ return 1; } + /* + * mlock() + * EPERM: + * (Linux 2.6.9 and later) the caller was not privileged (CAP_IPC_LOCK) + * and its RLIMIT_MEMLOCK soft resource limit was 0. + */ + + rlim.rlim_cur = 0; + rlim.rlim_max = 0; + if ((ret = setrlimit(RLIMIT_MEMLOCK,&rlim)) != 0) + printf("Failed at setrlimit() return %d \n", ret); + if(seteuid(pw->pw_uid) != 0) { if(errno == EPERM) { printf("You don't have permission to change your UID.\n");
ltp-posix-mlock_12-1.patch
Description: Binary data
------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects
_______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
