[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xorg-server: Changes to 'upstream-1.11+input'



 Xext/xace.c                      |    4 +
 Xext/xselinux_ext.c              |    6 -
 configure.ac                     |    7 ++
 dix/dispatch.c                   |   14 ++--
 dix/dixutils.c                   |    7 --
 dix/getevents.c                  |   17 ++++-
 dix/grabs.c                      |    3 
 hw/xfree86/common/xf86Xinput.c   |   11 +--
 hw/xquartz/bundle/Info.plist.cpp |    8 +-
 include/inputstr.h               |    2 
 mi/mibitblt.c                    |    2 
 os/backtrace.c                   |    6 +
 os/client.c                      |  118 +++++++++++++++++++++++++++++++++------
 13 files changed, 156 insertions(+), 49 deletions(-)

New commits:
commit 03e15dc10aa7cec2d1db294beb0c006ea0e24e25
Author: Chase Douglas <chase.douglas@canonical.com>
Date:   Wed Jan 18 19:09:21 2012 -0800

    Don't set X and Y valuators for indirect touch events
    
    For expediency, it made sense to always have the X and Y axes set for
    direct touch device event propagation. The last X and Y values are
    stored internally. However, indirect device touch event propagation
    does not depend on the touch's X and Y values. Thus, we don't need to
    set the values for every indirect touch event.
    
    On top of this, the previous X and Y values aren't stored for indirect
    touches, so without this change the axes get erroneously set to 0.
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit e1085a0da0b9299f48b3dc41dee5e33bf022bea5)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index a4343f5..048cba5 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1836,7 +1836,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
     default:
         return 0;
     }
-    if (!(flags & TOUCH_CLIENT_ID))
+    if (t->mode == XIDirectTouch && !(flags & TOUCH_CLIENT_ID))
     {
         if (!valuator_mask_isset(&mask, 0))
             valuator_mask_set_double(&mask, 0, valuator_mask_get_double(touchpoint.ti->valuators, 0));

commit 17e9669a686c5b943b6e22ed740c2e8ffcb39c27
Author: Daniel Stone <daniel@fooishbar.org>
Date:   Thu Jan 19 22:40:32 2012 +1100

    UngrabAllDevices: Don't kill clients if not told to
    
    The kill_client argument to UngrabAllClients specifies if we want to
    kill the client holding the grab or just deactivate the grab.
    
    Signed-off-by: Daniel Stone <daniel@fooishbar.org>
    Reported-by: Julien Cristau <jcristau@debian.org>
    Reviewed-by: Cyril Brulebois <kibi@debian.org>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 5201310559fe8708ba8278bdef77cdc1673fff71)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/dix/grabs.c b/dix/grabs.c
index 701470c..cc2c946 100644
--- a/dix/grabs.c
+++ b/dix/grabs.c
@@ -195,7 +195,8 @@ UngrabAllDevices(Bool kill_client)
         client = clients[CLIENT_ID(dev->deviceGrab.grab->resource)];
         if (!client || client->clientGone)
             dev->deviceGrab.DeactivateGrab(dev);
-        CloseDownClient(client);
+        if (kill_client)
+            CloseDownClient(client);
     }
 
     ErrorF("End list of ungrabbed devices\n");

commit 36d20ea69467e0a873a457078c5032d7447ac984
Author: Chase Douglas <chase.douglas@canonical.com>
Date:   Wed Jan 18 18:04:14 2012 -0800

    Only update pointer motion data for pointer emulated touch events
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 9b1e18f42a05a79d9ebec372a37b47442e397ca9)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index 1dc7615..a4343f5 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1878,9 +1878,13 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
                              &devx, &devy, &screenx, &screeny);
 
     /* see fill_pointer_events for coordinate systems */
-    updateHistory(dev, &mask, ms);
+    if (emulate_pointer)
+        updateHistory(dev, &mask, ms);
+
     clipValuators(dev, &mask);
-    storeLastValuators(dev, &mask, 0, 1, devx, devy);
+
+    if (emulate_pointer)
+        storeLastValuators(dev, &mask, 0, 1, devx, devy);
 
     event->root = scr->root->drawable.id;
 

