Commit Graph

768 Commits

Author SHA1 Message Date
Jon TURNEY
28337cb14e xserver: Move 'pragma GCC diagnostic' outside functions
$ gcc --version
gcc (Gentoo 4.4.3-r2 p1.2) 4.4.3

/jhbuild/checkout/xorg/xserver/os/log.c: In function ‘LogInit’:
/jhbuild/checkout/xorg/xserver/os/log.c:199: error: #pragma GCC diagnostic not allowed inside functions
/jhbuild/checkout/xorg/xserver/os/log.c:201: warning: format not a string literal, argument types not checked
/jhbuild/checkout/xorg/xserver/os/log.c:212: error: #pragma GCC diagnostic not allowed inside functions
/jhbuild/checkout/xorg/xserver/os/log.c:214: warning: format not a string literal, argument types not checked

etc.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-09-18 22:28:27 -07:00
Jon TURNEY
e3aa13b8d6 Update help text since -iglx is now the default
This should have been part of d0da0e9c3b

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-09-17 15:45:05 -07:00
Eric Anholt
d0da0e9c3b glx: Disable indirect GLX contexts by default.
Almost every situation of someone running indirect GLX is a mistake
that results in X Server crashes.  Indirect GLX is the cause of
regular security vulnerabilities, and rarely provides any capability
to the user.  Just disable it unless someone wants to enable it for
their special use case (using +iglx on the command line).

