Beispiel #1
0
func DropPrivileges(name string) {
	cname := C.CString(name)
	home := C.CString("HOME")
	slash := C.CString("/")
	defer C.cfree(unsafe.Pointer(home))
	defer C.cfree(unsafe.Pointer(cname))
	defer C.cfree(unsafe.Pointer(slash))
	cpw := C.getpwnam(cname)
	C.setgid(cpw.pw_gid)
	C.setuid(cpw.pw_uid)
	C.setenv(home, cpw.pw_dir, 1)
	C.setsid()
	C.chdir(slash)
	C.umask(022)
}
Beispiel #2
0
func (self *PulseMainLoop) NewContext(name string, flags int) *PulseContext {
	name_ := C.CString(name)
	ctx := C.context_new(self.pa, name_, C.pa_context_flags_t(flags))
	var retval *PulseContext = nil
	if ctx != nil {
		retval = &PulseContext{MainLoop: self, ctx: ctx}
	}
	C.cfree(unsafe.Pointer(name_))
	return retval
}
Beispiel #3
0
func (self *PulseContext) NewStream(name string, spec *PulseSampleSpec) *PulseStream {
	name_ := C.CString(name)
	st := C.stream_new(self.MainLoop.pa, self.ctx, name_, C.pa_sample_format_t(spec.Format), C.int(spec.Rate), C.int(spec.Channels))
	var retval *PulseStream = nil
	if st != nil {
		retval = &PulseStream{Context: self, st: st}
	}
	C.cfree(unsafe.Pointer(name_))
	return retval
}
Beispiel #4
0
func (self *PulseContext) SetDefaultSink(name string) int {
	name_ := C.CString(name)
	retval := int(C.context_set_default_sink(self.MainLoop.pa, self.ctx, name_))
	C.cfree(unsafe.Pointer(name_))
	return retval
}