commit b6e21d8b973f46fe70517d37385342b5e2f47d22
Author: Chase Douglas <chase.douglas@canonical.com>
Date:   Wed Jan 18 18:04:13 2012 -0800

    Only scale direct device touch coordinates
    
    Indirect touch devices provide valuator values in pure device
    coordinates. They also don't need to be fixed up for screen crossings.
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit f00e5b02f5d9928cd88961e761da91b5faff1b32)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index 3b40a5b..1dc7615 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1867,7 +1867,12 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
     if (need_rawevent)
         set_raw_valuators(raw, &mask, raw->valuators.data);
 
-    scr = scale_to_desktop(dev, &mask, &devx, &devy, &screenx, &screeny);
+    /* Indirect device touch coordinates are not used for cursor positioning.
+     * They are merely informational, and are provided in device coordinates.
+     * The device sprite is used for positioning instead, and it is already
+     * scaled. */
+    if (t->mode == XIDirectTouch)
+        scr = scale_to_desktop(dev, &mask, &devx, &devy, &screenx, &screeny);
     if (emulate_pointer)
         scr = positionSprite(dev, Absolute, &mask,
                              &devx, &devy, &screenx, &screeny);

commit ebf3e90cbb271b00dbe767ce848a9687390ec887
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Jan 16 12:53:39 2012 +1000

    include: Fix comment typo
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 24dc0389da3970e83e4908039957567e55f9ea05)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/include/inputstr.h b/include/inputstr.h
index 518e2f4..c3297db 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -544,7 +544,7 @@ typedef struct _DeviceIntRec {
     DeviceRec	public;
     DeviceIntPtr next;
     Bool	startup;		/* true if needs to be turned on at
-				          server intialization time */
+				          server initialization time */
     DeviceProc	deviceProc;		/* proc(DevicePtr, DEVICE_xx). It is
 					  used to initialize, turn on, or
 					  turn off the device */

commit 1fbd9c6f967484485f1e8b333f21a1dac0da7680
Author: Jeremy Huddleston <jeremyhu@apple.com>
Date:   Wed Jan 18 11:47:21 2012 -0800

    XQuartz: Bump bundle version to 2.7.1
    
    Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
    (cherry picked from commit b747a91485184649c05aba6fa10734f70e926032)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp
index a4b8e19..60251f7 100644
--- a/hw/xquartz/bundle/Info.plist.cpp
+++ b/hw/xquartz/bundle/Info.plist.cpp
@@ -19,9 +19,9 @@
 	<key>CFBundlePackageType</key>
 		<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-		<string>2.7.0</string>
+		<string>2.7.1</string>
 	<key>CFBundleVersion</key>
-		<string>2.7.0</string>
+		<string>2.7.1</string>
 	<key>CFBundleSignature</key>
 		<string>x11a</string>
 	<key>CSResourcesFileMapped</key>
@@ -37,9 +37,9 @@
 	<key>LSApplicationCategoryType</key>
 		<string>public.app-category.utilities</string>
 	<key>NSHumanReadableCopyright</key>
-		<string>© 2003-2011 Apple Inc.
+		<string>© 2003-2012 Apple Inc.
 © 2003 XFree86 Project, Inc.
-© 2003-2011 X.org Foundation, Inc.
+© 2003-2012 X.org Foundation, Inc.
 </string>
 	<key>NSMainNibFile</key>
 		<string>main</string>

commit 800d82ff45f150aa6680d8c3a0172a851d8a55ab
Author: Zhigang Gong <zhigang.gong@linux.intel.com>
Date:   Wed Jan 4 07:01:19 2012 +0000

    mi/mibitblt: Fix an overflow bug of bit shift.
    
    When depth equal to 32 and planeMask equal to 0, the overflow will
    occur and cause the pixmap can't be cleared. There are some test
    cases in XTS hit this bug, and this fix can eliminate the corresponding
    failures.
    
    Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit f4956faab9ccf9aba6cf9603f4489f5dad19a347)
    (cherry picked from commit dea9377a257a402b2c7fe4a96c958d951a7d4579)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/mi/mibitblt.c b/mi/mibitblt.c
