<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: C/C++ access() problem in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199513#M680752</link>
    <description>Further reading -- I may be wrong, but it looks to me that the getaccess(2) function provides what you want, just in a bit more arcane fashion.&lt;BR /&gt;&lt;BR /&gt;If you check the example at the bottom of the man page -- they're checking whether the file "test" is accessible based on the Effective UID instead of the Real UID, which is what you want.&lt;BR /&gt;</description>
    <pubDate>Thu, 17 Sep 2009 19:03:49 GMT</pubDate>
    <dc:creator>Don Morris_1</dc:creator>
    <dc:date>2009-09-17T19:03:49Z</dc:date>
    <item>
      <title>C/C++ access() problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199507#M680746</link>
      <description>&lt;!--!*#--&gt;When using the access() function in a program that has super-user privs, it will no longer detect presense of a file located under a different directory, with directory and file will only root permissions. &lt;BR /&gt;&lt;BR /&gt;This used to work fine using the C compiler and HP OS 10.x.  Never noticed till now that it does not on HP OS 11iv2 and the aCC/C v3.7 compiler...&lt;BR /&gt;&lt;BR /&gt;Don't know if this is/was a bug and whether the OS or compiler is causing this...any ideas?&lt;BR /&gt;&lt;BR /&gt;Thx. &lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt;&lt;BR /&gt;&lt;BR /&gt;int main(int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;int tmp1 = 0;&lt;BR /&gt;&lt;BR /&gt;  tmp1 = access("/root_owned_dir/testfile.txt", 0);&lt;BR /&gt;&lt;BR /&gt;  printf("result= %d\n", tmp1);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/UNISTD.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Thu, 17 Sep 2009 18:08:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199507#M680746</guid>
      <dc:creator>Craig Smith_13</dc:creator>
      <dc:date>2009-09-17T18:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: C/C++ access() problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199508#M680747</link>
      <description>Hi Craig:&lt;BR /&gt;&lt;BR /&gt;The code works for me on an 11.23 Itanium box.  It correctly returns a result of zero when a file exists and -1 when it doesn't.&lt;BR /&gt;&lt;BR /&gt;By the way, you really should replace the mode parameter with 'F_OK' :-)&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 17 Sep 2009 18:23:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199508#M680747</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-17T18:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: C/C++ access() problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199509#M680748</link>
      <description>James,&lt;BR /&gt;&lt;BR /&gt;Ok thanks for checking.&lt;BR /&gt;&lt;BR /&gt;I assume you did the following:&lt;BR /&gt;mkdir /root_own_dir&lt;BR /&gt;touch /root_own_dir/testifile.txt&lt;BR /&gt;chmod -R 700 /root_own_dir&lt;BR /&gt;chown -R root /root_own_dir&lt;BR /&gt;chmod 6755 testit&lt;BR /&gt;Then run it as a regular user...&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Sep 2009 18:34:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199509#M680748</guid>
      <dc:creator>Craig Smith_13</dc:creator>
      <dc:date>2009-09-17T18:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: C/C++ access() problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199510#M680749</link>
      <description>I don't know how to address this (I've never played with ACLs yet, sorry) -- but the man page indicates this is to be expected:&lt;BR /&gt;&lt;BR /&gt;-- start man page quote ---&lt;BR /&gt;The access() system call checks the file pointed to by path for accessibility according to the bit pattern contained in amode. access() uses the real user ID, not the effective user ID, and the real group ID, not the effective group ID.&lt;BR /&gt;&lt;BR /&gt;--- end man page quote ---&lt;BR /&gt;&lt;BR /&gt;Superuser privileges only change the effective user ID -- the real user ID is still the original user. Hence the behavior you see. Same man page on v1 and v3 and 11.0 -- which makes sense as this could break existing programs and could only have been changed across a major release number version.</description>
      <pubDate>Thu, 17 Sep 2009 18:50:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199510#M680749</guid>
      <dc:creator>Don Morris_1</dc:creator>
      <dc:date>2009-09-17T18:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: C/C++ access() problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199511#M680750</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I assume you did the following...&lt;BR /&gt;&lt;BR /&gt;Well no, not the first time; sorry that was silly :-)&lt;BR /&gt;&lt;BR /&gt;OK, so correcting your typos of "/root_own_dir" and "/root_owned_dir" to match and adding a display of the actual 'errno' I do see failure when running as a regular user:&lt;BR /&gt;&lt;BR /&gt;# ./access.o&lt;BR /&gt;result=-1 errno=13&lt;BR /&gt;&lt;BR /&gt;# ls -l ./access.o&lt;BR /&gt;ls -l access.o&lt;BR /&gt;-rwsr-sr-x   1 root       sys          70288 Sep 17 15:46 access.o&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 17 Sep 2009 18:55:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199511#M680750</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-17T18:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: C/C++ access() problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199512#M680751</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Don just showed me how to read better :-)&lt;BR /&gt;&lt;BR /&gt;I looked at that manpage and completely missed that even having seen errno=13 as the darn result!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 17 Sep 2009 18:58:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199512#M680751</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-17T18:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: C/C++ access() problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199513#M680752</link>
      <description>Further reading -- I may be wrong, but it looks to me that the getaccess(2) function provides what you want, just in a bit more arcane fashion.&lt;BR /&gt;&lt;BR /&gt;If you check the example at the bottom of the man page -- they're checking whether the file "test" is accessible based on the Effective UID instead of the Real UID, which is what you want.&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Sep 2009 19:03:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199513#M680752</guid>
      <dc:creator>Don Morris_1</dc:creator>
      <dc:date>2009-09-17T19:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: C/C++ access() problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199514#M680753</link>
      <description>Don,&lt;BR /&gt;&lt;BR /&gt;Thanks, should have read the man page first. Replacing it with getaccess() does the trick.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;James, &lt;BR /&gt;&lt;BR /&gt;Thanks for testing it out for me.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Craig.&lt;BR /&gt;&lt;BR /&gt;Code:&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt;&lt;BR /&gt;#include &lt;ERRNO.H&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;int main(int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;int tmp1 = 0, err = 0;&lt;BR /&gt;&lt;BR /&gt;  tmp1 = getaccess("/root_owned_dir/testfile.txt", UID_EUID, NGROUPS_EGID_SUPP,&lt;BR /&gt;  (int *)0, (void *)0, (void *)0);&lt;BR /&gt;  &lt;BR /&gt;  if (tmp1 &amp;lt; 0 )&lt;BR /&gt;    err = errno;&lt;BR /&gt;    &lt;BR /&gt;  printf("result= %d, err = %d\n", tmp1, err);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;/SYS&gt;&lt;/ERRNO.H&gt;&lt;/UNISTD.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Thu, 17 Sep 2009 19:32:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199514#M680753</guid>
      <dc:creator>Craig Smith_13</dc:creator>
      <dc:date>2009-09-17T19:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: C/C++ access() problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199515#M680754</link>
      <description>&lt;BR /&gt;Replaced access() with getaccess()&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Sep 2009 19:34:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-c-access-problem/m-p/5199515#M680754</guid>
      <dc:creator>Craig Smith_13</dc:creator>
      <dc:date>2009-09-17T19:34:48Z</dc:date>
    </item>
  </channel>
</rss>

