All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH/RFC] lib: add LTP_IPC_PATH to env. variables by default
@ 2017-10-10 12:36 Jan Stancek
  2017-10-10 13:10 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2017-10-10 12:36 UTC (permalink / raw)
  To: ltp

Child started by exec() that needs to do tst_reinit() in order
to use checkpoints will inherit LTP_IPC_PATH by default.
Parent can choose to override/omit it in envp array when calling
exec[lvp]e().

Also fix couple places to use IPC_ENV_VAR define.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 lib/tst_test.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/tst_test.c b/lib/tst_test.c
index 233b370794a6..27a0b7c36679 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -100,10 +100,12 @@ static void setup_ipc(void)
 	results = SAFE_MMAP(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, ipc_fd, 0);
 
 	/* Checkpoints needs to be accessible from processes started by exec() */
-	if (tst_test->needs_checkpoints)
+	if (tst_test->needs_checkpoints) {
 		sprintf(ipc_path, IPC_ENV_VAR "=%s", shm_path);
-	else
+		putenv(ipc_path);
+	} else {
 		SAFE_UNLINK(shm_path);
+	}
 
 	SAFE_CLOSE(ipc_fd);
 
@@ -131,13 +133,13 @@ static void cleanup_ipc(void)
 
 void tst_reinit(void)
 {
-	const char *path = getenv("LTP_IPC_PATH");
+	const char *path = getenv(IPC_ENV_VAR);
 	size_t size = getpagesize();
 	int fd;
 	void *ptr;
 
 	if (!path)
-		tst_brk(TBROK, "LTP_IPC_PATH is not defined");
+		tst_brk(TBROK, IPC_ENV_VAR" is not defined");
 
 	if (access(path, F_OK))
 		tst_brk(TBROK, "File %s does not exist!", path);
-- 
1.8.3.1


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

* [LTP] [PATCH/RFC] lib: add LTP_IPC_PATH to env. variables by default
  2017-10-10 12:36 [LTP] [PATCH/RFC] lib: add LTP_IPC_PATH to env. variables by default Jan Stancek
@ 2017-10-10 13:10 ` Cyril Hrubis
  2017-10-10 15:06   ` Jan Stancek
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2017-10-10 13:10 UTC (permalink / raw)
  To: ltp

Hi!
Can you also remove the explicit passing of tst_ipc_envp in the
creat07.c? Then we may as well get rid of the tst_ipc_envp[] array
completely.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH/RFC] lib: add LTP_IPC_PATH to env. variables by default
  2017-10-10 13:10 ` Cyril Hrubis
@ 2017-10-10 15:06   ` Jan Stancek
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Stancek @ 2017-10-10 15:06 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> Hi!
> Can you also remove the explicit passing of tst_ipc_envp in the
> creat07.c? Then we may as well get rid of the tst_ipc_envp[] array
> completely.

Sent as new series except for 2 patches you already ACK-ed:
  5deaf719987f security/dirtyc0w: synchronize parent and child
  13b2549855af lib: allow checkpoints to be used by any uid

Regards,
Jan

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

end of thread, other threads:[~2017-10-10 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-10 12:36 [LTP] [PATCH/RFC] lib: add LTP_IPC_PATH to env. variables by default Jan Stancek
2017-10-10 13:10 ` Cyril Hrubis
2017-10-10 15:06   ` Jan Stancek

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.