Make sure we remove rlimit for unloading too

pull/92/head 0.10.0
lawl 3 years ago
parent 730dc35d94
commit 54f9e012e3

@ -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)
}

Loading…
Cancel
Save