Commit Graph

10 Commits

Author SHA1 Message Date
Crypt Keeper
7498ad335f gojs: drops HTTP support to be compatible with Go 1.21 (#1557)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-05 16:56:18 +08:00
Crypt Keeper
40341af448 fs: returns EBADF on negative file descriptor (#1391)
This changes file descriptors from uint32 to int32 and the
corresponding file table to reject negative values. This ensures
invalid values aren't mistaken for very large descriptor entries, which
can use a lot of memory as the table implementation isn't designed to
be sparse.

See https://pubs.opengroup.org/onlinepubs/9699919799/functions/dirfd.html#tag_16_90

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-04-21 16:08:35 +02:00
Crypt Keeper
8464474e21 gojs: adds support for uid and gid (#1245)
This adds `gojs.WithOSUser` which passes through current user IDs so
that GOOS=js compiled wasm can read them. This also adds support for
reading back the uid and gid on files. In summary, this passes
`os.TestChown` except on windows where it will not work due to lack of
support.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-16 11:07:27 +08:00
Takeshi Yoneda
f24a3f49a4 gojs: refactors out gojs.Config type (#1240)
In order to support more configuration, we should stop using context as
it is getting gnarly.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-15 12:27:47 +08:00
Crypt Keeper
7e953d7483 gojs: introduces --experimental-workdir CLI arg (#1226)
When compiled to `GOOS=js`, wasm does not maintain the working
directory: it is defined by the host. While not explicitly documented,
`os.TestDirFSRootDir` in Go suggests the working directory must be valid
to pass (literally the directory holding the file).

This adds an experimental CLI flag that gives the initial working
directory. This is experimental because while GOOS=js uses this, current
WASI compilers will not, as they maintain working directory in code
managed by wasi-libc, or as a convention (e.g. in Zig).

It is not yet known if wasi-cli will maintain working directory
externally or not.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-13 15:43:45 +08:00
Edoardo Vacchi
599c097603 Add -hostlogging=crypto (#1064)
This allows you to specify multiple logging scopes, both in API and the CLI.

e.g for the CLI.
```bash
$ wazero run --hostlogging=crypto --hostlogging=filesystem --mount=.:/:ro cat.wasm
```

e.g. for Go
```go
loggingCtx := context.WithValue(testCtx, experimental.FunctionListenerFactoryKey{},
	logging.NewHostLoggingListenerFactory(&log, logging.LogScopeCrypto|logging.LogScopeFilesystem))
```

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Adrian Cole <adrian@tetrate.io>
2023-01-28 12:51:44 +02:00
Crypt Keeper
f8a33cef8d logging: avoids logging activity to stdio file descriptors (#1007)
This avoids logging activity on stdio file descriptors, in order to help
make troubleshooting easier. Usually, there isn't an issue in these, yet
wasm panics are harder to read if there is also logging of the ..
logging.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-01-04 16:04:40 +08:00
Crypt Keeper
921df7e7a6 cli: adds -hostlogging=filesystem for diagnosing problems (#966)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-12-28 11:38:24 +08:00
Crypt Keeper
5751bd758c gojs: extracts parameter names into a pseudo name section (#963)
`GOARCH=wasm GOOS=js` defines parameter names in go source, and they are
indirectly related to the wasm parameter "sp". This creates a pseudo
name section so that we can access the parameter names. The alternative
would be adding a hack to normal FunctionDefinition, only used for gojs.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-12-27 14:09:20 +08:00
Crypt Keeper
1ad900d179 gojs: refactors GOOS and GOARCH specific code into their own packages (#959)
This refactors GOOS and GOARCH specific code into their own packages.
This allows logging interceptors to be built without cyclic package
dependencies.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-12-27 08:45:43 +08:00