From: Subrata <sub...@us...> - 2009-06-15 18:32:12
|
Update of /cvsroot/ltp/ltp/testcases/open_posix_testsuite/conformance/interfaces/mlock/speculative In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1132/ltp/testcases/open_posix_testsuite/conformance/interfaces/mlock/speculative Modified Files: 12-1.c Log Message: POSIX mlock/12-1.c and mlock/speculative/12-1.c. EPERM: (Linux 2.6.9 and later) the caller was not privileged (CAP_IPC_LOCK) and its RLIMIT_MEMLOCK soft resource limit was 0. Signed-off-by: Naresh Kamboju < nar...@gm... >. Index: 12-1.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/open_posix_testsuite/conformance/interfaces/mlock/speculative/12-1.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** 12-1.c 26 Jul 2007 12:02:13 -0000 1.1 --- 12-1.c 15 Jun 2009 18:32:09 -0000 1.2 *************** *** 9,13 **** * * Test that the mlock() function sets errno = EPERM if the calling process ! * does not have the appropriate privilege to perform the requested operation. */ --- 9,14 ---- * * Test that the mlock() function sets errno = EPERM if the calling process ! * 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. */ *************** *** 22,25 **** --- 23,27 ---- #include <pwd.h> #include <string.h> + #include <sys/resource.h> #include "posixtest.h" *************** *** 30,33 **** --- 32,38 ---- { struct passwd *pw; + struct rlimit rlim; + int ret=0; + setpwent(); /* search for the first user which is non root */ *************** *** 41,44 **** --- 46,61 ---- } + /* + * 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) { |