#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/updater/linux/systemd_util.h"
#include <fcntl.h>
#include <sys/un.h>
#include <systemd/sd-daemon.h>
#include <unistd.h>
#include <optional>
#include <utility>
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/files/file_descriptor_watcher_posix.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
#include "base/process/launch.h"
#include "base/process/process.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/linux/ipc_constants.h"
#include "chrome/updater/updater_branding.h"
#include "chrome/updater/util/posix_util.h"
namespace updater {
class [[maybe_unused, nodiscard]] SystemctlLauncherScopedAllowBaseSyncPrimitives
: public base::ScopedAllowBaseSyncPrimitives { … };
namespace {
const base::FilePath kSystemUnitDirectory("/etc/systemd/system");
const base::FilePath kUserUnitRelativeDirectory(".local/share/systemd/user");
constexpr char kUpdaterServiceName[] = PRODUCT_FULLNAME_STRING ".service";
constexpr char kUpdaterSocketName[] = PRODUCT_FULLNAME_STRING ".socket";
constexpr char kUpdaterServiceDefinitionTemplate[] = …;
constexpr char kUpdaterSocketDefinitionTemplate[] = …;
std::optional<base::FilePath> GetUnitDirectory(UpdaterScope scope) { … }
base::CommandLine GetBaseSystemctlCommand(UpdaterScope scope) { … }
void LaunchWithRemaps(base::CommandLine command) { … }
void ReloadUnitFiles(UpdaterScope scope) { … }
void EnableSocketUnit(UpdaterScope scope) { … }
void StopService(UpdaterScope scope) { … }
[[nodiscard]] bool InstallSystemdUnit(base::FilePath unit_path,
std::string unit_definition) { … }
std::string GetLauncherCommandLine(UpdaterScope scope,
base::FilePath launcher) { … }
}
SystemdService::SystemdService() { … }
SystemdService::~SystemdService() = default;
void SystemdService::OnSocketReadable() { … }
bool InstallSystemdUnits(UpdaterScope scope) { … }
bool UninstallSystemdUnits(UpdaterScope scope) { … }
bool SystemdUnitsInstalled(UpdaterScope scope) { … }
}