From 31d659d9a0a76102c31202b4ed7bd73a4227ff05 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Mon, 9 Aug 2021 21:25:16 +0200 Subject: [PATCH] LaunchServer: Resolve symlinks when querying for handler application This lets us launch proper handler application for symlinks :^) --- Userland/Services/LaunchServer/Launcher.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Userland/Services/LaunchServer/Launcher.cpp b/Userland/Services/LaunchServer/Launcher.cpp index dfb08bc457..d2d0ccbd3e 100644 --- a/Userland/Services/LaunchServer/Launcher.cpp +++ b/Userland/Services/LaunchServer/Launcher.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -252,8 +253,8 @@ void Launcher::for_each_handler(const String& key, HashMap& user void Launcher::for_each_handler_for_path(const String& path, Function 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 { + 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));