index 49e17bd..6e00557 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -648,7 +648,7 @@ miGetImage( DrawablePtr pDraw, int sx, int sy, int w, int h,
     depth = pDraw->depth;
     if(format == ZPixmap)
     {
-	if ( (((1<<depth)-1)&planeMask) != (1<<depth)-1 )
+	if ( (((1LL<<depth)-1)&planeMask) != (1LL<<depth)-1 )
 	{
 	    ChangeGCVal gcv;
 	    xPoint pt;

commit 8f40cad6e07065691799b54da37204747cb428fa
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Fri Oct 28 21:29:50 2011 -0700

    Convert DetermineClientCmd to use strdup instead of malloc+strncpy
    
    *cmdname is initialized to NULL earlier in the function, so it's
    okay to overwrite it with NULL if strdup fails, don't need that
    extra check.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
    (cherry picked from commit 780133f9ae7fada462714b47e79d26075bbd9abe)
    (cherry picked from commit d2db5100b1bafeeea8c1febd390631c8f8abb094)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/os/client.c b/os/client.c
index aa9be84..fbccf22 100644
--- a/os/client.c
+++ b/os/client.c
@@ -234,13 +234,7 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
     /* Contruct the process name without arguments. */
     if (cmdname)
     {
-        char *name = malloc(cmdsize);
-        if (name)
-        {
-            strncpy(name, path, cmdsize);
-            name[cmdsize - 1] = '\0';
-            *cmdname = name;
-        }
+        *cmdname = strdup(path);
     }
 
     /* Construct the arguments for client process. */

commit 2538c43541a48bddc654eea645bd3408e741a49a
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Dec 13 21:23:12 2011 -0500

    dix: Tune dixLookupDrawable for success
    
    The vast vast vast majority of resource lookups are successful.  Move some
    work to the error paths so we don't punish success.
    
    Before:
    40000000 trep @   0.0009 msec (1109091.3/sec): PutImage 10x10 square
    60000000 trep @   0.0005 msec (2072652.2/sec): ShmPutImage 10x10 square
    
    After:
    40000000 trep @   0.0009 msec (1148346.9/sec): PutImage 10x10 square
    60000000 trep @   0.0005 msec (2091666.1/sec): ShmPutImage 10x10 square
    
    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Signed-off-by: Adam Jackson <ajax@redhat.com>
    (cherry picked from commit 8f9bdfd293ad8e45755efe8d764b4dcc2a724f51)
    (cherry picked from commit 5b28bcb340e279e7f4e76617e86b439092367690)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/dix/dixutils.c b/dix/dixutils.c
index 1e31346..cfb0397 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -202,13 +202,12 @@ dixLookupDrawable(DrawablePtr *pDraw, XID id, ClientPtr client,
     int rc;
 
     *pDraw = NULL;
-    client->errorValue = id;
-
-    if (id == INVALID)
-	return BadDrawable;
 
     rc = dixLookupResourceByClass((pointer *)&pTmp, id, RC_DRAWABLE, client, access);
 
+    if (rc != Success)
+	client->errorValue = id;
+
     if (rc == BadValue)
 	return BadDrawable;
     if (rc != Success)

commit d0c6ccbfb61eb4b0e5c83b8ecf5ebcf3a4e90ba7
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Dec 13 20:23:40 2011 -0500

    dix: Tune dtrace hooks around Dispatch
    
    Don't call LookupMajorName if the hooks aren't active, it's quite expensive.
    
    Before:
    40000000 trep @   0.0009 msec (1087458.5/sec): PutImage 10x10 square
    60000000 trep @   0.0005 msec (2012238.6/sec): ShmPutImage 10x10 square
    
    After:
    40000000 trep @   0.0009 msec (1109091.3/sec): PutImage 10x10 square
    60000000 trep @   0.0005 msec (2072652.2/sec): ShmPutImage 10x10 square
    
    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Signed-off-by: Adam Jackson <ajax@redhat.com>
    (cherry picked from commit 83a98543b58c661a22574a6f8d8f9d777c0955b8)
    (cherry picked from commit e1ea93fec93b13d18df4451210aaaf322b769b6a)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 7d8b8e1..8f910f4 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -425,9 +425,11 @@ Dispatch(void)
 			client->minorOp = ext->MinorOpcode(client);
 		}
 #ifdef XSERVER_DTRACE
-		XSERVER_REQUEST_START(LookupMajorName(client->majorOp), client->majorOp,
-			      ((xReq *)client->requestBuffer)->length,
-			      client->index, client->requestBuffer);
+		if (XSERVER_REQUEST_START_ENABLED())
+		    XSERVER_REQUEST_START(LookupMajorName(client->majorOp),
+					  client->majorOp,
+					  ((xReq *)client->requestBuffer)->length,
+					  client->index, client->requestBuffer);
 #endif
 		if (result > (maxBigRequestSize << 2))
 		    result = BadLength;
@@ -438,8 +440,10 @@ Dispatch(void)
 		    XaceHookAuditEnd(client, result);
 		}
 #ifdef XSERVER_DTRACE
-		XSERVER_REQUEST_DONE(LookupMajorName(client->majorOp), client->majorOp,
-			      client->sequence, client->index, result);
+		if (XSERVER_REQUEST_DONE_ENABLED())
+		    XSERVER_REQUEST_DONE(LookupMajorName(client->majorOp),
+					 client->majorOp, client->sequence,
+					 client->index, result);
 #endif
 
 		if (client->noClientException != Success)

commit 33af6a8d422a6ba95883e448dbfe6fb8ff4ce2ec
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Dec 13 21:00:05 2011 -0500

    xace: ricer tuning for XaceHook
    
    gcc doesn't want to hoist the check for XaceHooks[hook] != NULL above the
    varargs code for some reason, so do it ourselves.
    
    Before:
    40000000 trep @   0.0010 msec (1050420.2/sec): PutImage 10x10 square
    60000000 trep @   0.0005 msec (1921147.6/sec): ShmPutImage 10x10 square
    
    After:
    40000000 trep @   0.0009 msec (1087458.5/sec): PutImage 10x10 square
    60000000 trep @   0.0005 msec (2012238.6/sec): ShmPutImage 10x10 square
    
    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Signed-off-by: Adam Jackson <ajax@redhat.com>
    (cherry picked from commit 11977fab546da35d579ebe285e3c26864007805e)
    (cherry picked from commit 9eaa0b5c89f645c50ea90e07e8b49ebacf4349a0)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/Xext/xace.c b/Xext/xace.c
index c757cad..ef69fe3 100644
--- a/Xext/xace.c
+++ b/Xext/xace.c
@@ -101,6 +101,10 @@ int XaceHook(int hook, ...)
     } u;
     int *prv = NULL;	/* points to return value from callback */
     va_list ap;		/* argument list */
+
+    if (!XaceHooks[hook])
+	return Success;
+
     va_start(ap, hook);
 
     /* Marshal arguments for passing to callback.

commit eecdd1c758c3a610038384308e0f9ae558cc92fc
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Jan 3 10:45:45 2012 +1000

    xfree86: split warning about missing identifier or input driver
    
    Check for identifier first and bail if it's missing (also remove the current
    identifier check after we've already bailed due to missing identifiers)
    
    If a driver is missing, warn but also say that we may have added this device
    already. I see too many bugreports with incorrectly shortened log files.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Cyril Brulebois <kibi@debian.org>
    (cherry picked from commit 75953ccb9e9e5f1dbbaa44c714716a0049e22aae)
    (cherry picked from commit a3b6ecc893e17028cfbe16d8d7981c9037fc0766)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 36c40d7..671c9e0 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -968,15 +968,16 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
         pInfo->attrs = DuplicateInputAttributes(attrs);
     }
 
-    if (!pInfo->driver || !pInfo->name) {
-        xf86Msg(X_INFO, "No input driver/identifier specified (ignoring)\n");
+    if (!pInfo->name) {
+        xf86Msg(X_INFO, "No identifier specified, ignoring this device.\n");
         rval = BadRequest;
         goto unwind;
     }
 
-    if (!pInfo->name) {
-        xf86Msg(X_ERROR, "No device identifier specified (ignoring)\n");
-        rval = BadMatch;
+    if (!pInfo->driver) {
+        xf86Msg(X_INFO, "No input driver specified, ignoring this device.\n");
+        xf86Msg(X_INFO, "This device may have been added with another device file.\n");
+        rval = BadRequest;
         goto unwind;
     }
 

commit f17bd8187cbce7f848c9613c51d0fcfe86c49489
Author: Julien Cristau <jcristau@debian.org>
Date:   Fri Dec 30 20:41:25 2011 +0100

    os: don't ignore failure from dladdr
    
    If dladdr returns 0, don't go and use the returned Dl_info, it may
    contain garbage.
    
    X.Org bug#44315 <https://bugs.freedesktop.org/show_bug.cgi?id=44315>
    
    Reported-and-tested-by: Cyril Brulebois <kibi@debian.org>
    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
    Reviewed-by: Cyril Brulebois <kibi@debian.org>
    Signed-off-by: Julien Cristau <jcristau@debian.org>
    (cherry picked from commit 6269977c91071e0ea16ca5b4b8e15fd6db0b6fcf)
    (cherry picked from commit 4a339afc586d55a9a248b893f007219d79c72600)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/os/backtrace.c b/os/backtrace.c
index 7ca6dab..f3255c7 100644
--- a/os/backtrace.c
+++ b/os/backtrace.c
@@ -44,7 +44,11 @@ void xorg_backtrace(void)
     ErrorF("\nBacktrace:\n");
     size = backtrace(array, 64);
     for (i = 0; i < size; i++) {
-	dladdr(array[i], &info);
+	int rc = dladdr(array[i], &info);
+	if (rc == 0) {
+	    ErrorF("%d: ?? [%p]\n", i, array[i]);
+	    continue;
+	}
 	mod = (info.dli_fname && *info.dli_fname) ? info.dli_fname : "(vdso)";
 	if (info.dli_saddr)
 	    ErrorF("%d: %s (%s+0x%lx) [%p]\n", i, mod,

commit 70130bf9e5feaefe9807a47d12c520b91baa5dca
Author: Matthieu Herrb <matthieu.herrb@laas.fr>
Date:   Mon Jan 2 13:23:59 2012 +0000

    Add OpenBSD support to DetermineClientCmd()
    
    Uses kvm_getargv() from libkvm.
    
    Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 6d6d4cb6043905d850834946e9bfc526ed5a9ef7)
    (cherry picked from commit 9a4be7e99f0e832df87b8e7fb548793dd4b52717)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/configure.ac b/configure.ac
index af6ea8c..2c89f08 100644
--- a/configure.ac
+++ b/configure.ac
@@ -999,6 +999,13 @@ if test "x$RES" = xyes && test "x$CLIENTIDS" = xyes; then
 else
 	CLIENTIDS=no
 fi
+if test "x$CLIENTIDS" = xyes; then
+	case $host_os in
+	openbsd*)
+		SYS_LIBS="$SYS_LIBS -lkvm"
+	;;
+	esac
+fi
 AC_MSG_RESULT([$CLIENTIDS])
 AM_CONDITIONAL(CLIENTIDS, [test "x$CLIENTIDS" = xyes])
 
diff --git a/os/client.c b/os/client.c
index e297f8c..aa9be84 100644
--- a/os/client.c
+++ b/os/client.c
@@ -64,6 +64,15 @@
 #include <procfs.h>
 #endif
 
+#ifdef __OpenBSD__
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/types.h>
+
+#include <kvm.h>
+#include <limits.h>
+#endif
+
 /**
  * Try to determine a PID for a client from its connection
  * information. This should be called only once when new client has
@@ -172,7 +181,39 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
         if (cmdargs && sp)
             *cmdargs = strdup(sp);
     }
-#else /* not Solaris */
+#elif defined(__OpenBSD__)
+    /* on OpenBSD use kvm_getargv() */
+    {
+	kvm_t *kd;
+	char errbuf[_POSIX2_LINE_MAX];
+	char **argv;
+	struct kinfo_proc *kp;
+	size_t len = 0;
+	int i, n;
+
+	kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, errbuf);
+	if (kd == NULL)
+		return;
+	kp = kvm_getprocs(kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &n);
+	if (n != 1)
+		return;
+	argv = kvm_getargv(kd, kp, 0);
+	*cmdname = strdup(argv[0]);
+	i = 1;
+	while (argv[i] != NULL) {
+		len += strlen(argv[i]) + 1;
+		i++;
+	}
+	*cmdargs = calloc(1, len);
+	i = 1;
+	while (argv[i] != NULL) {
+		strlcat(*cmdargs, argv[i], len);
+		strlcat(*cmdargs, " ", len);
+		i++;
+	}
+	kvm_close(kd);
+    }
+#else /* Linux using /proc/pid/cmdline */
 
     /* Check if /proc/pid/cmdline exists. It's not supported on all
      * operating systems. */

