Commit 4d18e145 authored by Jouke Witteveen's avatar Jouke Witteveen
Browse files

Improve handling of untrimmed profile names (FS#55295)

Reported by Michaël Cadilhac <michael@cadilhac.name>
parent b1b03d8e
......@@ -8,13 +8,13 @@ PROFILE_FILE="$STATE_DIR/ifplugd-$1.profile"
case "$2" in
up)
while read -r profile; do
while IFS= read -r profile; do
if ForceConnect=yes "$SUBR_DIR/network" start "$profile"; then
mkdir -p "$(dirname "$PROFILE_FILE")"
printf "%s" "$profile" > "$PROFILE_FILE"
exit 0
fi
done < <(list_profiles | while read -r profile; do
done < <(list_profiles | while IFS= read -r profile; do
report_debug "Examining profile '$profile'"
(
source "$PROFILE_DIR/$profile" > /dev/null
......
......@@ -103,7 +103,7 @@ timeout_wait() {
### Profile management
## List all acceptable profiles names (assume they don't contain newlines)
## List all acceptable profiles names separated by newlines
list_profiles() {
# Follow aliases with -L, skip forbidden/reserved names
find -L "$PROFILE_DIR/" -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name $'*\n*' -not -name '*.action' -not -name '*.conf' -not -name '*.service' -printf "%f\n"
......@@ -116,9 +116,9 @@ load_profile() {
if [[ -z $1 || ! -r "$PROFILE_DIR/$1" ]]; then
exit_error "Profile '$1' does not exist or is not readable"
fi
while read -r hook; do
while IFS= read -r hook; do
source "$hook"
done < <(find -L "$PROFILE_DIR/hooks" -maxdepth 1 -type f -executable -not -name '.*' -not -name '*~' | sort -u)
done < <(find -L "$PROFILE_DIR/hooks" -maxdepth 1 -type f -executable -not -name '.*' -not -name '*~' -not -name $'*\n*' | sort -u)
source "$PROFILE_DIR/$1"
if [[ -z $Interface ]]; then
exit_error "Profile '$1' does not specify an interface"
......
......@@ -214,7 +214,7 @@ start() {
echo "p2p_disabled=1" >> "$wpa_conf"
local profile
list_profiles | while read -r profile; do
list_profiles | while IFS= read -r profile; do
report_debug "Examining profile '$profile'"
(
source "$PROFILE_DIR/$profile"
......
......@@ -30,7 +30,7 @@ END
list() {
local indicators=( ' ' '+' '*' ) i
list_profiles | while read -r Profile; do
list_profiles | while IFS= read -r Profile; do
if sd_call "is-active --quiet" "$Profile" &> /dev/null; then
[[ $(sd_status_text "$Profile") == "online" ]]
(( i = 2 - $? ))
......@@ -43,7 +43,7 @@ list() {
store() {
mkdir -p "$(dirname "$STATE_FILE")"
list_profiles | while read -r Profile; do
list_profiles | while IFS= read -r Profile; do
if sd_call "is-active --quiet" "$Profile" &> /dev/null; then
printf "%s\n" "$Profile"
fi
......
......@@ -33,7 +33,7 @@ quote_safe() {
# for interface $1.
init_profiles() {
local i=0 essid profile
while read -r profile; do
while IFS= read -r profile; do
essid=$(
unset INTERFACE ESSID
source "$PROFILE_DIR/$profile" > /dev/null
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment