mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 18:32:28 -05:00
LaunchServer: Resolve symlinks when querying for handler application
This lets us launch proper handler application for symlinks :^)
This commit is contained in:
parent
51d559e253
commit
31d659d9a0
1 changed files with 10 additions and 2 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibDesktop/AppFile.h>
|
||||
#include <errno.h>
|
||||
#include <serenity.h>
|
||||
|
@ -252,8 +253,8 @@ void Launcher::for_each_handler(const String& key, HashMap<String, String>& user
|
|||
void Launcher::for_each_handler_for_path(const String& path, Function<bool(const Handler&)> f)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(path.characters(), &st) < 0) {
|
||||
perror("stat");
|
||||
if (lstat(path.characters(), &st) < 0) {
|
||||
perror("lstat");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -269,6 +270,13 @@ void Launcher::for_each_handler_for_path(const String& path, Function<bool(const
|
|||
if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode))
|
||||
return;
|
||||
|
||||
if (S_ISLNK(st.st_mode)) {
|
||||
auto real_path = Core::File::real_path_for(String::formatted("{}/{}", LexicalPath::dirname(path), Core::File::read_link(path)));
|
||||
return for_each_handler_for_path(real_path, [&](const auto& handler) -> bool {
|
||||
return f(handler);
|
||||
});
|
||||
}
|
||||
|
||||
if ((st.st_mode & S_IFMT) == S_IFREG && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
|
||||
f(get_handler_for_executable(Handler::Type::Application, path));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue