mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Shell: use access() syscall to check if files are executable by user
This commit is contained in:
parent
9e365a6c1c
commit
13c122b8b2
Notes:
sideshowbarker
2024-07-19 07:15:28 +09:00
Author: https://github.com/sunverwerth Commit: https://github.com/SerenityOS/serenity/commit/13c122b8b22 Pull-request: https://github.com/SerenityOS/serenity/pull/1984
1 changed files with 2 additions and 4 deletions
|
@ -1019,9 +1019,7 @@ void cache_path()
|
|||
while (programs.has_next()) {
|
||||
auto program = programs.next_path();
|
||||
String program_path = String::format("%s/%s", directory.characters(), program.characters());
|
||||
struct stat program_status;
|
||||
int stat_error = stat(program_path.characters(), &program_status);
|
||||
if (!stat_error && (program_status.st_mode & S_IXUSR))
|
||||
if (access(program_path.characters(), X_OK) == 0)
|
||||
cached_path.append(program.characters());
|
||||
}
|
||||
}
|
||||
|
@ -1098,7 +1096,7 @@ int main(int argc, char** argv)
|
|||
int stat_error = stat(file_path.characters(), &program_status);
|
||||
if (stat_error)
|
||||
continue;
|
||||
if (!(program_status.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
|
||||
if (access(file_path.characters(), X_OK) != 0)
|
||||
continue;
|
||||
if (S_ISDIR(program_status.st_mode)) {
|
||||
if (!suggest_executables)
|
||||
|
|
Loading…
Reference in a new issue