title: Modify file permissions using C API
body: <p>I have a server component that reads its configuration from a file. The configuration file is also read and written by an administration component. The components are separate programs, and they will be running under separate accounts. I want to change the ACL on the configuration file to:</p>
  
  <pre><code>application: read
  administration: read and write
  </code></pre>
  
  <p>Its important to drop write from the application because the application opens a listening socket. That is, its high risk and I want to contain it as much as possible.</p>
  
  <p>After some searching, it looks like <code>ioctl</code> is used to do it in C. <code>ioctl_list</code> offers a list of control codes but its not apparent to me how to add two users with different permissions on the configuration file. The man page online at <a href="http://linux.die.net/man/2/ioctl_list" rel="nofollow">die.net</a> does not discuss the permissions in-depth or offer sample code. For example the word "perm" (root of "permission") only shows up once in the discussion.</p>
  
  <p>On Windows, reducing permission to honor least privilege is drawn out but its pretty straight forward (Richter gives good examples in his <a href="http://www.amazon.com/Jeffrey-Richter/e/B000APH134" rel="nofollow">Advanced Windows</a> programming series).</p>
  
  <p>How does one change permissions on a linux file using C APIs? What control codes are to be used?</p>
  
  <p>Thanks in advance.</p>