From d28cd0100b89ef182c5c7b39ec1b6b90062647b7 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 2 Apr 2019 07:33:37 +0200 Subject: ringlogger: give unprivd access via inheritable mapping handle --- service/ipc_client.go | 5 ----- service/ipc_server.go | 6 ------ service/service_manager.go | 7 ++++++- 3 files changed, 6 insertions(+), 12 deletions(-) (limited to 'service') diff --git a/service/ipc_client.go b/service/ipc_client.go index 7e260ea7..e6295b91 100644 --- a/service/ipc_client.go +++ b/service/ipc_client.go @@ -141,11 +141,6 @@ func IPCClientQuit(stopTunnelsOnQuit bool) (bool, error) { return alreadyQuit, rpcClient.Call("ManagerService.Quit", stopTunnelsOnQuit, &alreadyQuit) } -func IPCClientLogFilePath() (string, error) { - var path string - return path, rpcClient.Call("ManagerService.LogFilePath", uintptr(0), &path) -} - func IPCClientRegisterTunnelChange(cb func(tunnel *Tunnel, state TunnelState, err error)) *TunnelChangeCallback { s := &TunnelChangeCallback{cb} tunnelChangeCallbacks[s] = true diff --git a/service/ipc_server.go b/service/ipc_server.go index 079dc85c..17ea67c2 100644 --- a/service/ipc_server.go +++ b/service/ipc_server.go @@ -11,7 +11,6 @@ import ( "github.com/Microsoft/go-winio" "golang.org/x/sys/windows/svc" "golang.zx2c4.com/wireguard/windows/conf" - "golang.zx2c4.com/wireguard/windows/ringlogger" "io/ioutil" "net/rpc" "os" @@ -207,11 +206,6 @@ func (s *ManagerService) Quit(stopTunnelsOnQuit bool, alreadyQuit *bool) error { return nil } -func (s *ManagerService) LogFilePath(unused uintptr, filepath *string) error { - *filepath = ringlogger.Global.Filename() - return nil -} - func IPCServerListen(reader *os.File, writer *os.File, events *os.File) error { service := &ManagerService{events: events} diff --git a/service/service_manager.go b/service/service_manager.go index 9fffbfe3..3d7449bd 100644 --- a/service/service_manager.go +++ b/service/service_manager.go @@ -169,6 +169,11 @@ func (service *managerService) Execute(args []string, r <-chan svc.ChangeRequest log.Printf("Unable to listen on IPC pipes: %v", err) return } + theirLogMapping, err := ringlogger.Global.ExportInheritableMappingHandleStr() + if err != nil { + log.Printf("Unable to export inheritable mapping handle for logging: %v", err) + return + } log.Printf("Starting UI process for user: '%s@%s'", username, domain) attr := &os.ProcAttr{ @@ -177,7 +182,7 @@ func (service *managerService) Execute(args []string, r <-chan svc.ChangeRequest }, Files: []*os.File{devNull, devNull, devNull}, } - proc, err := os.StartProcess(path, []string{path, "/ui", theirReaderStr, theirWriterStr, theirEventStr}, attr) + proc, err := os.StartProcess(path, []string{path, "/ui", theirReaderStr, theirWriterStr, theirEventStr, theirLogMapping}, attr) theirReader.Close() theirWriter.Close() theirEvents.Close() -- cgit v1.2.3-59-g8ed1b