Bug 79924

Summary: LibreOffice should use stemp in other directories than $HOME first
Product: LibreOffice Reporter: Alban Crequy <alban.crequy>
Component: sdkAssignee: Not Assigned <libreoffice-bugs>
Status: NEW --- QA Contact:
Severity: normal    
Priority: medium CC: caolanm, michael.meeks
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard: EasyHack DifficultyBeginner SkillCpp
i915 platform: i915 features:

Description Alban Crequy 2014-06-11 17:51:35 UTC
Libre Office double mmaps a temporary file to build trampolines block. It attempts to create the temporary file in $HOME, and fallbacks on /tmp:

bridges/source/cpp_uno/shared/vtablefactory.cxx
236	#ifdef USE_DOUBLE_MMAP
237	bool VtableFactory::createBlock(Block &block, sal_Int32 slotCount) const

But $HOME is more likely to be noexec, so it is better to try /tmp first. Using $HOME first can also create annoying complains in LSM such as SELinux or AppArmor.

As an example, libffi tries the following directories, in this order, until it finds something suitable:
1. $TMPDIR,
2. /tmp,
3. /var/tmp,
4. /dev/shm,
5. $HOME,
6. whatever is listed in /etc/mtab,
7. whatever is listed in /proc/mounts

See https://github.com/atgreen/libffi/blob/master/src/closures.c#L382
Comment 1 Michael Meeks 2014-06-11 17:59:16 UTC
T'was Caolan who first told me of the existence of this magic =)
Comment 2 Caolán McNamara 2014-06-12 09:59:00 UTC
I just used /home falling back to /tmp because Ulrich indicated that the temp dirs were more likely to have noexec set (http://www.akkadia.org/drepper/selinux-mem.html)

Should be fairly easy to adapt the code to look in more places and reorder the places it checks, I've no problem with applying any patch that does that. Not on my own current radar to do it though, so I'll set the easyhack flags

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.