Miniglx clients now authorize with server DRM
This commit is contained in:
parent
84e6b16d8f
commit
dc8a7603a3
|
@ -1091,6 +1091,14 @@ CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc)
|
||||||
err_extra = NULL;
|
err_extra = NULL;
|
||||||
|
|
||||||
if (drmGetMagic(fd, &magic)) goto done;
|
if (drmGetMagic(fd, &magic)) goto done;
|
||||||
|
|
||||||
|
dpy->authorized = False;
|
||||||
|
send_char_msg( dpy, 0, _Authorize );
|
||||||
|
send_msg( dpy, 0, &magic, sizeof(magic));
|
||||||
|
|
||||||
|
/* force net buffer flush */
|
||||||
|
while (!dpy->authorized)
|
||||||
|
handle_fd_events( dpy, 0 );
|
||||||
|
|
||||||
version = drmGetVersion(fd);
|
version = drmGetVersion(fd);
|
||||||
if (version) {
|
if (version) {
|
||||||
|
|
|
@ -139,6 +139,8 @@ struct MiniGLXDisplayRec {
|
||||||
int clientID;
|
int clientID;
|
||||||
int nrFds; /**< \brief number of connections (usually just one for the clients) */
|
int nrFds; /**< \brief number of connections (usually just one for the clients) */
|
||||||
struct MiniGLXConnection *fd; /**< \brief connections */
|
struct MiniGLXConnection *fd; /**< \brief connections */
|
||||||
|
int drmFd; /**< \brief handle to drm device */
|
||||||
|
int authorized; /**< \brief has server authorized this process? */
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int nr, head, tail;
|
int nr, head, tail;
|
||||||
|
@ -183,6 +185,21 @@ struct MiniGLXDisplayRec {
|
||||||
/*@}*/
|
/*@}*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Character messages. */
|
||||||
|
enum msgs {
|
||||||
|
_CanIHaveFocus,
|
||||||
|
_IDontWantFocus,
|
||||||
|
_YouveGotFocus,
|
||||||
|
_YouveLostFocus,
|
||||||
|
_RepaintPlease,
|
||||||
|
_Authorize,
|
||||||
|
};
|
||||||
|
extern int send_msg( Display *dpy, int i, const void *msg, size_t sz );
|
||||||
|
extern int send_char_msg( Display *dpy, int i, char msg );
|
||||||
|
extern int blocking_read( Display *dpy, int connection, char *msg, size_t msg_size );
|
||||||
|
extern int handle_fd_events( Display *dpy, int nonblock );
|
||||||
|
|
||||||
|
|
||||||
extern Bool __glXWindowExists(__DRInativeDisplay *dpy, GLXDrawable draw);
|
extern Bool __glXWindowExists(__DRInativeDisplay *dpy, GLXDrawable draw);
|
||||||
|
|
||||||
extern int __miniglx_open_connections( Display *dpy );
|
extern int __miniglx_open_connections( Display *dpy );
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: miniglx_events.c,v 1.3 2004/06/26 17:16:42 jonsmirl Exp $ */
|
/* $Id: miniglx_events.c,v 1.4 2004/07/16 04:27:00 jonsmirl Exp $ */
|
||||||
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -62,20 +62,12 @@
|
||||||
#include <linux/kd.h>
|
#include <linux/kd.h>
|
||||||
#include <linux/vt.h>
|
#include <linux/vt.h>
|
||||||
|
|
||||||
|
#include "xf86drm.h"
|
||||||
#include "miniglxP.h"
|
#include "miniglxP.h"
|
||||||
|
|
||||||
|
|
||||||
#define MINIGLX_FIFO_NAME "/tmp/miniglx.fifo"
|
#define MINIGLX_FIFO_NAME "/tmp/miniglx.fifo"
|
||||||
|
|
||||||
/** Character messages. */
|
|
||||||
enum msgs {
|
|
||||||
_CanIHaveFocus,
|
|
||||||
_IDontWantFocus,
|
|
||||||
_YouveGotFocus,
|
|
||||||
_YouveLostFocus,
|
|
||||||
_RepaintPlease,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Allocate an XEvent structure on the event queue.
|
* \brief Allocate an XEvent structure on the event queue.
|
||||||
*
|
*
|
||||||
|
@ -180,7 +172,7 @@ static void shut_fd( Display *dpy, int i )
|
||||||
* This will be actually sent to that file descriptor from
|
* This will be actually sent to that file descriptor from
|
||||||
* __miniglx_Select().
|
* __miniglx_Select().
|
||||||
*/
|
*/
|
||||||
static int send_msg( Display *dpy, int i,
|
int send_msg( Display *dpy, int i,
|
||||||
const void *msg, size_t sz )
|
const void *msg, size_t sz )
|
||||||
{
|
{
|
||||||
int cnt = dpy->fd[i].writebuf_count;
|
int cnt = dpy->fd[i].writebuf_count;
|
||||||
|
@ -204,7 +196,7 @@ static int send_msg( Display *dpy, int i,
|
||||||
* \internal
|
* \internal
|
||||||
* Use send_msg() to send a one-byte message to a socket.
|
* Use send_msg() to send a one-byte message to a socket.
|
||||||
*/
|
*/
|
||||||
static int send_char_msg( Display *dpy, int i, char msg )
|
int send_char_msg( Display *dpy, int i, char msg )
|
||||||
{
|
{
|
||||||
return send_msg( dpy, i, &msg, sizeof(char));
|
return send_msg( dpy, i, &msg, sizeof(char));
|
||||||
}
|
}
|
||||||
|
@ -224,7 +216,7 @@ static int send_char_msg( Display *dpy, int i, char msg )
|
||||||
*
|
*
|
||||||
* Only called from welcome_message_part().
|
* Only called from welcome_message_part().
|
||||||
*/
|
*/
|
||||||
static int blocking_read( Display *dpy, int connection,
|
int blocking_read( Display *dpy, int connection,
|
||||||
char *msg, size_t msg_size )
|
char *msg, size_t msg_size )
|
||||||
{
|
{
|
||||||
int i, r;
|
int i, r;
|
||||||
|
@ -386,6 +378,9 @@ static int handle_new_client( Display *dpy )
|
||||||
static int
|
static int
|
||||||
handle_fifo_read( Display *dpy, int i )
|
handle_fifo_read( Display *dpy, int i )
|
||||||
{
|
{
|
||||||
|
drm_magic_t magic;
|
||||||
|
int err;
|
||||||
|
|
||||||
while (dpy->fd[i].readbuf_count) {
|
while (dpy->fd[i].readbuf_count) {
|
||||||
char id = dpy->fd[i].readbuf[0];
|
char id = dpy->fd[i].readbuf[0];
|
||||||
XEvent *er;
|
XEvent *er;
|
||||||
|
@ -448,6 +443,10 @@ handle_fifo_read( Display *dpy, int i )
|
||||||
if (dpy->driver->notifyFocus)
|
if (dpy->driver->notifyFocus)
|
||||||
dpy->driver->notifyFocus( 0 );
|
dpy->driver->notifyFocus( 0 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case _Authorize:
|
||||||
|
dpy->authorized = True;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Client received unhandled message type %d\n", id);
|
fprintf(stderr, "Client received unhandled message type %d\n", id);
|
||||||
|
@ -488,6 +487,21 @@ handle_fifo_read( Display *dpy, int i )
|
||||||
er->xunmap.window = (Window)i;
|
er->xunmap.window = (Window)i;
|
||||||
er->xunmap.from_configure = False;
|
er->xunmap.from_configure = False;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case _Authorize:
|
||||||
|
/* is full message here yet? */
|
||||||
|
if (dpy->fd[i].readbuf_count < count + sizeof(magic)) {
|
||||||
|
count = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
memcpy(&magic, dpy->fd[i].readbuf + count, sizeof(magic));
|
||||||
|
fprintf(stderr, "Authorize - magic %d\n", magic);
|
||||||
|
|
||||||
|
err = drmAuthMagic(dpy->driverContext.drmFD, magic);
|
||||||
|
count += sizeof(magic);
|
||||||
|
|
||||||
|
send_char_msg( dpy, i, _Authorize );
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Server received unhandled message type %d\n", id);
|
fprintf(stderr, "Server received unhandled message type %d\n", id);
|
||||||
|
@ -713,7 +727,7 @@ __miniglx_Select( Display *dpy, int n, fd_set *rfds, fd_set *wfds, fd_set *xfds,
|
||||||
* \internal
|
* \internal
|
||||||
* This function is the select() main loop.
|
* This function is the select() main loop.
|
||||||
*/
|
*/
|
||||||
static int handle_fd_events( Display *dpy, int nonblock )
|
int handle_fd_events( Display *dpy, int nonblock )
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
struct timeval tv = {0, 0};
|
struct timeval tv = {0, 0};
|
||||||
|
|
Loading…
Reference in New Issue