Re: [Fuego] Exception in ftc if called from privileged directory

"Bird, Tim" <[email protected]>
Newsgroups dev.linux.lists.fuego
Message-ID <CY4PR13MB1175946288A6C6CFD675DDB7FD770@CY4PR13MB1175.namprd13.prod.outlook.com>

> -----Original Message-----
> From: Georg Piewald
> 
> 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.

Thanks for the bug report.  I just took a look at the code for do_run_test(),
where this occurs, and you are correct.  do_run_test() is called from
multiple places, though, and I had to double-check that the solution
(to just not do the directory change), worked for all callers.

It worked in my quick testing.  I made a change and pushed it to the
master branch.  Can you pull the change (in fuego-core), and let
me know if this fixes the behavior for you?  (It should, I just tested it
here - but, just to be sure...)

Thanks.
 -- Tim

P.S. By the way,  I added your name and e-mail in the commit message
with a "Reported-by:" line.  Let me know if you'd rather stay anonymous.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.