Bug 5690

Summary: Lack of sanity check for TMPDIR
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Chen Qi <Qi.Chen>
Component: coreAssignee: Chen Qi <Qi.Chen>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: Medium CC: liezhi.yang, meta.mr.watcher, meta.watcher, richard.purdie, sgw
Version: 1.5   
Target Milestone: 1.7   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Chen Qi 2013-12-27 06:15:19 UTC
Our build system uses a lot of tools and hence have more restrictions on paths than what we might expect.

Here's an example.
If we set in local.conf:
TMPDIR = "/home/chenqi/poky/build-systemd/tmp-no-empty-dev/"
(Pretty reasonable path at a first glance, right?)

We would get the following error.
     ERROR: debugedit failed with exit code 256 (cmd was '/home/chenqi/poky/build-systemd/tmp-no-empty-dev//sysroots/i686-linux/usr/lib/rpm/bin/debugedit' -b '/home/chenqi/poky/build-systemd/tmp-no-empty-dev\
//work/i586-poky-linux' -d '/usr/src/debug' -i -l '/home/chenqi/poky/build-systemd/tmp-no-empty-dev//work/i586-poky-linux/gcc-runtime/4.8.2-r0/debugsources.list' '/home/chenqi/poky/build-systemd/tmp-no-empty\
-dev//work/i586-poky-linux/gcc-runtime/4.8.2-r0/package/usr/lib/libgomp.so.1.0.0'):
     /home/chenqi/poky/build-systemd/tmp-no-empty-dev/sysroots/i686-linux/usr/lib/rpm/bin/debugedit: canonicalization unexpectedly shrank by one character
     ERROR: Function failed: split_and_strip_files
     ERROR: Logfile of failure stored in: /home/chenqi/poky/build-systemd/tmp-no-empty-dev//work/i586-poky-linux/gcc-runtime/4.8.2-r0/temp/log.do_package.7625
     ERROR: Task 731 (/home/chenqi/poky/meta/recipes-devtools/gcc/gcc-runtime_4.8.bb, do_package) failed with exit code '1'

This is because the debugedit tool doesn't like double slashes.
And this puts a restriction on our TMPDIR, that is, the TMPDIR cannot end with trailing slashes.

Compared to having our users stair at the screen trying to figure out what's going on, I think it's better that we output informative error messages early.

That's why a sanity check for TMPDIR is needed.

For now, I'd like to propose the following regexp for our TMPDIR:
^/[a-zA-Z0-9\-_/.~]*[a-zA-Z0-9\-_.~]$

The above regexp implies:
1) TMPDIR must be an absolute path
2) TMPDIR must not contain special chars like # or @.
3) TMPDIR cannot end with trailing slashes.

//Chen Qi
Comment 1 Chen Qi 2014-07-03 07:40:05 UTC
Close this bug as 'WONT FIX' as people don't care about this issue, althought related patches have been sent to the mailing list.