Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a file in the root directory which I want to open for editing in my QT application. Generally we use "sudo (editor) filepath" to open the file with roots permissions. But i want to achieve this in my c++ QT application. Any kind of help is appreciable. Thank you.

share|improve this question
    
sudo (editor) filepath runs (editor) with Administrator privileges passing filepath to it as a parameter. So sudo my-c-application would run my-c-application as with the required privileges. Or if your application has a GUI gksudo my-c-application. Replace my-c-application with the name of your program –  Warren Hill May 10 '13 at 17:52
add comment

1 Answer

up vote 0 down vote accepted

as I know you can do it in two ways.

  1. Remove or disable the root prompt when ever we are trying to access the root mounted dir. But the pros & cons are mentioned here very clearly.

  2. Everytime if you will access the same directory/file then you can change file permission to that directory as everyone access& modify it. for that consideration read this page.

so choose what best suits you.

hope that helps a bit.

share|improve this answer
    
The second option looks interesting. But is it possible to give permission to a file such that only my application can access it when the application is ran by any user. but those any user can't modify the file unless they are using the application. –  Aces Smart May 10 '13 at 17:02
    
No you can't make it for application but you can make it for current login user . Look at the link I gave you. –  raaz May 10 '13 at 17:22
add comment

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.