kernel: more directory permissions
This commit is contained in:
parent
86b377d4b8
commit
c1dcfca920
11
apps/ls.c
11
apps/ls.c
@ -20,6 +20,7 @@
|
||||
#include <termios.h>
|
||||
#include <time.h>
|
||||
#include <pwd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
@ -417,7 +418,9 @@ int main (int argc, char * argv[]) {
|
||||
|
||||
if (argc == 1 || optind == argc) {
|
||||
TRACE("no file to look up");
|
||||
display_dir(p);
|
||||
if (display_dir(p) == 2) {
|
||||
fprintf(stderr, "%s: %s: %s\n", argv[0], p, strerror(errno));
|
||||
}
|
||||
} else {
|
||||
list_t * files = list_create();
|
||||
while (p) {
|
||||
@ -427,7 +430,7 @@ int main (int argc, char * argv[]) {
|
||||
int t = lstat(p, &f->statbuf);
|
||||
|
||||
if (t < 0) {
|
||||
printf("ls: cannot access %s: No such file or directory\n", p);
|
||||
fprintf(stderr, "%s: %s: %s\n", argv[0], p, strerror(errno));
|
||||
free(f);
|
||||
out = 2;
|
||||
} else {
|
||||
@ -476,7 +479,9 @@ int main (int argc, char * argv[]) {
|
||||
if (i != 0) {
|
||||
printf("\n");
|
||||
}
|
||||
display_dir(file_arr[i]->name);
|
||||
if (display_dir(file_arr[i]->name) == 2) {
|
||||
fprintf(stderr, "%s: %s: %s\n", argv[0], file_arr[i]->name, strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1633,7 +1633,7 @@ uint32_t shell_cmd_cd(int argc, char * argv[]) {
|
||||
}
|
||||
return 0;
|
||||
cd_error:
|
||||
fprintf(stderr, "%s: could not cd '%s': no such file or directory\n", argv[0], argv[1]);
|
||||
fprintf(stderr, "%s: could not cd '%s': %s\n", argv[0], argv[1], strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -500,6 +500,10 @@ static int sys_chdir(char * newdir) {
|
||||
close_fs(chd);
|
||||
return -ENOTDIR;
|
||||
}
|
||||
if (!has_permission(chd, 01)) {
|
||||
close_fs(chd);
|
||||
return -EACCES;
|
||||
}
|
||||
close_fs(chd);
|
||||
free(current_process->wd_name);
|
||||
current_process->wd_name = malloc(strlen(path) + 1);
|
||||
|
Loading…
Reference in New Issue
Block a user