bytecodealliance / bytecodealliance/wasmtime

Permission denied

Open
#7,331 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 19h
Merged PRs (30d)
121

Description

### Steps to Reproduce
(1) The cfile is :
```
#include
#include
#include
#include
#include

int get_fd(const char* file_name, int open_style){
int fd = open(file_name, open_style);
if (fd == -1) {
perror("Failed to open the file");
return 1;
}

return fd;
}

int fd_readdir(const char *path) {
printf("Enter fd_readdir.\n");

DIR *directory;
struct dirent *entry;

directory = opendir(path);

if (directory == NULL) {
perror("opendir");
return 1;
}

while ((entry = readdir(directory)) != NULL) {
printf("%s\n", entry->d_name);
}

closedir(directory);
printf("Leave fd_readdir.\n");
return 0;
}

int readdirQ6TwcRnVK4 (const char *path) {
return fd_readdir(path);
}

int main() {
const char *dirPath = "Data/mydir";
int open_style= O_RDONLY;
int fd = get_fd(dirPath, open_style);
readdirQ6TwcRnVK4(dirPath);
return 0;
}
```
(2)compile the c file into wasm: `./wasi-sdk-16.0/bin/clang --target=wasm32-unkown-wasi --sysroot=./wasi-sdk-16.0/share/wasi-sysroot readdir.c -o readdir.wasm`
(3)exeute open.wasm
`wasmtime run --dir=./Data readdir.wasm`
The permission of Data/mydir is 0400 or 0500 or 0600, user1 create the Data/mydir directory before and user1 execute the Wasm file.

### Expected Results
Using `gcc readdir.c -o readdir` and `./readdir` to execute get the following result:
```
Enter fd_readdir.
.
..
test.txt
Leave fd_readdir.
```

And wamr, wasmedge also print the above message.

### Actual Results
wasmtime prints:
```
Enter fd_readdir.
opendir: Permission denied
```

I'm not sure whether wasmtime and native ubuntu and other runtimes get different could be a bug or only difference ? Maybe something error about the permission?
0400 r--
0500 r-x
0600 rw-

0400, 0500, and 0600 has the read permission

Sorry for bothering you. Thanks a lot !

### Versions and Environment
wasmtime 13.0.0
Operating system: Ubuntu 20.04

Architecture: x86_64

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.