mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-07-01 18:39:16 +00:00
feat(kernel): implement handling symbolic links in paths
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
@ -100,6 +100,12 @@ namespace Execute
|
||||
BinaryType GetBinaryType(std::string Path)
|
||||
{
|
||||
FileNode *node = fs->GetByPath(Path.c_str(), nullptr);
|
||||
if (node->IsSymbolicLink())
|
||||
{
|
||||
char buffer[512];
|
||||
node->ReadLink(buffer, sizeof(buffer));
|
||||
node = fs->GetByPath(buffer, node->Parent);
|
||||
}
|
||||
debug("Checking binary type of %s (returning %p)", Path.c_str(), node);
|
||||
assert(node != nullptr);
|
||||
return GetBinaryType(node);
|
||||
|
@ -335,6 +335,13 @@ namespace Execute
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ifd->IsSymbolicLink())
|
||||
{
|
||||
char buffer[512];
|
||||
ifd->ReadLink(buffer, sizeof(buffer));
|
||||
ifd = fs->GetByPath(buffer, ifd->Parent);
|
||||
}
|
||||
|
||||
debug("ifd: %p, interpreter: %s", ifd, interpreterPath.c_str());
|
||||
if (GetBinaryType(interpreterPath) != BinTypeELF)
|
||||
{
|
||||
@ -798,6 +805,14 @@ namespace Execute
|
||||
error("Failed to open %s, errno: %d", AbsolutePath.c_str(), fd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fd->IsSymbolicLink())
|
||||
{
|
||||
char buffer[512];
|
||||
fd->ReadLink(buffer, sizeof(buffer));
|
||||
fd = fs->GetByPath(buffer, fd->Parent);
|
||||
}
|
||||
|
||||
debug("Opened %s", AbsolutePath.c_str());
|
||||
|
||||
int argc = 0;
|
||||
|
@ -40,9 +40,20 @@ namespace Execute
|
||||
return -ENOENT;
|
||||
|
||||
if (!fd->IsRegularFile())
|
||||
return -ENOEXEC;
|
||||
{
|
||||
if (fd->IsSymbolicLink())
|
||||
{
|
||||
char buffer[512];
|
||||
fd->ReadLink(buffer, sizeof(buffer));
|
||||
fd = fs->GetByPath(buffer, fd->Parent);
|
||||
if (fd == nullptr)
|
||||
return -ENOENT;
|
||||
}
|
||||
else
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
switch (GetBinaryType(Path))
|
||||
switch (GetBinaryType(fd))
|
||||
{
|
||||
case BinaryType::BinTypeELF:
|
||||
{
|
||||
|
Reference in New Issue
Block a user