[Mono-list] Aquire Root Privileges

Ian Norton inb at ncipher.com
Thu Jun 16 02:43:09 EDT 2011

I think the op meant you to use chmod and chown to make the exe setguid 

I will admit that i've not tried this yet. You make have to provide a small shell script wrapper like so.

mono path/to/myprog.exe

And then do :

$ su -
$ chown root myscript
$ chmod 700 myscript
$ chmod u+s myscript
$ exit
$ ./myscript

Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Enqueue <danielku15 at yahoo.de> wrote:

Thanks for the idea. I did a lot of research but I don't get it work. I tried
to create a small application for testing purposes:
using System;
using System.IO;
using System.Runtime.InteropServices;

namespace AdminTest {
class AdminTest {
public static void Main(string[] args) {
Console.WriteLine("Current uid/gid: {0}/{1}", getuid(),
int resultGid = setgid(0);
if(resultGid != 0)
Console.WriteLine("Errorcode gid: {0}",
int resultUid = setuid(0);
if(resultUid != 0)
Console.WriteLine("Errorcode uid: {0}",
Console.WriteLine("Aquire root rights {0}", result);
[DllImport ("libc", SetLastError=true)]
public static extern int setgid(int gid);
[DllImport ("libc", SetLastError=true)]
public static extern int getgid();
[DllImport ("libc", SetLastError=true)]
public static extern int setuid(int uid);
[DllImport ("libc", SetLastError=true)]
public static extern int getuid();

After compiling and executing I only get:
Current uid/gid: 501/20
Errorcode gid: 1
Errorcode uid: 1
Aquire root rights -1/-1
Current uid/gid: 501/20
I tried the same exe under (sudo su):
Current uid/gid: 0/0
Aquire root rights 0/0
Current uid/gid: 0/0
I expected some kind of "Mono wants to access administrator
privileges"-Popup of the keychain but nothing happened. I would still need
to do some chown and chmod stuff (chown root.root, chmod +s) to allow the
application accessing root privileges and therefore I still have the same
problem. How do all those installers solve this problem?


View this message in context: http://mono.1490590.n4.nabble.com/Aquire-Root-Privileges-tp3600287p3600761.html
Sent from the Mono - General mailing list archive at Nabble.com.

Mono-list maillist - Mono-list at lists.ximian.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20110616/a940047a/attachment-0001.html 

More information about the Mono-list mailing list