1 From 7d2fea61a95e9498b5a19c8cffcb2ab5631d5685 Mon Sep 17 00:00:00 2001
2 From: Tom Hochstein <tom.hochstein@nxp.com>
3 Date: Wed, 22 Feb 2017 15:53:30 +0200
4 Subject: [PATCH] weston-launch: Provide a default version that doesn't require
7 weston-launch requires PAM for starting weston as a non-root user.
9 Since starting weston as root is a valid use case by itself, if
10 PAM is not available, provide a default version of weston-launch
11 without non-root-user support.
13 Upstream-Status: Pending
15 Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
16 Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
17 Signed-off-by: Denys Dmytriyenko <denys@ti.com>
20 configure.ac | 9 +++++++--
21 libweston/weston-launch.c | 20 ++++++++++++++++++++
22 2 files changed, 27 insertions(+), 2 deletions(-)
24 diff --git a/configure.ac b/configure.ac
25 index 6da6e04..681f7c8 100644
28 @@ -515,13 +515,17 @@ AC_ARG_ENABLE(resize-optimization,
29 AS_IF([test "x$enable_resize_optimization" = "xyes"],
30 [AC_DEFINE([USE_RESIZE_POOL], [1], [Use resize memory pool as a performance optimization])])
33 + AS_HELP_STRING([--with-pam], [Use PAM]),
34 + [use_pam=$withval], [use_pam=yes])
35 AC_ARG_ENABLE(weston-launch, [ --enable-weston-launch],, enable_weston_launch=yes)
36 AM_CONDITIONAL(BUILD_WESTON_LAUNCH, test x$enable_weston_launch = xyes)
37 -if test x$enable_weston_launch = xyes; then
38 +if test x$enable_weston_launch = xyes -a x$use_pam = xyes; then
39 WESTON_SEARCH_LIBS([PAM], [pam], [pam_open_session], [have_pam=yes], [have_pam=no])
40 if test x$have_pam = xno; then
41 - AC_ERROR([weston-launch requires pam])
42 + AC_ERROR([PAM support is explicitly requested, but libpam couldn't be found])
44 + AC_DEFINE([HAVE_PAM], [1], [Define if PAM is available])
47 AM_CONDITIONAL(HAVE_PANGO, test "x$have_pango" = "xyes")
48 @@ -767,6 +771,7 @@ AC_MSG_RESULT([
49 Enable developer documentation ${enable_devdocs}
51 weston-launch utility ${enable_weston_launch}
52 + PAM support ${use_pam}
53 systemd-login support ${have_systemd_login}
54 systemd notify support ${enable_systemd_notify}
56 diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c
57 index 9064439..c6abe92 100644
58 --- a/libweston/weston-launch.c
59 +++ b/libweston/weston-launch.c
65 #include <security/pam_appl.h>
68 #ifdef HAVE_SYSTEMD_LOGIN
69 #include <systemd/sd-login.h>
70 @@ -101,8 +103,10 @@ drmSetMaster(int drm_fd)
73 struct weston_launch {
81 @@ -191,6 +195,7 @@ weston_launch_allowed(struct weston_launch *wl)
87 pam_conversation_fn(int msg_count,
88 const struct pam_message **messages,
89 @@ -231,6 +236,7 @@ setup_pam(struct weston_launch *wl)
96 setup_launcher_socket(struct weston_launch *wl)
97 @@ -424,6 +430,7 @@ quit(struct weston_launch *wl, int status)
103 err = pam_close_session(wl->ph, 0);
105 @@ -431,6 +438,7 @@ quit(struct weston_launch *wl, int status)
106 err, pam_strerror(wl->ph, err));
107 pam_end(wl->ph, err);
111 if (ioctl(wl->tty, KDSKBMUTE, 0) &&
112 ioctl(wl->tty, KDSKBMODE, wl->kb_mode))
113 @@ -610,6 +618,7 @@ setup_session(struct weston_launch *wl, char **child_argv)
114 setenv("HOME", wl->pw->pw_dir, 1);
115 setenv("SHELL", wl->pw->pw_shell, 1);
118 env = pam_getenvlist(wl->ph);
120 for (i = 0; env[i]; ++i) {
121 @@ -618,6 +627,7 @@ setup_session(struct weston_launch *wl, char **child_argv)
128 * We open a new session, so it makes sense
129 @@ -685,8 +695,10 @@ static void
130 help(const char *name)
132 fprintf(stderr, "Usage: %s [args...] [-- [weston args..]]\n", name);
134 fprintf(stderr, " -u, --user Start session as specified username,\n"
135 " e.g. -u joe, requires root.\n");
137 fprintf(stderr, " -t, --tty Start session on alternative tty,\n"
138 " e.g. -t /dev/tty4, requires -u option.\n");
139 fprintf(stderr, " -v, --verbose Be verbose\n");
140 @@ -700,7 +712,9 @@ main(int argc, char *argv[])
143 struct option opts[] = {
145 { "user", required_argument, NULL, 'u' },
147 { "tty", required_argument, NULL, 't' },
148 { "verbose", no_argument, NULL, 'v' },
149 { "help", no_argument, NULL, 'h' },
150 @@ -712,9 +726,13 @@ main(int argc, char *argv[])
151 while ((c = getopt_long(argc, argv, "u:t:vh", opts, &i)) != -1) {
155 wl.new_user = optarg;
157 error(1, 0, "Permission denied. -u allowed for root only");
159 + error(1, 0, "-u is unsupported in this weston-launch build");
164 @@ -755,8 +773,10 @@ main(int argc, char *argv[])
165 if (setup_tty(&wl, tty) < 0)
169 if (wl.new_user && setup_pam(&wl) < 0)
173 if (setup_launcher_socket(&wl) < 0)