[前][次][番号順一覧][スレッド一覧]

ruby-changes:26761

From: keiju <ko1@a...>
Date: Mon, 14 Jan 2013 23:17:29 +0900 (JST)
Subject: [ruby-changes:26761] keiju:r38813 (trunk): * lib/irb/ext/save-history.rb: outputs its history to

keiju	2013-01-14 23:17:18 +0900 (Mon, 14 Jan 2013)

  New Revision: 38813

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38813

  Log:
    * lib/irb/ext/save-history.rb: outputs its history to
      owner-only-readable file and change the permission of a file that
      already exists [Bug #7694]. Thanks Nobuhiro IMAI for bug reports.

  Modified files:
    trunk/ChangeLog
    trunk/lib/irb/ext/save-history.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38812)
+++ ChangeLog	(revision 38813)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jan 14 23:06:41 2013  Keiju Ishitsuka  <keiju@i...>
+
+	* lib/irb/ext/save-history.rb: outputs its history to
+	  owner-only-readable file and change the permission of a file that
+	  already exists [Bug #7694]. Thanks Nobuhiro IMAI for bug reports.
+
 Mon Jan 14 17:12:48 2013  Shugo Maeda  <shugo@r...>
 
 	* enumerator.c (lazy_flat_map_func): flat_map should call each only
Index: lib/irb/ext/save-history.rb
===================================================================
--- lib/irb/ext/save-history.rb	(revision 38812)
+++ lib/irb/ext/save-history.rb	(revision 38813)
@@ -92,7 +92,18 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/ext/save-history.rb#L92
 	  history_file = File.expand_path(history_file)
 	end
 	history_file = IRB.rc_file("_history") unless history_file
-	open(history_file, 'w' ) do |f|
+
+	# Change the permission of a file that already exists[BUG #7694]
+	begin
+	  if File.stat(history_file).mode & 066
+	    File.chmod(0600, history_file)
+	  end
+	rescue Errno::ENOENT
+	rescue
+	  raise
+	end
+
+	open(history_file, 'w', 0600 ) do |f|
 	  hist = HISTORY.to_a
 	  f.puts(hist[-num..-1] || hist)
 	end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]