* [PATCH 1/4] um: port_user: Search for in.telnetd in PATH
2022-03-03 7:53 [PATCH 0/4] Improvements to port on various error conditions Glenn Washburn
@ 2022-03-03 7:53 ` Glenn Washburn
2022-03-03 7:53 ` [PATCH 2/4] um: port_user: Allow setting path to port-helper using UML_PORT_HELPER envvar Glenn Washburn
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Glenn Washburn @ 2022-03-03 7:53 UTC (permalink / raw)
To: linux-um; +Cc: Glenn Washburn
This allows in.telnetd to be run from non-standard installation locations
and is especially useful when running a UML instance as an unprivileged user
on a system where the administrator has not installed the in.telnetd binary.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
arch/um/drivers/port_user.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c
index 5b5b64cb1071..0625aa42041d 100644
--- a/arch/um/drivers/port_user.c
+++ b/arch/um/drivers/port_user.c
@@ -167,7 +167,7 @@ static void port_pre_exec(void *arg)
int port_connection(int fd, int *socket, int *pid_out)
{
int new, err;
- char *argv[] = { "/usr/sbin/in.telnetd", "-L",
+ char *argv[] = { "in.telnetd", "-L",
OS_LIB_PATH "/uml/port-helper", NULL };
struct port_pre_exec_data data;
--
2.30.2
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/4] um: port_user: Allow setting path to port-helper using UML_PORT_HELPER envvar
2022-03-03 7:53 [PATCH 0/4] Improvements to port on various error conditions Glenn Washburn
2022-03-03 7:53 ` [PATCH 1/4] um: port_user: Search for in.telnetd in PATH Glenn Washburn
@ 2022-03-03 7:53 ` Glenn Washburn
2022-03-03 7:53 ` [PATCH 3/4] um: port_user: Improve error handling when port-helper is not found Glenn Washburn
2022-03-03 7:53 ` [PATCH 4/4] um: run_helper: Write error message to kernel log on exec failure on host Glenn Washburn
3 siblings, 0 replies; 5+ messages in thread
From: Glenn Washburn @ 2022-03-03 7:53 UTC (permalink / raw)
To: linux-um; +Cc: Glenn Washburn
This is useful when the uml-utilities user-space package has not been
installed by the administrator and an unprivileged user wants to be able to
telnet into a UML instance. The user can install the port-helper binary to
a writable path and set UML_PORT_HELPER. Fallback to using hardcoded path to
port-helper if environment variable is not set.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
arch/um/drivers/port_user.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c
index 0625aa42041d..3e32351dadad 100644
--- a/arch/um/drivers/port_user.c
+++ b/arch/um/drivers/port_user.c
@@ -167,10 +167,14 @@ static void port_pre_exec(void *arg)
int port_connection(int fd, int *socket, int *pid_out)
{
int new, err;
+ char *env;
char *argv[] = { "in.telnetd", "-L",
OS_LIB_PATH "/uml/port-helper", NULL };
struct port_pre_exec_data data;
+ if ((env = getenv("UML_PORT_HELPER")))
+ argv[2] = env;
+
new = accept(fd, NULL, 0);
if (new < 0)
return -errno;
--
2.30.2
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 3/4] um: port_user: Improve error handling when port-helper is not found
2022-03-03 7:53 [PATCH 0/4] Improvements to port on various error conditions Glenn Washburn
2022-03-03 7:53 ` [PATCH 1/4] um: port_user: Search for in.telnetd in PATH Glenn Washburn
2022-03-03 7:53 ` [PATCH 2/4] um: port_user: Allow setting path to port-helper using UML_PORT_HELPER envvar Glenn Washburn
@ 2022-03-03 7:53 ` Glenn Washburn
2022-03-03 7:53 ` [PATCH 4/4] um: run_helper: Write error message to kernel log on exec failure on host Glenn Washburn
3 siblings, 0 replies; 5+ messages in thread
From: Glenn Washburn @ 2022-03-03 7:53 UTC (permalink / raw)
To: linux-um; +Cc: Glenn Washburn
Check if port-helper exists and is executable. If not, write an error
message to the kernel log with information to help the user diagnose the
issue and exit with an error. If UML_PORT_HELPER was not set, write a
message suggesting that the user set it. This makes it easier to understand
why telneting to the UML instance is failing and what can be done to fix it.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
arch/um/drivers/port_user.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c
index 3e32351dadad..3c62ae81df62 100644
--- a/arch/um/drivers/port_user.c
+++ b/arch/um/drivers/port_user.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <errno.h>
#include <termios.h>
#include <unistd.h>
@@ -179,6 +180,17 @@ int port_connection(int fd, int *socket, int *pid_out)
if (new < 0)
return -errno;
+ err = os_access(argv[2], X_OK);
+ if (err < 0) {
+ printk(UM_KERN_ERR "port_connection : error accessing port-helper "
+ "executable at %s: %s\n", argv[2], strerror(-err));
+ if (env == NULL)
+ printk(UM_KERN_ERR "Set UML_PORT_HELPER environment "
+ "variable to path to uml-utilities port-helper "
+ "binary\n");
+ goto out_close;
+ }
+
err = os_pipe(socket, 0, 0);
if (err < 0)
goto out_close;
--
2.30.2
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 4/4] um: run_helper: Write error message to kernel log on exec failure on host
2022-03-03 7:53 [PATCH 0/4] Improvements to port on various error conditions Glenn Washburn
` (2 preceding siblings ...)
2022-03-03 7:53 ` [PATCH 3/4] um: port_user: Improve error handling when port-helper is not found Glenn Washburn
@ 2022-03-03 7:53 ` Glenn Washburn
3 siblings, 0 replies; 5+ messages in thread
From: Glenn Washburn @ 2022-03-03 7:53 UTC (permalink / raw)
To: linux-um; +Cc: Glenn Washburn
The best place to log errors from the host side is in the kernel log within
the UML guest. Letting the user now that exec() failed and why is very
helpful when the user is trying to determine why some aspect of UML is not
working. For instance, when telneting into the UML instance, if the
connection is established and then immediately dropped, this may be due to
exec() failing because in.telnetd is not found.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
arch/um/os-Linux/helper.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c
index 32e88baf18dd..b459745f52e2 100644
--- a/arch/um/os-Linux/helper.c
+++ b/arch/um/os-Linux/helper.c
@@ -4,6 +4,7 @@
*/
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sched.h>
@@ -99,6 +100,10 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
CATCH_EINTR(waitpid(pid, NULL, __WALL));
}
+ if (ret < 0)
+ printk(UM_KERN_ERR "run_helper : failed to exec %s on host: %s\n",
+ argv[0], strerror(-ret));
+
out_free2:
kfree(data.buf);
out_close:
--
2.30.2
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
^ permalink raw reply related [flat|nested] 5+ messages in thread