Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 939158 - app-admin/sudo: Consider alternative secure_path order
Summary: app-admin/sudo: Consider alternative secure_path order
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-06 05:34 UTC by konsolebox
Modified: 2024-09-07 14:39 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description konsolebox 2024-09-06 05:34:05 UTC
Currently when secure_path is enabled, app-admin/sudo inserts the default paths before the extracted values changing the wanted order.

Perhaps a use flag can be added so the default paths can be added differently:


```
-IUSE="gcrypt ldap nls offensive pam sasl +secure-path selinux +sendmail skey ssl sssd"
+IUSE="gcrypt ldap nls offensive pam sasl +secure-path selinux +sendmail skey ssl sssd alt-secure-path-order"
 
 DEPEND="
 	sys-libs/zlib:=
@@ -120,7 +120,11 @@ set_secure_path() {
 		done
 		SECURE_PATH=${newpath#:}
 	}
-	cleanpath /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin${SECURE_PATH:+:${SECURE_PATH}}
+	if use alt-secure-path-order; then
+		cleanpath ${SECURE_PATH:+${SECURE_PATH}:}/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
+	else
+		cleanpath /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin${SECURE_PATH:+:${SECURE_PATH}}
+	fi
```

Or maybe change to the new behavior permanently.

The whole function can also be simplified:


```
set_secure_path() {
	einfo "Setting SECURE_PATH ..."

	SECURE_PATH=$(unset ROOTPATH; . "${EPREFIX}"/etc/profile.env; echo "${ROOTPATH}")
	[[ ${SECURE_PATH} != */usr/bin* ]] && SECURE_PATH=$(unset PATH; . "${EPREFIX}"/etc/profile.env;
			echo "${PATH}")

	local IFS=: __

	if use alt-secure-path-order; then
		set -- ${SECURE_PATH} /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /opt/bin
	else
		set -- /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /opt/bin ${SECURE_PATH}
	fi

	SECURE_PATH=

	for __; do
		case $__ in
		''|*/gcc-bin/*|*/gnat-gcc-bin/*|*/gnat-gcc/*) # bug #136027
			;;
		*)
			[[ :${SECURE_PATH}: != *:"$__":* ]] && SECURE_PATH+=:$__
			;;
		esac
	done

	SECURE_PATH=${SECURE_PATH#:}
}
```

Note that `*/usr/sbin*` has been changed to `*/usr/bin*.  See bug #939157.