commit 364540f76e0c80ef26f301785214e6a9cb0e5a04
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Sat Dec 24 10:00:56 2011 -0800

    Add Solaris support to DetermineClientCmd
    
    Uses /proc/pid/psinfo to read command & partial arguments.
    
    Moves cmdsize & argsize variables into non-Solaris #else clause
    to avoid unused variable warnings.
    
    Fixes format mismatch errors when building with DEBUG defined on
    a 64-bit platform (where Mask is defined as CARD32).
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Reviewed-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit cfc4c3d7fa8bd4da4c08b2ab8e6f85435f75353a)
    (cherry picked from commit 8046717d720c1bbbf02ba986622bc96c6b52a36c)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/os/client.c b/os/client.c
index b534977..e297f8c 100644
--- a/os/client.c
+++ b/os/client.c
@@ -59,6 +59,11 @@
 #include "os.h"
 #include "dixstruct.h"
 
+#ifdef __sun
+#include <errno.h>
+#include <procfs.h>
+#endif
+
 /**
  * Try to determine a PID for a client from its connection
  * information. This should be called only once when new client has
@@ -117,8 +122,6 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
 {
     char path[PATH_MAX + 1];
     int totsize = 0;
-    int cmdsize = 0;
-    int argsize = 0;
     int fd = 0;
 
     if (cmdname)
@@ -129,6 +132,48 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
     if (pid == -1)
         return;
 
+#ifdef __sun /* Solaris */
+    /* Solaris does not support /proc/pid/cmdline, but makes information
+     * similar to what ps shows available in a binary structure in the
+     * /proc/pid/psinfo file. */
+    if (snprintf(path, sizeof(path), "/proc/%d/psinfo", pid) < 0)
+        return;
+    fd = open(path, O_RDONLY);
+    if (fd < 0)
+    {
+        ErrorF ("Failed to open %s: %s\n", path, strerror(errno));
+        return;
+    }
+    else
+    {
+        psinfo_t psinfo = { 0 };
+        char *sp;
+
+        totsize = read(fd, &psinfo, sizeof(psinfo_t));
+        close(fd);
+        if (totsize <= 0)
+            return;
+
+        /* pr_psargs is the first PRARGSZ (80) characters of the command
+         * line string - assume up to the first space is the command name,
+         * since it's not delimited.   While there is also pr_fname, that's
+         * more limited, giving only the first 16 chars of the basename of
+         * the file that was exec'ed, thus cutting off many long gnome
+         * command names, or returning "isapython2.6" for all python scripts.
+         */
+        psinfo.pr_psargs[PRARGSZ-1] = '\0';
+        sp = strchr(psinfo.pr_psargs, ' ');
+        if (sp)
+            *sp++ = '\0';
+
+        if (cmdname)
+            *cmdname = strdup(psinfo.pr_psargs);
+
+        if (cmdargs && sp)
+            *cmdargs = strdup(sp);
+    }
+#else /* not Solaris */
+
     /* Check if /proc/pid/cmdline exists. It's not supported on all
      * operating systems. */
     if (snprintf(path, sizeof(path), "/proc/%d/cmdline", pid) < 0)
