From: RAHUL on
Hi All,

I was trying to figure out the write permissions for a network mounted
directory on my Mac 10.5.8 with the following code, but it seems that
stat and access does not work on mapped directories, while they
reported correct permission for local files, they failed on mapped
directories and reported even the readonly directories as writable.

Is there any other function which I can use to find the permissions
(read/write/execute) for network mounted directories (The mounted
directory resides on a win XP machine)

Thanks in advance

struct stat objFile;
if (0 == stat("/Volumes/readDir", &objFile) && S_IWUSR &
objFile.st_mode )
printf("Dir is writable \n"); // The code printed
success, while I just have read permissions for this drive

// similarly the following also failed and reported SUCCESS
if (0 != access("/Volumes/readDir", W_OK))
printf("FAIL\n");
else
printf("SUCCESS\n");



From: RAHUL on
On Mar 5, 8:21 am, RAHUL <rsharma.ch...(a)gmail.com> wrote:
> Hi All,
>
> I was trying to figure out the write permissions for a network mounted
> directory on my Mac 10.5.8 with the following code, but it seems that
> stat and access does not work on mapped directories, while they
> reported correct permission for local files, they failed on mapped
> directories and reported even the readonly directories as writable.
>
> Is there any other function which I can use to find the permissions
> (read/write/execute) for network mounted directories (The mounted
> directory resides on a win XP machine)
>
> Thanks in advance
>
>      struct stat objFile;
>    if (0 == stat("/Volumes/readDir", &objFile)  && S_IWUSR &
> objFile.st_mode )
>           printf("Dir is writable \n");       // The code printed
> success, while I just have read permissions for this drive
>
> // similarly the following also failed and reported SUCCESS
>      if (0 != access("/Volumes/readDir", W_OK))
>          printf("FAIL\n");
>     else
>          printf("SUCCESS\n");

When I check the mapped dir permission using ls -ltr it shows me
"drwx------" which is the same stat and access are reporting, but the
directory is shared as read only from windows and If I try to create a
file or modify anything it says "The operation could not be completed
because you do not have enough privileges".

So why is ls -ltr reporting wrong when I do not have write permissions
on /volume/redDir

From: Barry Margolin on
In article
<9ba4e4c3-69fa-4c42-9328-89f34068f265(a)w27g2000pre.googlegroups.com>,
RAHUL <rsharma.champ(a)gmail.com> wrote:

> On Mar 5, 8:21�am, RAHUL <rsharma.ch...(a)gmail.com> wrote:
> > Hi All,
> >
> > I was trying to figure out the write permissions for a network mounted
> > directory on my Mac 10.5.8 with the following code, but it seems that
> > stat and access does not work on mapped directories, while they
> > reported correct permission for local files, they failed on mapped
> > directories and reported even the readonly directories as writable.
> >
> > Is there any other function which I can use to find the permissions
> > (read/write/execute) for network mounted directories (The mounted
> > directory resides on a win XP machine)
> >
> > Thanks in advance
> >
> > � � �struct stat objFile;
> > � �if (0 == stat("/Volumes/readDir", &objFile) �&& S_IWUSR &
> > objFile.st_mode )
> > � � � � � printf("Dir is writable \n"); � � � // The code printed
> > success, while I just have read permissions for this drive
> >
> > // similarly the following also failed and reported SUCCESS
> > � � �if (0 != access("/Volumes/readDir", W_OK))
> > � � � � �printf("FAIL\n");
> > � � else
> > � � � � �printf("SUCCESS\n");
>
> When I check the mapped dir permission using ls -ltr it shows me
> "drwx------" which is the same stat and access are reporting, but the
> directory is shared as read only from windows and If I try to create a
> file or modify anything it says "The operation could not be completed
> because you do not have enough privileges".
>
> So why is ls -ltr reporting wrong when I do not have write permissions
> on /volume/redDir

These programs just display the permission mode from the inode.
Mounting a filesystem read-only doesn't change the file mode.

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: RAHUL on
On Mar 5, 8:41 am, Barry Margolin <bar...(a)alum.mit.edu> wrote:
> In article
> <9ba4e4c3-69fa-4c42-9328-89f34068f...(a)w27g2000pre.googlegroups.com>,
>
>
>
>
>
>  RAHUL <rsharma.ch...(a)gmail.com> wrote:
> > On Mar 5, 8:21 am, RAHUL <rsharma.ch...(a)gmail.com> wrote:
> > > Hi All,
>
> > > I was trying to figure out the write permissions for a network mounted
> > > directory on my Mac 10.5.8 with the following code, but it seems that
> > > stat and access does not work on mapped directories, while they
> > > reported correct permission for local files, they failed on mapped
> > > directories and reported even the readonly directories as writable.
>
> > > Is there any other function which I can use to find the permissions
> > > (read/write/execute) for network mounted directories (The mounted
> > > directory resides on a win XP machine)
>
> > > Thanks in advance
>
> > >      struct stat objFile;
> > >    if (0 == stat("/Volumes/readDir", &objFile)  && S_IWUSR &
> > > objFile.st_mode )
> > >           printf("Dir is writable \n");       // The code printed
> > > success, while I just have read permissions for this drive
>
> > > // similarly the following also failed and reported SUCCESS
> > >      if (0 != access("/Volumes/readDir", W_OK))
> > >          printf("FAIL\n");
> > >     else
> > >          printf("SUCCESS\n");
>
> > When I check the mapped dir permission using ls -ltr it shows me
> > "drwx------" which is the same stat and access are reporting, but the
> > directory is shared as read only from windows and If I try to create a
> > file or modify anything it says "The operation could not be completed
> > because you do not have enough privileges".
>
> > So why is ls -ltr reporting wrong when I do not have write permissions
> > on /volume/redDir
>
> These programs just display the permission mode from the inode.  
> Mounting a filesystem read-only doesn't change the file mode.
>
> --
> Barry Margolin, bar...(a)alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***
> *** PLEASE don't copy me on replies, I'll read them in the group ***

Then is there any way to get the actual file permissions, with which
the directory was shsared on its original computer.
Will lstat help??

Thanks
From: David Schwartz on
On Mar 4, 7:41 pm, Barry Margolin <bar...(a)alum.mit.edu> wrote:

> These programs just display the permission mode from the inode.  
> Mounting a filesystem read-only doesn't change the file mode.

The behavior for 'stat' seems reasonable to me, nothing assures that
other system policies will result in you not getting the access that
the permission bits suggest you should get. However, the behavior for
'access' seems unacceptable to me. This is especially true considering
'EROFS' is a documented return code from 'access'. The point of the
'access' call is to replicate the same checks the actual operation
would do, so that the result from 'access' can be used in place of the
normal access check.

DS