diff options
Diffstat (limited to 'recipes-graphics/wayland/weston/0001-weston-launch-Provide-a-default-version-that-doesn-t.patch')
-rw-r--r-- | recipes-graphics/wayland/weston/0001-weston-launch-Provide-a-default-version-that-doesn-t.patch | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/recipes-graphics/wayland/weston/0001-weston-launch-Provide-a-default-version-that-doesn-t.patch b/recipes-graphics/wayland/weston/0001-weston-launch-Provide-a-default-version-that-doesn-t.patch new file mode 100644 index 00000000..d684b1c1 --- /dev/null +++ b/recipes-graphics/wayland/weston/0001-weston-launch-Provide-a-default-version-that-doesn-t.patch | |||
@@ -0,0 +1,166 @@ | |||
1 | From d02226b3d5872b184c1d50c7f4706ac9467ffb81 Mon Sep 17 00:00:00 2001 | ||
2 | From: Tom Hochstein <tom.hochstein@nxp.com> | ||
3 | Date: Fri, 15 Jul 2016 11:00:15 +0300 | ||
4 | Subject: [PATCH] weston-launch: Provide a default version that doesn't require | ||
5 | PAM | ||
6 | |||
7 | weston-launch requires PAM for starting weston as a non-root user. | ||
8 | |||
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. | ||
12 | |||
13 | Upstream-Status: Pending | ||
14 | |||
15 | Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com> | ||
16 | --- | ||
17 | configure.ac | 9 +++++++-- | ||
18 | src/weston-launch.c | 20 ++++++++++++++++++++ | ||
19 | 2 files changed, 27 insertions(+), 2 deletions(-) | ||
20 | |||
21 | --- a/configure.ac | ||
22 | +++ b/configure.ac | ||
23 | @@ -416,13 +416,17 @@ AC_ARG_ENABLE(resize-optimization, | ||
24 | AS_IF([test "x$enable_resize_optimization" = "xyes"], | ||
25 | [AC_DEFINE([USE_RESIZE_POOL], [1], [Use resize memory pool as a performance optimization])]) | ||
26 | |||
27 | +AC_ARG_WITH(pam, | ||
28 | + AS_HELP_STRING([--with-pam], [Use PAM]), | ||
29 | + [use_pam=$withval], [use_pam=yes]) | ||
30 | AC_ARG_ENABLE(weston-launch, [ --enable-weston-launch],, enable_weston_launch=yes) | ||
31 | AM_CONDITIONAL(BUILD_WESTON_LAUNCH, test x$enable_weston_launch == xyes) | ||
32 | -if test x$enable_weston_launch == xyes; then | ||
33 | +if test x$enable_weston_launch = xyes -a x$use_pam = xyes; then | ||
34 | WESTON_SEARCH_LIBS([PAM], [pam], [pam_open_session], [have_pam=yes], [have_pam=no]) | ||
35 | if test x$have_pam == xno; then | ||
36 | - AC_ERROR([weston-launch requires pam]) | ||
37 | + AC_ERROR([PAM support is explicitly requested, but libpam couldn't be found]) | ||
38 | fi | ||
39 | + AC_DEFINE([HAVE_PAM], [1], [Define if PAM is available]) | ||
40 | fi | ||
41 | |||
42 | AM_CONDITIONAL(HAVE_PANGO, test "x$have_pango" = "xyes") | ||
43 | @@ -673,6 +677,7 @@ AC_MSG_RESULT([ | ||
44 | Enable developer documentation ${enable_devdocs} | ||
45 | |||
46 | weston-launch utility ${enable_weston_launch} | ||
47 | + PAM support ${use_pam} | ||
48 | systemd-login support ${have_systemd_login} | ||
49 | systemd notify support ${enable_systemd_notify} | ||
50 | |||
51 | --- a/src/weston-launch.c | ||
52 | +++ b/src/weston-launch.c | ||
53 | @@ -51,7 +51,9 @@ | ||
54 | |||
55 | #include <pwd.h> | ||
56 | #include <grp.h> | ||
57 | +#ifdef HAVE_PAM | ||
58 | #include <security/pam_appl.h> | ||
59 | +#endif | ||
60 | |||
61 | #ifdef HAVE_SYSTEMD_LOGIN | ||
62 | #include <systemd/sd-login.h> | ||
63 | @@ -93,8 +95,10 @@ drmSetMaster(int drm_fd) | ||
64 | #endif | ||
65 | |||
66 | struct weston_launch { | ||
67 | +#ifdef HAVE_PAM | ||
68 | struct pam_conv pc; | ||
69 | pam_handle_t *ph; | ||
70 | +#endif | ||
71 | int tty; | ||
72 | int ttynr; | ||
73 | int sock[2]; | ||
74 | @@ -181,6 +185,7 @@ weston_launch_allowed(struct weston_laun | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | +#ifdef HAVE_PAM | ||
79 | static int | ||
80 | pam_conversation_fn(int msg_count, | ||
81 | const struct pam_message **messages, | ||
82 | @@ -221,6 +226,7 @@ setup_pam(struct weston_launch *wl) | ||
83 | |||
84 | return 0; | ||
85 | } | ||
86 | +#endif | ||
87 | |||
88 | static int | ||
89 | setup_launcher_socket(struct weston_launch *wl) | ||
90 | @@ -414,6 +420,7 @@ quit(struct weston_launch *wl, int statu | ||
91 | close(wl->signalfd); | ||
92 | close(wl->sock[0]); | ||
93 | |||
94 | +#ifdef HAVE_PAM | ||
95 | if (wl->new_user) { | ||
96 | err = pam_close_session(wl->ph, 0); | ||
97 | if (err) | ||
98 | @@ -421,6 +428,7 @@ quit(struct weston_launch *wl, int statu | ||
99 | err, pam_strerror(wl->ph, err)); | ||
100 | pam_end(wl->ph, err); | ||
101 | } | ||
102 | +#endif | ||
103 | |||
104 | if (ioctl(wl->tty, KDSKBMUTE, 0) && | ||
105 | ioctl(wl->tty, KDSKBMODE, wl->kb_mode)) | ||
106 | @@ -600,6 +608,7 @@ setup_session(struct weston_launch *wl) | ||
107 | setenv("HOME", wl->pw->pw_dir, 1); | ||
108 | setenv("SHELL", wl->pw->pw_shell, 1); | ||
109 | |||
110 | +#ifdef HAVE_PAM | ||
111 | env = pam_getenvlist(wl->ph); | ||
112 | if (env) { | ||
113 | for (i = 0; env[i]; ++i) { | ||
114 | @@ -608,6 +617,7 @@ setup_session(struct weston_launch *wl) | ||
115 | } | ||
116 | free(env); | ||
117 | } | ||
118 | +#endif | ||
119 | } | ||
120 | |||
121 | static void | ||
122 | @@ -665,7 +675,9 @@ static void | ||
123 | help(const char *name) | ||
124 | { | ||
125 | fprintf(stderr, "Usage: %s [args...] [-- [weston args..]]\n", name); | ||
126 | +#ifdef HAVE_PAM | ||
127 | fprintf(stderr, " -u, --user Start session as specified username\n"); | ||
128 | +#endif | ||
129 | fprintf(stderr, " -t, --tty Start session on alternative tty\n"); | ||
130 | fprintf(stderr, " -v, --verbose Be verbose\n"); | ||
131 | fprintf(stderr, " -h, --help Display this help message\n"); | ||
132 | @@ -678,7 +690,9 @@ main(int argc, char *argv[]) | ||
133 | int i, c; | ||
134 | char *tty = NULL; | ||
135 | struct option opts[] = { | ||
136 | +#ifdef HAVE_PAM | ||
137 | { "user", required_argument, NULL, 'u' }, | ||
138 | +#endif | ||
139 | { "tty", required_argument, NULL, 't' }, | ||
140 | { "verbose", no_argument, NULL, 'v' }, | ||
141 | { "help", no_argument, NULL, 'h' }, | ||
142 | @@ -690,9 +704,13 @@ main(int argc, char *argv[]) | ||
143 | while ((c = getopt_long(argc, argv, "u:t::vh", opts, &i)) != -1) { | ||
144 | switch (c) { | ||
145 | case 'u': | ||
146 | +#ifdef HAVE_PAM | ||
147 | wl.new_user = optarg; | ||
148 | if (getuid() != 0) | ||
149 | error(1, 0, "Permission denied. -u allowed for root only"); | ||
150 | +#else | ||
151 | + error(1, 0, "-u is unsupported in this weston-launch build"); | ||
152 | +#endif | ||
153 | break; | ||
154 | case 't': | ||
155 | tty = optarg; | ||
156 | @@ -732,8 +750,10 @@ main(int argc, char *argv[]) | ||
157 | if (setup_tty(&wl, tty) < 0) | ||
158 | exit(EXIT_FAILURE); | ||
159 | |||
160 | +#ifdef HAVE_PAM | ||
161 | if (wl.new_user && setup_pam(&wl) < 0) | ||
162 | exit(EXIT_FAILURE); | ||
163 | +#endif | ||
164 | |||
165 | if (setup_launcher_socket(&wl) < 0) | ||
166 | exit(EXIT_FAILURE); | ||