Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 413485

Summary: x11-libs/gtk+:2, x11-libs/gtk+:3 unsafe gtk-query-immodules-* usage
Product: Gentoo Linux Reporter: Fabio Erculiani (RETIRED) <lxnay>
Component: New packagesAssignee: Gentoo Linux Gnome Desktop Team <gnome>
Status: RESOLVED FIXED    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 413529    

Description Fabio Erculiani (RETIRED) gentoo-dev 2012-04-25 10:50:40 UTC
In short, gtk-query-immodules-* can fail at runtime and its exit status should be checked before truncating immodules.cache.

Please use something like this (this is the gtk-3.0 version!):

gtk_query_immodules_3() {
	local gtk_conf="${1}"
	local gtk_conf_dir=$(dirname "${gtk_conf}")

	einfo "Generating Gtk3 immodules/gdk-pixbuf loaders listing:"
	einfo "-> ${gtk_conf}"

	mkdir -p "${gtk_conf_dir}"
	local tmp_file=$(mktemp -t tmp.XXXXXXXXXXgtk_query_immodules)
	if [ -z "${tmp_file}" ]; then
		ewarn "gtk_query_immodules: cannot create temporary file"
		return 1
	fi

	if gtk-query-immodules-3.0 > "${tmp_file}"; then
		cat "${tmp_file}" > "${gtk_conf}" || \
			ewarn "Failed to write to ${gtk_conf}"
	else
		ewarn "Cannot update gtk.immodules, file generation failed"
	fi
	rm "${tmp_file}"
}

Reproducible: Always
Comment 1 Fabio Erculiani (RETIRED) gentoo-dev 2012-04-25 10:52:21 UTC
If we want to be 100% paranoid, we should also make "cat" atomic, but I think it's overkill.
Comment 2 Naohiro Aota gentoo-dev 2012-05-13 22:06:45 UTC
Seems "/usr/bin/gtk-query-immodules-3.0 --update-cache" do this properly. It create /usr/lib64/gtk-3.0/3.0.0/immodules.cache.XXXXXX
Comment 3 Gilles Dartiguelongue (RETIRED) gentoo-dev 2013-01-13 16:26:55 UTC
Does this report still apply to current eclass ?
Comment 4 Pacho Ramos gentoo-dev 2013-01-13 22:53:48 UTC
  21 Jun 2012; Naohiro Aota <naota@gentoo.org> gnome2-utils.eclass:
  Add new function gnome2_query_immodules_gtk{2,3} to update immodules cache.
  #413529