Commit Graph

452 Commits

Author SHA1 Message Date
Jeremy Huddleston
a818b30598 os: Pass the FatalError message to OsVendorFatalError
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2012-03-24 01:07:05 -07:00
Peter Hutterer
a7eac500e6 Merge branch 'per-device-sync-counters' into for-keith 2012-03-22 13:13:07 +10:00
Peter Hutterer
6aef209ebc Change lastDeviceIdleTime to be per-device
Preparation work for per-device idle counters.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: James Jones <jajones@nvidia.com>
2012-03-22 13:12:56 +10:00
Peter Hutterer
14e3ea730e include: add an X_DEBUG message type
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2012-03-22 11:33:21 +10:00
Keith Packard
9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Peter Hutterer
a60d87ffe6 os: prettify backtrace output
Changes to output:
* "Backtrace:" now appears on a separate line _with_ a timestamp
* A blank line is inserted after the last backtrace line

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2012-01-13 09:03:05 +10:00
Keith Packard
5de0c2582f Revert "os: Repack ConnectionOutput for LP64"
This reverts commit d5f724544a.

ABI change pended for 1.13
2012-01-12 12:10:07 -08:00
Keith Packard
d9eeede52f Revert "dix: Pull client-is-local flag up to the ClientRec"
This reverts commit 49d38b75c8.

ABI change pended for 1.13
2012-01-12 12:09:59 -08:00
Keith Packard
3be37375ee Revert "dix: Extend initial connection handshake for forwarding proxies"
This reverts commit 78fa121f40.

ABI change pended for 1.13
2012-01-12 12:09:55 -08:00
Keith Packard
5b9f5c8a53 Revert "os: Hide the Connection{In,Out}put implementation details"
This reverts commit 48e7a2ef57.

ABI change pended for 1.13
2012-01-12 12:09:44 -08:00
Matthieu Herrb
6d6d4cb604 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>
2012-01-09 13:09:49 -08:00
Keith Packard
0b113f7cdf Merge commit '777bf90abeac37087a3d0538b847742523d5acf2' 2012-01-09 13:07:25 -08:00
Keith Packard
1f5587e144 Merge remote-tracking branch 'kibi/master' 2012-01-09 11:37:59 -08:00
Adam Jackson
c44ef2e1ff os: Minor header cleanup
Move some constants near their only users, and remove some
getdtablesize() logic that's second-guessing configure.

Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-01-06 13:29:53 -05:00
Adam Jackson
48e7a2ef57 os: Hide the Connection{In,Out}put implementation details
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-01-06 13:29:53 -05:00
Adam Jackson
78fa121f40 dix: Extend initial connection handshake for forwarding proxies
Forwarding proxies like sshd will appear to be local, even though they
aren't really.  This leads to weird behaviour for extensions that truly
require running under the same OS services as the client, like MIT-SHM
and DRI2.

Add two new legal values for the initial connection's byteOrder field,
'r' and 'R'.  These act like 'l' and 'B' respectively, but have the side
effect of forcing the client to be treated as non-local.  Forwarding
proxies should attempt to munge the first packet of the connection
accordingly; older servers will reject connections thusly munged, so the
proxy should fall back to passthrough if the munged connection attempt
fails.

Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-01-06 13:29:53 -05:00
Adam Jackson
49d38b75c8 dix: Pull client-is-local flag up to the ClientRec
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-01-06 13:29:53 -05:00
Adam Jackson
d5f724544a os: Repack ConnectionOutput for LP64
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-01-06 13:29:53 -05:00
Julien Cristau
6269977c91 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>
2011-12-31 02:34:55 +01:00
Alan Coopersmith
cfc4c3d7fa 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>
2011-12-27 13:12:27 -08:00
Alan Coopersmith
83ac9502ea xdmcp.c: fix three small const warnings
xdmcp.c:63:36: warning: initialization discards qualifiers from pointer target type

xdmcp.c: In function 'XdmcpRegisterConnection':
xdmcp.c:482:8: warning: cast discards qualifiers from pointer target type
xdmcp.c:482:8: warning: cast discards qualifiers from pointer target type
xdmcp.c:482:8: warning: cast discards qualifiers from pointer target type

xdmcp.c: In function 'get_mcast_options':
xdmcp.c:1596:21: warning: initialization discards qualifiers from pointer target type

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:10 -08:00
Alan Coopersmith
3839d14808 LockServer: store path to LOCKDIR literal string in a const char *
And instead of initializing to NULL, then resetting to LOCKDIR almost
immediately (before ever using the NULL value), skip directly to setting
it to LOCKDIR.

tmppath variable is only used as input for generating the path name
via calls to strlen, sprintf, etc.

Fixes gcc warning of:
utils.c: In function 'LockServer':
utils.c:259:11: warning: assignment discards qualifiers from pointer target type

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:10 -08:00
Alan Coopersmith
af4113bfeb WriteToClient: preserve constness of buf while extracting length value
Fixes gcc warning:
io.c: In function 'WriteToClient':
io.c:826:6: warning: cast discards qualifiers from pointer target type

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:10 -08:00
Alan Coopersmith
2c9800f915 OsInit: store "/dev/null" in a const char *
It's only passed as the input side of a strcpy and as the filename to
fopen, so doesn't need to be non-const.   Fixes gcc warning:

