summaryrefslogtreecommitdiff
path: root/os/utils.c
AgeCommit message (Collapse)AuthorFilesLines
2012-09-08Update "spawnl()" patch to reflect fix to Win32TempDir()Jon TURNEY1-1/+1
XXX: Really this should check TMPDIR first, as that's the canonical UNIX way to set this...
2012-09-05Add -notrapsignalsJon TURNEY1-0/+6
Add -notrapsignals to disable catching of fatal signals (to either continue or log) and just use the default signal processing instead Log the thread id where the signal is delivered Various cosmetic fixes to fatal error logging Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2012-09-05Use spawnl() rather than pipe() & fork() to invoke xkbcompJon TURNEY1-0/+32
Implement System() specially on Cygwin not to use fork() and exec(), but spawnl() Use System() and a temp file rather than pipe() & fork() to invoke xkbcomp on cygwin, just as done on mingw Somewhat the counsel of despair, but sometimes Windows is being such a little bitch that the cygwin DLL just can't emulate fork() successfully, so just using spawnl() here is more robust and means I don't have to deal with end-users reporting this as a problem with the xserver Popen is not used, but must be built as it is referenced by sdksyms Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2012-09-05Cygwin/X: turn on -nolock if /tmp is on FATJon TURNEY1-1/+1
Try to be more intelligent with default options, turn on -nolock if /tmp is on FAT as it can't work in that case Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2012-09-05Disable smart scheduler on CygwinJon TURNEY1-0/+2
The smart scheduler firing SIGALRM every 20ms causes serious problems on Cygwin. Symptoms include sporadic 'accept() failed' messages in the log and deadlocks in multiwindow mode. Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
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 Packard1-0/+13
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-09Reliably reset signals at server init timeKeith Packard1-0/+13
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-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-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-01os: Add -displayfd optionChase Douglas1-0/+9
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-21Introduce a consistent coding styleKeith Packard1-851/+815
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>
2011-12-12LockServer: store path to LOCKDIR literal string in a const char *Alan Coopersmith1-3/+1
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-11-23Mark arguments to fopen/popen/system wrappers as const char *Alan Coopersmith1-3/+3
Silencing more gcc -Wwrite-strings warnings Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23Convert a bunch of sprintf to snprintf callsAlan Coopersmith1-2/+2
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-23Convert some malloc + strncpy pairs into strndup callsAlan Coopersmith1-3/+1
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-10-18Fix CVE-2011-4029: File permission change vulnerability.Matthieu Herrb1-1/+1
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-18Fix CVE-2011-4028: File disclosure vulnerability.Matthieu Herrb1-1/+1
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-08-22config: add udev/systemd multi-seat supportLennart Poettering1-0/+10
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-04-04os: fix memory and fd leaks in PopenTiago Vignatti1-0/+3
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-04os: use DebugF for debuggingTiago Vignatti1-14/+4
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-03-14Consolidate all the PATH_MAX handling into misc.hChristopher James Halse Rogers1-11/+0
Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2010-12-27GetTimeInMillis: Use CLOCK_MONOTONIC_COARSE where availableDaniel Stone1-1/+15
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-11-11dix: adds support for none root window backgroundTiago Vignatti1-0/+9
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-11dix: delete logo hack screen saverTiago Vignatti1-14/+0
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-09-10os: simplify smart scheduler init processTiago Vignatti1-5/+4
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-10os: remove useless smart scheduler macrosTiago Vignatti1-19/+2
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-10os/xfree86: remove macro checking for POSIX symbolsTiago Vignatti1-21/+0
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-10os: add -sigstop option for Upstart (or equivalent) startupVignatti Tiago (Nokia-MS/Helsinki)1-0/+5
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-06-20os: Remove unused dev_tty_from_init variableMikhail Gusarov1-4/+1
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-06-20os: Remove unused pread/pwrite/lockit functionsMikhail Gusarov1-50/+0
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-06-10Remove unnecessary parentheses around return values in functionsMikhail Gusarov1-7/+7
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-06Replace deprecated bzero with memsetMikhail Gusarov1-2/+2
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-05-13Removed outdated comments obsoleted by documentation in headersMikhail Gusarov1-27/+0
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-13Replace X-allocation functions with their C89 counterpartsMikhail Gusarov1-8/+8
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-13Clean {X,XNF}{alloc,calloc,realloc,free,strdup} from pre-C89 baggageMikhail Gusarov1-64/+44
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-04-21Merge remote branch 'vignatti/for-keith'Keith Packard1-3/+0
Conflicts: exa/exa.c Signed-off-by: Keith Packard <keithp@keithp.com>
2010-04-21Death to Multibuffer extensionTiago Vignatti1-3/+0
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-19unifdef -B -DRENDER to always include RENDER codeKeith Packard1-8/+0
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-03-29darwin: Generate crash reports on FatalError()Jeremy Huddleston1-0/+2
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com> Acked-by: Adam Jackson <ajax@redhat.com>
2010-03-11os: remove INTERNAL_MALLOC define.Peter Hutterer1-3/+0
There doesn't seem to be anything that defines it and given that the counterpart (the X internal malloc) was removed in 01cfba75229f4b9bf1e4fe80814931acdacde14c it's unlikely to work anyway. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-02-17os: Introduce OsAbort for proper core dumps.Rami Ylimaki1-0/+12
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-12Merge remote branch 'jturney/master'Keith Packard1-4/+0