feat: add package sudo-rs

Signed-off-by: sisungo <[email protected]>
This commit is contained in:
sisungo committed 2026-10-29 06:00:54 +00:00
1 parent 9a4c9b6701
commit 25428dc52c
7 files changed
+126 -1

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
# SemiOS PAM service config for un-as operations,
# like sudo.
auth required pam_semios.so
account required pam_semios.so
password required pam_permit.so
session required pam_permit.so
+1 -1
View File
@@ -5,7 +5,7 @@ from lib import arch, cpp
from lib.make import *
version("1.7.2")
version("1.7.2+1")
description("Linux PAM (Pluggable Authentication Modules for Linux) project")
maintainer("sisungo <[email protected]>")
source_url("https://github.com/linux-pam/linux-pam/releases/download/v1.7.2/Linux-PAM-1.7.2.tar.xz")
+38
View File
@@ -0,0 +1,38 @@
## sudoers file.
##
## This file SHOULD be edited with the 'visudo' command as root.
## Failure to use 'visudo' may result in syntax or file permission errors
## that prevent sudo from running.
##
## See the sudoers man page for the details on how to write a sudoers file.
## Defaults specification
##
## Preserve editor environment variables for visudo.
## To preserve these for all commands, remove the "!visudo" qualifier.
Defaults!/bin/visudo env_keep += "SUDO_EDITOR EDITOR VISUAL"
##
## Use a hard-coded PATH instead of the user's to find commands.
## This also helps prevent poorly written scripts from running
## arbitrary commands under sudo.
Defaults secure_path="/bin"
##
## Uncomment this to allow commands run by sudo to see the
## environment variables set by sshd(8).
# Defaults env_keep += "SSH_*"
##
## Uncomment to disable "use_pty" when running commands as root.
## Commands run as non-root users will run in a pseudo-terminal,
## not the user's own terminal, to prevent command injection.
# Defaults>root !use_pty
##
## Uncomment if the historical silent password prompt is desired
# Defaults !pwfeedback
### User privilege specifications
## Allow root to execute any command
root ALL=(ALL:ALL) ALL
## Allow members of group wheel to execute any command
%wheel ALL=(ALL:ALL) ALL
@@ -0,0 +1,26 @@
--- a/src/sudo/mod.rs
+++ b/src/sudo/mod.rs
50,61c50,59
< let mut path = if cfg!(target_os = "freebsd") {
< option_env!("LOCALBASE").unwrap_or("/usr/local").into()
< } else {
< PathBuf::from("/")
< };
< path.push("etc/sudoers-rs");
< if !path.exists() {
< path.set_file_name("sudoers");
< };
<
< dev_info!("Running with {} file", path.display());
< path
---
> let user = PathBuf::from("/var/config/sudo/sudoers");
> if !user.exists() {
> if let Ok(mut path) = std::env::current_exe() {
> path.pop();
> path.pop();
> path.push("share/config/sudoers");
> return path;
> }
> }
> user
@@ -0,0 +1,8 @@
--- a/src/sudo/pam.rs
+++ b/src/sudo/pam.rs
42,43c42,43
< LaunchType::Login if cfg!(feature = "pam-login") => "sudo-i",
< LaunchType::Login | LaunchType::Shell | LaunchType::Direct => "sudo",
---
> LaunchType::Login if cfg!(feature = "pam-login") => "run-as",
> LaunchType::Login | LaunchType::Shell | LaunchType::Direct => "run-as",
@@ -0,0 +1,11 @@
--- a/src/common/resolve.rs
+++ b/src/common/resolve.rs
@@ -144,7 +144,7 @@
// when no -u or -g is specified, default to root:root
(None, None) => {
target_user = User::from_name(c"root")?;
- target_group = Group::from_name(if cfg!(target_os = "linux") {
+ target_group = Group::from_name(if false {
c"root"
} else {
c"wheel"
+35
View File
@@ -0,0 +1,35 @@
import os
import lib.rust as rust
from lib.make import *
version("0.2.15")
description("A memory safe implementation of sudo.")
maintainer("sisungo <[email protected]>")
source_managed("github://trifectatechfoundation/sudo-rs#v0.2.15", "rust")
builddep("shortcut/rust")
builddep("libpam-dev @target")
def build():
rust.build()
on_build(build)
configdir = os.getcwd() + "/config"
def pack(composer):
os.chdir(rust.artifacts_dir())
composer.makedir("bin")
composer.add("sudo", "bin/sudo")
composer.add("visudo", "bin/visudo")
composer.makedir("share")
composer.add(configdir, "share/config")
package("sudo")
dep("semi-libc @same-arch")
dep("libpam @same-arch")
on_pack(pack)