aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark2012-09-24 04:38:30 -0500
committerXavier Boudet2012-09-24 10:12:12 -0500
commit0c0ed32efd7569d2c65a4946c56150a344a63c5b (patch)
tree2ecc965ac36a33aadd4514fba2e1addd68758cc0
parentf8ceaa494055a5a35753e721c4bc62182bd56dd3 (diff)
downloaddce-0c0ed32efd7569d2c65a4946c56150a344a63c5b.tar.gz
dce-0c0ed32efd7569d2c65a4946c56150a344a63c5b.tar.xz
dce-0c0ed32efd7569d2c65a4946c56150a344a63c5b.zip
fix authentication issues
Fix a few issues with the re-worked authentication. If x11/wayland auth fails, we want to preserve the original fd, and *not* call drmOpen() again if dce_set_fd() has been called.
-rw-r--r--libdce-wayland.c16
-rw-r--r--libdce-x11.c9
-rw-r--r--libdce.c14
3 files changed, 26 insertions, 13 deletions
diff --git a/libdce-wayland.c b/libdce-wayland.c
index 891a9e4..093f7de 100644
--- a/libdce-wayland.c
+++ b/libdce-wayland.c
@@ -77,7 +77,7 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device)
77 d->fd = open(device, O_RDWR | O_CLOEXEC); 77 d->fd = open(device, O_RDWR | O_CLOEXEC);
78 if (d->fd == -1) { 78 if (d->fd == -1) {
79 ERROR("could not open %s: %m", device); 79 ERROR("could not open %s: %m", device);
80 d->error = 1; 80 d->error = -1;
81 return; 81 return;
82 } 82 }
83 } 83 }
@@ -120,14 +120,19 @@ display_handle_global (struct wl_display *display, uint32_t id,
120 } 120 }
121} 121}
122 122
123int dce_auth_wayland(int fd) 123int dce_auth_wayland(int *fd)
124{ 124{
125 struct display disp = {0}; 125 struct display disp = {0};
126 struct display *d = &disp; 126 struct display *d = &disp;
127 127
128 d->fd = fd; 128 d->fd = *fd;
129 129
130 INFO("attempting to open wayland connection");
130 d->display = wl_display_connect(NULL); 131 d->display = wl_display_connect(NULL);
132 if (!d->display) {
133 ERROR("Could not open display");
134 return -1;
135 }
131 wl_display_add_global_listener (d->display, 136 wl_display_add_global_listener (d->display,
132 display_handle_global, d); 137 display_handle_global, d);
133 138
@@ -141,5 +146,8 @@ int dce_auth_wayland(int fd)
141 wl_display_flush (d->display); 146 wl_display_flush (d->display);
142 wl_display_disconnect (d->display); 147 wl_display_disconnect (d->display);
143 148
144 return d->fd; 149 if (!d->error)
150 *fd = d->fd;
151
152 return d->error;
145} 153}
diff --git a/libdce-x11.c b/libdce-x11.c
index be7ad03..d2d5056 100644
--- a/libdce-x11.c
+++ b/libdce-x11.c
@@ -51,13 +51,15 @@
51 51
52#include <ti/dce/dce_priv.h> 52#include <ti/dce/dce_priv.h>
53 53
54int dce_auth_x11(int fd) 54int dce_auth_x11(int *pfd)
55{ 55{
56 Display *dpy; 56 Display *dpy;
57 Window root; 57 Window root;
58 drm_magic_t magic; 58 drm_magic_t magic;
59 int eventBase, errorBase, major, minor; 59 int eventBase, errorBase, major, minor;
60 char *driver, *device; 60 char *driver, *device;
61 int ret = -1;
62 int fd = *pfd;
61 63
62 INFO("attempting to open X11 connection"); 64 INFO("attempting to open X11 connection");
63 dpy = XOpenDisplay(NULL); 65 dpy = XOpenDisplay(NULL);
@@ -118,9 +120,12 @@ int dce_auth_x11(int fd)
118 goto no_x11_free; 120 goto no_x11_free;
119 } 121 }
120 122
123 ret = 0;
124 *pfd = fd;
125
121no_x11_free: 126no_x11_free:
122 XFree(driver); 127 XFree(driver);
123 XFree(device); 128 XFree(device);
124no_x11: 129no_x11:
125 return fd; 130 return ret;
126} 131}
diff --git a/libdce.c b/libdce.c
index a06fb2c..4cc641c 100644
--- a/libdce.c
+++ b/libdce.c
@@ -51,10 +51,10 @@
51#include <ti/sdo/ce/video2/videnc2.h> 51#include <ti/sdo/ce/video2/videnc2.h>
52 52
53#ifdef HAVE_X11 53#ifdef HAVE_X11
54int dce_auth_x11(int fd); 54int dce_auth_x11(int *fd);
55#endif 55#endif
56#ifdef HAVE_WAYLAND 56#ifdef HAVE_WAYLAND
57int dce_auth_wayland(int fd); 57int dce_auth_wayland(int *fd);
58#endif 58#endif
59 59
60static int init(void); 60static int init(void);
@@ -430,20 +430,20 @@ static int init(void)
430 430
431#ifdef HAVE_X11 431#ifdef HAVE_X11
432 if (!authenticated) { 432 if (!authenticated) {
433 fd = dce_auth_x11(fd); 433 int ret = dce_auth_x11(&fd);
434 if (fd != -1) 434 if (!ret)
435 authenticated = 1; 435 authenticated = 1;
436 } 436 }
437#endif 437#endif
438#ifdef HAVE_WAYLAND 438#ifdef HAVE_WAYLAND
439 if (!authenticated) { 439 if (!authenticated) {
440 fd = dce_auth_wayland(fd); 440 int ret = dce_auth_wayland(&fd);
441 if (fd != -1) 441 if (!ret)
442 authenticated = 1; 442 authenticated = 1;
443 } 443 }
444#endif 444#endif
445 445
446 if (!authenticated) { 446 if ((fd == -1) && !authenticated) {
447 INFO("no X11/wayland, fallback to opening DRM device directly"); 447 INFO("no X11/wayland, fallback to opening DRM device directly");
448 fd = drmOpen("omapdrm", "platform:omapdrm:00"); 448 fd = drmOpen("omapdrm", "platform:omapdrm:00");
449 } 449 }