Bug 248536 - periodic(8) /absolute/path/where/basename/contains-hyphens interpreted as options to mail(1)
Summary: periodic(8) /absolute/path/where/basename/contains-hyphens interpreted as opt...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-08 12:28 UTC by danielsh
Modified: 2020-10-05 13:57 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description danielsh 2020-08-08 12:28:15 UTC
I ran «periodic /usr/local/etc/periodic/one-off» from /etc/crontab and got the following output:

[[[
Subject: Cron <root@zsh> periodic /usr/local/etc/periodic/one-off

mail: illegal option -- o
Usage: mail [-dEiInv] [-s subject] [-c cc-addr] [-b bcc-addr] [-F] to-addr ...
            [-sendmail-option ...]
       mail [-dEHiInNv] [-F] -f [name]
       mail [-dEHiInNv] [-F] [-u user]
       mail [-d] -e [-f name]
]]]

What happens: The function output_pipe() is called with a first argument of «/usr/local/etc/periodic/one-off», which then runs «eval» on the string «output=$one-off_output», which sets the variable $output to the value «-off_output» (because $one expands to nothing), and that variable is then used to build the mail command in $pipe, which works out to «mail -E -s '…' -off_output», which produces the above output.

Reproduced in 11.2R, but by source inspection applies to CURRENT too.
Comment 1 Yang Zhong 2020-10-05 13:57:07 UTC
https://reviews.freebsd.org/D26609