title: Use PolicyKit to give my application access to restricted files
body: <p>I'm writing an <a href="http://robinj.be/unity-2d-config-util/" rel="nofollow">application</a> for Ubuntu, which allows you to customize the Unity 2D desktop environment.<br />
  Some settings, I can change using Dconf, which is user-specific. So if one user changes a setting, it only applies for that user.<br />
  For other settings, however, I need to edit text files which are located in <code>/usr/share/unity-2d/</code>, to which a normal user can't write. To solve this problem, I thought it was a good idea to have users run the application as root, which makes sure they have access to <code>/usr/share/unity-2d/</code>. Only, when the application is running as root, and one of the Dconf settings is changed, it gets changed in the root user's Dconf, so the changes don't apply to the actual user.</p>
  
  <p>I need to find a solution to this problem, and my first realistic idea was to use PolicyKit. I need to make sure that my application runs as the current user (so not always as root), but that it <em>does</em> have access to <code>/usr/share/unity-2d/</code> and the files inside it. I'm writing the application in C#, using the Mono framework. I don't really have any experience with PolicyKit, and to be honest this is my first attempt in making a serious Linux application.</p>
  
  <p>My idea was PolicyKit, but if one of you has another (realistic) way to achieve this, that fine with me as well. If it comes down to using PolicyKit, I'd like to have a bit more information on how to do this, and what everything does, please. I know I can probably just run my application using <code>pkexec</code>, but I was actually thinking more among the lines of a button in my application to unlock the features which need access to that directory, which <em>at that moment</em> asks for a password to get writing access to the files in the folder. In this way, people who don't have special permissions on the system the application is running on, can still customize some basic settings.</p>