Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I sometimes need to run a Qt Creator from root. After that, some config files of Qt Creator suddenly have a root as an owner. Therefore when running Qt Creator as user, I am getting nag warnings about impossibility of writing to those files. Is it possible to prohibit from changing owner of those files?

share|improve this question
2  
Simple, don't run QtCreator as root. Why would that be necessary, you can setup custom post-build script that run as root –  warl0ck Feb 12 '13 at 10:28
    
I used gksudo with path to program as parameter. It allows to run but not to debug. Is it possible to debug? –  ASten Feb 12 '13 at 11:05
    
No, debug a process that doesn't belongs to you requires root permission –  warl0ck Feb 12 '13 at 13:34
    
Perhaps suid /usr/bin/gdb, worth a try and introduce security problem –  warl0ck Feb 12 '13 at 13:34
1  
Thanks, sudo gdbserver helps. –  ASten Feb 12 '13 at 16:14

3 Answers 3

up vote 5 down vote accepted

Problem was solved by using gdbserver run by root.

sudo gdbserver :1234 <path_to_program>

After that, I have connected to 127.0.0.1:1234 from QtCreator's menu and got debugging working. QtCreator was run from ordinary user. Thanks to all for the answering!

share|improve this answer

As aforementioned you shouldn't run Qt Creator as root, but to give answer to your question you can prevent file from changing owner by setup immutable attribute of file (chattr +i filename). It will prevent any modifications of file!

share|improve this answer
1  
Immutable attribute does not solve an issue. Files are still unmodifiable. Although I can run a program using gksudo (for example), the debugging is impossible ("This does not seem to be a debug build"). –  ASten Feb 12 '13 at 11:03
    
You can change ownership back from root account. As I wrote - immutable attribute prevents file to be changed. So if file has owner f.e. "user" and you set +i attr even root user won't be able to change its ownership. He won't be able to modify file at all unless you will remove "i" attr. –  Krzysztof Księżyk Feb 12 '13 at 12:48
    
Good, but neither root can modify those files nor I can do that. Immutable attribute does not allow to change neither content of file nor metadata. The problem is that Qt Creator modifies files at every startup and closing. –  ASten Feb 12 '13 at 16:01

root probably doesn't explicitly change the ownership of those files. Most likely, it deletes or renames them and then recreates ones with the same name.

Forcing root to recreate them with the original uid in that case would not be straightforward. You'd need to remember what the original uid was.

Probably the best you can do is keep track of what files root creates and change the ownership back afterwards.

Of course, as already pointed out, running something like Qt Creator as root is a bad idea in any case.

share|improve this answer
1  
I agree that working under root is bad thing. But the program I need to debug to needs absolute rights. Found solution with help of gdbserver. Thanks for the answer! –  ASten Feb 12 '13 at 15:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.