- Bug 242404. Use "lstat()" to find the owner of micasad socket file.

This commit is contained in:
Rajasekaran Nagarajan 2007-03-12 11:11:27 +00:00
parent 27a4acbb83
commit 9f2f0ff262

View File

@ -25,6 +25,7 @@ using System.Net;
using System.IO; using System.IO;
using System.Net.Sockets; using System.Net.Sockets;
using Mono.Unix; using Mono.Unix;
using Mono.Unix.Native;
using System.Text; using System.Text;
namespace Novell.CASA.MiCasa.Communication namespace Novell.CASA.MiCasa.Communication
@ -45,6 +46,7 @@ namespace Novell.CASA.MiCasa.Communication
public void Open() public void Open()
{ {
Stat socketFileStatus;
mSocket = new Socket(AddressFamily.Unix, mSocket = new Socket(AddressFamily.Unix,
SocketType.Stream, SocketType.Stream,
ProtocolType.IP); ProtocolType.IP);
@ -54,13 +56,11 @@ namespace Novell.CASA.MiCasa.Communication
throw new Exception("could not get socket"); throw new Exception("could not get socket");
} }
sockEndPoint = new UnixEndPoint(socketFileName); Syscall.lstat(socketFileName, out socketFileStatus);
UnixFileSystemInfo sockFileInfo = new UnixFileInfo(socketFileName);
UnixUserInfo sockFileOwner = sockFileInfo.OwnerUser;
// root is the owner of the file "/tmp/.novellCASA" // root is the owner of the file "/tmp/.novellCASA"
if (sockFileOwner.UserId == 0) if (socketFileStatus.st_uid == 0)
{ {
sockEndPoint = new UnixEndPoint(socketFileName);
mSocket.Connect(sockEndPoint); mSocket.Connect(sockEndPoint);
} }
else else