All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] Fix issue when running fcntl31 and fcntl31_64 over SSH as session leader
@ 2020-05-13 12:13 Yann Sionneau
  2021-02-17 16:24 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Yann Sionneau @ 2020-05-13 12:13 UTC (permalink / raw)
  To: ltp

If you run the test like this:
ssh localhost path/to/fcntl31

It will fail like this:
TBROK  :  fcntl31.c:121: setpgrp() failed: errno=EPERM(1): Operation not permitted

As man page for setpgrp says, it is indeed not permitted to change process group ID
when you are session leader (PID == SID).

Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
---
 testcases/kernel/syscalls/fcntl/fcntl31.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/fcntl/fcntl31.c b/testcases/kernel/syscalls/fcntl/fcntl31.c
index 52b4932fa..fd284fd7e 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl31.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl31.c
@@ -116,9 +116,12 @@ static void setup(void)
 
 	pid = getpid();
 
-	ret = setpgrp();
-	if (ret < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "setpgrp() failed");
+	/* Changing process group ID is forbidden when PID == SID i.e. we are session leader */
+	if (pid != getsid(0)) {
+		ret = setpgrp();
+		if (ret < 0)
+			tst_brkm(TBROK | TERRNO, cleanup, "setpgrp() failed");
+	}
 	pgrp_pid = getpgid(0);
 	if (pgrp_pid < 0)
 		tst_brkm(TBROK | TERRNO, cleanup, "getpgid() failed");
-- 
2.17.1


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

* [LTP] [PATCH] Fix issue when running fcntl31 and fcntl31_64 over SSH as session leader
  2020-05-13 12:13 [LTP] [PATCH] Fix issue when running fcntl31 and fcntl31_64 over SSH as session leader Yann Sionneau
@ 2021-02-17 16:24 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2021-02-17 16:24 UTC (permalink / raw)
  To: ltp

Hi!
Applied, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2021-02-17 16:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-13 12:13 [LTP] [PATCH] Fix issue when running fcntl31 and fcntl31_64 over SSH as session leader Yann Sionneau
2021-02-17 16:24 ` Cyril Hrubis

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.