title: How can I check to see if user has execute permissions?
body: <p>I wish to know how to check if the "user" (other than who is running this program)
  has execute permissions on a file ? [C api] </p>
  
  <p>I have looked at "access" it gives information with respect to the caller.</p>
  
  <p>I am looking for something like :-</p>
  
  <pre><code>"&lt;cmd&gt; &lt;user_name&gt; &lt;file_name&gt;"
  </code></pre>
  
  <p>here I am trying to get if <code>&lt;user_name&gt;</code> has execute permissions for <code>&lt;file_name&gt;</code> ?</p>
  
  <p>I am looking C api ?</p>
  
  <p>Possible solution :- I am using the following algo to get this information</p>
  
  <pre><code>boolean_t
  is_user_has_execute_permissions(char *run_as_user)
  {
          /* Check world execute permission */
          if ((cmd_stat.st_mode &amp; S_IXOTH) == S_IXOTH) {
                  return (TRUE);
          }
  
          /* group id for run_as_user */
          getpwnam_r(run_as_user, &amp;pw, buf, passwd_len);
  
          /* Check group execute permission */
          if ((cmd_stat.st_mode &amp; S_IXGRP) == S_IXGRP) {
                  if (pw-&gt;pw_gid == cmd_stat.st_gid)
                          return (TRUE);
          }
  
          return (FALSE);
  }
  </code></pre>
  
  <p>Did anyone see any error in this one ?</p>