diff --git a/cmd/aisap/main.go b/cmd/aisap/main.go index 378391d..71ea539 100644 --- a/cmd/aisap/main.go +++ b/cmd/aisap/main.go @@ -69,11 +69,6 @@ func main() { return } - perms, err := ai.Permissions() - if err != nil { - cli.Fatal(invalidPerms, err) - return - } if *extractIcon != "" { if *verbose { @@ -126,6 +121,8 @@ func main() { return } + perms, err := ai.Permissions() + if *profile != "" { f, err := os.Open(*profile) if err != nil { @@ -288,7 +285,7 @@ func main() { err = ai.Sandbox(perms, flag.Args()[1:]) if err != nil { - fmt.Fprintln(os.Stdout, "sandbox error:", err) + cli.Fatal("sandbox error:", err); return } } diff --git a/include/aisap.h b/include/aisap.h index 6eba60b..3b7397b 100644 --- a/include/aisap.h +++ b/include/aisap.h @@ -12,11 +12,10 @@ typedef struct aisap_appimage { // For Zig implemenation, points to Zig AppImage void* _zig_parent; -} aisap_appimage ; +} aisap_appimage; typedef enum aisap_socket { AISAP_SOCKET_ALSA, - AISAP_SOCKET_AUDIO, AISAP_SOCKET_CGROUP, AISAP_SOCKET_DBUS, AISAP_SOCKET_IPC, @@ -70,15 +69,12 @@ typedef uint8_t aisap_error; extern "C" { #endif -// Zig-implemented C functions -// `aisap_appimage_new` initializes both the Zig and Go AppImage structs, so -// until I can get the rest of the functions ported over you'll still be able -// to call all of them +// Inits a new `aisap_appimage` +// `path` is a null-terminated string extern aisap_appimage aisap_appimage_new(const char* path, aisap_error* err); -// Like `aisap_appimage_new`, but takes a path length instead of a -// null-terminated path. For this function, path does NOT have to be null- -// terminated +// Like `aisap_appimage_new`, but takes a path length instead of requiring a +// null-terminated path extern aisap_appimage aisap_appimage_newn(const char* path, size_t path_len, aisap_error* err); extern void aisap_appimage_destroy(aisap_appimage* ai); diff --git a/zig/lib/appimage.zig b/zig/lib/appimage.zig index da4aae1..08983b2 100644 --- a/zig/lib/appimage.zig +++ b/zig/lib/appimage.zig @@ -1064,14 +1064,14 @@ pub const AppImage = struct { } /// Returns a `char**` for use in C - pub fn wrapArgsZ(ai: *AppImage, allocator: std.mem.Allocator) ![*:null]?[*:0]const u8 { + pub fn wrapArgsZ(ai: *AppImage, allocator: std.mem.Allocator, perms: Permissions) ![*:null]?[*:0]const u8 { var list = std.ArrayList(?[*:0]const u8).init(allocator); var arena = std.heap.ArenaAllocator.init(allocator); const arena_allocator = arena.allocator(); defer arena.deinit(); - const args_slice = try ai.wrapArgs(arena_allocator); + const args_slice = try ai.wrapArgs(arena_allocator, perms); for (args_slice) |arg| { try list.append(try allocator.dupeZ(u8, arg)); diff --git a/zig/lib/c_api.zig b/zig/lib/c_api.zig index 394bbde..4ac78b6 100644 --- a/zig/lib/c_api.zig +++ b/zig/lib/c_api.zig @@ -135,6 +135,7 @@ export fn aisap_appimage_md5( // Returned memory must be freed export fn aisap_appimage_wrapargs( c_ai: *c.aisap_appimage, + //perms: *c.aisap_permissions, err: *CAppImageError, ) [*:null]?[*:0]const u8 { const ai = getParent(c_ai);