diff options
author | lawl <github@dumbinter.net> | 2021-01-31 07:52:11 +0100 |
---|---|---|
committer | lawl <github@dumbinter.net> | 2021-01-31 07:57:33 +0100 |
commit | 54f9e012e3ca3913ab1f1c911db6750c7e80f8a0 (patch) | |
tree | 75b0194bd6a41540f190169f0e7bc48c142479f3 | |
parent | 730dc35d94734a41bf59eeed4955ff8c87da7b60 (diff) |
Make sure we remove rlimit for unloading too0.10.0
-rw-r--r-- | main.go | 12 | ||||
-rw-r--r-- | module.go | 6 |
2 files changed, 8 insertions, 10 deletions
@@ -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} @@ -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) } |