@@ -146,7 +191,6 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
     path[totsize - 1] = '\0';
 
     /* Contruct the process name without arguments. */
-    cmdsize = strlen(path) + 1;
     if (cmdname)
     {
         char *name = malloc(cmdsize);
@@ -159,10 +203,14 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
     }
 
     /* Construct the arguments for client process. */
-    argsize = totsize - cmdsize;
-    if (cmdargs && (argsize > 0))
+    if (cmdargs)
     {
-        char *args = malloc(argsize);
+        int cmdsize = strlen(path) + 1;
+        int argsize = totsize - cmdsize;
+        char *args = NULL;
+
+        if (argsize > 0)
+            args = malloc(argsize);
         if (args)
         {
             int i = 0;
@@ -175,6 +223,7 @@ void DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
             *cmdargs = args;
         }
     }
+#endif
 }
 
 /**
@@ -198,9 +247,9 @@ void ReserveClientIds(struct _Client *client)
         DetermineClientCmd(client->clientIds->pid, &client->clientIds->cmdname, &client->clientIds->cmdargs);
 
     DebugF("client(%lx): Reserved pid(%d).\n",
-           client->clientAsMask, client->clientIds->pid);
+           (unsigned long) client->clientAsMask, client->clientIds->pid);
     DebugF("client(%lx): Reserved cmdname(%s) and cmdargs(%s).\n",
-           client->clientAsMask,
+           (unsigned long) client->clientAsMask,
            client->clientIds->cmdname ? client->clientIds->cmdname : "NULL",
            client->clientIds->cmdargs ? client->clientIds->cmdargs : "NULL");
 #endif /* CLIENTIDS */
