1 From 228349e796e9baa86f2ba8232c730c18ac41283d Mon Sep 17 00:00:00 2001
2 From: Tom Hochstein <tom.hochstein@nxp.com>
3 Date: Fri, 13 May 2016 09:31:55 -0500
4 Subject: [PATCH weston] weston-launch: Provide a default version that doesn't
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>
18 configure.ac | 12 +++++++-----
19 src/weston-launch.c | 20 ++++++++++++++++++++
20 3 files changed, 27 insertions(+), 8 deletions(-)
22 Index: weston-1.10.0/configure.ac
23 ===================================================================
24 --- weston-1.10.0.orig/configure.ac 2016-05-13 11:02:05.711817559 -0500
25 +++ weston-1.10.0/configure.ac 2016-05-13 13:30:28.000000000 -0500
27 AS_IF([test "x$have_systemd_login_209" = "xyes"],
28 [AC_DEFINE([HAVE_SYSTEMD_LOGIN_209], [1], [Have systemd-login >= 209])])
31 + AS_HELP_STRING([--with-pam], [Use PAM]),
32 + [use_pam=$withval], [use_pam=yes])
33 AC_ARG_ENABLE(weston-launch, [ --enable-weston-launch],, enable_weston_launch=yes)
34 AM_CONDITIONAL(BUILD_WESTON_LAUNCH, test x$enable_weston_launch == xyes)
35 -if test x$enable_weston_launch == xyes; then
36 +if test x$enable_weston_launch = xyes -a x$use_pam = xyes; then
37 AC_CHECK_LIB([pam], [pam_open_session], [have_pam=yes], [have_pam=no])
38 if test x$have_pam == xno; then
39 - AC_ERROR([weston-launch requires pam])
40 + AC_ERROR([PAM support is explicitly requested, but libpam couldn't be found])
42 + AC_DEFINE([HAVE_PAM], [1], [Define if PAM is available])
47 Enable developer documentation ${enable_devdocs}
49 weston-launch utility ${enable_weston_launch}
50 + PAM support ${use_pam}
51 systemd-login support ${have_systemd_login}
52 systemd notify support ${enable_systemd_notify}
54 Index: weston-1.10.0/src/weston-launch.c
55 ===================================================================
56 --- weston-1.10.0.orig/src/weston-launch.c 2016-05-13 11:02:05.779817896 -0500
57 +++ weston-1.10.0/src/weston-launch.c 2016-05-13 11:02:05.851818253 -0500
63 #include <security/pam_appl.h>
66 #ifdef HAVE_SYSTEMD_LOGIN
67 #include <systemd/sd-login.h>
71 struct weston_launch {
85 pam_conversation_fn(int msg_count,
86 const struct pam_message **messages,
94 setup_launcher_socket(struct weston_launch *wl)
101 err = pam_close_session(wl->ph, 0);
104 err, pam_strerror(wl->ph, err));
105 pam_end(wl->ph, err);
109 if (ioctl(wl->tty, KDSKBMUTE, 0) &&
110 ioctl(wl->tty, KDSKBMODE, wl->kb_mode))
112 setenv("HOME", wl->pw->pw_dir, 1);
113 setenv("SHELL", wl->pw->pw_shell, 1);
116 env = pam_getenvlist(wl->ph);
118 for (i = 0; env[i]; ++i) {
128 help(const char *name)
130 fprintf(stderr, "Usage: %s [args...] [-- [weston args..]]\n", name);
132 fprintf(stderr, " -u, --user Start session as specified username\n");
134 fprintf(stderr, " -t, --tty Start session on alternative tty\n");
135 fprintf(stderr, " -v, --verbose Be verbose\n");
136 fprintf(stderr, " -h, --help Display this help message\n");
140 struct option opts[] = {
142 { "user", required_argument, NULL, 'u' },
144 { "tty", required_argument, NULL, 't' },
145 { "verbose", no_argument, NULL, 'v' },
146 { "help", no_argument, NULL, 'h' },
148 while ((c = getopt_long(argc, argv, "u:t::vh", opts, &i)) != -1) {
152 wl.new_user = optarg;
154 error(1, 0, "Permission denied. -u allowed for root only");
156 + error(1, 0, "-u is unsupported in this weston-launch build");
162 if (setup_tty(&wl, tty) < 0)
166 if (wl.new_user && setup_pam(&wl) < 0)
170 if (setup_launcher_socket(&wl) < 0)