mirror of
https://github.com/openwrt/openwrt.git
synced 2026-11-27 14:41:12 +04:00
ppp: give the jailed pppd copies of the secrets files
50-ppp-secrets-mode.sh makes chap-secrets and pap-secrets readable for
the ppp group, so that the jailed pppd can read them. pppd 2.5.4 refuses
a secrets file with any group or other permission while
strict-secrets-files is on, which is the default, and logs "Can't use
/etc/ppp/chap-secrets: secret file has world and/or group access".
After the script neither the jailed pppd nor a pppd running as root,
such as the one pptpd starts, can use the files.
pppd also wants the file owned by root or by its own uid, so one file
cannot serve both. Have the jail setup copy each secrets file to
/var/run/pppd, owned by ppp with mode 0600, the same way it writes the
options file. The chap-secrets and pap-secrets options point the
jailed pppd at the copies, and teardown removes them.
The script now puts the files back to the 0600 root:root mode they are
installed with, so that a pppd running as root can read them again. It
only touches a file in the state it left: owned by root, group ppp,
mode 0640.
A jailed pppd reads the copies made when the interface was set up, so a
change to the secrets files reaches it at the next setup. A pppd running
as root rereads them at every authentication.
The RADIUS servers file stays group readable, because the radius plugin
reads it without the secrets file check.
Fixes: b855f33ea9 ("ppp: run pppd in ujail as an unprivileged user")
Signed-off-by: Semih Baskan <strst.gs@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26319
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
1 parent
7be6b668ad
commit
fc8ff4d2ed
2 files changed
+14
-7
No files matched your search
@@ -1,11 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
# pppd reads these as uid ppp, and INSTALL_CONF ships them 0600 root:root -
|
||||
# as does a file preserved across sysupgrade from an install predating the uid.
|
||||
for secret in /etc/ppp/chap-secrets /etc/ppp/pap-secrets; do
|
||||
[ -f "$secret" ] || continue
|
||||
chgrp ppp "$secret"
|
||||
chmod 0640 "$secret"
|
||||
[ -n "$(find "$secret" -user root -group ppp -perm 0640 2>/dev/null)" ] || continue
|
||||
chown root:root "$secret"
|
||||
chmod 0600 "$secret"
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -173,7 +173,7 @@ ppp_generic_setup() {
|
||||
[ "$delegate" != "0" ] && delegate=""
|
||||
[ "$norelease" = "1" ] || norelease=""
|
||||
|
||||
local jail arg caps=/etc/capabilities/pppd.json
|
||||
local jail arg secret secrets caps=/etc/capabilities/pppd.json
|
||||
[ -x /sbin/ujail ] && [ -f "$caps" ] && id -u ppp >/dev/null 2>&1 && {
|
||||
jail="/sbin/ujail -t 5 -n pppd -U ppp -G ppp -C $caps -c --"
|
||||
chown ppp /dev/ppp
|
||||
@@ -188,6 +188,12 @@ ppp_generic_setup() {
|
||||
for arg in "$@"; do
|
||||
[ -c "$arg" ] && chown ppp "$arg"
|
||||
done
|
||||
for secret in chap-secrets pap-secrets; do
|
||||
[ -f "/etc/ppp/$secret" ] || continue
|
||||
ppp_install_file "/var/run/pppd/$config.$secret" ppp \
|
||||
< "/etc/ppp/$secret" || continue
|
||||
secrets="$secrets $secret /var/run/pppd/$config.$secret"
|
||||
done
|
||||
}
|
||||
|
||||
local optfile
|
||||
@@ -215,6 +221,7 @@ ppp_generic_setup() {
|
||||
$demand $persist maxfail $maxfail \
|
||||
${holdoff:+holdoff "$holdoff"} \
|
||||
${optfile:+file "$optfile" net-init-script /lib/netifd/ppp-net-init} \
|
||||
$secrets \
|
||||
${connect:+connect "$connect"} \
|
||||
${disconnect:+disconnect "$disconnect"} \
|
||||
ip-up-script /lib/netifd/ppp-up \
|
||||
@@ -229,7 +236,9 @@ ppp_generic_teardown() {
|
||||
local interface="$1"
|
||||
local errorstring=$(ppp_exitcode_tostring $ERROR)
|
||||
|
||||
rm -f "/var/run/pppd/$interface.opts"
|
||||
rm -f "/var/run/pppd/$interface.opts" \
|
||||
"/var/run/pppd/$interface.chap-secrets" \
|
||||
"/var/run/pppd/$interface.pap-secrets"
|
||||
|
||||
case "$ERROR" in
|
||||
0)
|
||||
|
||||
Reference in new issue
Block a user