akrennmair / newsbeuter

Newsbeuter is an open-source RSS/Atom feed reader for text terminals.
http://www.newsbeuter.org/
MIT License
780 stars 100 forks source link

notify-program unable to handle arguments #439

Open tsipinakis opened 7 years ago

tsipinakis commented 7 years ago

Newsbeuter version (copy from newsbeuter -v): 2.10-3df01

notify-program doesn't properly handle command line arguments.

With notify-program notify --arg in the config, notify is called without any arguments:

DEBUG: controller:notify: notifying external program `notify'
DEBUG: utils::run_command: notify '100 unread articles'

With notify-program "notify --arg" in the config, the entire string is attempted to be executed as an executable:

DEBUG: controller:notify: notifying external program `notify --arg'
DEBUG: utils::run_command: notify --arg '100 unread articles'¬
DEBUG: utils::run_command: execlp of notify --arg failed: No such file or directory
Minoru commented 7 years ago

Turns out we have three ways to run an external executable: utils::run_interactively, utils::run_program and utils::run_command. notify-program is interpreted by the last one, and it indeed doesn't split the command into arguments—it just calls execlp. This is inconsistent with two other functions, which pass their arguments to /bin/sh.

We can't simply do the same in run_command because we have to be sure that the argument we're passing to notify-program isn't mangled by the shell.

TODO:

Setting this aside for now.