- Bug 242404. Use "lstat()" to find the owner of micasad socket file.
This commit is contained in:
		| @@ -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 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user