The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/2792

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
On android system sh is located at /system/bin/sh
If /bin/sh does not exist, try /system/bin/sh

Signed-off-by: ondra <ondrak@localhost.localdomain>
From 649717cea8a5a7963f6ec589e5e4057a0019b9cd Mon Sep 17 00:00:00 2001
From: ondra <ondrak@localhost.localdomain>
Date: Fri, 11 Jan 2019 16:42:13 +0000
Subject: [PATCH] Fixing hooks functionality Android where 'sh' is placed under
 /system/bin

Signed-off-by: ondra <ondrak@localhost.localdomain>
---
 src/lxc/utils.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/lxc/utils.c b/src/lxc/utils.c
index ef71b6df7..cf343abca 100644
--- a/src/lxc/utils.c
+++ b/src/lxc/utils.c
@@ -405,6 +405,7 @@ struct lxc_popen_FILE *lxc_popen(const char *command)
        int pipe_fds[2];
        pid_t child_pid;
        struct lxc_popen_FILE *fp = NULL;
+       FILE *sh;
 
        ret = pipe2(pipe_fds, O_CLOEXEC);
        if (ret < 0)
@@ -447,7 +448,14 @@ struct lxc_popen_FILE *lxc_popen(const char *command)
                if (ret < 0)
                        _exit(EXIT_FAILURE);
 
-               execl("/bin/sh", "sh", "-c", command, (char *)NULL);
+               // check if we are not on android where sh is under 
/system/bin/sh
+               if ((sh = fopen("/bin/sh", "r"))) {
+                       fclose(sh);
+                       execl("/bin/sh", "sh", "-c", command, (char *)NULL);
+               } else {
+                       // try /system/bin/sh
+                       execl("/system/bin/sh", "sh", "-c", command, (char 
*)NULL);
+               }
                _exit(127);
        }
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to