Revert "libc-wasi: Make rights of STDIN/STDOUT/STDERR fixed and overl…
…ook their access modes (#3694)"
This reverts commit 67fa155878861699336380980c3601f733f56194.
because it broke certain use cases while it isn't clear what it fixed.
tested with: https://github.com/yamt/garbage/tree/master/wasm/httpd https://github.com/yamt/garbage/tree/master/wasm/tty
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4447 https://github.com/bytecodealliance/wasm-micro-runtime/issues/3686#issuecomment-2998903186
I mostly agree that STDXXX can have variant st_filetype because of those tricks,
But, are you suggesting that removing read/write bits based on the access mode is acceptable according to STDXX?
switch (access_mode) {
case WASI_LIBC_ACCESS_MODE_READ_ONLY:
*rights_base &= ~(__wasi_rights_t)__WASI_RIGHT_FD_WRITE;
break;
case WASI_LIBC_ACCESS_MODE_WRITE_ONLY:
*rights_base &= ~(__wasi_rights_t)__WASI_RIGHT_FD_READ;
break;
}
But, are you suggesting that removing read/write bits based on the access mode is acceptable according to STDXX?
yes. i think it's the most straightforward behavior. what's your concern?
@lum1n0us can we decide on this? (and/or https://github.com/bytecodealliance/wasm-micro-runtime/pull/4395) or, do you have some more info? (eg. need a research on something)
The main concern is that after this modification, the code below will allow STDIN to be unreadable and STDOUT to be unwritable in some scenarios, which I don't think should be permitted.
switch (access_mode) {
case WASI_LIBC_ACCESS_MODE_READ_ONLY:
*rights_base &= ~(__wasi_rights_t)__WASI_RIGHT_FD_WRITE;
break;
case WASI_LIBC_ACCESS_MODE_WRITE_ONLY:
*rights_base &= ~(__wasi_rights_t)__WASI_RIGHT_FD_READ;
break;
}
In my view, the access mode (fcntl() & O_ACCMODE) of STDIN and STDOUT should remain untouchable. Therefore, the rights of STDIN and STDOUT should also be constant.
The main concern is that after this modification, the code below will allow STDIN to be unreadable and STDOUT to be unwritable in some scenarios, which I don't think should be permitted.
switch (access_mode) { case WASI_LIBC_ACCESS_MODE_READ_ONLY: *rights_base &= ~(__wasi_rights_t)__WASI_RIGHT_FD_WRITE; break; case WASI_LIBC_ACCESS_MODE_WRITE_ONLY: *rights_base &= ~(__wasi_rights_t)__WASI_RIGHT_FD_READ; break; }In my view, the access mode (fcntl() & O_ACCMODE) of STDIN and STDOUT should remain untouchable. Therefore, the rights of STDIN and STDOUT should also be constant.
do you mean that wasi should be different from the most of posix platforms in the regard? why?