all: initial support for freebsd
Some checks failed
Build / Nix (push) Has been cancelled
Build / Nix-1 (push) Has been cancelled
Build / Nix-2 (push) Has been cancelled
Build / Nix-3 (push) Has been cancelled
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled

- Use `copy_file_range(2)` over `sendfile(2)` which has wider
compatibility.
- Special case pam on freebsd and document `configDirectory`
incompatibility.
- Disable jemalloc for FreeBSD by default as it is the system allocator.
- Disable breakpad by default on FreeBSD as breakpad is not supported.
This commit is contained in:
molyuu 2025-12-15 12:27:51 +08:00 committed by outfoxxed
parent 341a07d05b
commit 6742148cf4
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
8 changed files with 39 additions and 10 deletions

View file

@ -44,8 +44,13 @@ boption(BUILD_TESTING "Build tests (dev)" OFF)
boption(ASAN "ASAN (dev)" OFF) # note: better output with gcc than clang boption(ASAN "ASAN (dev)" OFF) # note: better output with gcc than clang
boption(FRAME_POINTERS "Keep Frame Pointers (dev)" ${ASAN}) boption(FRAME_POINTERS "Keep Frame Pointers (dev)" ${ASAN})
boption(CRASH_REPORTER "Crash Handling" ON) if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
boption(USE_JEMALLOC "Use jemalloc" ON) boption(CRASH_REPORTER "Crash Handling" OFF)
boption(USE_JEMALLOC "Use jemalloc" OFF)
else()
boption(CRASH_REPORTER "Crash Handling" ON)
boption(USE_JEMALLOC "Use jemalloc" ON)
endif()
boption(SOCKETS "Unix Sockets" ON) boption(SOCKETS "Unix Sockets" ON)
boption(WAYLAND "Wayland" ON) boption(WAYLAND "Wayland" ON)
boption(WAYLAND_WLR_LAYERSHELL " Wlroots Layer-Shell" ON REQUIRES WAYLAND) boption(WAYLAND_WLR_LAYERSHELL " Wlroots Layer-Shell" ON REQUIRES WAYLAND)

View file

@ -21,6 +21,7 @@ set shell id.
## Other Changes ## Other Changes
- FreeBSD is now partially supported.
- IPC operations filter available instances to the current display connection by default. - IPC operations filter available instances to the current display connection by default.
## Bug Fixes ## Bug Fixes

View file