osinit.c: In function 'OsInit':
osinit.c:154:28: warning: initialization discards qualifiers from pointer target type

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:10 -08:00
Alan Coopersmith
50b1097643 Constify the reason string throughout the authorization check framework
Almost all of the places the string is assigned point to a literal
string constant, so use const char * for those, and const char **
for function calls that return it via an argument.   Fortunately
the top level function, ClientAuthorized, which returns the string
as its return value is called from only one place, ProcEstablishConnection.

ProcEstablishConnection stores either that return value or a string literal
in char *reason.  It only uses reason as an argument to SendConnSetup.
SendConnSetup passes the reason argument to strlen & WriteToClient,
both of which already have const qualifiers on their args.
Thus added const to the reason variable in ProcEstablishConnection
and the reason argument to SendConnSetup.

Fixes gcc warnings:
dispatch.c: In function 'ProcEstablishConnection':
dispatch.c:3711:9: warning: assignment discards qualifiers from pointer target type
auth.c: In function 'CheckAuthorization':
auth.c:218:14: warning: assignment discards qualifiers from pointer target type
auth.c:220:20: warning: assignment discards qualifiers from pointer target type
connection.c: In function 'ClientAuthorized':
connection.c:683:3: warning: return discards qualifiers from pointer target type
mitauth.c: In function 'MitCheckCookie':
mitauth.c:88:13: warning: assignment discards qualifiers from pointer target type
xdmauth.c:259:14: warning: assignment discards qualifiers from pointer target type
xdmauth.c:270:14: warning: assignment discards qualifiers from pointer target type
xdmauth.c:277:11: warning: assignment discards qualifiers from pointer target type
xdmauth.c:293:15: warning: assignment discards qualifiers from pointer target type
xdmauth.c:313:14: warning: assignment discards qualifiers from pointer target type
xdmauth.c:322:11: warning: assignment discards qualifiers from pointer target type
rpcauth.c: In function 'SecureRPCCheck':
rpcauth.c:136:10: warning: assignment discards qualifiers from pointer target type

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:10 -08:00
Alan Coopersmith
9999819601 Constify string for authorization protocol names
gcc was warning from storing string constants in a char *name field:
auth.c:64:1: warning: initialization discards qualifiers from pointer target type
auth.c:72:1: warning: initialization discards qualifiers from pointer target type
auth.c:81:1: warning: initialization discards qualifiers from pointer target type

Making the field const requires changing AuthorizationFromID to take
a const char ** pointer for the name argument which it sets to point
to the matching name entry.

Changing that argument requires changing its sole caller in the security
extension to pass the address of a const char * variable to it, which it
can do, since the only thing it does with the returned name is to pass
it back to the RemoveAuthorization function that already expects a const
char *name.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:10 -08:00
Alan Coopersmith
01834e99e4 os/access.c: replace acmp & acopy macros with memcmp & memcpy calls
No need to cast to char * now that all supported platforms use C89-standard
void * argument types, so just drop the casts from acmp & acopy macros,
which clears the gcc warnings for places const pointers were cast non-const:

access.c: In function 'DefineSelf':
access.c:786:3: warning: cast discards qualifiers from pointer target type
access.c:795:6: warning: cast discards qualifiers from pointer target type
access.c: In function 'NewHost':
access.c:1293:9: warning: cast discards qualifiers from pointer target type
access.c:1298:6: warning: cast discards qualifiers from pointer target type
access.c:1309:5: warning: cast discards qualifiers from pointer target type

Without the casts, acmp & acopy are just a funny way to write memcmp
& memmove, so drop the macros and inline the calls, taking care to
swap the first two arguments to memmove since it had swapped them.

Since all the calls to memmove end up being to non-overlapping memory
(mostly copying from an existing pointer to a newly allocated one),
replace those with memcpy.

