1 From 5f2d71998eb77068cbaee2d468cbb296a42d5739 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>
18 Signed-off-by: Ming Liu <ming.liu@toradex.com>
21 libweston/meson.build | 16 ++++++++++++----
22 libweston/weston-launch.c | 21 +++++++++++++++++++++
23 meson_options.txt | 7 +++++++
24 3 files changed, 40 insertions(+), 4 deletions(-)
26 diff --git a/libweston/meson.build b/libweston/meson.build
27 index 08d23ec..cb9fd3f 100644
28 --- a/libweston/meson.build
29 +++ b/libweston/meson.build
30 @@ -216,16 +216,24 @@ dep_vertex_clipping = declare_dependency(
33 if get_option('weston-launch')
34 - dep_pam = cc.find_library('pam')
35 + deps_weston_launch = [systemd_dep, dep_libdrm]
37 - if not cc.has_function('pam_open_session', dependencies: dep_pam)
38 - error('pam_open_session not found for weston-launch')
39 + if get_option('pam')
40 + dep_pam = cc.find_library('pam')
41 + if not cc.has_function('pam_open_session', dependencies: dep_pam)
42 + error('pam_open_session not found for weston-launch')
46 + deps_weston_launch += dep_pam
47 + config_h.set('HAVE_PAM', '1')
54 - dependencies: [dep_pam, systemd_dep, dep_libdrm],
55 + dependencies: deps_weston_launch,
56 include_directories: common_inc,
59 diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c
60 index 8a711b4..54c567a 100644
61 --- a/libweston/weston-launch.c
62 +++ b/libweston/weston-launch.c
68 #include <security/pam_appl.h>
71 #ifdef HAVE_SYSTEMD_LOGIN
72 #include <systemd/sd-login.h>
73 @@ -100,8 +102,10 @@ drmSetMaster(int drm_fd)
76 struct weston_launch {
84 @@ -192,6 +196,7 @@ weston_launch_allowed(struct weston_launch *wl)
90 pam_conversation_fn(int msg_count,
91 const struct pam_message **messages,
92 @@ -232,6 +237,7 @@ setup_pam(struct weston_launch *wl)
99 setup_launcher_socket(struct weston_launch *wl)
100 @@ -431,6 +437,7 @@ quit(struct weston_launch *wl, int status)
106 err = pam_close_session(wl->ph, 0);
108 @@ -438,6 +445,7 @@ quit(struct weston_launch *wl, int status)
109 err, pam_strerror(wl->ph, err));
110 pam_end(wl->ph, err);
114 if (ioctl(wl->tty, KDSKBMUTE, 0) &&
115 ioctl(wl->tty, KDSKBMODE, wl->kb_mode))
116 @@ -666,6 +674,7 @@ setup_session(struct weston_launch *wl, char **child_argv)
117 setenv("HOME", wl->pw->pw_dir, 1);
118 setenv("SHELL", wl->pw->pw_shell, 1);
121 env = pam_getenvlist(wl->ph);
123 for (i = 0; env[i]; ++i) {
124 @@ -674,6 +683,7 @@ setup_session(struct weston_launch *wl, char **child_argv)
131 * We open a new session, so it makes sense
132 @@ -745,8 +755,10 @@ static void
133 help(const char *name)
135 fprintf(stderr, "Usage: %s [args...] [-- [weston args..]]\n", name);
137 fprintf(stderr, " -u, --user Start session as specified username,\n"
138 " e.g. -u joe, requires root.\n");
140 fprintf(stderr, " -t, --tty Start session on alternative tty,\n"
141 " e.g. -t /dev/tty4, requires -u option.\n");
142 fprintf(stderr, " -v, --verbose Be verbose\n");
143 @@ -760,7 +772,9 @@ main(int argc, char *argv[])
146 struct option opts[] = {
148 { "user", required_argument, NULL, 'u' },
150 { "tty", required_argument, NULL, 't' },
151 { "verbose", no_argument, NULL, 'v' },
152 { "help", no_argument, NULL, 'h' },
153 @@ -772,11 +786,16 @@ main(int argc, char *argv[])
154 while ((c = getopt_long(argc, argv, "u:t:vh", opts, &i)) != -1) {
158 wl.new_user = optarg;
160 fprintf(stderr, "weston: Permission denied. -u allowed for root only\n");
164 + fprintf(stderr, "weston: -u is unsupported in this weston-launch build\n");
165 + exit(EXIT_FAILURE);
170 @@ -828,8 +847,10 @@ main(int argc, char *argv[])
171 if (setup_tty(&wl, tty) < 0)
175 if (wl.new_user && setup_pam(&wl) < 0)
179 if (setup_launcher_socket(&wl) < 0)
181 diff --git a/meson_options.txt b/meson_options.txt
182 index c862ecc..73ef2c3 100644
183 --- a/meson_options.txt
184 +++ b/meson_options.txt
185 @@ -73,6 +73,13 @@ option(
192 + description: 'Define if PAM is available'