[Fuego] Exception in ftc if called from privileged directory
Georg Piewald <[email protected]>
| Newsgroups | dev.linux.lists.fuego |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I just experienced a Python exception when executing an "ftc run-test"
command:
Traceback (most recent call last):
File "/usr/local/bin/ftc", line 5661, in <module>
main()
File "/usr/local/bin/ftc", line 5550, in main
rcode, run_id = do_run_test(conf, options)
File "/usr/local/bin/ftc", line 4358, in do_run_test
os.chdir(saved_cur_dir)
OSError: [Errno 13] Permission denied: '/root'
It turned out that the problem occurred because I called ftc run-test
from "/root". Ftc first switches to the non-privileged user "jenkins",
then changes the directory, and later wants to switch back to the
previous directory, which fails because of missing privileges.
The author of the code was actually aware of that problem (lines 4357
and 4358 in rev 600c12f):
# FIXTHIS: if called as root, we may need to become root again
before moving here
os.chdir(saved_cur_dir)
I believe there is a really simple fix to this. Just remove these lines
(and also the corresponding line, where saved_cur_dir is set). I'm 99%
sure that changing the current working directory only affects the
current process ("sudo python" in this case), and not the parent
process. So once this process exits, we'll be back in the original
directory anyway. No need to manually switch back.
Greetings,
Georg