And finally, don't actually call memcpy to copy 0 bytes from one place
to another, since that's just a waste of a perfectly good function call.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:09 -08:00
Alan Coopersmith
d829a7c5cb Move to autoconf standard function name checks & defines
Replace multiple methods of checking for functions with AC_CHECK_FUNCS
Replace multiple methods of selecting fallback funcs with AC_REPLACE_FUNCS
Replace HAS_* and NEED_* #defines with autogenerated HAVE_*

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Gaetan Nadon <memsize@videotron.ca>
2011-12-05 14:32:45 -08:00
Alan Coopersmith
cccafabd56 Mark arguments to fopen/popen/system wrappers as const char *
Silencing more gcc -Wwrite-strings warnings

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:06 -08:00
Alan Coopersmith
05d8a7f7a7 Convert a bunch of sprintf to snprintf calls
This batch is the straightforward set - others are more complex and
need more analysis to determine right size to pass.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:06 -08:00
Alan Coopersmith
f3cb512dc4 LogVMessageVerb: Fix const mismatch warning
"log.c", line 382: warning: assignment type mismatch:
	pointer to char "=" pointer to const char

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:06 -08:00
Alan Coopersmith
3d2d88029b AuthAudit: clean up string handling calls
The extra "out" pointer to redirect writes to the array isn't needed since
the removal of LBX (commit a9ed5a8790), and eliminating it allows more
logical use of sizeof(addr) in length-checked strlcpy & snprintf calls to
write to it.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:06 -08:00
Alan Coopersmith
780133f9ae 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>
2011-11-23 12:15:05 -08:00
Alan Coopersmith
6e6d732bac Convert strncpy/strncat to strlcpy/strlcat
As long as we're carrying around a compatibility copy in os/strl*.c,
might as well use them.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:05 -08:00
Alan Coopersmith
08093c25a9 Convert some malloc + strncpy pairs into strndup calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:05 -08:00
Alan Coopersmith
acde97a39d Add fallback implementation of strndup()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Linux test code fixed by: Keith Packard <keithp@keithp.com>
2011-11-23 12:15:05 -08:00
Alan Coopersmith
7ee7fd1f4c Remove a couple Error() instances left behind by 09dbfcb0ad
Two instances found in the SIOCGIFCONF code for listing network interfaces.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-11-23 12:15:05 -08:00
Rami Ylimäki
c1bb8f43b9 record: Prevent out of bounds access when recording a reply.
Any pad bytes in replies are written to the client from a zeroed
array. However, record extension tries to incorrectly access the pad
bytes from the end of reply data.

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
2011-11-18 11:26:02 -08:00
Keith Packard
c841336204 Merge remote-tracking branch 'herrb/master' 2011-10-18 07:45:24 -07:00
Matthieu Herrb
b67581cf82 Fix CVE-2011-4029: File permission change vulnerability.
Use fchmod() to change permissions of the lock file instead
of chmod(), thus avoid the race that can be exploited to set
a symbolic link to any file or directory in the system.

Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-10-18 15:58:00 +02:00
Matthieu Herrb
6ba44b91e3 Fix CVE-2011-4028: File disclosure vulnerability.
use O_NOFOLLOW to open the existing lock file, so symbolic links
aren't followed, thus avoid revealing if it point to an existing
file.

Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-10-18 15:58:00 +02:00
Jeremy Huddleston
09dbfcb0ad os: Remove Error()
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-11 21:23:46 -07:00
Keith Packard
9a55b3661b Merge remote-tracking branch 'alanc/master' 2011-10-03 11:49:23 -07:00
Keith Packard
afb1fe695d Merge remote-tracking branch 'whot/next' 2011-09-26 20:24:15 -07:00
Gaetan Nadon
84bb0207f6 dix and os: gitignore dix.O and os.O
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-09-23 17:14:47 -07:00
Matt Turner
2c7c520cfe Use internal temp variable for swap macros
Also, fix whitespace, mainly around
	swaps(&rep.sequenceNumber)

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2011-09-21 17:12:04 -04:00
Lennart Poettering
159b03e137 config: add udev/systemd multi-seat support
Add support for multi-seat-aware input device hotplugging. This
implements the multi-seat scheme explained here:

http://www.freedesktop.org/wiki/Software/systemd/multiseat

This introduces a new X server switch "-seat" which allows configuration
of the seat to enumerate hotplugging devices on. If specified the value
of this parameter will also be exported as root window property
Xorg_Seat.

To properly support input hotplugging devices need to be tagged in udev
according to the seat they are on. Untagged devices are assumed to be on
the default seat "seat0". If no "-seat" parameter is passed only devices
on "seat0" are used. This means that the new scheme is perfectly
compatible with existing setups which have no tagged input devices.

Note that the -seat switch takes a completely generic identifier, and
that it has no effect on non-Linux systems. In fact, on other OSes a
completely different identifier scheme for seats could be used but still
be exposed with the Xorg_Seat and -seat.

I tried to follow the coding style of the surrounding code blocks if
there was any one could follow.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-08-22 15:56:49 +10:00
Daniel Kurtz
b31d104fc0 os/log: Add LogVHdrMessageVerb and friends
LogVHdrMessageVerb allows a custom header to be inserted in a log message,
between the Log system's MessageType string, and a formatted variable
message body. The custom header can itself be a formatted variable string.

These functions can be used, for example, by driver abstraction layers to
format specific driver messages in a standard format, but do it in a way
that is efficient, obeys the log-layers verbosity settings, and is safe
to use in signal handlers (because they don't call malloc), even for
types besides X_NONE.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-08-22 15:49:18 +10:00
Daniel Kurtz
b82f934db6 os/log: Pull LogMessageTypeVerbString out of LogVMessageVerb
Also, optimize how the type and format strings are combined.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-08-22 15:48:14 +10:00
Peter Hutterer
f51e42f583 Terminate the log with one last message.
Instead of just closing the log when everything is done, put one more
message in stating that we're actually terminating. Users or scripts that
look at the Xorg.log will then know that a) the server has terminated
properly and b) why the server terminated (to some degree, given that most
real-world errors will be caused by AbortServer()).

Acked-by: Gaetan Nadon <memsize@videotron.ca>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Tested-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Tested-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-07-27 09:31:02 +10:00