All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [FIX PATCH] POSIX mlock/12-1.c and mlock/speculative/12-1.c
@ 2009-06-12 13:46 naresh kamboju
  2009-06-15 19:15 ` Subrata Modak
  0 siblings, 1 reply; 2+ messages in thread
From: naresh kamboju @ 2009-06-12 13:46 UTC (permalink / raw)
  To: ltp-list; +Cc: maxin john, brinda_mn, rohit.170309, naresh.kernel

[-- Attachment #1: Type: text/plain, Size: 3856 bytes --]

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 < naresh.kernel@gmail.com >

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");

[-- Attachment #2: ltp-posix-mlock_12-1.patch --]
[-- Type: application/octet-stream, Size: 3380 bytes --]

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");

[-- Attachment #3: Type: text/plain, Size: 332 bytes --]

------------------------------------------------------------------------------
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

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [LTP] [FIX PATCH] POSIX mlock/12-1.c and mlock/speculative/12-1.c
  2009-06-12 13:46 [LTP] [FIX PATCH] POSIX mlock/12-1.c and mlock/speculative/12-1.c naresh kamboju
@ 2009-06-15 19:15 ` Subrata Modak
  0 siblings, 0 replies; 2+ messages in thread
From: Subrata Modak @ 2009-06-15 19:15 UTC (permalink / raw)
  To: naresh kamboju; +Cc: ltp-list, maxin john, brinda_mn, rohit.170309

On Fri, 2009-06-12 at 19:16 +0530, naresh kamboju wrote: 
> 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 < naresh.kernel@gmail.com >

Thanks.

Regards--
Subrata

> 
> 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");


------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-06-15 19:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-12 13:46 [LTP] [FIX PATCH] POSIX mlock/12-1.c and mlock/speculative/12-1.c naresh kamboju
2009-06-15 19:15 ` Subrata Modak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.