func CreateCloneParams(filename string, args []string, env *[]string, cwd *string, suid int, stdhandles StdHandles) (*CloneParams, error) { result := &CloneParams{} var err error result.CommReader, result.CommWriter, err = os.Pipe() if err != nil { return nil, err } result.tls = tools.AlignedBuffer(4096, 16) result.stack = tools.AlignedBuffer(4096, 16) result.repr.tls = (*C.char)(unsafe.Pointer(&result.tls[0])) result.repr.stack = (*C.char)(unsafe.Pointer(&result.stack[len(result.stack)-1])) result.repr.commfd = C.int32_t(result.CommWriter.Fd()) result.repr.filename = C.CString(filename) if cwd != nil { result.repr.cwd = C.CString(*cwd) } if args != nil { result.args = stringsToCchars(args) result.repr.argv = &result.args[0] } if env != nil { result.env = stringsToCchars(*env) result.repr.envp = &result.env[0] } result.repr.suid = C.uint32_t(suid) result.stdhandles = stdhandles result.repr.stdhandles[0] = getFd(result.stdhandles.StdIn) result.repr.stdhandles[1] = getFd(result.stdhandles.StdOut) result.repr.stdhandles[2] = getFd(result.stdhandles.StdErr) runtime.SetFinalizer(result, freeCloneParams) return result, nil }
func CreateNewAcl(length int) (*Acl, error) { result := (*Acl)(unsafe.Pointer(&tools.AlignedBuffer(length, 4)[0])) if err := InitializeAcl(result, uint32(length), ACL_REVISION); err != nil { return nil, err } return result, nil }
func CreateSecurityDescriptor(length int) ([]byte, error) { result := tools.AlignedBuffer(length, 4) if err := InitializeSecurityDescriptor(result); err != nil { return nil, err } return result, nil }