diff --git a/main.go b/main.go index 1d997c3..aeb3ad7 100644 --- a/main.go +++ b/main.go @@ -60,18 +60,16 @@ func main() { flag.BoolVar(&list, "l", false, "List available PulseAudio devices") flag.Parse() - // we also execute this opportunistically on pulsepid since that's also called as root, but need to do so silently, so no os.Exit()'s - if setcap || pulsepid > 0 { + if setcap { err := makeBinarySetcapped() - if err != nil && !(pulsepid > 0) { + if err != nil { os.Exit(1) } - - if !(pulsepid > 0) { - os.Exit(0) - } + os.Exit(0) } + //TODO:remove this after 0.10. Not required anymore after that. + //We don't remove it right now, since someone could have an old instance running that calls the updated binary if pulsepid > 0 { const MaxUint = ^uint64(0) new := syscall.Rlimit{Cur: MaxUint, Max: MaxUint} diff --git a/module.go b/module.go index ff1e103..f33e961 100644 --- a/module.go +++ b/module.go @@ -205,12 +205,12 @@ func loadSupressor(ctx *ntcontext, inp *device, out *device) error { func unloadSupressor(ctx *ntcontext) error { log.Printf("Unloading pulseaudio modules\n") - // we ignore errors here on purpose, since NT didn't use to do this for unloading anyways - // and we don't want to prompt for root again - // so this only suceeds with CAP_SYS_RESOURCE, which we want to make the new default anyways. if pid, err := getPulsePid(); err == nil { if lim, err := getRlimit(pid); err == nil { + log.Printf("Trying to remove rlimit. Limit is: %+v\n", lim) removeRlimit(pid) + newLim, _ := getRlimit(pid) + log.Printf("Rlimit: %+v\n", newLim) defer setRlimit(pid, &lim) }