mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
SystemServer: Change group ownership on all framebuffer devices
WindowServer was not able to utilize any other framebuffer device in the /dev directory due to wrong group ownership of other framebuffer devices. Therefore we need to ensure that when SystemServer starts, it checks all directory entries in /dev, searching for framebuffer devices, and then apply the correct ownership for them.
This commit is contained in:
parent
342e1f0a84
commit
16979bec15
1 changed files with 24 additions and 1 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/Event.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/File.h>
|
||||
|
@ -82,6 +83,28 @@ static void chown_wrapper(const char* path, uid_t uid, gid_t gid)
|
|||
}
|
||||
}
|
||||
|
||||
static void chown_all_framebuffer_devices(group* phys_group)
|
||||
{
|
||||
VERIFY(phys_group);
|
||||
struct stat cur_file_stat;
|
||||
|
||||
Core::DirIterator di("/dev/", Core::DirIterator::SkipParentAndBaseDir);
|
||||
if (di.has_error())
|
||||
VERIFY_NOT_REACHED();
|
||||
while (di.has_next()) {
|
||||
auto entry_name = di.next_full_path();
|
||||
auto rc = stat(entry_name.characters(), &cur_file_stat);
|
||||
if (rc < 0)
|
||||
continue;
|
||||
if (!S_ISBLK(cur_file_stat.st_mode))
|
||||
continue;
|
||||
// FIXME: Try to find a way to not hardcode the major number of framebuffer device nodes.
|
||||
if (major(cur_file_stat.st_rdev) != 29)
|
||||
continue;
|
||||
chown_wrapper(entry_name.characters(), 0, phys_group->gr_gid);
|
||||
}
|
||||
}
|
||||
|
||||
static void prepare_devfs()
|
||||
{
|
||||
// FIXME: Find a better way to all of this stuff, without hardcoding all of this!
|
||||
|
@ -113,7 +136,7 @@ static void prepare_devfs()
|
|||
|
||||
auto phys_group = getgrnam("phys");
|
||||
VERIFY(phys_group);
|
||||
chown_wrapper("/dev/fb0", 0, phys_group->gr_gid);
|
||||
chown_all_framebuffer_devices(phys_group);
|
||||
|
||||
chown_wrapper("/dev/keyboard0", 0, phys_group->gr_gid);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue