From 7b377d282e5cdf0bd4e9dec9570aca3647040cb0 Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Thu, 3 Aug 2023 08:34:22 -0400 Subject: [PATCH] Fix x11 socket directory by setting umask --- ph-init/src/audio.rs | 2 +- ph-init/src/init.rs | 9 ++++++--- ph-init/src/sys.rs | 5 +++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ph-init/src/audio.rs b/ph-init/src/audio.rs index cc83cae..a6eb0a6 100644 --- a/ph-init/src/audio.rs +++ b/ph-init/src/audio.rs @@ -1,5 +1,5 @@ use std::fs; -use crate::{Error, sys, warn}; +use crate::{Error, sys}; use crate::error::Result; use std::path::Path; diff --git a/ph-init/src/init.rs b/ph-init/src/init.rs index 5e2f12e..51f03c7 100644 --- a/ph-init/src/init.rs +++ b/ph-init/src/init.rs @@ -1,7 +1,7 @@ -use crate::{Error, Result, Logger, LogLevel, netlink}; +use crate::{Error, Result, Logger, LogLevel, netlink, sys}; use crate::cmdline::CmdLine; -use crate::sys::{sethostname, setsid, set_controlling_tty, mount_devtmpfs, mount_tmpfs, mkdir, umount, mount_sysfs, mount_procfs, mount_devpts, chown, chmod, create_directories, mount_overlay, move_mount, pivot_root, mount_9p, mount, waitpid, reboot, getpid, mount_tmpdir, mount_cgroup, mkdir_mode, umask, _chown}; +use crate::sys::{sethostname, setsid, set_controlling_tty, mount_devtmpfs, mount_tmpfs, mkdir, umount, mount_sysfs, mount_procfs, mount_devpts, chown, chmod, create_directories, mount_overlay, move_mount, pivot_root, mount_9p, mount, waitpid, reboot, getpid, mount_tmpdir, mount_cgroup, umask, _chown}; use std::path::Path; use std::{fs, process, io, env}; use crate::service::{Service, ServiceLaunch}; @@ -90,6 +90,7 @@ impl InitServer { } pub fn setup_filesystem(&self) -> Result<()> { + sys::set_umask(0o022); //mount_devtmpfs()?; mount_tmpfs("/tmp")?; mkdir("/tmp/sysroot")?; @@ -223,7 +224,8 @@ impl InitServer { return Ok(()); } - mkdir_mode("/tmp/.X11-unix", 0o1777)?; + mkdir("/tmp/.X11-unix")?; + chmod("/tmp/.X11-unix", 0o1777)?; self.write_xauth().map_err(Error::XAuthFail)?; let sommelierx = ServiceLaunch::new("sommelier-x", "/opt/ph/usr/bin/sommelier") @@ -249,6 +251,7 @@ impl InitServer { self.configure_network(ip) .map_err(Error::NetworkConfigure)?; } + sys::bind_mount("/opt/ph/etc/resolv.conf", "/etc/resolv.conf")?; } Ok(()) } diff --git a/ph-init/src/sys.rs b/ph-init/src/sys.rs index 16eda2f..67d4966 100644 --- a/ph-init/src/sys.rs +++ b/ph-init/src/sys.rs @@ -7,6 +7,11 @@ use crate::error::{Result,Error}; use libc; use std::path::Path; +pub fn set_umask(mode: u32) { + unsafe { + let _ = libc::umask(mode); + } +} pub fn mount_tmpfs(target: &str) -> Result<()> { mount("tmpfs", target, "tmpfs", 0, Some("mode=755"))