Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
229 commits
Select commit Hold shift + click to select a range
9cb8875
app-admin/logrotate: Sync with Gentoo
Oct 26, 2026
19066c1
app-admin/sudo: Sync with Gentoo
Oct 26, 2026
e1414a2
app-arch/gzip: Sync with Gentoo
Oct 26, 2026
0f652a9
app-arch/libarchive: Sync with Gentoo
Oct 26, 2026
ca1178b
app-arch/xz-utils: Sync with Gentoo
Oct 26, 2026
2dbe9b0
app-containers/conmon: Sync with Gentoo
Oct 26, 2026
5945b0f
app-containers/container-libs: Sync with Gentoo
Oct 26, 2026
4766261
app-containers/containerd: Sync with Gentoo
Oct 26, 2026
18a1e4e
app-containers/containers-shortnames: Sync with Gentoo
Oct 26, 2026
98d4143
app-containers/docker: Sync with Gentoo
Oct 26, 2026
731f6dc
app-containers/docker-buildx: Sync with Gentoo
Oct 26, 2026
0525d09
app-containers/docker-cli: Sync with Gentoo
Oct 26, 2026
d5169c7
app-containers/incus: Sync with Gentoo
Oct 26, 2026
b7e32a8
app-containers/podman: Sync with Gentoo
Oct 26, 2026
f46762e
app-containers/runc: Sync with Gentoo
Oct 26, 2026
f1a8b3a
app-crypt/ccid: Sync with Gentoo
Oct 26, 2026
7293012
app-crypt/gnupg: Sync with Gentoo
Oct 26, 2026
f1834c9
app-crypt/gpgme: Sync with Gentoo
Oct 26, 2026
85d1423
app-crypt/mit-krb5: Sync with Gentoo
Oct 26, 2026
67f5c58
app-crypt/p11-kit: Sync with Gentoo
Oct 26, 2026
efc92aa
app-crypt/sbsigntools: Sync with Gentoo
Oct 26, 2026
08b2d89
app-crypt/tpm2-tools: Sync with Gentoo
Oct 26, 2026
dcedbce
app-doc/eclass-manpages: Sync with Gentoo
Oct 26, 2026
e4888d8
app-editors/nano: Sync with Gentoo
Oct 26, 2026
b4e5589
app-editors/vim: Sync with Gentoo
Oct 26, 2026
7d9eea3
app-editors/vim-core: Sync with Gentoo
Oct 26, 2026
df141c6
app-emulation/qemu: Sync with Gentoo
Oct 26, 2026
5b1eb4c
app-eselect/eselect-pinentry: Sync with Gentoo
Oct 26, 2026
b061ad6
app-misc/pax-utils: Sync with Gentoo
Oct 26, 2026
bc829c3
app-portage/elt-patches: Sync with Gentoo
Oct 26, 2026
c859f1e
app-portage/gemato: Sync with Gentoo
Oct 26, 2026
f8cd190
app-portage/gentoolkit: Sync with Gentoo
Oct 26, 2026
13d147f
app-shells/bash: Sync with Gentoo
Oct 26, 2026
948492a
app-shells/gentoo-bashcomp: Sync with Gentoo
Oct 26, 2026
784a7b4
app-vim/gentoo-syntax: Sync with Gentoo
Oct 26, 2026
a09f59c
dev-build/autoconf: Sync with Gentoo
Oct 26, 2026
0a3794b
dev-build/automake: Sync with Gentoo
Oct 26, 2026
e9ef891
dev-build/automake-wrapper: Sync with Gentoo
Oct 26, 2026
b7ea0c4
dev-build/cmake: Sync with Gentoo
Oct 26, 2026
69cc4f9
dev-build/libtool: Sync with Gentoo
Oct 26, 2026
c234c42
dev-build/meson: Sync with Gentoo
Oct 26, 2026
c72724d
dev-build/ninja: Sync with Gentoo
Oct 26, 2026
45f1e60
dev-db/sqlite: Sync with Gentoo
Oct 26, 2026
35c7d7b
dev-debug/gdb: Sync with Gentoo
Oct 26, 2026
6f35a2d
dev-debug/strace: Sync with Gentoo
Oct 26, 2026
ca308db
dev-lang/go: Sync with Gentoo
Oct 26, 2026
85acb31
dev-lang/perl: Sync with Gentoo
Oct 26, 2026
3052dc5
dev-lang/python: Sync with Gentoo
Oct 26, 2026
25d3c95
dev-lang/rust: Sync with Gentoo
Oct 26, 2026
e3a2ff5
dev-lang/rust-bin: Sync with Gentoo
Oct 26, 2026
396e237
dev-lang/rust-common: Sync with Gentoo
Oct 26, 2026
52efa5d
dev-lang/swig: Sync with Gentoo
Oct 26, 2026
dad13a8
dev-lang/tcl: Sync with Gentoo
Oct 26, 2026
cd71321
dev-libs/blake3: Sync with Gentoo
Oct 26, 2026
8dc2df4
dev-libs/elfutils: Sync with Gentoo
Oct 26, 2026
53c3950
dev-libs/expat: Sync with Gentoo
Oct 26, 2026
52daf38
dev-libs/gmp: Sync with Gentoo
Oct 26, 2026
2846248
dev-libs/json-c: Sync with Gentoo
Oct 26, 2026
23682ed
dev-libs/libffi: Sync with Gentoo
Oct 26, 2026
a0197f0
dev-libs/libksba: Sync with Gentoo
Oct 26, 2026
cc84361
dev-libs/libltdl: Sync with Gentoo
Oct 26, 2026
bc8aeeb
dev-libs/libp11: Sync with Gentoo
Oct 26, 2026
5c62746
dev-libs/libpcre2: Sync with Gentoo
Oct 26, 2026
fa05be1
dev-libs/libusb: Sync with Gentoo
Oct 26, 2026
e997c07
dev-libs/libuv: Sync with Gentoo
Oct 26, 2026
bb4ea36
dev-libs/libxml2: Sync with Gentoo
Oct 26, 2026
688d401
dev-libs/mpc: Sync with Gentoo
Oct 26, 2026
55db4d1
dev-libs/mpfr: Sync with Gentoo
Oct 26, 2026
921dc42
dev-libs/opensc: Sync with Gentoo
Oct 26, 2026
3065de6
dev-libs/openssl: Sync with Gentoo
Oct 26, 2026
a0e18bd
dev-libs/tree-sitter: Sync with Gentoo
Oct 26, 2026
30914d8
dev-libs/xmlsec: Sync with Gentoo
Oct 26, 2026
37a3b24
dev-python/charset-normalizer: Sync with Gentoo
Oct 26, 2026
16e8277
dev-python/crcmod: Sync with Gentoo
Oct 26, 2026
d9facfb
dev-python/cryptography: Sync with Gentoo
Oct 26, 2026
76e144e
dev-python/cython: Sync with Gentoo
Oct 26, 2026
0f59c78
dev-python/dependency-groups: Sync with Gentoo
Oct 26, 2026
70b9e85
dev-python/distlib: Sync with Gentoo
Oct 26, 2026
8b6628d
dev-python/editables: Sync with Gentoo
Oct 26, 2026
7485110
dev-python/ensurepip-pip: Sync with Gentoo
Oct 26, 2026
39139b3
dev-python/ensurepip-setuptools: Sync with Gentoo
Oct 26, 2026
3345e69
dev-python/fastjsonschema: Sync with Gentoo
Oct 26, 2026
80cb609
dev-python/flit-core: Sync with Gentoo
Oct 26, 2026
2db0752
dev-python/gpep517: Sync with Gentoo
Oct 26, 2026
e6bc63d
dev-python/hatch-vcs: Sync with Gentoo
Oct 26, 2026
ae64c0a
dev-python/hatchling: Sync with Gentoo
Oct 26, 2026
8bf0a21
dev-python/idna: Sync with Gentoo
Oct 26, 2026
c80609a
dev-python/installer: Sync with Gentoo
Oct 26, 2026
6bea155
dev-python/jaraco-collections: Sync with Gentoo
Oct 26, 2026
ec6c100
dev-python/jaraco-context: Sync with Gentoo
Oct 26, 2026
90f96ba
dev-python/jaraco-functools: Sync with Gentoo
Oct 26, 2026
8c2e689
dev-python/jaraco-text: Sync with Gentoo
Oct 26, 2026
23362a6
dev-python/lazy-object-proxy: Sync with Gentoo
Oct 26, 2026
29782c8
dev-python/linkify-it-py: Sync with Gentoo
Oct 26, 2026
4eb1b09
dev-python/lxml: Sync with Gentoo
Oct 26, 2026
177a811
dev-python/markupsafe: Sync with Gentoo
Oct 26, 2026
b85e119
dev-python/more-itertools: Sync with Gentoo
Oct 26, 2026
70194ab
dev-python/msgpack: Sync with Gentoo
Oct 26, 2026
69b9130
dev-python/packaging: Sync with Gentoo
Oct 26, 2026
090143d
dev-python/pathspec: Sync with Gentoo
Oct 26, 2026
80794be
dev-python/pip: Sync with Gentoo
Oct 26, 2026
6fcb12c
dev-python/platformdirs: Sync with Gentoo
Oct 26, 2026
759a43f
dev-python/pluggy: Sync with Gentoo
Oct 26, 2026
44d955f
dev-python/poetry-core: Sync with Gentoo
Oct 26, 2026
ac928a6
dev-python/pycparser: Sync with Gentoo
Oct 26, 2026
923fc3f
dev-python/pygments: Sync with Gentoo
Oct 26, 2026
a6f5619
dev-python/pyproject-hooks: Sync with Gentoo
Oct 26, 2026
c57acab
dev-python/setuptools: Sync with Gentoo
Oct 26, 2026
f5e1f99
dev-python/setuptools-scm: Sync with Gentoo
Oct 26, 2026
8ad41bf
dev-python/six: Sync with Gentoo
Oct 26, 2026
9bace9e
dev-python/snakeoil: Sync with Gentoo
Oct 26, 2026
e60b488
dev-python/tomli: Sync with Gentoo
Oct 26, 2026
e33eec6
dev-python/tomli-w: Sync with Gentoo
Oct 26, 2026
f47a77a
dev-python/tomlkit: Sync with Gentoo
Oct 26, 2026
f9f07ae
dev-python/tree-sitter: Sync with Gentoo
Oct 26, 2026
5303fa5
dev-python/trove-classifiers: Sync with Gentoo
Oct 26, 2026
f1dcb7f
dev-python/truststore: Sync with Gentoo
Oct 26, 2026
6350cbc
dev-python/typing-extensions: Sync with Gentoo
Oct 26, 2026
9a89115
dev-python/urllib3: Sync with Gentoo
Oct 26, 2026
3fa6294
dev-python/vcs-versioning: Sync with Gentoo
Oct 26, 2026
9bbf4cb
dev-python/wheel: Sync with Gentoo
Oct 26, 2026
e531e9b
dev-util/bpftool: Sync with Gentoo
Oct 26, 2026
635f9c1
dev-util/catalyst: Sync with Gentoo
Oct 26, 2026
19a4c72
dev-util/maturin: Sync with Gentoo
Oct 26, 2026
decfb27
dev-util/pahole: Sync with Gentoo
Oct 26, 2026
eacfcad
dev-util/patchelf: Sync with Gentoo
Oct 26, 2026
aa6a1b3
dev-util/pkgcheck: Sync with Gentoo
Oct 26, 2026
8e825fe
dev-util/xdelta: Sync with Gentoo
Oct 26, 2026
189c078
dev-vcs/git: Sync with Gentoo
Oct 26, 2026
13ec62c
eclass/acct-group: Sync with Gentoo
Oct 26, 2026
c83f216
eclass/acct-user: Sync with Gentoo
Oct 26, 2026
19a4c5d
eclass/autotools: Sync with Gentoo
Oct 26, 2026
7d6e552
eclass/cargo: Sync with Gentoo
Oct 26, 2026
ff03337
eclass/distutils-r1: Sync with Gentoo
Oct 26, 2026
9b9c0c0
eclass/edo: Sync with Gentoo
Oct 26, 2026
e2a8be5
eclass/python-utils-r1: Sync with Gentoo
Oct 26, 2026
262ec8e
eclass/qmake-utils: Sync with Gentoo
Oct 26, 2026
d460e98
eclass/rust: Sync with Gentoo
Oct 26, 2026
bc01825
eclass/selinux-policy-2: Sync with Gentoo
Oct 26, 2026
85b6085
eclass/shell-completion: Sync with Gentoo
Oct 26, 2026
e27636a
eclass/toolchain: Sync with Gentoo
Oct 26, 2026
4a16222
eclass/tree-sitter-grammar: Sync with Gentoo
Oct 26, 2026
49cb8c6
eclass/verify-sig: Sync with Gentoo
Oct 26, 2026
70dfb0f
licenses: Sync with Gentoo
Oct 26, 2026
b0d90e1
media-libs/libpng: Sync with Gentoo
Oct 26, 2026
cd8b5a6
net-analyzer/tcpdump: Sync with Gentoo
Oct 26, 2026
117e8f2
net-dns/bind: Sync with Gentoo
Oct 26, 2026
9d16ff9
net-dns/c-ares: Sync with Gentoo
Oct 26, 2026
3aa0fdf
net-dns/dnsmasq: Sync with Gentoo
Oct 26, 2026
59506cf
net-firewall/ipset: Sync with Gentoo
Oct 26, 2026
f2772b9
net-firewall/nftables: Sync with Gentoo
Oct 26, 2026
6ddebd9
net-fs/cifs-utils: Sync with Gentoo
Oct 26, 2026
4cfda78
net-fs/nfs-utils: Sync with Gentoo
Oct 26, 2026
cc4617a
net-fs/samba: Sync with Gentoo
Oct 26, 2026
042e242
net-libs/libnftnl: Sync with Gentoo
Oct 26, 2026
fde04f2
net-libs/libpcap: Sync with Gentoo
Oct 26, 2026
3a49803
net-libs/libpsl: Sync with Gentoo
Oct 26, 2026
b7d1cfc
net-libs/nghttp2: Sync with Gentoo
Oct 26, 2026
784494d
net-libs/ngtcp2: Sync with Gentoo
Oct 26, 2026
8368e69
net-misc/chrony: Sync with Gentoo
Oct 26, 2026
5e5b0ef
net-misc/curl: Sync with Gentoo
Oct 26, 2026
0380aa5
net-misc/iperf: Sync with Gentoo
Oct 26, 2026
49befa0
net-misc/openssh: Sync with Gentoo
Oct 26, 2026
832d9de
net-misc/passt: Sync with Gentoo
Oct 26, 2026
70540e5
net-misc/rsync: Sync with Gentoo
Oct 26, 2026
ee6766d
net-misc/socat: Sync with Gentoo
Oct 26, 2026
e1dbe44
net-misc/wget: Sync with Gentoo
Oct 26, 2026
6bd99ff
net-vpn/wireguard-tools: Sync with Gentoo
Oct 26, 2026
eef38d8
profiles: Sync with Gentoo
Oct 26, 2026
a953d93
sec-policy/selinux-base: Sync with Gentoo
Oct 26, 2026
5e3692b
sec-policy/selinux-base-policy: Sync with Gentoo
Oct 26, 2026
1b98e35
sec-policy/selinux-container: Sync with Gentoo
Oct 26, 2026
589f205
sec-policy/selinux-dbus: Sync with Gentoo
Oct 26, 2026
95e7d1e
sec-policy/selinux-policykit: Sync with Gentoo
Oct 26, 2026
844014e
sec-policy/selinux-sssd: Sync with Gentoo
Oct 26, 2026
c598e17
sec-policy/selinux-unconfined: Sync with Gentoo
Oct 26, 2026
164da85
sys-apps/bubblewrap: Sync with Gentoo
Oct 26, 2026
ab366bf
sys-apps/busybox: Sync with Gentoo
Oct 26, 2026
f0e6bcb
sys-apps/coreutils: Sync with Gentoo
Oct 26, 2026
c237ec5
sys-apps/dbus: Sync with Gentoo
Oct 26, 2026
6431766
sys-apps/gawk: Sync with Gentoo
Oct 26, 2026
5e625d9
sys-apps/groff: Sync with Gentoo
Oct 26, 2026
da80101
sys-apps/iproute2: Sync with Gentoo
Oct 26, 2026
82fdbcc
sys-apps/less: Sync with Gentoo
Oct 26, 2026
4814af2
sys-apps/man-pages: Sync with Gentoo
Oct 26, 2026
df22e97
sys-apps/pcsc-lite: Sync with Gentoo
Oct 26, 2026
8c3a9eb
sys-apps/pkgcore: Sync with Gentoo
Oct 26, 2026
7b97790
sys-apps/portage: Sync with Gentoo
Oct 26, 2026
a4b383f
sys-apps/pv: Sync with Gentoo
Oct 26, 2026
e801b3e
sys-apps/shadow: Sync with Gentoo
Oct 26, 2026
7c8f252
sys-apps/systemd: Sync with Gentoo
Oct 26, 2026
676796e
sys-apps/util-linux: Sync with Gentoo
Oct 26, 2026
2486ab8
sys-auth/pambase: Sync with Gentoo
Oct 26, 2026
5fd1e54
sys-auth/sssd: Sync with Gentoo
Oct 26, 2026
d5cd012
sys-block/thin-provisioning-tools: Sync with Gentoo
Oct 26, 2026
3b93736
sys-boot/grub: Sync with Gentoo
Oct 26, 2026
e958df0
sys-devel/binutils: Sync with Gentoo
Oct 26, 2026
6874ebf
sys-devel/crossdev: Sync with Gentoo
Oct 26, 2026
ab240c5
sys-devel/dwz: Sync with Gentoo
Oct 26, 2026
85d4dc4
sys-devel/gcc: Sync with Gentoo
Oct 26, 2026
6b6e80d
sys-devel/gnuconfig: Sync with Gentoo
Oct 26, 2026
5fcba20
sys-firmware/intel-microcode: Sync with Gentoo
Oct 26, 2026
7fba38c
sys-fs/btrfs-progs: Sync with Gentoo
Oct 26, 2026
4908eb7
sys-fs/cryptsetup: Sync with Gentoo
Oct 26, 2026
71f388f
sys-fs/fuse: Sync with Gentoo
Oct 26, 2026
65b4964
sys-fs/inotify-tools: Sync with Gentoo
Oct 26, 2026
519a068
sys-fs/xfsprogs: Sync with Gentoo
Oct 26, 2026
518b884
sys-libs/binutils-libs: Sync with Gentoo
Oct 26, 2026
1e48afd
sys-libs/glibc: Sync with Gentoo
Oct 26, 2026
4379ec6
sys-libs/libcap-ng: Sync with Gentoo
Oct 26, 2026
3f35f8d
sys-libs/libunwind: Sync with Gentoo
Oct 26, 2026
4b90ef7
sys-libs/liburing: Sync with Gentoo
Oct 26, 2026
2ed1243
sys-libs/libxcrypt: Sync with Gentoo
Oct 26, 2026
fa399ea
sys-libs/ncurses: Sync with Gentoo
Oct 26, 2026
8e6253c
sys-libs/readline: Sync with Gentoo
Oct 26, 2026
3bbc480
sys-libs/talloc: Sync with Gentoo
Oct 26, 2026
8639bfe
sys-libs/tevent: Sync with Gentoo
Oct 26, 2026
3c51f9b
sys-libs/timezone-data: Sync with Gentoo
Oct 26, 2026
3252f20
sys-process/audit: Sync with Gentoo
Oct 26, 2026
fd55437
sys-process/procps: Sync with Gentoo
Oct 26, 2026
b9a5d01
virtual/acl: Sync with Gentoo
Oct 26, 2026
6ae849f
virtual/editor: Sync with Gentoo
Oct 26, 2026
964a84a
virtual/libpcre2-internals: Sync with Gentoo
Oct 26, 2026
b420255
virtual/openssh: Sync with Gentoo
Oct 26, 2026
a8a6ec5
virtual/perl-Encode: Sync with Gentoo
Oct 26, 2026
e586ab4
virtual/perl-ExtUtils-MakeMaker: Sync with Gentoo
Oct 26, 2026
38227e2
virtual/tmpfiles: Sync with Gentoo
Oct 26, 2026
14f7baa
x11-drivers/nvidia-drivers: Sync with Gentoo
Oct 26, 2026
c8ff7e9
x11-misc/makedepend: Sync with Gentoo
Oct 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else
SRC_URI="https://github.com/${PN}/${PN}/releases/download/${PV}/${P}.tar.xz"
SRC_URI+=" verify-sig? ( https://github.com/${PN}/${PN}/releases/download/${PV}/${P}.tar.xz.asc )"

KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~m68k ~mips ppc ppc64 ~riscv ~s390 ~sparc x86"
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~m68k ~mips ppc ppc64 ~riscv ~s390 ~sparc x86"

BDEPEND="verify-sig? ( sec-keys/openpgp-keys-cgzones )"
fi
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
diff --git a/src/sudo.c b/src/sudo.c
index 0ed053839..89d97b6e8 100644
--- a/src/sudo.c
+++ b/src/sudo.c
@@ -341,13 +341,48 @@ access_denied:
return EXIT_FAILURE;
}

+/*
+ * Set the time zone using tzset(3), removing the user's TZ
+ * environment variable. The original value of TZ may still
+ * be present in the command's environment, depending on sudoers.
+ */
+static void
+set_time_zone(void)
+{
+ /* Use system time zone, not user-specified. */
+ unsetenv("TZ");
+ (void) tzset();
+}
+
int
os_init_common(int argc, char *argv[], char *envp[])
{
+ extern char **environ;
+ int envc;
#ifdef STATIC_SUDOERS_PLUGIN
preload_static_symbols();
#endif
gc_init();
+
+ /*
+ * Make a copy of environ[] that is distinct from envp[].
+ * This allows us to remove variables from sudo's environment
+ * while still providing the original envp to the plugins.
+ */
+ for (envc = 0; envp[envc] != NULL; envc++)
+ continue;
+ if (envc != 0) {
+ char **new_env = reallocarray(NULL, sizeof(char *), envc + 1);
+ if (new_env == NULL || !gc_add(GC_PTR, new_env)) {
+ sudo_fatalx_nodebug(U_("%s: %s"), __func__,
+ U_("unable to allocate memory"));
+ }
+ for (envc = 0; envp[envc] != NULL; envc++)
+ new_env[envc] = envp[envc];
+ new_env[envc] = NULL;
+ environ = new_env;
+ }
+
return 0;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From f97a34bc7b390f185d544e21b0ef75db1275953e Mon Sep 17 00:00:00 2001
From: Theo Buehler <tb@openbsd.org>
Date: Sat, 22 Nov 2025 12:28:50 +0100
Subject: [PATCH] Use accessor for getting an ASN1_STRING's length

OpensSSL 4 has plans to make ASN1_STRING opaque [1]. hostcheck.c's code
mostly treats it as opaque, but accesses two lengths. This is API added
in OpenSSL 0.9.0, so I'm not sure we need a configure check.

WolfSSL only recently const corrected ASN1_STRING_length(), so maybe
there will be a need to cast away const.

[1]: https://github.com/openssl/openssl/issues/29117

--- a/lib/iolog/hostcheck.c
+++ b/lib/iolog/hostcheck.c
@@ -323,14 +323,14 @@
#endif

/* IPV4 address */
- if(current_name->d.iPAddress->length == 4) {
+ if(ASN1_STRING_length(current_name->d.iPAddress) == 4) {
if (inet_ntop(AF_INET, san_ip, san_ip_str, INET_ADDRSTRLEN) == NULL) {
result = MalformedCertificate;
break;
}
#if defined(HAVE_STRUCT_IN6_ADDR)
/* IPV6 address */
- } else if (current_name->d.iPAddress->length == 16) {
+ } else if (ASN1_STRING_length(current_name->d.iPAddress) == 16) {
if (inet_ntop(AF_INET6, san_ip, san_ip_str, INET6_ADDRSTRLEN) == NULL) {
result = MalformedCertificate;
break;
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit pam tmpfiles toolchain-funcs

MY_P="${P/_/}"
MY_P="${MY_P/beta/b}"

DESCRIPTION="Allows users or groups to run commands as other users"
HOMEPAGE="https://www.sudo.ws/"

if [[ ${PV} == 9999 ]] ; then
EGIT_REPO_URI="
https://github.com/sudo-project/sudo
https://git.sudo.ws/sudo
"
inherit autotools git-r3
else
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/sudo.ws.asc
inherit libtool verify-sig

uri_prefix=
case ${P} in
*_beta*|*_rc*) uri_prefix=beta/ ;;
esac

SRC_URI="
https://www.sudo.ws/sudo/dist/${uri_prefix}${MY_P}.tar.gz
verify-sig? (
https://www.sudo.ws/sudo/dist/${uri_prefix}${MY_P}.tar.gz.sig
)
"

if [[ ${PV} != *_beta* && ${PV} != *_rc* ]] ; then
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
fi

BDEPEND="verify-sig? ( sec-keys/openpgp-keys-sudo )"
fi

S="${WORKDIR}/${MY_P}"

# Basic license is ISC-style as-is, some files are released under
# 3-clause BSD license
LICENSE="ISC BSD"
SLOT="0"
IUSE="gcrypt ldap nls offensive pam sasl +secure-path selinux +sendmail skey ssl sssd"

DEPEND="
virtual/zlib:=
virtual/libcrypt:=
gcrypt? ( dev-libs/libgcrypt:= )
ldap? (
>=net-nds/openldap-2.1.30-r1:=
sasl? (
dev-libs/cyrus-sasl
net-nds/openldap:=[sasl]
)
)
pam? ( sys-libs/pam )
sasl? ( dev-libs/cyrus-sasl )
selinux? ( sys-libs/libselinux )
skey? ( >=sys-auth/skey-1.1.5-r1 )
ssl? ( dev-libs/openssl:= )
sssd? ( sys-auth/sssd[sudo(+)] )
"
RDEPEND="
${DEPEND}
>=app-misc/editor-wrapper-3
virtual/editor
ldap? ( dev-lang/perl )
pam? ( sys-auth/pambase )
selinux? ( sec-policy/selinux-sudo )
sendmail? ( virtual/mta )
"
BDEPEND+="
app-alternatives/yacc
virtual/pkgconfig
"

REQUIRED_USE="
?? ( pam skey )
?? ( gcrypt ssl )
"

MAKEOPTS+=" SAMPLES="

PATCHES=(
"${FILESDIR}/CVE-2026-96512.patch"
"${FILESDIR}"/${P}-openssl-4.patch
)

src_prepare() {
default

if [[ ${PV} == 9999 ]] ; then
eautoreconf
else
elibtoolize
fi
}

set_secure_path() {
# First extract the default ROOTPATH from build env
SECURE_PATH=$(unset ROOTPATH; . "${EPREFIX}"/etc/profile.env; echo "${ROOTPATH}")

case "${SECURE_PATH}" in
*/usr/sbin*)
;;
*)
SECURE_PATH=$(unset PATH; . "${EPREFIX}"/etc/profile.env; echo "${PATH}")
;;
esac

if [[ -z ${SECURE_PATH} ]] ; then
ewarn " Failed to detect SECURE_PATH, please report this"
fi

# Then remove duplicate path entries
cleanpath() {
local newpath thisp IFS=:
for thisp in $1 ; do
if [[ :${newpath}: != *:${thisp}:* ]] ; then
newpath+=:${thisp}
else
einfo " Duplicate entry ${thisp} removed..."
fi
done
SECURE_PATH=${newpath#:}
}
cleanpath /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin${SECURE_PATH:+:${SECURE_PATH}}

# Finally, strip gcc paths, bug #136027
rmpath() {
local e newpath thisp IFS=:
for thisp in ${SECURE_PATH} ; do
for e ; do
[[ ${thisp} == ${e} ]] && continue 2 ;
done
newpath+=:${thisp}
done
SECURE_PATH=${newpath#:}
}
rmpath '*/gcc-bin/*' '*/gnat-gcc-bin/*' '*/gnat-gcc/*'
}

src_configure() {
local SECURE_PATH

set_secure_path

# bug #767712
tc-export PKG_CONFIG

# - audit: somebody got to explain me how I can test this before I
# enable it.. - Diego
# - plugindir: autoconf code is crappy and does not delay evaluation
# until `make` time, so we have to use a full path here rather than
# basing off other values.
local myeconfargs=(
# We set all of the relevant options by ourselves (patched
# into the toolchain) and setting these in the build system
# actually causes a downgrade when using e.g. -D_FORTIFY_SOURCE=3
# (it'll downgrade to =2). So, this has no functional effect on
# the hardening for users. It's safe.
--disable-hardening

# requires some python eclass
--disable-python
--enable-tmpfiles.d="${EPREFIX}"/usr/lib/tmpfiles.d
--enable-zlib=system
--with-editor="${EPREFIX}"/usr/libexec/editor
--with-env-editor
--with-plugindir="${EPREFIX}"/usr/$(get_libdir)/sudo
--with-rundir="${EPREFIX}"/run/sudo
--with-vardir="${EPREFIX}"/var/db/sudo
--without-linux-audit
--without-opie
$(use_enable gcrypt)
$(use_enable nls)
$(use_enable sasl)
$(use_enable ssl openssl)
$(use_with ldap)
$(use_with ldap ldap_conf_file /etc/ldap.conf.sudo)
$(use_with offensive insults)
$(use_with offensive all-insults)
$(use_with pam)
$(use_with pam pam-login)
$(use_with secure-path)
"$(use_with secure-path secure-path-value "${SECURE_PATH}")"
$(use_with selinux)
$(use_with sendmail)
$(use_with skey)
$(use_with sssd)
)

econf "${myeconfargs[@]}"
}

src_install() {
default

if use ldap ; then
dodoc README.LDAP.md

cat <<-EOF > "${T}"/ldap.conf.sudo
# See ldap.conf(5) and README.LDAP.md for details
# This file should only be readable by root

# supported directives: host, port, ssl, ldap_version
# uri, binddn, bindpw, sudoers_base, sudoers_debug
# tls_{checkpeer,cacertfile,cacertdir,randfile,ciphers,cert,key}
EOF

if use sasl ; then
cat <<-EOF >> "${T}"/ldap.conf.sudo

# SASL directives: use_sasl, sasl_mech, sasl_auth_id
# sasl_secprops, rootuse_sasl, rootsasl_auth_id, krb5_ccname
EOF
fi

insinto /etc
doins "${T}"/ldap.conf.sudo
fperms 0440 /etc/ldap.conf.sudo

insinto /etc/openldap/schema
newins docs/schema.OpenLDAP sudo.schema
fi

if use pam ; then
pamd_mimic system-auth sudo auth account session
pamd_mimic system-auth sudo-i auth account session
fi

keepdir /var/db/sudo/lectured
fperms 0700 /var/db/sudo/lectured
# bug #652958
fperms 0711 /var/db/sudo

# Don't install into /run as that is a tmpfs most of the time
# (bug #504854)
rm -rf "${ED}"/run || die

# bug #697812
find "${ED}" -type f -name "*.la" -delete || die
}

pkg_postinst() {
tmpfiles_process sudo.conf

# bug #652958
local sudo_db="${EROOT}/var/db/sudo"
if [[ "$(stat -c %a "${sudo_db}")" -ne 711 ]] ; then
chmod 711 "${sudo_db}" || die
fi

if use ldap ; then
ewarn
ewarn "sudo uses the ${ROOT}/etc/ldap.conf.sudo file for ldap configuration."
ewarn
if grep -qs '^[[:space:]]*sudoers:' "${ROOT}"/etc/nsswitch.conf ; then
ewarn "In 1.7 series, LDAP is no more consulted, unless explicitly"
ewarn "configured in ${ROOT}/etc/nsswitch.conf."
ewarn
ewarn "To make use of LDAP, add this line to your ${ROOT}/etc/nsswitch.conf:"
ewarn " sudoers: ldap files"
ewarn
fi
fi
if use prefix ; then
ewarn
ewarn "To use sudo on Prefix, you need to change file ownership and permissions"
ewarn "with root privileges, as follows:"
ewarn
ewarn " # chown root:root ${EPREFIX}/usr/bin/sudo"
ewarn " # chown root:root ${EPREFIX}/usr/lib/sudo/sudoers.so"
ewarn " # chown root:root ${EPREFIX}/etc/sudoers"
ewarn " # chown root:root ${EPREFIX}/etc/sudoers.d"
ewarn " # chown root:root ${EPREFIX}/var/db/sudo"
ewarn " # chmod 4111 ${EPREFIX}/usr/bin/sudo"
ewarn
fi

elog "To use the -A (askpass) option, you need to install a compatible"
elog "password program from the following list. Starred packages will"
elog "automatically register for the use with sudo (but will not force"
elog "the -A option):"
elog ""
elog " [*] net-misc/ssh-askpass-fullscreen"
elog " net-misc/x11-ssh-askpass"
elog ""
elog "You can override the choice by setting the SUDO_ASKPASS environmnent"
elog "variable to the program you want to use."
}
Loading