@ -27,7 +27,7 @@
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include <qtypes.h> #include <qtypes.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/sendfile.h> #include <unistd.h>
#include "instanceinfo.hpp" #include "instanceinfo.hpp"
#include "logcat.hpp" #include "logcat.hpp"
@ -392,7 +392,7 @@ void ThreadLogging::initFs() {
delete detailedFile; delete detailedFile;
detailedFile = nullptr; detailedFile = nullptr;
} else { } else {
auto lock = flock { struct flock lock = {
.l_type = F_WRLCK, .l_type = F_WRLCK,
.l_whence = SEEK_SET, .l_whence = SEEK_SET,
.l_start = 0, .l_start = 0,
@ -414,7 +414,7 @@ void ThreadLogging::initFs() {
auto* oldFile = this->file; auto* oldFile = this->file;
if (oldFile) { if (oldFile) {
oldFile->seek(0); oldFile->seek(0);
sendfile(file->handle(), oldFile->handle(), nullptr, oldFile->size()); copy_file_range(oldFile->handle(), nullptr, file->handle(), nullptr, oldFile->size(), 0);
} }
this->file = file; this->file = file;
@ -426,7 +426,14 @@ void ThreadLogging::initFs() {
auto* oldFile = this->detailedFile; auto* oldFile = this->detailedFile;
if (oldFile) { if (oldFile) {
oldFile->seek(0); oldFile->seek(0);
sendfile(detailedFile->handle(), oldFile->handle(), nullptr, oldFile->size()); copy_file_range(
oldFile->handle(),
nullptr,
detailedFile->handle(),
nullptr,
oldFile->size(),
0
);
} }
crash::CrashInfo::INSTANCE.logFd = detailedFile->handle(); crash::CrashInfo::INSTANCE.logFd = detailedFile->handle();
@ -889,7 +896,7 @@ bool LogReader::continueReading() {
} }
void LogFollower::FcntlWaitThread::run() { void LogFollower::FcntlWaitThread::run() {
auto lock = flock { struct flock lock = {
.l_type = F_RDLCK, // won't block other read locks when we take it .l_type = F_RDLCK, // won't block other read locks when we take it
.l_whence = SEEK_SET, .l_whence = SEEK_SET,
.l_start = 0, .l_start = 0,

View file

@ -361,7 +361,7 @@ void QsPaths::createLock() {
return; return;
} }
auto lock = flock { struct flock lock = {
.l_type = F_WRLCK, .l_type = F_WRLCK,
.l_whence = SEEK_SET, .l_whence = SEEK_SET,
.l_start = 0, .l_start = 0,
@ -389,7 +389,7 @@ bool QsPaths::checkLock(const QString& path, InstanceLockInfo* info, bool allowD
auto file = QFile(QDir(path).filePath("instance.lock")); auto file = QFile(QDir(path).filePath("instance.lock"));
if (!file.open(QFile::ReadOnly)) return false; if (!file.open(QFile::ReadOnly)) return false;
auto lock = flock { struct flock lock = {
.l_type = F_WRLCK, .l_type = F_WRLCK,
.l_whence = SEEK_SET, .l_whence = SEEK_SET,
.l_start = 0, .l_start = 0,

View file

@ -54,7 +54,7 @@ bool QmlToolingSupport::lockTooling() {
return false; return false;
} }
auto lock = flock { struct flock lock = {
.l_type = F_WRLCK, .l_type = F_WRLCK,
.l_whence = SEEK_SET, // NOLINT (fcntl.h??) .l_whence = SEEK_SET, // NOLINT (fcntl.h??)
.l_start = 0, .l_start = 0,

View file

@ -6,6 +6,8 @@
#include <qsocketnotifier.h> #include <qsocketnotifier.h>
#include <qstring.h> #include <qstring.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include <csignal>
#include <sys/signal.h>
#include <sys/wait.h> #include <sys/wait.h>
#include "../../core/logcat.hpp" #include "../../core/logcat.hpp"

View file

@ -6,7 +6,11 @@
#include <qtclasshelpermacros.h> #include <qtclasshelpermacros.h>
#include <qthread.h> #include <qthread.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#ifdef __FreeBSD__
#include <security/pam_types.h>
#else
#include <security/_pam_types.h> #include <security/_pam_types.h>
#endif
#include <security/pam_appl.h> #include <security/pam_appl.h>
#include "conversation.hpp" #include "conversation.hpp"
@ -35,6 +39,8 @@ class PamContext
/// ///
/// The configuration directory is resolved relative to the current file if not an absolute path. /// The configuration directory is resolved relative to the current file if not an absolute path.
/// ///
/// On FreeBSD this property is ignored as the pam configuration directory cannot be changed.
///
/// This property may not be set while @@active is true. /// This property may not be set while @@active is true.
Q_PROPERTY(QString configDirectory READ configDirectory WRITE setConfigDirectory NOTIFY configDirectoryChanged); Q_PROPERTY(QString configDirectory READ configDirectory WRITE setConfigDirectory NOTIFY configDirectoryChanged);
/// The user to authenticate as. If unset the current user will be used. /// The user to authenticate as. If unset the current user will be used.

View file

@ -7,7 +7,11 @@
#include <qloggingcategory.h> #include <qloggingcategory.h>
#include <qstring.h> #include <qstring.h>
#include <sched.h> #include <sched.h>
#ifdef __FreeBSD__
#include <security/pam_types.h>
#else
#include <security/_pam_types.h> #include <security/_pam_types.h>
#endif
#include <security/pam_appl.h> #include <security/pam_appl.h>
#include <unistd.h> #include <unistd.h>
@ -83,7 +87,11 @@ PamIpcExitCode PamSubprocess::exec(const char* configDir, const char* config, co
logIf(this->log) << "Starting pam session for user \"" << user << "\" with config \"" << config logIf(this->log) << "Starting pam session for user \"" << user << "\" with config \"" << config
<< "\" in dir \"" << configDir << "\"" << std::endl; << "\" in dir \"" << configDir << "\"" << std::endl;
#ifdef __FreeBSD__
auto result = pam_start(config, user, &conv, &handle);
#else
auto result = pam_start_confdir(config, user, &conv, configDir, &handle); auto result = pam_start_confdir(config, user, &conv, configDir, &handle);
#endif
if (result != PAM_SUCCESS) { if (result != PAM_SUCCESS) {
logIf(true) << "Unable to start pam conversation with error \"" << pam_strerror(handle, result) logIf(true) << "Unable to start pam conversation with error \"" << pam_strerror(handle, result)