Link to home
Start Free TrialLog in
Avatar of rich brown
rich brown

asked on

How do I check if user has write access to a Linux shared network folder using C#?

How do I check if user has write access to a Linux shared network folder using C#?
ASKER CERTIFIED SOLUTION
Avatar of David Favor
David Favor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dr. Klahn
Dr. Klahn

David is correct regarding permissions. stat would seem to be the answer but  the basic linux permissions of (system, group, world) go out the window on modern systems with access control.  

http://man7.org/linux/man-pages/man2/stat.2.html
Usually, user rights are done on the sharing system versus from the client side outside the suggestion David and Dr. KLahn.
Try to open, wrote list, access while trapping.  The difficulty, you would need to be running as the user.
Creating a file requires write access to the directory you want to create it in.

using syscall:  access() might give sufficient answer.
In the case of selinux your program does need a description to allow it to call a creat() on a specific set of directories to create files so you should specify what is allowed....
(would also be needed to open such a file).

man 2 access  might help:   https://linux.die.net/man/2/access
You will need to check for write access to the parent directory.