@@ -222,9 +271,9 @@ void ReleaseClientIds(struct _Client *client)
         return;
 
     DebugF("client(%lx): Released pid(%d).\n",
-           client->clientAsMask, client->clientIds->pid);
+           (unsigned long) client->clientAsMask, client->clientIds->pid);
     DebugF("client(%lx): Released cmdline(%s) and cmdargs(%s).\n",
-           client->clientAsMask,
+           (unsigned long) client->clientAsMask,
            client->clientIds->cmdname ? client->clientIds->cmdname : "NULL",
            client->clientIds->cmdargs ? client->clientIds->cmdargs : "NULL");
 

commit 2c973d2c078e8af01a06334a4a2ee8705e369bf2
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Nov 9 15:31:10 2011 +1000

    Xext: don't swap CARD8 in SProcSELinuxQueryVersion
    
    xselinux_ext.c: In function 'SELinuxSendItemsToClient':
    xselinux_ext.c:340:16: warning: unused variable 'n' [-Wunused-variable]
    xselinux_ext.c: In function 'SProcSELinuxQueryVersion':
    xselinux_ext.c:532:62: error: call to 'wrong_size' declared with attribute
    error: wrong sized variable passed to swap
    xselinux_ext.c:533:62: error: call to 'wrong_size' declared with attribute
    error: wrong sized variable passed to swap
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Julien Cristau <jcristau@debian.org>
    (cherry picked from commit bb4aa1f263ad38c175bfda3b7e6c325260ce3f28)
    
    Conflicts:
    
    	Xext/xselinux_ext.c
    (cherry picked from commit cf296f2eeffe4b438e9378268f84a1f63c555e52)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/Xext/xselinux_ext.c b/Xext/xselinux_ext.c
index 374571c..85ca2dc 100644
--- a/Xext/xselinux_ext.c
+++ b/Xext/xselinux_ext.c
@@ -528,12 +528,6 @@ ProcSELinuxDispatch(ClientPtr client)
 static int
 SProcSELinuxQueryVersion(ClientPtr client)
 {
-    REQUEST(SELinuxQueryVersionReq);
-    int n;
-
-    REQUEST_SIZE_MATCH(SELinuxQueryVersionReq);
-    swaps(&stuff->client_major, n);
-    swaps(&stuff->client_minor, n);
     return ProcSELinuxQueryVersion(client);
 }
 


Reply to: