[Mono-list] Changing owner, group and permissions

Srdan Dukic srdan.dukic at gmail.com
Tue Apr 13 20:11:55 EDT 2010


On 13 April 2010 16:15, Jonathan Pryor <jonpryor at vt.edu> wrote:

> On Tue, 2010-04-13 at 15:53 +1200, Srdan Dukic wrote:
> > I have a mono program (runs as root) which (as a part of its
> > functionality) goes and creates a directory. This directory should
> > have a non-root owner, a non-root group and I would like to specify
> > what permissions are on the directory.
> >
> > From my understanding of the documentation, there are two ways of
> > doing this: System.IO.Directory.Create(DirectorySecurity) method and
> > Mono.Unix.UnixDirectoryInfo.Create(FileAccessPermissions).
>
> As per the source [0], Directory.Create() doesn't do anything.  Other
> methods which accept a DirectorySecurity argument (like
> Directory.SetAccessControl()) throw NotImplementedException.
>
> In short, I don't think that'll work. :-)
>
> Which leaves UnixDirectoryInfo.Create(FileAccessPermissions) for
> creation.
>
> Setting owner and group can be handled via
> UnixFileSystemInfo.SetOwner()[1].
>
> Setting permissions on the directory can be done via
> UnixFileSystemInfo.FileAccessPermissions [2] or
> UnixFileSystemInfo.Protection [3].
>
>  - Jon
>
> [0]
>
> http://anonsvn.mono-project.com/source/trunk/mcs/class/corlib/System.IO/Directory.cs
> [1]
>
> http://www.go-mono.com/docs/index.aspx?link=M:Mono.Unix.UnixFileSystemInfo.SetOwner
> [2]
>
> http://www.go-mono.com/docs/index.aspx?link=P:Mono.Unix.UnixFileSystemInfo.FileAccessPermissions
> [3]
>
> http://www.go-mono.com/docs/index.aspx?link=P:Mono.Unix.UnixFileSystemInfo.Protection
>
>
>
Thank you for that, looks like exactly what I need. However, I still have a
problem. Now, when I go to try and compile my program, I get the following
error:

gmcs DirCreator.cs -r:Mono.Unix -out:bin/DirCreator.dll
-target:library
error CS0006: cannot find metadata file `Mono.Unix'

I am running CentOS 5.4 (64-bit) version and have the following mono
packages installed:

mono-winforms-1.2.4-2.el5.centos
mono-extras-1.2.4-2.el5.centos
mono-nunit-1.2.4-2.el5.centos
mono-core-1.2.4-2.el5.centos
mono-data-1.2.4-2.el5.centos
mono-web-1.2.4-2.el5.centos
mono-devel-1.2.4-2.el5.centos
mono-locale-extras-1.2.4-2.el5.centos
mono-jscript-1.2.4-2.el5.centos

There is a 'Mono.Posix' namespace which I can get to load, but it doesn't
have a 'UnixFileSystemInfo' class.

I've tried running a 'locate Mono.Unix' command with no result. I can see
the other namespaces under '/usr/lib64/mono/gac/', but no Mono.Unix.

Which packages do I have to install to get the Mono.Unix namespace?

Thank you
-- 
Srđan Đukić
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20100414/4e49ffde/attachment.html 


More information about the Mono-list mailing list