summaryrefslogtreecommitdiff
path: root/os
AgeCommit message (Collapse)AuthorFilesLines
2012-12-05Fix formatting of address operatorsHEADmasterYaakov Selkowitz3-8/+8
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-11-28dix/dispatch.c, os/utils.c: Disable smart scheduler on WIN32Jon TURNEY1-0/+9
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-28os/osinit.c: no getpgrp() and setpgrp() on WIN32Ryan Pavlik1-0/+2
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-28os/utils.c: Fix compilation of OsBlockSIGIO when SIGIO isn't definedJon TURNEY1-2/+2
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-28os/osinit.c, os/utils.c: Exclude sigaction code when building for MinGWRyan Pavlik2-0/+9
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-05os: Add libnettle as a choice of SHA1 implementationYaakov Selkowitz1-0/+30
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-10-29os/utils.c: Provide only stubs for Lock/UnlockServer on WIN32Ryan Pavlik1-0/+20
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-08os: fix typo in OsSigHandler() error messageDenys Vlasenko1-1/+1
Recieved → Received Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-10-04os: Don't re-declare ConnectionInputPtr and ConnectionOutputPtrKeith Packard1-2/+2
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-04Fix FlushClient to write extraBuf when provided (regression fix)Keith Packard1-1/+4
In commit: commit 092c57ab173c8b71056f6feb3b9d04d063a46579 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-09-20os: Hide the Connection{In,Out}put implementation detailsAdam Jackson3-20/+23
Reviewed-by: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-09-20dix: Extend initial connection handshake for forwarding proxiesAdam Jackson1-5/+5
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-20dix: Pull client-is-local flag up to the ClientRecAdam Jackson3-11/+2
Reviewed-by: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-09-20os: Repack ConnectionOutput for LP64Adam Jackson1-1/+1
Reviewed-by: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-08-23os: fix typo, fsync when WIN32 is _not_ definedPeter Hutterer1-1/+1
Introduced in 164b38c72fe9c69d13ea4f9c46d4ccc46566d826 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-21os: don't block signal-unsafe logging, merely warn about it.Peter Hutterer1-14/+24
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-21os: add support for %d and %i to pnprintfPeter Hutterer1-0/+10
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-21Add FormatInt64 to convert signed integers in signal-safe mannerPeter Hutterer1-0/+14
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2012-08-07os: don't unconditionally unblock SIGIO in OsReleaseSignals()Peter Hutterer1-8/+5
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-03os: Fix TMP fall-back in Win32TempDir()Colin Harrison1-1/+1
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-07-17xwin: Clean up os wrappers for System, Popen and Pclose on WindowsKeith Packard1-0/+73
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-10Merge branch 'local-fixes'Keith Packard2-0/+14
2012-07-10GLX: Remove unused noGlxVisualInitDaniel Stone1-1/+0
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-09Don't make failure to -nolisten fatalDaniel Stone1-2/+2
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-09Replace padlength tables with inline functions from misc.hAlan Coopersmith1-4/+2
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-09Initialize padding bits to 0 in ErrorConnMax()Alan Coopersmith1-1/+1
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-09Set padding bytes to 0 in WriteToClientAlan Coopersmith1-1/+5
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-09Reliably reset signals at server init timeKeith Packard2-0/+14
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-04Merge branch 'sigio-vt-switch-issues' into for-keithPeter Hutterer1-3/+51
Conflicts: test/Makefile.am Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-03os: add OsBlockSIGIO and OsReleaseSIGIOPeter Hutterer1-3/+51
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-02Merge branch 'sigsafe-logging-varargs'Keith Packard4-28/+250
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-02Log safely in fatal signal handlerChase Douglas1-4/+4
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-02Warn when attempting to log in a signal unsafe manner from signal contextChase Douglas1-0/+20
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-02Print backtrace in a signal-safe mannerChase Douglas1-20/+29
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-02Add ErrorFSigSafe() alternative to ErrorF()Chase Douglas1-0/+16
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-02Add LogMessageVerbSigSafe() for logging messages while in signal contextChase Douglas1-4/+131
[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-06-22os: print newline after printing display namePeter Hutterer1-0/+1
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-21Add FormatUInt64{,Hex}() for formatting numbers in a signal safe mannerChase Douglas1-0/+44
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-21Save log file file descriptor for signal context loggingChase Douglas1-0/+4
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-21Add global variable inSignalContextChase Douglas1-0/+2
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-05-09Merge remote-tracking branch 'whot/for-keith'Keith Packard2-55/+94
2012-05-04os: Add CryptoAPI as a choice of SHA1 implementationYaakov Selkowitz1-0/+42
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-03os/log: refactor loggingDaniel Kurtz1-51/+46
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-03os/log: only write timestamp if a message is actually written to logfileDaniel Kurtz1-9/+9
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-03os/xprintf: add Xvscnprintf and XscnprintfDaniel Kurtz1-0/+44
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-03os/log: trivial cleanupsDaniel Kurtz1-2/+2
* 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-01os: make timers signal-safePeter Hutterer1-2/+16
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-01os: Add -displayfd optionChase Douglas2-20/+57
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-03-30os: Fix regression with FatalError not calling va_startJeremy Huddleston1-0/+2
Regression From: a818b305989bbcde4e585112a7ee70cbc0b14a92 Found-by: Colin Harrison <colin.harrison@virgin.net> Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-03-24os: Pass the FatalError message to OsVendorFatalErrorJeremy Huddleston1-7/+11
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com> Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>