Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writable pipe for an Elevated service? #36

Open
precisionpete opened this issue Oct 27, 2023 · 1 comment
Open

Writable pipe for an Elevated service? #36

precisionpete opened this issue Oct 27, 2023 · 1 comment

Comments

@precisionpete
Copy link

How do I create a named pipe from an elevated service that allows writing from a user space program?

The examples work fine if both ends are running as a user. But I need a user-space program to talk to a service running as the system account.

How do i set the permissions on the pipe?

@precisionpete
Copy link
Author

precisionpete commented Oct 27, 2023

I think I figured it out using github.com/hectane/go-acl

import "github.com/hectane/go-acl"

func server() error {
	server, err := npipe.Listen(pipeName)
	if err != nil {
		return fmt.Errorf("error creating pipe listener: %w", err)
	}
	defer server.Close()

	err = acl.Apply(pipeName, true, false, acl.GrantName(windows.GENERIC_READ|windows.GENERIC_WRITE, "EVERYONE"))
	if err != nil {
		return fmt.Errorf("cannot set permissions on pipe: %w", err)
	}

	myService := new(MyService)
	rpc.Register(myService)

	fmt.Println("Named pipe server is waiting for connections...")

	for {
		conn, err := server.Accept()
		if err != nil {
			return fmt.Errorf("error accepting connection: %w", err)
		}

		go rpc.ServeConn(conn)
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant