Skip to content

Commit

Permalink
chore: minor tweaks for future sshd support
Browse files Browse the repository at this point in the history
empty implement for sys_setsid, add SO_BINDTODEVICE for sys_getsockopt,
add a new user in `passwd` file, add setitimer syscall id for aarch64
  • Loading branch information
Stone749990226 committed Feb 27, 2025
1 parent 787bbad commit 3d8ce37
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion api/ruxos_posix_api/src/imp/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,8 @@ pub fn sys_getsockopt(
| ctypes::SO_RCVTIMEO
| ctypes::SO_REUSEADDR
| ctypes::SO_SNDBUF
| ctypes::SO_SNDTIMEO => 0,
| ctypes::SO_SNDTIMEO
| ctypes::SO_BINDTODEVICE => 0,
_ => return Err(LinuxError::ENOPROTOOPT),
};

Expand Down
8 changes: 8 additions & 0 deletions api/ruxos_posix_api/src/imp/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ pub fn sys_setpgid(pid: pid_t, pgid: pid_t) -> c_int {
debug!("sys_setpgid: pid {}, pgid {} ", pid, pgid);
syscall_body!(sys_setpgid, Ok(0))
}

/// set process sid (empty implementation)
///
/// TODO:
pub fn sys_setsid() -> c_int {
warn!("sys_setsid: do nothing",);
syscall_body!(sys_setsid, Ok(0))
}
2 changes: 1 addition & 1 deletion api/ruxos_posix_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub use imp::prctl::{sys_arch_prctl, sys_prctl};
pub use imp::resources::{sys_getrlimit, sys_prlimit64, sys_setrlimit};
pub use imp::stat::{
sys_getegid, sys_geteuid, sys_getgid, sys_getpgid, sys_getuid, sys_setgid, sys_setpgid,
sys_setuid, sys_umask,
sys_setsid, sys_setuid, sys_umask,
};
pub use imp::sys::{sys_sysinfo, sys_uname};
pub use imp::sys_invalid;
Expand Down
10 changes: 9 additions & 1 deletion modules/ruxfs/src/mounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ pub(crate) fn etcfs() -> VfsResult<Arc<fs::ramfs::RamFileSystem>> {
etc_root.create("passwd", VfsNodeType::File)?;
let file_passwd = etc_root.clone().lookup("passwd")?;
// format: username:password:uid:gid:allname:homedir:shell
file_passwd.write_at(0, b"root:x:0:0:root:/root:/bin/bash\n")?;
file_passwd.write_at(
0,
b"root:x:0:0:root:/root:/bin/busybox\n\
syswonder:x:1000:1000:root:/root:/bin/busybox\n",
)?;

// Create /etc/group
etc_root.create("group", VfsNodeType::File)?;
Expand All @@ -125,6 +129,10 @@ pub(crate) fn etcfs() -> VfsResult<Arc<fs::ramfs::RamFileSystem>> {
ff02::3 ip6-allhosts\n",
)?;

etc_root.create("services", VfsNodeType::File)?;
let file_services = etc_root.clone().lookup("services")?;
file_services.write_at(0, b"ssh 22/tcp")?;

// Create /etc/resolv.conf
etc_root.create("resolv.conf", VfsNodeType::File)?;
let file_resolv = etc_root.clone().lookup("resolv.conf")?;
Expand Down
3 changes: 3 additions & 0 deletions ulib/ruxmusl/src/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize {
args[0] as *const ctypes::timespec,
args[1] as *mut ctypes::timespec,
) as _,
#[cfg(feature = "signal")]
SyscallId::SETITIMER => ruxos_posix_api::sys_setitimer(args[0] as _, args[1] as _) as _,
SyscallId::CLOCK_SETTIME => ruxos_posix_api::sys_clock_settime(
args[0] as ctypes::clockid_t,
args[1] as *const ctypes::timespec,
Expand Down Expand Up @@ -269,6 +271,7 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize {
ruxos_posix_api::sys_setpgid(args[0] as pid_t, args[1] as pid_t) as _
}
SyscallId::GETPGID => ruxos_posix_api::sys_getpgid(args[0] as pid_t) as _,
SyscallId::SETSID => ruxos_posix_api::sys_setsid() as _,
SyscallId::UNAME => ruxos_posix_api::sys_uname(args[0] as *mut core::ffi::c_void) as _,
SyscallId::GETRLIMIT => {
ruxos_posix_api::sys_getrlimit(args[0] as c_int, args[1] as *mut ctypes::rlimit)
Expand Down
3 changes: 3 additions & 0 deletions ulib/ruxmusl/src/aarch64/syscall_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ pub enum SyscallId {
#[cfg(feature = "multitask")]
FUTEX = 98,
NANO_SLEEP = 101,
#[cfg(feature = "signal")]
SETITIMER = 103,
CLOCK_SETTIME = 112,
CLOCK_GETTIME = 113,
CLOCK_GETRES = 114,
Expand All @@ -100,6 +102,7 @@ pub enum SyscallId {
TIMES = 153,
SETPGID = 154,
GETPGID = 155,
SETSID = 157,
UNAME = 160,
GETRLIMIT = 163,
SETRLIMIT = 164,
Expand Down

0 comments on commit 3d8ce37

Please sign in to comment.