glib/glib
Colin Walters d6cbb29f59 CVE-2012-3524: Hardening for being run in a setuid environment
Some programs attempt to use libglib (or even libgio) when setuid.
For a long time, GTK+ simply aborted if launched in this
configuration, but we never had a real policy for GLib.

I'm not sure whether we should advertise such support.  However, given
that there are real-world programs that do this currently, we can make
them safer with not too much effort.

Better to fix a problem caused by an interaction between two
components in *both* places if possible.

This patch adds a private function g_check_setuid() which is used to
first ensure we don't run an external dbus-launch binary if
DBUS_SESSION_BUS_ADDRESS isn't set.

Second, we also ensure the local VFS is used in this case.  The
gdaemonvfs extension point will end up talking to the session bus
which is typically undesirable in a setuid context.

Implementing g_check_setuid() is interesting - whether or not we're
running in a privilege-escalated path is operating system specific.
Note that GTK+'s code to check euid versus uid worked historically on
Unix, more modern systems have filesystem capabilities and SELinux
domain transitions, neither of which are captured by the uid
comparison.

On Linux/glibc, the way this works is that the kernel sets an
AT_SECURE flag in the ELF auxiliary vector, and glibc looks for it on
startup.  If found, then glibc sets a public-but-undocumented
__libc_enable_secure variable which we can use.  Unfortunately, while
it *previously* worked to check this variable, a combination of newer
binutils and RPM break it:
http://www.openwall.com/lists/owl-dev/2012/08/14/1

So for now on Linux/glibc, we fall back to the historical Unix version
until we get glibc fixed.

On some BSD variants, there is a issetugid() function.  On other Unix
variants, we fall back to what GTK+ has been doing.

