bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HISTFILE=/dev/null, HISTSIZE=0 removes /dev/null on exit


From: Piotr Grzybowski
Subject: Re: HISTFILE=/dev/null, HISTSIZE=0 removes /dev/null on exit
Date: Tue, 20 Oct 2015 20:53:51 +0200

hey,

 just out of curiosity, does this fix it (sorry I just finished when
you wrote that it had been fixed):

diff --git a/bashhist.c b/bashhist.c
index d4c62e7..9b5cf5d 100644
--- a/bashhist.c
+++ b/bashhist.c
@@ -354,7 +354,7 @@ save_history ()
   int r;

   hf = get_string_value ("HISTFILE");
-  if (hf && *hf && file_exists (hf))
+  if (hf && *hf && file_exists (hf) && file_isregular(hf))
     {
       /* Append only the lines that occurred this session to
         the history file. */

diff --git a/general.c b/general.c
index 087689e..1b5d6cf 100644
--- a/general.c
+++ b/general.c
@@ -549,6 +549,15 @@ file_exists (fn)
 }

 int
+file_isregular (fn)
+     char *fn;
+{
+  struct stat sb;
+
+  return ((stat (fn, &sb) == 0) && S_ISREG (sb.st_mode));
+}
+
+int
 file_isdir (fn)
      char *fn;
 {

cheers,
pg


On Tue, Oct 20, 2015 at 8:42 PM, Chet Ramey <chet.ramey@case.edu> wrote:
> On 10/20/15 11:03 AM, Marko Teiste wrote:
>
>> Description:
>> setting HISTFILE=/dev/null and HISTSIZE=0 will replace /dev/null
>> with regular file on exit (when running as root).
>>
>> Repeat-By:
>> start bash with root priviledges
>> HISTFILE=/dev/null
>> HISTSIZE=0
>> exit
>>
>> Fix:
>> Check if HISTFILE points to regular file before unlink/recreate?
>
> Thanks for the report.  This has been fixed for the next release of bash.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]