From 7176eb2df98ed89e686c5cc116e9e88ecb238a1c Mon Sep 17 00:00:00 2001 From: sonots Date: Thu, 21 Dec 2017 05:07:43 +0000 Subject: [PATCH] * lib/logger.rb (Logger::LogDevice#open_logfile, #create_logfile): Logger should be able to open only files [Bug #14212] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- NEWS | 7 +++++++ lib/logger.rb | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 92715387cd..1390117375 100644 --- a/NEWS +++ b/NEWS @@ -416,6 +416,13 @@ with all sufficient information, see the ChangeLog file or Redmine === Stdlib compatibility issues (excluding feature bug fixes) +* Logger + + * Logger.new("| command") had been working to open a command + unintentionally. It was prohibitted, and now Logger#initialize + treats a String argument only as a filename, as its specification. + [Bug #14212] + * Net::HTTP * Net::HTTP#start now passes :ENV to p_addr by default. [Bug #13351] diff --git a/lib/logger.rb b/lib/logger.rb index f572921db4..4ccc03b614 100644 --- a/lib/logger.rb +++ b/lib/logger.rb @@ -743,7 +743,7 @@ private def open_logfile(filename) begin - open(filename, (File::WRONLY | File::APPEND)) + File.open(filename, (File::WRONLY | File::APPEND)) rescue Errno::ENOENT create_logfile(filename) end @@ -751,7 +751,7 @@ private def create_logfile(filename) begin - logdev = open(filename, (File::WRONLY | File::APPEND | File::CREAT | File::EXCL)) + logdev = File.open(filename, (File::WRONLY | File::APPEND | File::CREAT | File::EXCL)) logdev.flock(File::LOCK_EX) logdev.sync = true add_log_header(logdev)