Post

Replies

Boosts

Views

Activity

How to authenticate shared memory?
I am listening for the ES_EVENT_TYPE_AUTH_MMAP event, but did not see mmap MAP_SHARED authentication callback, only see the following logs 2023-02-02 20:11:32.713347+0800 0x12ac8 Default 0x0 404 0 com.test.es: ➔D|320 [M_IPC]: ES_EVENT_TYPE_AUTH_MMAP: pid:1443, path:/Users/armmini/go/src/myapp/maptest, sourcePath:/Users/armmini/go/src/myapp/maptest, path_tuncated:0, flag:0x40002, protection:0x1, max_protection:0x7 2023-02-02 20:11:32.715234+0800 0x12ac8 Default 0x0 404 0 com.test.es: ➔D|320 [M_IPC]: ES_EVENT_TYPE_AUTH_MMAP: pid:1443, path:/Users/armmini/go/src/myapp/maptest, sourcePath:/Users/armmini/go/src/myapp/maptest, path_tuncated:0, flag:0x12, protection:0x3, max_protection:0x3 2023-02-02 20:11:32.715402+0800 0x12ac8 Default 0x0 404 0 com.test.es: ➔D|320 [M_IPC]: ES_EVENT_TYPE_AUTH_MMAP: pid:1443, path:/Users/armmini/go/src/myapp/maptest, sourcePath:/Users/armmini/go/src/myapp/maptest, path_tuncated:0, flag:0x12, protection:0x3, max_protection:0x3 Demo as follows package main /* #include <sys/mman.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/shm.h> #include <sys/ipc.h> #define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) int my_shm_new(char *name) { shm_unlink(name); return shm_open(name, O_RDWR|O_CREAT|O_EXCL, FILE_MODE); } int my_shm_open(char *name) { return shm_open(name, O_RDWR); } */ import "C" import ( "flag" "fmt" "unsafe" ) const SHM_Name = "my_shm" const SHM_Size = 1000 * 1000 type SHM_Data struct { data [1024]byte } func main() { send(*msg) // receive() } func send(msg string) { fd, err := C.my_shm_new(C.CString(SHM_Name)) if err != nil { fmt.Printf("1 %v", err) return } C.ftruncate(fd, SHM_Size) ptr, err := C.mmap(nil, SHM_Size, C.PROT_READ|C.PROT_WRITE, C.MAP_SHARED, fd, 0) if err != nil { fmt.Printf("2 %v", err) return } C.close(fd) data := (*SHM_Data)(unsafe.Pointer(ptr)) msgByte := []byte(msg) for idx, b := range msgByte { data.data[idx] = b } } func receive() { fd, err := C.my_shm_open(C.CString(SHM_Name)) if err != nil { fmt.Println(err) return } ptr, err := C.mmap(nil, SHM_Size, C.PROT_READ|C.PROT_WRITE, C.MAP_SHARED, fd, 0) if err != nil { fmt.Println(err) return } C.close(fd) data := (*SHM_Data)(unsafe.Pointer(ptr)) bt := make([]byte, 0) for _, b := range data.data { bt = append(bt, b) } fmt.Println("Receive:", string(bt)) }
0
0
626
Feb ’23
A very serious problem about NetworkExtension NETransparentProxyProvider
Version: MacOS 12.1 When I was using NETransparentProxyProvider, I overrive handleNewFlow, handleNewUDPFlow , and return true for some process, and then call - (void)openWithLocalEndpoint:(NWHostEndpoint *)localEndpoint completionHandler:(void (^)(NSError *error))completionHandler; at the beginning, work fine, buy sometime, when I visited qiye.163.com website, I often got an error when I do code below: - (void)writeData:(NSData *)data withCompletionHandler:(void (^)(NSError *error))completionHandler; Error Domain=NEAppProxyFlowErrorDomain Code=1 "The operation could not be completed because the flow is not connected" UserInfo={NSLocalizedDescription=The operation could not be completed because the flow is not connected , and the whole computer could not access the Internet , handleNewFlow and handleNewUDPFlow both are no longer called, unless I turn off the VPN. Turn off VPN and then Internet can be access
9
0
2.2k
Feb ’22
system extension install failed in macos10.15.7, but successful in macos11.6
When I use NEAppProxyProvider system extension, I call OSSystemExtensionRequest.activationRequest and submitRequest, it can do success in macos 11.6, but failed in macos10.15.7 (got: Error Domain=OSSystemExtensionErrorDomain Code=9 "(null)") Why? Here is my plist <dict> <key>NEMachServiceName</key> <string>$(TeamIdentifierPrefix)</string> <key>NEProviderClasses</key> <dict> <key>com.apple.networkextension.app-proxy</key> <string>$(PRODUCT_MODULE_NAME).AppProxyProvider</string> </dict> </dict>
1
0
530
Nov ’21