Fix x11 socket directory by setting umask

This commit is contained in:
Bruce Leidl 2023-08-03 08:34:22 -04:00
parent 3dabe69881
commit 7b377d282e
3 changed files with 12 additions and 4 deletions

View File

@ -1,5 +1,5 @@
use std::fs; use std::fs;
use crate::{Error, sys, warn}; use crate::{Error, sys};
use crate::error::Result; use crate::error::Result;
use std::path::Path; use std::path::Path;

View File

@ -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::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::path::Path;
use std::{fs, process, io, env}; use std::{fs, process, io, env};
use crate::service::{Service, ServiceLaunch}; use crate::service::{Service, ServiceLaunch};
@ -90,6 +90,7 @@ impl InitServer {
} }
pub fn setup_filesystem(&self) -> Result<()> { pub fn setup_filesystem(&self) -> Result<()> {
sys::set_umask(0o022);
//mount_devtmpfs()?; //mount_devtmpfs()?;
mount_tmpfs("/tmp")?; mount_tmpfs("/tmp")?;
mkdir("/tmp/sysroot")?; mkdir("/tmp/sysroot")?;
@ -223,7 +224,8 @@ impl InitServer {
return Ok(()); return Ok(());
} }
mkdir_mode("/tmp/.X11-unix", 0o1777)?; mkdir("/tmp/.X11-unix")?;
chmod("/tmp/.X11-unix", 0o1777)?;
self.write_xauth().map_err(Error::XAuthFail)?; self.write_xauth().map_err(Error::XAuthFail)?;
let sommelierx = ServiceLaunch::new("sommelier-x", "/opt/ph/usr/bin/sommelier") let sommelierx = ServiceLaunch::new("sommelier-x", "/opt/ph/usr/bin/sommelier")
@ -249,6 +251,7 @@ impl InitServer {
self.configure_network(ip) self.configure_network(ip)
.map_err(Error::NetworkConfigure)?; .map_err(Error::NetworkConfigure)?;
} }
sys::bind_mount("/opt/ph/etc/resolv.conf", "/etc/resolv.conf")?;
} }
Ok(()) Ok(())
} }

View File

@ -7,6 +7,11 @@ use crate::error::{Result,Error};
use libc; use libc;
use std::path::Path; use std::path::Path;
pub fn set_umask(mode: u32) {
unsafe {
let _ = libc::umask(mode);
}
}
pub fn mount_tmpfs(target: &str) -> Result<()> { pub fn mount_tmpfs(target: &str) -> Result<()> {
mount("tmpfs", target, "tmpfs", 0, Some("mode=755")) mount("tmpfs", target, "tmpfs", 0, Some("mode=755"))