Signed-off-by: Eric Anholt <eric@anholt.net>
Acked-by:  Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-09-11 18:24:03 -07:00
Thomas Petazzoni
7a0c79c8c4 os/log: adjust gcc version conditions for #pragma
In commit e67f2d7e0f ("gcc 4.2.1 doesn't
support #pragma GCC diagnostic ignored"), some compile time
conditionals were added around the #pragma usage. Those conditionals
ensure that the #pragma are not used on gcc <= 4.2.

However, the usage of #pragma diagnostic inside functions was only
added in gcc 4.6, and a build failure is therefore experienced with
gcc 4.5:

log.c: In function 'LogInit':
log.c:199:9: error: #pragma GCC diagnostic not allowed inside functions
log.c:201:9: warning: format not a string literal, argument types not checked
log.c:212:9: error: #pragma GCC diagnostic not allowed inside functions
log.c:214:17: warning: format not a string literal, argument types not checked

$ ./host/usr/bin/powerpc-linux-gnu-gcc -v
[...]
gcc version 4.5.2 (Sourcery G++ Lite 2011.03-38)

This patch therefore adjusts the compile time conditionals to make
sure the #pragma is not used on gcc <= 4.5, and only used on gcc >=
4.6.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by:  Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-09-11 18:18:09 -07:00
Keith Packard
d09c9ddb86 Merge remote-tracking branch 'jeremyhu/master' 2014-08-12 16:34:24 -07:00
Daphne Pfister
4599a4492c os: Regenerate os/oscolor.c from app/rgb #52289
Regenerate os/oscolor.c from rgb.txt. This adds the following
colors: aqua, lime, fuchsia, crimson, indigo, olive, rebecca
purple, silver and teal. It also adds versions of gray, grey,
green, maroon and purple prefixed with web and x11 for the
colors that are different between X11 and HTML/CSS web colors.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=52289
Related: https://bugs.freedesktop.org/show_bug.cgi?id=80371

Signed-off-by: nobody
Tested-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-08-12 15:51:52 -07:00
Jeremy Huddleston Sequoia
dfbc6a1a78 ListenOnOpenFD: Remove Resets since this is intended to be for hotplugging connections
pharris says that the resets should not be done in the hotplugging case.

This may fix a crash reported against XQuartz:
http://xquartz.macosforge.org/trac/ticket/869

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Peter Harris <pharris@opentext.com>
2014-08-11 12:49:54 -07:00
Adam Jackson
578026fcd5 os: Remove LocalClientCred
The comment lies, shm hasn't used this code since:

    commit fdef7be5c8
    Author: Alan Coopersmith <alan.coopersmith@sun.com>
    Date:   Tue Oct 9 18:44:04 2007 -0700

        Sun bug 6589829: include zoneid of shm segment in access [...]

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2014-07-29 09:52:04 -04:00
Adam Jackson
cad9b053d5 os: Remove deprecated malloc/free wrappers
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2014-07-29 09:51:50 -04:00
Peter Harris
5eb77697ea Avoid starting a comment with */*
Even though -Wcomment doesn't mind it (in gcc or clang), the appearance
of */* confuses the syntax highlighter of some editors (eg. vim), and
causes warnings in MSVC.

Signed-off-by: Peter Harris <pharris@opentext.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-07-17 10:19:52 -07:00
Peter Hutterer
daa1a9d22d os: prevent negative array index access (#80890)
If an empty string is provided to LogMessageVerbSigSafe, the length of the
printed string is 0.

Read-only access only and the only effect it had was adding a linebreak or not.

X.Org Bug 80890 <http://bugs.freedesktop.org/show_bug.cgi?id=80890>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-07-10 10:24:04 +10:00
Peter Hutterer
d3a3ee7a0e os: automatically switch to sigsafe logging when needed
If we're smart enough to warn, we should be smart enough to just pass it
through to the right function. Worst case we lose some formatting specifiers
which pnprintf will complain about anyway. And in most cases it won't matter.

This requires renaming pnprintf to vpnprintf and changing the size_t to int to
be compatible with Xvscnprintf. pnprintf is internal only, the others are
exported API so we can't change them as easily.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-05-23 11:08:13 +10:00
Robert Ancell
2535b76c0d os: Add -displayfd into -help text
Add -displayfd into -help text. It was mentioned in the man page but seem to have been missed from the -help text.

Signed-off-by: Keith Packard <keithp@keithp.com>
2014-04-30 10:23:54 -07:00
Eric Anholt
99f0365b1f Add a command line argument for disabling indirect GLX.
The attack surface for indirect GLX is huge, and it's of no use to
most people (if you get an indirect GL context, you're better served
by a immediate X error than actually trying to use an indirect GL
context and finding out that it doesn't support doing anything you
want, slowly).  This flag gives you a chance to disable indirect GLX
in environments where you just don't need it.

I put in both the '+' and '-' arguments right now, so that it's easy
to patch the value to change the default policy.

Signed-off-by: Eric Anholt <eric@anholt.net>
Acked-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-04-23 13:24:22 -07:00
Eric Anholt
35d275c751 os: Initialize the set of signals to be suppressed during our handler.
Fixes a valgrind complaint:

==8805== Syscall param rt_sigaction(act->sa_mask) points to uninitialised byte(s)
==8805==    at 0x5EB8315: __libc_sigaction (sigaction.c:66)
==8805==    by 0x5B13DA: busfault_init (busfault.c:145)
==8805==    by 0x5A60A2: OsInit (osinit.c:191)
==8805==    by 0x46EBA2: dix_main (main.c:163)

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-04-21 22:05:00 -07:00
Keith Packard
0af8788579 os: Ignore log file write failures
There's no place to log the message if writing to the log file fails,
and we surely don't want to crash in that case, so just ignore errors
and keep going.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2014-04-18 16:30:17 -07:00
Keith Packard
7abd286850 os: Make sure that writing our pid to the lock file actually worked
There's no sense verifying that we can create the lock file and then
ignoring the return value from write.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2014-04-18 16:30:17 -07:00
Keith Packard
d72f691c0c os: FatalError if -displayfd writes fail
When the server is started with the -displayfd option, check to make
sure that the writes succeed and give up running if they don't.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2014-04-18 16:30:17 -07:00
Keith Packard
4957e98684 os: Clear the -displayfd option after closing the file
Failing to clear this means that we'll attempt to write the display
number to a random file descriptor on subsequent X server generations.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2014-04-18 16:30:17 -07:00
Jon TURNEY
bc348bd2c4 Handle -displayfd and an explicit display number sensibly
Handle -displayfd and an explicit display number sensibly, e.g. use the
explicitly specified display number, and write it to the displayfd

v2: displayfd might be 0, so use -1 as invalid value
v3: Rebase for addition of NoListenAll flag

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-03-27 14:34:34 +00:00
Kristian Høgsberg
215f3d2e0f os: Add AddClientOnOpenFD() to create a new client for an file descriptor
When the Xwayland server is socket-activated, we need to connect and
initialize the window manager before the activating client gets to
proceed with connecting.  We do this by passing a socket file
descriptor for the window manager connection to the Xwayland server,
which then uses this new function to set it up as an X client.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-03-25 08:46:12 +10:00
Kristian Høgsberg
44fe1b8ea2 os: Add a mechanism to prevent creating any listen sockets
A socket-activated server will receive its listening sockets from the
parent process and should not create its own sockets.  This patch
introduces a NoListen flag that can be set by a DDX to prevent
the server from creating the sockets.  When NoListen is enabled, we
also disable the server lock checking, since the parent process is
responsible for checking the lock before picking the display name and
creating the sockets.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2014-03-20 09:23:16 +10:00
Kristian Høgsberg
62d584d631 os: Always compile ListenOnOpenFD() and export it
This function was written to allow the X server to inherit the listen
socket from launchd on OS X.  The code is not specific to OS X though
and will be useful for on-demand launched Xwayland servers.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2014-03-20 09:23:09 +10:00
Matthieu Herrb
e67f2d7e0f gcc 4.2.1 doesn't support #pragma GCC diagnostic ignored
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-02-24 16:30:07 -08:00
Peter Hutterer
675f215af2 Revert "os: xstrtokenize takes and returns const char * now"
This reverts commit d0339a5c66.

seriously, what the fuck? Are we making xstrdup() return a const char now too?

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-02-04 11:27:48 +10:00
Keith Packard
08d0481e29 os: Fix -Wshadow errors
Rename variables to avoid shadowing globals

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-22 19:56:31 -08:00
Keith Packard
1ad8d12e7f Ignore a couple of format-nonliteral warnings
These are generated in code which uses sprintf as a convenient way to
construct strings from various pieces.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-22 19:56:31 -08:00
Keith Packard
25ebb9dbc9 Merge remote-tracking branch 'whot/for-keith' 2014-01-22 11:33:53 -08:00
Alan Coopersmith
457bc83549 If EAGAIN == EWOULDBLOCK, only need to check errno for one of them
Solaris <sys/errno.h> has:
 #define EWOULDBLOCK       EAGAIN
so checking (errno == EAGAIN || errno == EWOULDBLOCK) is overkill.

This leads cppcheck 1.62 to complain:
[xserver/os/io.c:365] -> [xserver/os/io.c:365]: (style) Same expression on both sides of '||'.
[xserver/os/io.c:941] -> [xserver/os/io.c:941]: (style) Same expression on both sides of '||'.

This quiets it, and reduces the number of calls Solaris Studio cc
generates to the __errno() function to get the thread-specific errno value.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-01-22 11:30:27 -08:00
Peter Hutterer
71baa466b1 os: restrict display names to digits
We call atoi() on the server's display to get the socket but otherwise use the
unmodified display for log file name, xkb paths, etc. This results in
Xorg :banana being the equivalent of Xorg :0, except for the log files being
in /var/log/Xorg.banana.log. I'm not sure there's a good use-case for this
behaviour.

Check the display for something that looks reasonable, i.e. digits only, but
do allow for :0.0 (i.e. digits, followed by a period, followed by one or two
digits).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-01-15 08:09:47 +10:00
Keith Packard
2d2d49dab5 Clean up a few function prototypes to not place formals in /**/
This just removes the comment markers from around the formals in
several function prototypes near where pointer -> void * changes were
made. There are plenty more of these to fix.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-01-12 10:24:12 -08:00
Keith Packard
60014a4a98 Replace 'pointer' type with 'void *'
This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer'
is used throughout the X server for other things, and having duplicate
names generates compiler warnings.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-12 10:24:11 -08:00
Keith Packard
d0339a5c66 os: xstrtokenize takes and returns const char * now
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-01-12 10:14:50 -08:00
Keith Packard
abce3206cb os: Clean up warnings
Just const char stuff.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-01-12 10:14:49 -08:00
Jeremy Huddleston Sequoia
ad8111d7c9 darwin: Don't leave stdin/stdout closed
<rdar://problem/15609419>

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2013-12-12 01:30:04 -08:00
Keith Packard
b6d7ed4d78 miext: Move SyncShm FDs out of the way of clients
Applications may end up allocating a bunch of shmfence objects, each
of which uses a file descriptor, which must be kept open lest some
other client ask for a copy of it later on.

Lacking an API that can turn a memory mapping back into a file
descriptor, about the best we can do is push the file descriptors out
of the way of other X clients so that we don't run out of the ability
to accept new connections.

This uses fcntl F_GETFD to push the FD up above MAXCLIENTS.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2013-12-02 12:57:08 -08:00
Keith Packard
d7f9be0f85 Proper spelling of MAP_ANONYMOUS is MAP_ANON.
The former doesn't exist on BSD and the latter is available everywhere
AFAIK (checked Solaris and Linux).

You also might want to wrap that line ;).

Reported-by: Mark Kettenis <mark.kettenis@xs4all.nl>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-11-11 15:48:41 -08:00
Keith Packard
fc84166e65 Get rid of the rest of the FD passing code when XTRANS_SEND_FDS isn't set
req_fds and SetReqFds in include/dixstruct.h

ReadFdFromClient, WriteFdToClient and the FD flushing in os/io.c

Signed-off-by: Keith Packard <keithp@keithp.com>
2013-11-11 15:32:07 -08:00
Keith Packard
41da295eb5 Trap SIGBUS to handle truncated shared memory segments
If a client passes a section of memory via file descriptor and then
subsequently truncates that file, the underlying pages will be freed
and the addresses invalidated. Subsequent accesses to the page will
fail with a SIGBUS error.

Trap that SIGBUS, figure out which segment was causing the error and
then allocate new pages to fill in for that region. Mark the offending
shared segment as invalid and free the resource ID so that the client
will be able to tell when subsequently attempting to use the segment.

Signed-off-by: Keith Packard <keithp@keithp.com>

v2: Use MAP_FIXED to simplify the recovery logic (Mark Kettenis)
v3: Also catch errors in ShmCreateSegment

Conflicts:
	include/dix-config.h.in
	include/xorg-config.h.in
2013-11-11 15:16:07 -08:00
Julien Cristau
5f1e832694 os: Actually use the computed clockid in GetTimeInMicros
The selection of which clock to use for this function was not actually
getting used when fetching the final clock value.

Reported-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-11-05 08:06:09 -08:00
Keith Packard
977e2644b1 Merge remote-tracking branch 'whot/for-keith' 2013-11-01 00:34:18 -07:00
Keith Packard
fdec793cdc Add support for MIT-SHM AttachFd request
This passes a file descriptor from the client to the server, which is
then mmap'd

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-10-31 16:58:28 -07:00
Keith Packard
9fd35daa31 Add interfaces to get FDs from clients over the socket
This adds two interfaces:

    void SetReqFds(ClientPtr client, int req_fds)

	Marks the number of file descriptors expected for this
	request. Call this before any request processing so that
	any un-retrieved file descriptors will be closed
	automatically.

    int ReadFdFromClient(ClientPtr client)

	Reads the next queued file descriptor from the connection. If
	this request is not expecting any more file descriptors, or
	if there are no more file descriptors available from the
	connection, then this will return -1.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-10-31 16:58:25 -07:00
Keith Packard
2d96948ab5 os: Add GetTimeInMicros
64-bit higher resolution current time value.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-10-31 16:58:21 -07:00
Keith Packard
d25c217964 Clean up a couple of warnings in os/
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-10-31 16:58:12 -07:00
Peter Hutterer
e8961b718d os: use a constant for backtrace array size
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2013-11-01 09:39:53 +10:00
Peter Hutterer
efc1035ca9 dix: provide accessor methods for the last device event time
And now that we have the accessors, localize it. No functional changes, just
preparing for a future change.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-10-18 16:44:32 +10:00
Pino Toscano
ccbe17b1c6 os: move <arpa/inet.h> for any !win32 system
It is needed in IPv6 configurations (for inet_pton) also when
SIOCGIFCONF is not defined.

Signed-off-by: Pino Toscano <toscano.pino@tiscali.it>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Julien Cristau <jcristau@debian.org>
2013-10-05 15:26:55 +02:00
Adam Jackson
abbd85742a dix: FIXES is not optional
It's already not optional at configure time, this just makes it so at
build time too.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-09-10 13:28:24 -04:00
Adam Jackson
e2b14a1d3b os: Factor out some common code in input buffer handling
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-09-10 13:28:23 -04:00
Chris Wilson
9bf46610a9 os: Immediately queue initial WriteToClient
If we immediately put the WriteToClient() buffer into the socket's write
queue, not only do we benefit from sending the response back to client
earlier, but we also avoid the overhead of copying the data into our own
staging buffer and causing extra work in the next select(). The write is
effectively free as typically we may only send one reply per client per
select() call, so the cost of the FlushClient() is the same.

shmget10:   26400 -> 110000
getimage10: 25000 -> 108000

shmget500:   3160 -> 13500
getimage500: 1000 -> 1010

The knock-on effect is that on a mostly idle composited desktop, the CPU
overhead is dominated by the memmove in WriteToClient, which is in turn
eliminated by this patch.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-09-10 13:26:25 -04:00
Jon TURNEY
59a6d3f1eb os: Remove any old logfile before trying to write to it
If we are not backing up logfiles, remove the old logfile before trying to write
a new logfile, as otherwise the operation may fail if the previous logfile was
created by a different user.

This change is useful when:
- The DDX doesn't use the logfile backup mechanism (i.e. not Xorg)
- The DDX is run by a non-root user, and then by a different non-root user
- The logfile directory doesn't have the restricted-deletion flag set

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Acked-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-07-11 07:39:03 +10:00
Robert Morell
67c66606c7 os: Reset input buffer's 'ignoreBytes' field
If a client sends a request larger than maxBigRequestSize, the server is
supposed to ignore it.

Before commit cf88363d, the server would simply disconnect the client.  After
that commit, it attempts to gracefully ignore the request by remembering how
long the client specified the request to be, and ignoring that many bytes.
However, if a client sends a BigReq header with a large size and disconnects
before actually sending the rest of the specified request, the server will
reuse the ConnectionInput buffer without resetting the ignoreBytes field.  This
makes the server ignore new X clients' requests.

This fixes that behavior by resetting the ignoreBytes field when putting the
ConnectionInput buffer back on the FreeInputs list.

Signed-off-by: Robert Morell <rmorell@nvidia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-05-10 09:02:57 +10:00
Peter Hutterer
042c6d861f os: Use ErrorFSigSafe from FatalError and it's friends
Backtrace logging etc. is already sigsafe, but the actual FatalError message
in response is not yet, leading to amusing logs like this:

    (EE) Segmentation fault at address 0x0
    (EE) BUG: triggered 'if (inSignalContext)'
    (EE) BUG: log.c:499 in LogVMessageVerb()
    (EE) Warning: attempting to log data in a signal unsafe manner while in
    signal context.
    Please update to check inSignalContext and/or use LogMessageVerbSigSafe() or
    ErrorFSigSafe().
    The offending log format message is:

    Fatal server error:

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-07 09:41:14 +10:00
Peter Hutterer
d9848fb4b1 os: complain about unsupported pnprintf directives
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-07 09:41:11 +10:00
Peter Hutterer
d903d17d7f os: support %c in pnprintf
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-07 09:41:09 +10:00
Peter Hutterer
58ef34ee6d os: support %% in pnprintf
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-07 09:41:07 +10:00
Peter Hutterer
5ea21560dd os: support pnprintf length modifiers for integers
Mainly for %ld, smaller than int is propagated anyway, and %lld isn't really
used.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-07 09:41:05 +10:00
Peter Hutterer
44fc062f85 os: document pnprintf as sigsafe snprintf
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-03-06 09:23:20 +10:00
Marcin Slusarz
e21e183059 os: use libunwind to generate backtraces
Libunwind generates backtraces much more reliably than glibc's "backtrace".

Before:
0: /opt/xserver/bin/X (0x400000+0x18ce36) [0x58ce36]
1: /opt/xserver/bin/X (xorg_backtrace+0x9) [0x58d119]
2: /opt/xserver/bin/X (0x400000+0x190d69) [0x590d69]
3: /lib64/libpthread.so.0 (0x7fb904268000+0x10a90) [0x7fb904278a90]
4: /lib64/libc.so.6 (ioctl+0x7) [0x7fb902fbf987]
5: /usr/lib64/libdrm.so.2 (drmIoctl+0x28) [0x7fb90405ffa8]
6: /usr/lib64/libdrm.so.2 (drmCommandWrite+0x1b) [0x7fb90406235b]
7: /usr/lib64/libdrm_nouveau.so.2 (nouveau_bo_wait+0x89) [0x7fb902009719]
8: /opt/xserver/lib/xorg/modules/drivers/nouveau_drv.so (0x7fb90220e000+0x76f3) [0x7fb9022156f3]
9: /opt/xserver/lib/xorg/modules/libexa.so (0x7fb9019c7000+0xbae0) [0x7fb9019d2ae0]
10: /opt/xserver/bin/X (0x400000+0x17d2b3) [0x57d2b3]
11: /opt/xserver/bin/X (0x400000+0xc9930) [0x4c9930]
12: /opt/xserver/bin/X (0x400000+0x3a81a) [0x43a81a]
13: /opt/xserver/bin/X (0x400000+0x3d6a1) [0x43d6a1]
14: /opt/xserver/bin/X (0x400000+0x2c2ca) [0x42c2ca]
15: /lib64/libc.so.6 (__libc_start_main+0xf5) [0x7fb902f019b5]
16: /opt/xserver/bin/X (0x400000+0x2c60d) [0x42c60d]
17: ?? [0x0]

After:
0: /opt/xserver/bin/X (OsSigHandler+0x39) [0x590d69]
1: /lib64/libpthread.so.0 (__restore_rt+0x0) [0x7fb904278a8f]
2: /lib64/libc.so.6 (ioctl+0x7) [0x7fb902fbf987]
3: /usr/lib64/libdrm.so.2 (drmIoctl+0x28) [0x7fb90405ffa8]
4: /usr/lib64/libdrm.so.2 (drmCommandWrite+0x1b) [0x7fb90406235b]
5: /usr/lib64/libdrm_nouveau.so.2 (nouveau_bo_wait+0x89) [0x7fb902009719]
6: /opt/xserver/lib/xorg/modules/drivers/nouveau_drv.so (nouveau_exa_download_from_screen+0x1a3) [0x7fb9022156f3]
7: /opt/xserver/lib/xorg/modules/libexa.so (exaGetImage+0x1f0) [0x7fb9019d2ae0]
8: /opt/xserver/bin/X (miSpriteGetImage+0x173) [0x57d2b3]
9: /opt/xserver/bin/X (compGetImage+0xb0) [0x4c9930]
10: /opt/xserver/bin/X (ProcGetImage+0x55a) [0x43a81a]
11: /opt/xserver/bin/X (Dispatch+0x341) [0x43d6a1]
12: /opt/xserver/bin/X (main+0x3ba) [0x42c2ca]
13: /lib64/libc.so.6 (__libc_start_main+0xf5) [0x7fb902f019b5]
14: /opt/xserver/bin/X (_start+0x29) [0x42c60d]
15: ? (?+0x29) [0x29]

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Knut Petersen <knut.petersen@t-online.de>
2013-02-26 07:59:53 +10:00
Keith Packard
90642948cc Merge remote-tracking branch 'jeremyhu/master' 2013-02-14 11:05:48 -08:00
Peter Hutterer
9a35d4240e os: fix pnprintf OOB buffer read for unterminated length modifiers
Format strings with length modifiers but missing format specifier like "%0"
will read one byte past the array size.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-02-14 11:01:21 -08:00
Jeremy Huddleston Sequoia
5da82f872d os: Ensure <dix-config.h> is included in strndup.c
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-02-14 09:20:46 -08:00
Peter Hutterer
9f79e93b6b Short-cut the input device cleanup process during AbortServer()
If we're about to abort, we're already in the signal handler and cannot call
down to the default device cleanup routines (which reset, free, alloc, and
do a bunch of other things).

Add a new DEVICE_ABORT mode to signal a driver's DeviceProc that it must
reset the hardware if needed but do nothing else. An actual HW reset is only
required for some drivers dealing with the HW directly.

This is largely backwards-compatible, hence the input ABI minor bump only.

Drivers we care about either return BadValue on a mode that's not
DEVICE_{INIT|ON|OFF|CLOSE} or print an error and return BadValue. Exception
here is vmmouse, which currently ignores it and would not reset anything.
This should be fixed if the reset is required.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-02-08 09:06:14 -08:00
Keith Packard
b173eb2ae3 os: Round fraction in pnprintf %f format
Truncating the fraction part leads to a test failure where -1203.30 is
printed as -1203.29. Round this to the nearest value instead by adding
0.5 before converting to an integer

Signed-off-by: Keith Packard <keithp@keithp.com>
2013-02-08 08:57:43 -08:00
Peter Hutterer
cde7cbe967 os: add support for %f to pnprintf
This is the lazy man's %f support. Print the decimal part of the number,
then append a decimal point, then print the first two digits of the
fractional part. So %f in sigsafe printing is really %.2f.

No boundary checks in place here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-01-17 17:17:41 +10:00
Peter Hutterer
20def57632 os: silently ignore length modifiers in pnprintf
Until we have support for them, ignore any length modifiers so we don't need
to update all callers.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-01-17 17:17:38 +10:00
Yaakov Selkowitz
ea1d76d1b6 Fix formatting of address operators
The formatter confused address operators preceded by casts with
bitwise-and expressions, placing spaces on either side of both.
That syntax isn't used by ordinary address operators, however,
so fix them for consistency.

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-12-05 18:09:48 -06:00
Jon TURNEY
fb170498ab dix/dispatch.c, os/utils.c: Disable smart scheduler on WIN32
setitimer() and SIGALRM aren't available on WIN32, so smart scheduler
code cannot be built.  Provide only stubs for smart scheduler timer
code, and disable smart scheduler by default.

Signed-off-by: Ryan Pavlik <rpavlik@iastate.edu>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Tested-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-11-28 14:44:12 +00:00
Ryan Pavlik
b20d2998cd os/osinit.c: no getpgrp() and setpgrp() on WIN32
Signed-off-by: Ryan Pavlik <rpavlik@iastate.edu>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Tested-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-11-28 14:44:11 +00:00
Jon TURNEY
98d5acc121 os/utils.c: Fix compilation of OsBlockSIGIO when SIGIO isn't defined
Fix compilation of OsBlockSIGIO with -Werror=return-type when SIGIO isn't
defined.

/jhbuild/checkout/xorg/xserver/os/utils.c: In function 'OsBlockSIGIO':
/jhbuild/checkout/xorg/xserver/os/utils.c:1248:1: error: control reaches end of non-void function [-Wreturn-type]

v2: Shuffle around to avoid writing unreachable code

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Tested-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-11-28 14:43:35 +00:00
Ryan Pavlik
8e2bac0a69 os/osinit.c, os/utils.c: Exclude sigaction code when building for MinGW
MinGW doesn't have sigaction, so this patch is needed for building.

No attempt is made to actually install the fatal error signal handler, as MinGW
will simply terminate the process rather than deliver a fatal signal.

Also avoid using strsignal

Signed-off-by: Ryan Pavlik <rpavlik@iastate.edu>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Tested-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-11-28 14:39:00 +00:00
Yaakov Selkowitz
54ba26cb1f os: Add libnettle as a choice of SHA1 implementation
libnettle is smaller than libgcrypt, currently being released more
frequently, and has replaced the latter in gnutls-3.x (which is used
by TigerVNC, so they can avoid pulling in two crypto libraries
simultaneously).

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2012-11-05 13:34:18 -06:00
Ryan Pavlik
f32ad6dd31 os/utils.c: Provide only stubs for Lock/UnlockServer on WIN32
MinGW and MSVC lack the POSIX functions to compile the lock file code.

Signed-off-by: Ryan Pavlik <rpavlik@iastate.edu>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
2012-10-29 12:23:12 +00:00
Denys Vlasenko
0c7109f321 os: fix typo in OsSigHandler() error message
Recieved → Received

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-10-08 14:18:46 +10:00
Keith Packard
7f9d78d8ff os: Don't re-declare ConnectionInputPtr and ConnectionOutputPtr
They're declared in osdep.h, so don't redeclare them in io.c as
well. Keeps the compiler happier.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2012-10-04 23:15:54 -07:00
Keith Packard
d5bf6f95f3 Fix FlushClient to write extraBuf when provided (regression fix)
In commit:

	commit 092c57ab17
	Author: Adam Jackson <ajax@redhat.com>
	Date:   Fri Jun 17 14:03:01 2011 -0400

	    os: Hide the Connection{In,Out}put implementation details

	    Reviewed-by: Daniel Stone <daniel@fooishbar.org>
	    Signed-off-by: Adam Jackson <ajax@redhat.com>

the check for an empty output buffer was moved from one calling
location into the FlushClient implementation itself. However, this
neglected the possibility that additional data, in the form of
'extraBuf' would be passed to FlushClient from other code paths. If the
output buffer happened to be empty at that time, the extra data would
never be written to the client.

This is fixed by checking the total data to be written, which includes
both pending and extra data, instead of just the pending data.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2012-10-04 14:58:49 -07:00
Adam Jackson
092c57ab17 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-09-20 14:40:18 -04:00
Adam Jackson
e2c7d70e5d 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-09-20 14:40:18 -04:00
Adam Jackson
ff8e3ad807 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-09-20 14:36:39 -04:00
Adam Jackson
3f7bc22263 os: Repack ConnectionOutput for LP64
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-09-20 14:36:36 -04:00
Peter Hutterer
24ffcfcded os: fix typo, fsync when WIN32 is _not_ defined
Introduced in 164b38c72f

Reported-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-08-23 14:48:18 +10:00
Peter Hutterer
1ebba43052 os: don't block signal-unsafe logging, merely warn about it.
Throw an error into the log file, but continue anyway. And after three
warnings, stop complaining. Not all input drivers will be fixed in time (or
ever) and our printf implementation is vastly inferior, so there is still a
use-case for non-sigsafe logging.

This also adds more linebreaks to the message.

CC: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-08-21 07:54:07 +10:00
Peter Hutterer
4912b4adb6 os: add support for %d and %i to pnprintf
The mouse driver uses %i in some debug messages

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-08-21 07:54:07 +10:00
Peter Hutterer
7f8c39c8b5 Add FormatInt64 to convert signed integers in signal-safe manner
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-08-21 07:54:07 +10:00
Peter Hutterer
7f09126e06 os: don't unconditionally unblock SIGIO in OsReleaseSignals()
Calling OsReleaseSignal() inside the signal handler releases SIGIO, causing
the signal handler to be called again from within the handler.

Practical use-case: when synaptics calls TimerSet in the signal handler,
this causes the signals to be released, eventually hanging the server.

Regression introduced in 08962951de.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-08-07 09:39:56 +10:00
Colin Harrison
a8464dfa28 os: Fix TMP fall-back in Win32TempDir()
Fix Win32TempDir() in the case where we fell back to checking the TMP
environment variable. It looks like this has been wrong since forever.

Signed-off-by: Colin Harrison <colin.harrison@virgin.net>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2012-08-03 22:58:09 +01:00
Keith Packard
75966a4186 xwin: Clean up os wrappers for System, Popen and Pclose on Windows
Popen and Pclose are never used on Windows, so don't bother to even
try to define them.

System(s) was defined as system(s), but the two users of that
function are in xkb, which carefully redefines that as
Win32System. Move Win32System and Win32TempDir to os/utils.c, renaming
Win32System to be just System, which simplifies the xkb code

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2012-07-17 16:08:04 +01:00
Keith Packard
6e12cb147d Merge branch 'local-fixes' 2012-07-10 00:52:11 -07:00
Daniel Stone
fadfc29470 GLX: Remove unused noGlxVisualInit
No-one ever did anything with this variable except assign its default
value to it.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-10 00:42:09 -07:00
Daniel Stone
656af2c7e7 Don't make failure to -nolisten fatal
If failing to disable a protocol specified by -nolisten failed, we'd
throw a FatalError and bomb startup entirely.  From poking at xtrans, it
looks like the only way we can get a failure here is because we've
specified a protocol name which doesn't exist, which probably doesn't
constitute a security risk.

And it makes it possible to start gdm even though you've built with
--disable-tcp-transport.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09 22:57:53 -07:00
Alan Coopersmith
ad4092cf7d Replace padlength tables with inline functions from misc.h
Adds new function padding_for_int32() and uses existing pad_to_int32()
depending on required results.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 22:52:30 -07:00
Alan Coopersmith
7a29f68782 Initialize padding bits to 0 in ErrorConnMax()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 22:52:30 -07:00
Alan Coopersmith
bed610fcae Set padding bytes to 0 in WriteToClient
Clear them out when needed instead of leaving whatever values were
present in previously sent messages.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 22:52:30 -07:00
Keith Packard
023127915e Reliably reset signals at server init time
Each DDX currently calls OsReleaseSIGIO in case it was suspended when
the server regen started. This causes a BUG to occur if SIGIO was
*not* blocked at that time. Instead of relying on each DDX, make the
OS layer reliably reset all signal state at server init time, ensuring
that signals are suitably unblocked and that the various signal state
counting variables are set back to zero.

Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09 16:34:39 -07:00
Peter Hutterer
d84f0f823e Merge branch 'sigio-vt-switch-issues' into for-keith
Conflicts:
	test/Makefile.am

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-04 21:23:48 +10:00
Peter Hutterer
6bf356ef28 os: add OsBlockSIGIO and OsReleaseSIGIO
Let the dix be in charge of changing the sigprocmask so we only have one
entity that changes it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-07-03 15:56:33 +10:00
Keith Packard
24525d96a3 Merge branch 'sigsafe-logging-varargs'
This merge includes a minor fixup for '%p' arguments; must cast to
uintptr_t instead of uint64_t as we use -Werror=pointer-to-int-cast
which complains when doing a cast (even explicitly) from a pointer
to an integer of different size.
2012-07-02 22:35:39 -07:00
Chase Douglas
89e3ac07ac Log safely in fatal signal handler
While we probably don't need to be signal safe here since we will never
return to the normal context, the logging signal context check will
cause unsafe logging to be unhandled. Using signal safe logging here
resolves the issue.

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>
2012-07-02 22:34:33 -07:00
Chase Douglas
82d1c6b310 Warn when attempting to log in a signal unsafe manner from signal context
Also, print out the offending message format. This will hopefully help
developers track down unsafe logging.

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>
2012-07-02 22:34:32 -07:00
Chase Douglas
0fa5217836 Print backtrace in a signal-safe manner
Backtraces are often printed in signal context, such as when a segfault
occurs.

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>

os: print offset as unsigned int, not long unsigned int

pnprintf() takes unsigned int for %u

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-02 22:34:32 -07:00
Chase Douglas
ac20815d52 Add ErrorFSigSafe() alternative to ErrorF()
ErrorF() is not signal safe. Use ErrorSigSafe() whenever an error
message may be logged in signal context.

[whot: edited to "ErrorFSigSafe"]

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>
2012-07-02 22:34:32 -07:00
Chase Douglas
164b38c72f Add LogMessageVerbSigSafe() for logging messages while in signal context
[whot: edited to use varargs, squashed commit below]

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>

os: fix vararg length calculation

Make %u and %x sizeof(unsigned int), %p sizeof(void*). This is printf
behaviour and we can't guarantee that void* is uint64_t anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-07-02 22:34:32 -07:00
Peter Hutterer
014ad46f1b os: print newline after printing display name
Much easier for scripts that try to read the display value off the file
descriptor. Plus, this restores the behaviour we had for this patch in
Fedora since server 1.6 (April 2009).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-06-22 10:49:06 +10:00
Chase Douglas
704b847abf Add FormatUInt64{,Hex}() for formatting numbers in a signal safe manner
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>
2012-06-21 15:45:22 +10:00
Chase Douglas
bc85c81687 Save log file file descriptor for signal context logging
None of the FILE based functions are signal safe, including fileno(), so
we need to save the file descriptor for when we are in signal context.

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>
2012-06-21 15:45:22 +10:00
Chase Douglas
d3725549f0 Add global variable inSignalContext
This will be used for checking for proper logging when in signal
context.

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>
2012-06-21 15:45:22 +10:00
Keith Packard
3a94b338aa Merge remote-tracking branch 'whot/for-keith' 2012-05-09 21:17:16 -07:00
Yaakov Selkowitz
e6461db6dc os: Add CryptoAPI as a choice of SHA1 implementation
Both Cygwin and MinGW can use Windows' native CryptoAPI for SHA1,
saving a dependency on libgcrypt or OpenSSL.  The necessary functions
are in ADVAPI32.DLL, which is among the default lib flags and is
already used in hw/xwin for accessing the registry.

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Tested-by: Colin Harrison <colin.harrison@virgin.net>
2012-05-04 13:13:50 -05:00
Daniel Kurtz
c91d00e0f3 os/log: refactor logging
It is not safe to ever use an arbitrary (possibly user supplied) string as
part of the format for a *sprintf() call.

For example:
  1. Name a Bluetooth keyboard "%n%n%n%n%n%n%n%n"
  2. Pair it with a computer running X and try to use it
  3. X is not happy when trying to do the following in xf86-input-evdev:
     xf86IDrvMsg(pInfo, X_CONFIG, "Device: \"%s\"\n", device);
     because LogVHdrMessageVerb() has put the %n from the device name
     into a format string of the form:
        "evdev: %n%n%n%n%n%n%n%n: Device: \"%s\"\n"

Instead, build up a log message in place by appending successive formatted
strings by sncprintf'ing to the end of the previous.

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>
2012-05-03 14:59:23 +10:00
Daniel Kurtz
6ce0eac4f8 os/log: only write timestamp if a message is actually written to logfile
The current code will write a timestamps into the logFile whenever
the last message ended with a '\n' - even if the verb for that timestamp
is at too high a level.  This timestamp will sit there with no matching
message until the next call to LogVWrite with a valid verb.

In other words, in some cases, timestamps in the X.org.log are for some
completely unrelated message that was previously ignored due to
insufficient verbosity, and not for the message that appears next to it
in the log file.

We keep the current policy which appears to be to only apply timestamps if
a message is actually written to a log file.  That is, no timestamps on
stderr, or in the mem buffer.  Therefore, the timestamp stringification
is moved to the conditional where it is used.

Since logging uses a fixed length buffer, this patch also forces a '\n'
whenever a buffer is terminated due to a too-long write request.  This
allows the newline detection to work even on overflow, and also cleans up
the log a bit in the overflow case.

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>
2012-05-03 14:59:23 +10:00
Daniel Kurtz
5c2e2a164d os/xprintf: add Xvscnprintf and Xscnprintf
Normal snprintf() usually returns the number of bytes that would have been
written into a buffer had the buffer been long enough.

The scnprintf() variants return the actual number of bytes written,
excluding the trailing '\0'.

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>
2012-05-03 14:59:23 +10:00
Daniel Kurtz
c30862879d os/log: trivial cleanups
* space->tab
 * remove comment that doesn't make any sense

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>
2012-05-03 14:59:23 +10:00
Peter Hutterer
08962951de os: make timers signal-safe
If TimerSet() is called from a signal handler (synaptics tap handling code)
may result in list corruption if we're currently inside TimerSet().

See backtrace in
https://bugzilla.redhat.com/show_bug.cgi?id=814869

Block signals for all list manipulations in the timers.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-05-01 11:36:35 +10:00
Chase Douglas
88bacc49f0 os: Add -displayfd option
This option specifies a file descriptor in the launching process.  X
will scan for an available display number and write that number back to
the launching process, at the same time as SIGUSR1 generation.  This
means display managers don't need to guess at available display numbers.
As a consequence, if X fails to start when using -displayfd, it's not
because the display was in use, so there's no point in retrying the X
launch on a higher display number.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Tested-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-05-01 11:36:30 +10:00
Jeremy Huddleston
eca58ee4db os: Fix regression with FatalError not calling va_start
Regression From: a818b30598

Found-by: Colin Harrison <colin.harrison@virgin.net>
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-03-30 14:42:11 -07:00
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
Dan Nicholson
7d5c8a12cb Don't use empty source files
When an empty _SOURCES variable is declared, automake will recognize that
only linking is needed.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Tested-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Tested-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-06-23 05:28:31 -07:00
Jeremy Huddleston
b47d2e43eb XQuartz: Make a copy of args for our crash reporter vsnprintf
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-05-05 09:04:41 -07:00
Jeremy Huddleston
c524f8bb76 os: Silence warnings when building with clang
access.c:1492:20: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses]
        if ((host->family == FamilyServerInterpreted)) {
             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
access.c:1492:20: note: use '=' to turn this equality comparison into an assignment
        if ((host->family == FamilyServerInterpreted)) {
                          ^~
                          =
access.c:1492:20: note: remove extraneous parentheses around the comparison to silence this warning
        if ((host->family == FamilyServerInterpreted)) {
            ~             ^                         ~

In file included from xstrans.c:8:
In file included from /usr/X11/include/X11/Xtrans/transport.c:62:
/usr/X11/include/X11/Xtrans/Xtranssock.c:262:5: error: implicit declaration of function 'ErrorF' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
    PRMSG (3,"SocketSelectFamily(%s)\n", family, 0, 0);
    ^

log.c:180:29: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
        if (asprintf(&logFileName, fname, display) == -1)
                                   ^~~~~
log.c:190:26: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
                if ((asprintf(&suffix, backup, display) == -1) ||
                                       ^~~~~~
log.c:382:25: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
        LogVWrite(verb, tmpBuf, args);
                        ^~~~~~

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2011-04-25 10:45:34 -07:00
Tiago Vignatti
f603061e94 os: fix use after free in EstablishNewConnections
In the case of failure on AllocNewConnection, new_trans_conn cannot be
dereferenced because it's already freed. Swapping the order of this logic fix
the changes introduced in 04956b8043.

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
CC: Jeremy Huddleston <jeremyhu@freedesktop.org>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-04-07 19:57:38 +03:00
Tiago Vignatti
a6c71ce5d2 os: fix memory and fd leaks in Popen
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
2011-04-04 15:41:47 +03:00
Tiago Vignatti
bafec9a25e os: use DebugF for debugging
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
2011-04-04 15:41:47 +03:00
Erkki Seppälä
2ef4ff45ef os/client: Prevent rare fd leak in DetermineClientPid
DetermineClientPid didn't close file descriptor if read on
/proc/pid/cmdline failed. Adjusted the code to disregard the close
return value and perform the return after that, if the read failed or
returned EOF.

Signed-off-by: Mark Kettenis <mark.kettenis@xs4all.nl>
Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Reviewed-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-03-27 18:16:36 -07:00
Jon TURNEY
a713832cbe When XDMCP -from is specified, only register the requested address
When XDMCP -from is specified, only register the requested address,
rather than the requested address, and any others we have of different
address families to the requested address.

e.g. if we have 4 interfaces with both IPv4 and IPv6 addresses (which
are not IPv6 mapped IPV4 addresses), using -from with one of those IPv4
addresses currently means only that IPv4 address, and all IPv6 addresses
are used in the connection data in XDMCP REQUEST packet.

(See http://cygwin.com/ml/cygwin-xfree/2011-02/msg00000.html)

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-03-14 13:11:38 -07:00
Christopher James Halse Rogers
d17a9fb841 Consolidate all the PATH_MAX handling into misc.h
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2011-03-14 13:42:55 -04:00
Keith Packard
8e4c3ce55b Merge remote branch 'rjy/clientids' 2011-03-03 13:42:07 -08:00
Adam Jackson
f953ae7d8a os: Reduce smart scheduler setup calls
We can return from WaitForSomething with no clients ready for any number
of reasons.  There's no reason to set up the scheduler timer when this
happens.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2011-01-20 21:08:17 -05:00
Pauli Nieminen
2d67ada3c4 os: always check if client is local when connection is accepted
LocalClient is used for all DRI2 requests that makes it frequently
called function. Querying if connection is local or not takes 10-15us
(on ARM) depending on malloc speed.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-12-31 12:52:51 +00:00
Pauli Nieminen
617b7d2211 os: Fix a memory leak
Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-12-31 12:52:51 +00:00
Daniel Stone
44adb31bfe GetTimeInMillis: Use CLOCK_MONOTONIC_COARSE where available
On some systems, using CLOCK_MONOTONIC forces a readback of HPET or some
similarly expensive timer.  CLOCK_MONOTONIC_COARSE can alleviate this,
at the cost of negligibly-reduced resolution, so prefer that where we
can.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
2010-12-27 09:43:44 -08:00
Rami Ylimäki
1e933665be os: Add facilities for client ID tracking.
An interface is provided for figuring out the PID and process name of
a client. Make some existing functionality from SELinux and IA
extensions available for general use.

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
2010-12-23 13:53:18 +02:00
Rami Ylimäki
2b364bf970 Revert "os: Prevent backtrace from being stopped in noreturn functions."
This reverts commit 579715f830.

The patch is not needed anymore. I haven't encountered backtrace
problems with GCC 4.3.3. Even if the problems still persisted, this
commit should be removed and instead the definition of _X_NORETURN
should be modified to be empty if GCC/ARM is used. However, currently
it seems that ARM backtraces are OK even if _X_NORETURN is used and
-mapcs-frame is not defined in CFLAGS.

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-12-23 11:20:42 +02:00
Adam Jackson
f28e48834e Remove SCO support
This has never been buildable in any modular server release.

Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-12-20 12:11:11 -05:00
Colin Harrison
1324b0ca9f Typo in xserver Xvasprintf()
I needed this patch in the wrapper around vsnprintf() in os/xprintf.c
(MinGW for Windows build) to correct various crashes.

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2010-12-18 00:22:29 -08:00
Alan Coopersmith
3a9bb93dd1 Convert alloc+sprintf pairs into asprintf() & XNFasprintf() calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2010-12-07 11:10:35 -08:00
Alan Coopersmith
c95c1d338f Add asprintf() implementation for platforms without it
Provides a portable implementation of this common allocating sprintf()
API found in many, but not yet all, of the platforms we support.
If the platform provides vasprintf() we simply wrap it, otherwise we
implement it - either way callers can use it regardless of platform.

Since not all platforms guarantee to NULL out the return pointer on
failure, we don't either, and require callers to check the return
value for -1.

The old Xprintf() API is deprecated, but left for compatibility for now.

The new API is added in a new header so that it can be used in parts of
the server such as hw/xfree86/parser that don't include all the server
headers.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2010-12-07 11:10:35 -08:00
Alan Coopersmith
2db6951763 Sun's copyrights now belong to Oracle
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2010-12-07 11:10:35 -08:00
Keith Packard
c4a7a5917a Merge remote branch 'jeremyhu/master' 2010-12-06 19:28:07 -08:00
Jeremy Huddleston
14f00449eb XQuartz: Cleanup some compiler warnings
Mark __crashreporter_info__ as __attribute__((__used__))

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-12-03 16:46:45 -08:00
Alan Coopersmith
8f42b2b693 Simplify Error() - don't allocate temporary copy of error string
Doesn't seem to be any reason to just not pass the error string
as another argument directly to LogVWrite()

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2010-11-30 16:25:22 -08:00
Tiago Vignatti
8976e9766e dix: adds support for none root window background
It lets the driver notify the server whether it can draw a background when
'-background none' option is used by the system platform. Use cases for that
could be video drivers performing mode-setting in kernel time, before X is up,
so a seamless transition would happen until X clients start to show up.

If the driver can copy the framebuffer cleanly then it can set the flag
(canDoBGNoneRoot), otherwise the server will fallback to the normal behaviour.
The system must explicit indicates willingness of doing so through
'-background none'. We could do this option as default; in such case,
malicious users would be able to steal the framebuffer with a bit of tricks.

For instance, I can see the content of my nVidia Quadro FX 580 framebuffer
old X session modifying a bit nv driver:

     xf86DPMSInit(pScreen, xf86DPMSSet, 0);

-    /* Clear the screen */
-    if(pNv->xaa) {
-        /* Use the acceleration engine */
-        pNv->xaa->SetupForSolidFill(pScrn, 0, GXcopy, ~0);
-        pNv->xaa->SubsequentSolidFillRect(pScrn,
-            0, 0, pScrn->displayWidth, pNv->offscreenHeight);
-        G80DmaKickoff(pNv);
-    } else {
-        /* Use a slow software clear path */
-        memset(pNv->mem, 0, pitch * pNv->offscreenHeight);
-    }
+    pScreen->canDoBGNoneRoot = TRUE;

The commit is originally based on discussions happened on xorg-devel:
http://lists.freedesktop.org/archives/xorg-devel/2010-June/009755.html

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Acked-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-11-11 23:24:43 +02:00
Tiago Vignatti
bfe9cdd11b dix: delete logo hack screen saver
Protocol doesn't mention about screen saver with logo being required and
people are already using more intelligent ways to draw screen saver themes. So
consider -logo as deprecated option, deleting its code.

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-11-11 23:20:35 +02:00
Keith Packard
4ed4915bc0 Merge remote branch 'whot/for-keith' 2010-11-10 16:58:21 -08:00
Aaron Plattner
c80c41767e os: Fix BigReq ignoring when another request is pending
Commit cf88363db0 fixed the handling of
BigReq requests that are way too large and handles the case where the
read() syscall returns a short read.  However, it neglected to handle
the case where it returns a long read, which happens when the client
has another request in the queue after the bogus large one.

Handle the long read case by subtracting the smaller of 'needed' and
'gotnow' from oci->ignoreBytes.  If needed < gotnow, simply subtract
the two, leaving gotnow equal to the number of extra bytes read.
Since the code immediately following the (oci->ignoreBytes > 0) block
tries to handle the next request, advance oci->bufptr immediately
instead of setting oci->lenLastReq and letting the next call to
ReadRequestFromClient do it.

Fixes the XTS pChangeKeyboardMapping-3 test.

         CASES TESTS  PASS UNSUP UNTST NOTIU  WARN   FIP  FAIL UNRES  UNIN ABORT
-Xproto    122   389   367     2    19     0     0     0     1     0     0     0
+Xproto    122   389   368     2    19     0     0     0     0     0     0     0

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-11-10 14:58:28 -08:00
Julien Cristau
69e8e1b0b9 os: include dix-config.h, not xorg-config.h
os/strlc{at,py}.c were trying to include xorg-config.h, which is not
available in dix.

Signed-off-by: Julien Cristau <jcristau@debian.org>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-11-11 08:41:38 +10:00
Cyril Brulebois
b142b0d274 Remove more superfluous if(p!=NULL) checks around free(p).
This patch has been generated by the following Coccinelle semantic patch:

@@
expression E;
@@
- if (E != NULL)
-   free(E);
+ free(E);

Signed-off-by: Cyril Brulebois <kibi@debian.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-11-11 08:29:54 +10:00
Mikhail Gusarov
44e8165414 Remove now-misleading comment
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2010-10-25 03:35:56 +04:00
Mikhail Gusarov
433dddcf29 Replace "if(buf) realloc(buf, size) else malloc(size)" with realloc()
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2010-10-25 03:35:54 +04:00
Mikhail Gusarov
04a04e1628 Remove now-misleading comment
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2010-10-25 03:33:10 +04:00
Adam Jackson
e2ada55de3 os: Clean up various xtrans bits that we've never supported
Or at least, not supported since xserver 1.0.

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-10-15 16:50:23 -04:00
Tiago Vignatti
7d8cabd027 os: simplify smart scheduler init process
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2010-09-10 21:49:29 +03:00
Tiago Vignatti
d9c18c3b9b os: remove useless smart scheduler macros
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2010-09-10 21:49:28 +03:00
Tiago Vignatti
a9e6080dc9 os/xfree86: remove macro checking for POSIX symbols
We assume already that our X implementation is POSIX compliant anyway. So
remove those redundant checking.

SA_SIGINFO is left there.

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2010-09-10 21:49:28 +03:00
Vignatti Tiago (Nokia-MS/Helsinki)
5b680f2c23 os: add -sigstop option for Upstart (or equivalent) startup
This is very similar to the RunFromSmartParent (implicit) option, except
we do not send the signal to our parent process, but our own process
instead, and that signal is SIGSTOP, not SIGUSR1.

Upstart or a similar equivalent program will detect this, realize that
we are ready to accept clients now, send us SIGCONT and move our job
status from SPAWNED to RUNNING.

Signed-off-by: Oliver McFadden <oliver.mcfadden@nokia.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-09-10 11:54:14 -07:00
Aaron Plattner
cf88363db0 os: Return BadLength instead of disconnecting BigReq clients (#4565)
If a client sends a big request that's too big (i.e. bigger than
maxBigRequestSize << 2 bytes), the server just disconnects it.  This makes the
client receive SIGPIPE the next time it tries to send something.

The X Test Suite sends requests that are too big when the test specifies the
TOO_LONG test type.  When the client receives SIGPIPE, XTS marks it as
UNRESOLVED, which counts as a failure.

Instead, remember how long the request is supposed to be and then return that
size.  Dispatch() checks the length and sends BadLength to the client.  Then,
whenever oci->ignoreBytes is nonzero, ignore the data read instead of trying to
process it as a request.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-09-10 11:48:17 -07:00
Kristian Høgsberg
c65f610e12 Always call the flush callback chain when we flush client buffers
We were missing the callback in a couple of places.  Drivers may use
the flush callback to submit batched up rendering before events (for
example, damage events) are sent out, to ensure that the rendering
has been queued when the client receives the event.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2010-08-06 08:28:10 -04:00
Jesse Barnes
28e33ae6f6 OS support: fix writeable client vs IgnoreClient behavior
When ResetCurrentRequest is called, or IgnoreClient is called when a
client has input pending, IgnoredClientsWithInput will be set.  However,
a subsequent IgnoreClient request will clear the client fd from that fd
set, potentially causing the client to hang.

So add an Ignore/Attend count, and only apply the ignore logic on the
first ignore and the attend logic on the last attend.  This is
consistent with the comments for these functions; callers must pair
them.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=27035.

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-30 07:59:04 -07:00
Simon Farnsworth
660f6ab549 Don't crash when asked if a client that has disconnected was local
ProcDRI2Dispatch uses LocalClient to determine if it's safe to respond
to a client that has made DRI2 requests which aren't sensible for
remote clients (anything but version). When the client has disappeared
mid-request stream (e.g. as a result of a kill -9, or a client-side
bug), LocalClient causes the X server to follow suit, as
((OsCommPtr)client->osPrivate)->trans_conn is NULL at this point.

The simple and obvious fix is to just return "not local" when
trans_conn is NULL, which fixes the crash I was seeing; however Keith
Packard pointed out that just checking trans_conn isn't enough;
quoting Keith:

"This looks almost right to me -- I reviewed the os code to see when
_XSERVTransClose is called (which is what frees the trans_conn data) and
found that every place which called that immediately set trans_conn to
NULL, except for the call in CloseDownFileDescriptor which is only
called from CloseDownConnection and which is immediately followed by
freeing the OsCommRec and setting client->osPrivate to NULL. So, I'd
suggest checking client->osPrivate in addition to the above check."

Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-22 11:42:33 -07:00
Mikhail Gusarov
c201667396 os: Remove unused dev_tty_from_init variable
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-06-20 05:36:22 +07:00
Mikhail Gusarov
2e15f1903d os: Remove unused pread/pwrite/lockit functions
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-06-20 05:36:22 +07:00
Mikhail Gusarov
7287ef9e6c Remove unnecessary parentheses around return values in functions
This patch was generated by the following Perl code:

perl -i -pe 's/([^_])return\s*\(\s*([^(]+?)\s*\)s*;(\s+(\n))?/$1return $2;$4/g;'

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-10 06:42:42 -07:00
Mikhail Gusarov
5a0fc0ad21 Replace deprecated bzero with memset
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Marcin Baczyński <marbacz@gmail.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-06-06 15:07:27 +07:00
Jamey Sharp
4b9600a416 Make WriteEventsToClient/WriteToClient no-op on fake or dead clients.
This matches the test in TryClientEvents, and is a superset of tests
done by the callers of these functions. The consequence of forgetting
these tests is a server crash, so they're always desirable. In my
opinion, it's better to not require the callers to remember to do these
checks.

For callers that don't do very much work before calling WriteToClient or
WriteEventsToClient, I've removed the redundant checks.

hw/xquartz/xpr/appledri.c has an interesting case: While its check for
"client == NULL" appears redundant with the test in WriteEventsToClient,
it dereferences client to get the sequence number.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=27497
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-19 12:32:34 -07:00
Jeremy Huddleston
37f0b45dbe XQuartz: Fix a build failure on Tiger
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-05-16 13:12:31 -07:00
Alan Coopersmith
e42a29d269 Fix compiler issues with getifaddrs() call on OpenSolaris
OpenSolaris recently added support for the getifaddrs() API.

Building with that uncovered two compiler issues (one warning, one error)
in the code that was now being built for the first time in our builds:

"access.c", line 768: warning: argument #1 is incompatible with prototype:
        prototype: pointer to struct sockaddr {unsigned short sa_family, array[14] of char sa_data} : "access.c", line 213
        argument : pointer to struct sockaddr_storage {unsigned short ss_family, array[6] of char _ss_pad1, double _ss_align, array[240] of char _ss_pad2}

"access.c", line 838: assignment type mismatch:
        struct sockaddr {unsigned short sa_family, array[14] of char sa_data} "=" struct sockaddr_storage {unsigned short ss_family, array[6] of char _ss_pad1, double _ss_align, array[240] of char _ss_pad2}

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-05-14 19:48:01 -07:00
Jeremy Huddleston
bca85e2e12 Use _X_ATTRIBUTE_PRINTF _X_DEPRECATED _X_NORETURN
Use the values from xproto rather than duplicating the effort

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-05-13 10:03:23 -07:00
Mikhail Gusarov
868e372a73 Introduce X_NORETURN macro defined as __attribute__((noreturn)) for gcc
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-05-13 04:54:34 +07:00
Mikhail Gusarov
ff2b4cf832 Turn sprintf argument into literaral string, shutting up gcc warning
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-05-13 04:53:57 +07:00
Mikhail Gusarov
801162919d Removed outdated comments obsoleted by documentation in headers
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-13 00:22:38 +07:00
Mikhail Gusarov
4d55c8c4ff Use lowercase variant of XNFalloc and Xstrdup
Using one variant of function/macro makes it easier to fix the code
later.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-13 00:22:37 +07:00
Mikhail Gusarov
3f3ff971ec Replace X-allocation functions with their C89 counterparts
The only remaining X-functions used in server are XNF*, the rest is converted to
plain alloc/calloc/realloc/free/strdup.

X* functions are still exported from server and x* macros are still defined in
header file, so both ABI and API are not affected by this change.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-13 00:22:37 +07:00
Mikhail Gusarov
e983848ab4 Clean {X,XNF}{alloc,calloc,realloc,free,strdup} from pre-C89 baggage
C89 guarantees alignment of pointers returned from malloc/calloc/realloc, so
stop fiddling with alignment manually and just pass the arguments to library
functions.

Also convert silent error when negative size is passed into function into
warning in log file.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-13 00:20:32 +07:00
Alan Coopersmith
2eab697adb Constify function prototypes in auth & xdmcp code
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Tested-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-05-07 12:22:58 -07:00
Keith Packard
7ac6a6b7d0 Merge remote branch 'vignatti/for-keith'
Conflicts:
	exa/exa.c

Signed-off-by: Keith Packard <keithp@keithp.com>
2010-04-21 16:07:38 -07:00
Tiago Vignatti
0ba82562ee Death to Multibuffer extension
The rationale behind is because no sane application will use this when we have
modern APIs such DRI2. Besides, as a fact, xfree86 server has already
deprecated this extension in 1998:

    http://www.xfree86.org/3.3.6/isc7.html

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2010-04-21 18:06:35 +03:00
Keith Packard
28b7b2b8d0 unifdef -B -DRENDER to always include RENDER code
This patch was created with:

git ls-files '*.[ch]' | while read f; do unifdef -B -DRENDER -o $f $f; done

Signed-off-by: Keith Packard <keithp@keithp.com>
2010-04-19 09:26:10 -07:00
Jeremy Huddleston
fe7778e58e XQuartz: Fix possible NULL dereference in ListenOnOpenFD
<rdar://problem/7862319>

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Marc Majka <majka@apple.com>
2010-04-15 10:57:03 -07:00
Jeremy Huddleston
0e342add77 darwin: Correct inline assembly for ___crashreporter_info__
It was missing an underscore.

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-01 15:32:51 -07:00
Jeremy Huddleston
436d0bb9cc darwin: Generate crash reports on FatalError()
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Acked-by: Adam Jackson <ajax@redhat.com>
2010-03-29 09:37:17 -07:00
Rami Ylimaki
579715f830 os: Prevent backtrace from being stopped in noreturn functions.
There are two noreturn functions in the X server: FatalError and
AbortServer. Having any of those two functions in the middle of a call
stack will prevent unwinding the program properly and stops the
backtrace at those functions in gdb.

The file containing FatalError and AbortServer, os/log.c, has to be
compiled with the -mapcs-frame option on ARM to get proper
backtraces. Automake imposes its own restrictions on compiling
individual source files with different options. The recommended way to
do this is to put os/log.c into a convenience library and add this
library inside os/libos.la. See the documentation of GNU Automake
manual, version 1.11.1, section 27.8 Per-Object Flags Emulation, for
details.

Signed-off-by: Rami Ylimaki <ext-rami.ylimaki@nokia.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-03-25 06:03:43 +01:00
Yaakov Selkowitz
abf4e0b7e3 New header for XF86Bigfont server functions
Xext/xf86bigfont.c contains three non-static functions which are called
elsewhere in the server.  This creates a new header containing these
declarations in order to fix several warnings:

xf86bigfont.c:285: warning: no previous prototype for `XF86BigfontFreeFontShm'
dixfonts.c:502: warning: implicit declaration of function `XF86BigfontFreeFontS$
dixfonts.c:502: warning: nested extern declaration of `XF86BigfontFreeFontShm'
log.c:436: warning: implicit declaration of function `XF86BigfontCleanup'
log.c:436: warning: nested extern declaration of `XF86BigfontCleanup'

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2010-03-22 00:48:04 -05:00
Colin Harrison
cca4952d75 Xming: Warning fixes
Fix warnings due to prototypes not specifying function arguments
Fix warning with RegQueryValueEx()
Tidy up an include

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2010-03-16 13:56:58 +00:00
Peter Hutterer
c39c8ece9b os: remove INTERNAL_MALLOC define.
There doesn't seem to be anything that defines it and given that the
counterpart (the X internal malloc) was removed in
01cfba7522 it's unlikely to work anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-03-11 08:48:48 +10:00
Rami Ylimaki
5b9a52be7e os: Prevent core dump from being truncated.
The problem fixed by this patch can be reproduced on Linux with the
following steps.
- Access NULL pointer intentionally in ProcessOtherEvent on key press.
- Instead of saving core dump to a file, write it into a pipe.
  echo "|/usr/sbin/my-core-dumper" > /proc/sys/kernel/core_pattern
- Dump the core by pressing a key.

While the core is being dumped into the pipe, the smart schedule timer
will cause a pending SIGALRM. Linux kernel stops writing data to the
pipe when there are pending signals. This causes the core dump to be
truncated. On my system I'm expecting a 6 MB dump but the size will be
60 kB instead. The problem is solved if we block the SIGALRM caused by
expired smart schedule timer.

I haven't been able to reproduce this problem in the following cases.
- Save core dump to a file instead of a pipe.
- kill -SEGV `pidof Xorg`
- Press a key to dump core while gdb is attached to Xorg.
- Give option -dumbSched to Xorg.

Also note that the fix works only when NoTrapSignals has the default
value FALSE. The problem can still be reproduced if error signals
aren't trapped. In addition to pending SIGALRM, there is a similar
problem with pending SIGIO from the keyboard driver during core dump.

Signed-off-by: Rami Ylimaki <ext-rami.ylimaki@nokia.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-02-17 23:20:52 -08:00
Rami Ylimaki
ca364ca82a os: Introduce OsAbort for proper core dumps.
Signed-off-by: Rami Ylimaki <ext-rami.ylimaki@nokia.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-02-17 23:20:41 -08:00
Keith Packard
57ffeb3f2b Merge remote branch 'jturney/master' 2010-02-12 13:36:32 -08:00
Peter Hutterer
3ac43df5d4 Add xstrtokenize to the dix.
Move tokenize out of the parser, make it a dix util function instead.
Splitting a string into multiple substrings is useful by other places, so
let's use it across the line. Future users include config/hal, config/udev
and of course the parser.

Example usage:
char **substrings = xstrtokenize(my_string, "\n");

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-02-11 19:25:39 +10:00
Jon TURNEY
c9cbbd5d1c Repair '-nolock'
commit 446fe9eecd removes the AC_DEFINE for
SERVER_LOCK and conditional compilation checking it, making it always on
everywhere, except in os/utils.c where code is left under SERVER_LOCK, which
now never gets built, making the '-nolock' option non-functional...

This seems to have been broken since Xserver 1.7.0, but this option is
actually of some slight use on cygwin, as if /tmp resides on a FAT filesystem
(yes, I know...), hard links aren't supported.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2010-02-05 19:21:17 +00:00
Kok, Auke
d2322b6309 xserver: Add timestamps to logfile output.
Add timestamps in seconds derived from clock_monotonic to the log
file.

Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-01-27 14:15:40 -08:00
Alan Coopersmith
837bd2bbc0 Remove unbalanced ( from failure to move log error
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-01-25 11:10:01 -08:00
Simon Thum
14e4e4a294 os: state effect of -a and -t options more precisely
Signed-off-by: Simon Thum <simon.thum@gmx.de>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-01-11 15:26:45 +10:00
Keith Packard
0cb638dc68 Merge remote branch 'alanc/master' 2009-12-16 21:58:44 -08:00
Tiago Vignatti
7284e19861 os: print log markers only if log level is >= 0
FWIW default log verbosity is 0, so this will affect only if one start the
server with a different -verbose argument.

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Acked-by: Rami Ylimaki <ext-rami.ylimaki@nokia.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-12-16 21:49:27 -08:00
Alan Coopersmith
c9726bbe31 Update Sun license notices to current X.Org standard form
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-12-16 17:11:35 -08:00
Jeremy Huddleston
1b8f90aa8b Miscellaneous compilation warning fixes
main.c:134: warning: no previous prototype for 'dix_main'
rootlessScreen.c: In function 'RootlessMarkOverlappedWindows':
rootlessScreen.c:434: warning: function declaration isn't a prototype
backtrace.c:51: warning: format '%lx' expects type 'long unsigned int', but argument 5 has type 'int'
backtrace.c:54: warning: format '%lx' expects type 'long unsigned int', but argument 5 has type 'int'
set.c: In function 'RecordSetMemoryRequirements':
set.c:413: warning: old-style function definition
set.c: In function 'RecordCreateSet':
set.c:425: warning: old-style function definition
stub.c: In function ‘main’:
stub.c:236: warning: ISO C90 forbids mixed declarations and code

Signed-off-by: Jeremy Huddleston <jeremyhu@freedesktop.org>
2009-12-08 15:50:28 -08:00
Gaetan Nadon
c739beb439 .gitignore: use common defaults with custom section #24239
Using common defaults will reduce errors and maintenance.
Only the very small or inexistent custom section need periodic maintenance
when the structure of the component changes. Do not edit defaults.

Reviewed-By: Jeremy Huddleston <jeremyhu@apple.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-11-11 21:40:20 -08:00
Jon TURNEY
28eb61fc04 Avoid a null dereference if IFF_BROADCAST is set but there is no broadcast address
It seems that the getifaddrs() function can return interfaces with
IFF_BROADCAST & IFF_UP set, but no broadcast address (at least
under Cygwin 1.7, this seems to happen for v6 mapped v4 addresses)

Avoid a null dereference if this ever happens

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2009-11-09 20:33:40 +00:00
Jeremy Huddleston
6b109919f6 SHA1: Add support for Common Crypto
libSystem on darwin can handle SHA1 computation without needing to pull in
OpenSSL. See CC_crypto(3)

Signed-off-by: Jeremy Huddleston <jeremyhu@freedesktop.org>
2009-11-05 18:34:50 -08:00
Matthieu Herrb
48b8c076a7 add libc as a choice for SHA1 implementation
On Sun, Nov 01, 2009 at 02:54:13PM -0800, Keith Packard wrote:
> Excerpts from Matthieu Herrb's message of Sun Nov 01 09:34:35 -0800 2009:
>
> > +AC_CHECK_FUNCS([SHA1Init], [HAVE_LIBC_SHA1=yes])
>
> I'd suggest AC_CHECK_FUNC instead; as far as I can tell, AC_CHECK_FUNCS
> will also define HAVE_SHA1INIT. Also, can you  use HAVE_LIBC_SHA1
> consistently rather than having two separate names (HAVE_LIBC_SHA1 and
> HAVE_SHA1_IN_LIBC)? Yes, I know one is a preprocessor symbol and the
> other is a cpp shell variable, but I think that will work anyway.
>
New version taking you comments into account.

From: Matthieu Herrb <matthieu.herrb@laas.fr>
Date: Sun, 1 Nov 2009 18:19:27 +0100
Subject: [PATCH] Add a probe for SHA1 functions in libc in *BSD.

The interface is the same as the one in libmd.

Signed-off-by: Keith Packard <keithp@keithp.com>
2009-11-02 07:37:30 -08:00
Mikhail Gusarov
d306373399 Supply all code using dl*() with DLOPEN_LIBS
Previously DLOPEN_LIBS was managed in top-level configure.ac.
Instead bundle it with the code using dl*() functions to
avoid breakages in uncommon configurations.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-10-29 14:15:02 -07:00