From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 1/6] webrick: httpauth requires regular files
Date: Thu, 21 Dec 2017 11:55:02 +0000 [thread overview]
Message-ID: <20171221115507.27500-2-e@80x24.org> (raw)
In-Reply-To: <20171221115507.27500-1-e@80x24.org>
Be sure we do not try to open a pipe to read from, since we care
about mtime in all cases.
* lib/webrick/httpauth/htdigest.rb: use File.open
* lib/webrick/httpauth/htgroup.rb: ditto
* lib/webrick/httpauth/htpasswd.rb: ditto
---
lib/webrick/httpauth/htdigest.rb | 4 ++--
lib/webrick/httpauth/htgroup.rb | 4 ++--
lib/webrick/httpauth/htpasswd.rb | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/webrick/httpauth/htdigest.rb b/lib/webrick/httpauth/htdigest.rb
index 1b42c02dfa..c35b38433b 100644
--- a/lib/webrick/httpauth/htdigest.rb
+++ b/lib/webrick/httpauth/htdigest.rb
@@ -40,7 +40,7 @@ def initialize(path)
@digest = Hash.new
@mutex = Thread::Mutex::new
@auth_type = DigestAuth
- open(@path,"a").close unless File::exist?(@path)
+ File.open(@path,"a").close unless File.exist?(@path)
reload
end
@@ -51,7 +51,7 @@ def reload
mtime = File::mtime(@path)
if mtime > @mtime
@digest.clear
- open(@path){|io|
+ File.open(@path){|io|
while line = io.gets
line.chomp!
user, realm, pass = line.split(/:/, 3)
diff --git a/lib/webrick/httpauth/htgroup.rb b/lib/webrick/httpauth/htgroup.rb
index 832ae8bd04..399a62c37f 100644
--- a/lib/webrick/httpauth/htgroup.rb
+++ b/lib/webrick/httpauth/htgroup.rb
@@ -36,7 +36,7 @@ def initialize(path)
@path = path
@mtime = Time.at(0)
@group = Hash.new
- open(@path,"a").close unless File::exist?(@path)
+ File.open(@path,"a").close unless File.exist?(@path)
reload
end
@@ -46,7 +46,7 @@ def initialize(path)
def reload
if (mtime = File::mtime(@path)) > @mtime
@group.clear
- open(@path){|io|
+ File.open(@path){|io|
while line = io.gets
line.chomp!
group, members = line.split(/:\s*/)
diff --git a/lib/webrick/httpauth/htpasswd.rb b/lib/webrick/httpauth/htpasswd.rb
index 8c7b09463b..976eeeb13e 100644
--- a/lib/webrick/httpauth/htpasswd.rb
+++ b/lib/webrick/httpauth/htpasswd.rb
@@ -40,7 +40,7 @@ def initialize(path)
@mtime = Time.at(0)
@passwd = Hash.new
@auth_type = BasicAuth
- open(@path,"a").close unless File::exist?(@path)
+ File.open(@path,"a").close unless File.exist?(@path)
reload
end
@@ -51,7 +51,7 @@ def reload
mtime = File::mtime(@path)
if mtime > @mtime
@passwd.clear
- open(@path){|io|
+ File.open(@path){|io|
while line = io.gets
line.chomp!
case line
--
EW
next prev parent reply other threads:[~2017-12-21 11:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 11:55 [PATCH 0/6] webrick: audit and fix Kernel#open misuse Eric Wong
2017-12-21 11:55 ` Eric Wong [this message]
2017-12-21 11:55 ` [PATCH 2/6] webrick/httpservlet/cgi_runner.rb: remove unnecessary open Eric Wong
2017-12-21 11:55 ` [PATCH 3/6] webrick: add test for WEBrick::HTTPServlet::ERBHandler Eric Wong
2017-12-21 11:55 ` [PATCH 4/6] webrick: WEBrick::Log requires path arg when given string Eric Wong
2017-12-21 11:55 ` [PATCH 5/6] webrick/httpservlet/*handler: use File.open Eric Wong
2017-12-21 11:55 ` [PATCH 6/6] webrick/httputils: note Kernel#open behavior Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171221115507.27500-2-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).