Reported-By: Sebastian Krahmer <krahmer@suse.de>
Signed-off-by: Colin Walters <walters@verbum.org>
2012-09-13 18:34:29 -04:00
..
deprecated docs: Describe GCompletion item memory management 2012-08-17 07:16:50 +01:00
glib-mirroring-tab removed all .cvsignore files. SVN doesn't need them. 2007-01-03 11:22:36 +00:00
gnulib Replace -I with $(glib_INCLUDES) and friends 2010-08-06 13:10:34 -04:00
libcharset Quiet down the build a bit 2011-05-28 14:29:08 -04:00
pcre regex: Import PCRE 8.31 2012-07-07 22:08:02 +02:00
tests Fix regression in g_shell_parse_argv() 2012-09-13 10:20:27 +02:00
update-pcre regex: Import PCRE 8.31 2012-07-07 22:08:02 +02:00
.gitignore update .gitignores 2011-06-12 16:17:30 -04:00
abicheck.sh Simply symbols files 2011-05-23 00:21:06 -04:00
docs.c docs: Improve G_GNUC_* documentation 2012-08-16 19:17:41 -04:00
galloca.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
garray.c Add missing allow-none annotations for function parameters. 2012-03-31 20:34:28 +11:00
garray.h array: Add a clear function 2012-01-24 23:25:38 -05:00
gasyncqueue.c Fix malformed GTK-Doc comment blocks: invalid parameters and tags. 2012-04-05 10:23:42 -03:00
gasyncqueue.h gasyncqueue: deprecate GTimeVal-based methods, add relative-delay ones 2012-02-13 09:09:08 -05:00
gasyncqueueprivate.h GAsyncQueue: Move private API to a private header 2011-10-01 20:22:46 -04:00
gatomic.c gatomic: introduce G_ATOMIC_LOCK_FREE 2011-10-18 16:45:28 -04:00
gatomic.h Annotate API introduced for 2.30 with GLIB_AVAILABLE_IN_2_30 2012-05-26 10:13:30 -04:00
gbacktrace.c gbacktrace: g_get_prgname () isn't called for a NULL argument 2012-01-06 14:41:08 -05:00
gbacktrace.h documentation fixes 2011-12-13 23:01:51 -05:00
gbase64.c comments/docs: Fix couple of typos 2012-01-28 07:52:56 +01:00
gbase64.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gbitlock.c GBitLock: turn assumptions of g_futex_int_address into a static assertion 2012-01-02 12:23:01 -05:00
gbitlock.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gbookmarkfile.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
gbookmarkfile.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gbsearcharray.h Spelling fixes 2011-08-29 14:49:32 -04:00
gbytes.c GBytes: add a size argument to g_bytes_get_data 2011-12-15 07:22:37 +01:00
gbytes.h Add a forgotten include guard 2012-03-24 23:00:15 -04:00
gcharset.c GLib: Add forgotten includes and build fixes 2011-10-17 23:54:05 +08:00
gcharset.h Fix an include guard mismatch 2011-10-17 17:01:36 -04:00
gchecksum.c gchecksum: Add g_compute_checksum_for_bytes() 2012-08-06 10:38:39 +02:00
gchecksum.h gchecksum: Add g_compute_checksum_for_bytes() 2012-08-06 10:38:39 +02:00
gconstructor.h Move constructor macros to an internal header and into generated code 2012-01-30 16:59:27 +01:00
gconvert.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
gconvert.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gdataset.c Add compare-and exchange for data lists 2012-09-02 15:09:12 -04:00
gdataset.h Add compare-and exchange for data lists 2012-09-02 15:09:12 -04:00
gdatasetprivate.h Don't include glib.h in other headers 2010-09-03 21:24:40 -04:00
gdate.c comments/docs: Fix couple of typos 2012-01-28 07:52:56 +01:00
gdate.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gdatetime.c GDateTime: pack the struct better 2012-08-17 00:27:10 -04:00
gdatetime.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gdir.c Improve the g_dir_read_name documentation 2012-07-05 22:25:49 -04:00
gdir.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gen-iswide-table.py Bug 648966 - Update g_unichar_iswide and g_unichar_iswide_cjk 2011-04-29 18:03:24 -04:00
gen-script-table.pl Bug 491554 – Update to Unicode 5.1.0 2008-04-08 02:59:05 +00:00
gen-unicode-tables.pl unicode: Add new line break classes from Unicode 6.1.0 2012-02-26 21:24:07 -05:00
genviron.c CVE-2012-3524: Hardening for being run in a setuid environment 2012-09-13 18:34:29 -04:00
genviron.h genviron: #include fixups 2011-10-16 21:41:15 -04:00
gerror.c Add missing allow-none annotations for function parameters. 2012-03-31 20:34:28 +11:00
gerror.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gfileutils.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
gfileutils.h Annotate API introduced for 2.30 with GLIB_AVAILABLE_IN_2_30 2012-05-26 10:13:30 -04:00
ggettext.c Add missing allow-none annotations for function parameters. 2012-03-31 20:34:28 +11:00
ggettext.h Move gettext variations into their own files 2011-10-17 01:50:00 -04:00
ghash.c Add missing allow-none annotations for function parameters. 2012-03-31 20:34:28 +11:00
ghash.h Annotate API introduced for 2.30 with GLIB_AVAILABLE_IN_2_30 2012-05-26 10:13:30 -04:00
ghmac.c g_hmac_get_string: don't allocate and leak an unused buffer 2011-12-14 12:26:16 +00:00
ghmac.h Annotate API introduced for 2.30 with GLIB_AVAILABLE_IN_2_30 2012-05-26 10:13:30 -04:00
ghook.c documentation fixes 2011-12-13 23:01:51 -05:00
ghook.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
ghostutils.c ghostutils: Convert non-ASCII dots to '.' when converting hostnames 2010-12-15 03:56:35 -05:00
ghostutils.h Add hostname-related utilities in glib/ghostutils.h 2009-04-22 08:36:02 -04:00
gi18n-lib.h Bug 548321 – <string.h> is not included in gi18n-lib.h 2008-09-11 16:48:44 +00:00
gi18n.h Bug 548321 – <string.h> is not included in gi18n-lib.h 2008-09-11 16:48:44 +00:00
giochannel.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
giochannel.h Don't use G_DISABLE_DEPRECATED guards around deprecated functions 2011-11-03 00:04:15 -04:00
giounix.c Switch all open() calls to use g_open() 2012-08-28 13:56:59 -04:00
giowin32.c Fix spelling of G_IO_FLAG_IS_WRITEABLE 2011-09-08 20:22:42 -04:00
gkeyfile.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
gkeyfile.h GKeyFile: Add refcounting API 2011-10-15 17:44:45 -04:00
glib_probes.d Initial support for dtrace and systemtap 2010-05-27 14:51:41 -04:00
glib_trace.h Initial support for dtrace and systemtap 2010-05-27 14:51:41 -04:00
glib-init.c glib-init: restore default for G_MESSAGES_PREFIXED 2012-03-13 20:15:21 -04:00
glib-init.h win32: Add a monotonic timer 2011-11-16 09:10:45 +01:00
glib-object.h Clean up includes 2011-05-28 23:27:24 -04:00
glib-private.c CVE-2012-3524: Hardening for being run in a setuid environment 2012-09-13 18:34:29 -04:00
glib-private.h CVE-2012-3524: Hardening for being run in a setuid environment 2012-09-13 18:34:29 -04:00
glib-unix.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
glib-unix.h Annotate API introduced for 2.30 with GLIB_AVAILABLE_IN_2_30 2012-05-26 10:13:30 -04:00
glib.h Add flexible API version boundaries 2012-02-26 23:58:41 -05:00
glib.py Fix GHashTable GDB pretty printing (bug #667420) 2012-01-09 09:29:20 +01:00
glib.rc.in Update the year in the *.rc.in files 2011-06-07 08:55:31 +08:00
glib.stp.in Initial support for dtrace and systemtap 2010-05-27 14:51:41 -04:00
glib.symbols Add new api to symbol lists and docs 2012-09-02 15:10:20 -04:00
glibconfig.h.win32.in Update glibconfig.h.win32(.in) 2012-03-19 15:55:20 +08:00
glibintl.h Remove all uses of G_CONST_RETURN 2011-06-09 11:15:40 -04:00
glist.c Adds g_list_copy_deep and g_slist_copy_deep 2012-06-21 17:21:30 -03:00
glist.h Adds g_list_copy_deep and g_slist_copy_deep 2012-06-21 17:21:30 -03:00
gmacros.h glib/gmacros.h: Fix up attribute to avoid namespace collisions 2012-03-03 13:29:29 -05:00
gmain-internal.h glib-unix: New API to watch some Unix signals 2011-04-27 16:01:39 -04:00
gmain.c gmain: remove unix signal watch if its GSourceFunc returns FALSE 2012-08-27 07:24:15 -04:00
gmain.h Add g_spawn_check_exit_status() 2012-07-10 18:03:56 -04:00
gmappedfile.c GMappedFile: Add g_mapped_file_get_bytes() 2012-08-17 00:48:40 -04:00
gmappedfile.h GMappedFile: Add g_mapped_file_get_bytes() 2012-08-17 00:48:40 -04:00
gmarkup.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
gmarkup.h Revert the GMarkup attribute collect changes 2012-08-20 18:34:13 -04:00
gmem.c gmem.c: array is only paritally filled by memcpy 2012-08-20 16:41:42 +02:00
gmem.h g_clear_pointer: work around gcc helpfulness 2012-05-17 10:47:05 -04:00
gmessages.c g_test_expect_message: add some g_return_if_fail 2012-08-20 16:26:25 -04:00
gmessages.h Don't use G_DISABLE_DEPRECATED guards around deprecated functions 2011-11-03 00:04:15 -04:00
gmirroringtable.h Bug 491554 – Update to Unicode 5.1.0 2008-04-08 02:59:05 +00:00
gnode.c Macro to insert a new GNode "after" the given sibling. 2012-01-24 23:41:23 -05:00
gnode.h Macro to insert a new GNode "after" the given sibling. 2012-01-24 23:41:23 -05:00
goption.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
goption.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gpattern.c Add missing allow-none annotations for function parameters. 2012-03-31 20:34:28 +11:00
gpattern.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gpoll.c Include giochannel.c for G_IO_IN, etc. 2010-09-13 16:52:51 +02:00
gpoll.h documentation fixes 2011-12-13 23:01:51 -05:00
gprimes.c Move gutils docs inline 2011-06-08 23:44:39 -04:00
gprimes.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gprintf.c Replace @Varargs with @... 2011-07-22 15:47:24 +02:00
gprintf.h make it possible to disable single-file includes by defining 2008-03-14 19:30:38 +00:00
gprintfint.h Fix #147651, reported by Oliver Guntermann: 2004-07-21 17:51:28 +00:00
gqsort.c glib/gqsort.c: Fix C99ism/GCCism 2012-03-20 22:29:50 -04:00
gqsort.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gquark.c gquark: clarify G_DEFINE_QUARK docs about the use of quotes 2012-08-28 13:16:23 -04:00
gquark.h G_DEFINE_QUARK: fix up some implementation issues 2012-09-08 14:08:01 -04:00
gqueue.c Fix malformed GTK-Doc comment blocks: add missing colons. 2012-04-05 10:23:39 -03:00
gqueue.h Added API g_queue_free_full(). 2011-12-16 09:51:16 -05:00
grand.c GRand: Check return value of fopen directly 2012-06-22 10:34:46 -04:00
grand.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gregex.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
gregex.h regex: Add new GRegexError code from PCRE 8.31 2012-07-07 22:08:08 +02:00
gscanner.c Fix malformed GTK-Doc comment blocks: add missing colons. 2012-04-05 10:23:39 -03:00
gscanner.h documentation fixes 2011-12-13 23:01:51 -05:00
gscripttable.h unicode: Regenerate gscripttable.h for Unicode 6.1.0 2012-02-26 21:24:07 -05:00
gsequence.c Add missing allow-none annotations for function parameters. 2012-03-31 20:34:28 +11:00
gsequence.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gshell.c Fix regression in g_shell_parse_argv() 2012-09-13 10:20:27 +02:00
gshell.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gslice.c comments/docs: Fix couple of typos 2012-01-28 07:52:56 +01:00
gslice.h Deprecated GSlice config API 2012-08-06 08:52:58 -04:00
gslist.c Add a note of caution to the g_slist_delete_link() docs 2012-06-23 17:30:10 -04:00
gslist.h Adds g_list_copy_deep and g_slist_copy_deep 2012-06-21 17:21:30 -03:00
gspawn-win32-helper.c glib/giowin32.c glib/gmain.c glib/gspawn-win32.c Change gssize casts 2008-08-04 18:46:59 +00:00
gspawn-win32.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
gspawn.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
gspawn.h Exterminate 'the the' 2012-08-18 23:15:58 -04:00
gstdio.c gstdio: Harden g_open() against EINTR 2012-08-27 18:10:12 -04:00
gstdio.h Spelling fixes 2011-08-29 14:49:32 -04:00
gstrfuncs.c Be more careful when using xlocale 2012-07-19 06:32:29 -04:00
gstrfuncs.h Don't use G_DISABLE_DEPRECATED guards around deprecated functions 2011-11-03 00:04:15 -04:00
gstring.c GString: Tweak documentation, add g_string_free_to_bytes() 2012-07-06 10:19:12 -04:00
gstring.h GString: Tweak documentation, add g_string_free_to_bytes() 2012-07-06 10:19:12 -04:00
gstringchunk.c gstringchunk.c: Include gutils.h 2011-10-04 23:08:12 +08:00
gstringchunk.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gtester-report gtester-report: Add an optional 'revision' node 2010-12-28 16:35:12 +00:00
gtester.c GTest: Improve --help output 2012-08-16 21:33:04 -04:00
gtestutils.c Switch all open() calls to use g_open() 2012-08-28 13:56:59 -04:00
gtestutils.h gtestutils: add g_test_add_data_func_full() 2012-08-27 07:31:13 -04:00
gthread-posix.c Fix a typo in a doc comment 2012-08-28 00:08:07 -04:00
gthread-win32.c gthread-win32: update for g_get_monotonic_time() changes 2012-02-09 06:48:12 -05:00
gthread.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
gthread.h Misc doc formatting fixes 2011-10-15 17:00:56 -04:00
gthreadpool.c gthreadpool: set default max_unused_threads and max_idle_time values 2012-07-31 14:37:56 -04:00
gthreadpool.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gthreadprivate.h GThread: handle thread names safely 2011-11-14 22:18:13 -05:00
gtimer.c Document exactly what g_time_val_to_iso8601() produces 2011-11-17 23:11:01 -05:00
gtimer.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gtimezone.c Correct the docs for g_time_zone_adjust_time 2012-06-11 10:25:24 -04:00
gtimezone.h Make single includes mandatory 2011-10-12 00:25:38 -04:00
gtrashstack.c Move GTrashStack out of gutils.[hc] 2011-10-16 16:52:24 -04:00
gtrashstack.h Move GTrashStack out of gutils.[hc] 2011-10-16 16:52:24 -04:00
gtree.c Remove two useless lines of code 2011-11-29 22:16:53 -05:00
gtree.h Don't use G_DISABLE_DEPRECATED guards around deprecated functions 2011-11-03 00:04:15 -04:00
gtypes.h Use __builtin_bswap* for GUINT*_SWAP_LE_BE if building with GCC 2012-03-17 23:28:48 -04:00
gunibreak.c Remove redundant header inclusions 2010-09-03 20:38:30 -04:00
gunibreak.h unicode: Regenerate tables from Unicode 6.1.0 2012-02-26 21:24:07 -05:00
gunichartables.h unicode: Regenerate tables from Unicode 6.1.0 2012-02-26 21:24:07 -05:00
gunicode.h glib/: gtk-doc cleanup 2012-06-25 23:23:58 -04:00
gunicodeprivate.h Don't include glib.h in other headers 2010-09-03 21:12:03 -04:00
gunicollate.c GLib: Add forgotten includes and build fixes 2011-10-17 23:54:05 +08:00
gunicomp.h Update to Unicode 6.0 2011-01-21 16:30:19 -05:00
gunidecomp.c Add missing allow-none annotations for function parameters. 2012-03-31 20:34:28 +11:00
gunidecomp.h Remove comp_step_table table 2011-07-14 16:55:35 -04:00
guniprop.c glib: fix locale detection on android 2012-07-27 19:41:05 +02:00
gurifuncs.c g_uri_unescape_segment: Mention (allow-none)/%NULL in documentation 2012-02-29 13:09:41 -05:00
gurifuncs.h Fix malformed GTK-Doc comment blocks: add missing colons. 2012-04-05 10:23:39 -03:00
gutf8.c Fix g_utf8_validate() out argument transfer mode 2012-06-18 07:39:23 +02:00
gutils.c CVE-2012-3524: Hardening for being run in a setuid environment 2012-09-13 18:34:29 -04:00
gutils.h Annotate API introduced for 2.30 with GLIB_AVAILABLE_IN_2_30 2012-05-26 10:13:30 -04:00
gvariant-core.c GBytes: add a size argument to g_bytes_get_data 2011-12-15 07:22:37 +01:00
gvariant-core.h GBytes: A new type for an immutable set of bytes. 2011-11-24 08:58:38 +01:00
gvariant-internal.h GVariant variable arguments, tests, cleanups 2010-03-08 10:31:19 -05:00
gvariant-parser.c glib: don't quote quark names for G_DEFINE_QUARK 2012-08-28 13:16:24 -04:00
gvariant-serialiser.c GVariant: fix string validation 2012-07-09 12:47:31 -04:00
gvariant-serialiser.h GVariant variable arguments, tests, cleanups 2010-03-08 10:31:19 -05:00
gvariant.c GVariant: add g_variant_check_format_string() 2012-08-20 16:26:25 -04:00
gvariant.h GVariant: add g_variant_check_format_string() 2012-08-20 16:26:25 -04:00
gvarianttype.c GVariantType: gut g_variant_type_check() 2012-08-27 16:12:30 -04:00
gvarianttype.h docs: Tell which function to use to avoid errors. 2011-11-07 15:29:51 +01:00
gvarianttypeinfo.c Add missing allow-none annotations for function parameters. 2012-03-31 20:34:28 +11:00
gvarianttypeinfo.h Spelling fixes 2011-08-29 14:49:32 -04:00
gversion.c Add flexible API version boundaries 2012-02-26 23:58:41 -05:00
gversion.h Fix malformed GTK-Doc comment blocks: remove repeated comment blocks. 2012-04-05 10:23:46 -03:00
gversionmacros.h Clarify the GLIB_VERSION_MIN_REQUIRED/MAX_ALLOWED docs 2012-07-06 12:10:42 -04:00
gwakeup.c docs fixups for glib/ 2011-09-05 19:00:11 -04:00
gwakeup.h gwakeup.h: add missing header for GPollFD 2011-09-09 14:30:01 -04:00
gwin32.c Add missing allow-none annotations for function parameters. 2012-03-31 20:34:28 +11:00
gwin32.h GLib: Add forgotten includes and build fixes 2011-10-17 23:54:05 +08:00
libglib-gdb.py.in Avoid shadowing dir builtin 2010-12-03 14:41:06 -05:00
Makefile.am Put quarks in their own source file 2012-08-28 00:08:06 -04:00
makefile.msc.in win32: Use timeGetTime as monotonic base 2011-11-16 09:10:46 +01:00
win_iconv.c dos2unix glib/win_iconv.c 2010-09-11 12:08:32 +03:00