Re: history issue - bug?

2018-01-16 Thread Felipe Salvador
On Sun, Jan 14, 2018 at 06:24:27PM +0100, Felipe Salvador wrote:
> On Sun, Jan 14, 2018 at 02:07:01PM +0100, Hans wrote:
> > Hi folks, 
> > 
> > try this:
> > 
> > 1. login as normal user
> > 
> > 2. become root with "su -"
> > 
> > 3. delete history with "history -c"
> 
> Then run "history -w" to "write the current history to the history
> file"

Maybe you could fill a bug report in order to ask if it is possible
change the history behaviour about -c and -w switches, actually it
doesn't accept this combination, you cannot use

$history -c -w  
or
$history -cw

You have to run separately

$history -c
AND
$history -w

Though I don't think this is a bug.


Regards
-- 
Felipe Salvador



Re: history issue - bug?

2018-01-15 Thread davidson

On Sun, 14 Jan 2018, Hans wrote:


Am Sonntag, 14. Januar 2018, 08:41:21 CET schrieb David Wright:
Hi David,

thanks for enlightening me. I always though, that "history -c" would
clear all the history and its files as the help file says:

-cclear the history list by deleting all of the entries

So IMO this should delete all related history files, even
bash_history.


"Even" bash_history? Besides .bash_history, what other files did you
have in mind?

If "history -c" deleted any file at all, the documentation would need
to be changed to reflect that fact. At present, the documentation is
accurate.

A list has entries, and if you delete all the entries, that means you
now have an empty list. It certainly does NOT mean that you have
thereby nuked any and all files to which (the at-most $HISTSIZE length
tails of) previous iterations of that list have been saved.

I suspect that you must be distressed to discover a workflow you had
relied on does not in fact accomplish what you had long thought it
accomplished, because you had conceptually conflated two distinct
entities:

 * your shell *session's* command history *list*

versus

 * your *account's* command history *file*.

Speaking from repeated experience, it does indeed suck to learn that
your beliefs about a trusted tool's behavior have been mistaken for a
long time.

If this is the case, you have my condolences.

But you also have my congratulations, and perhaps you will agree that
finding out you were wrong is still far better than the alternative,
which is to remain forever blissfully mistaken.


And as far as I remember, this did it do in former times.

In my eyes this is a security hole, as someone, who gaines root
somehow (what already is bad eneough) might get more informations of
commands, root did in the past.


You'd like to do without the convenience of a persistent command
history file for root shells.

Since it is your concern to ensure that you don't leave behind shell
command history in a history file:

 1. Did you see Felipe Salvador's suggested addition (elsewhere in
this thread) to your original workflow? Looked pretty slick to me.

 2. The shell variables HISTFILE and HISTFILESIZE are documented in
the bash man page. Set HISTFILESIZE to 0, or unset HISTFILE.
(Since for bash login shells my /root/.profile sources ~/.bashrc,
my understanding is that it would suffice in my case to set/unset
these in /root/.bashrc to the appropriate value.)

If you know you won't want persistent command history on a given
account, this seems a reasonably reliable way to arrange that you
don't get one.

 3. Also in the bash man page is documentation of the shell variables
HISTIGNORE and HISTCONTROL.

 * HISTIGNORE is a colon-separated list of patterns that match
   commands you wish to omit from the history list altogether.

 * HISTCONTROL is a colon-separated list. If one of its elements
   is 'ignorespace', then any command line that begins with a
   space will be omitted from the history list.

NB: Subsequent lines after the first line, of a multi-line
command, are stored in the history list regardless of HISTIGNORE
and HISTCONTROL.

 4. If I remember correctly mksh, the MirBSD Korn shell, by default
writes to no command history file at all, even for a regular user
account. (Though this can of course be configured to suit user
preference.)  Maybe its design would please you better than bash
in other ways, as well.


As I said, history -c should delete ALL traces of history, just as
the help files tells, shouldn't it?


Just FYI, the documentation on bash builtins you get from "help
[builtin]" is intentionally terse, and provides far less contextual
information, than the information available in the bash man page.


As you confirmed, it does not and you also confirmed, that this is
normal behaviour.

In this case, I recommend this as a failure-by-design.

Again, thanks for your clearence, I will file a bug report.


Of course you will do what seems best to you.

But it seems to me that studying the bash man page, to see what else
you might have wrongly assumed, might make better use of your time.

I base this advice this on two rules of thumb:

 1. Better sooner than later.

 2. The bash man page is dense with useful information.

Good luck with your stuff.

--

"We’re not arguing for censorship, we’re arguing just take it off the
page, put it somewhere else." -- Eric Schmidt

Re: history issue - bug?

2018-01-14 Thread David Wright
On Sun 14 Jan 2018 at 12:59:55 (-0500), rhkra...@gmail.com wrote:
> On Sunday, January 14, 2018 12:14:47 PM bw wrote:
> > On Sun, 14 Jan 2018, Hans wrote:
> > > Am Sonntag, 14. Januar 2018, 08:41:21 CET schrieb David Wright:
> > > Hi David,
> > > 
> > > thanks for enlightening me. I always though, that "history -c" would
> > > clear all the history and its files as the help file says:
> > > 
> > > -cclear the history list by deleting all of the entries
> > > 
> > > So IMO this should delete all related history files, even bash_history.
> > 
> > Shouldn't it do what it says it will do?
> > 
> > It says "clear... the list" it does not say delete files.  I can't answer
> > the question about how long it has been this way, but I'm sure it is
> > documented, so maybe look that up before fiing a bug about it?
> 
> I don't know if I want to comment or not.  To me, it takes a fairly savvy 
> user 
> to recognize that list and file are not synonymous--for many casual users 
> (including me, and I consider myself generally as something more than just a 
> casual user), that documentation is not sufficient.

[…]

>  (Of course, I haven't gone looking 
> for documentation on the history command, perhaps this behavior is reasonably 
> documented.

!

man bash

Cheers,
David.



Re: history issue - bug?

2018-01-14 Thread David Wright
On Sun 14 Jan 2018 at 17:46:51 (+0100), Hans wrote:
> Am Sonntag, 14. Januar 2018, 08:41:21 CET schrieb David Wright:
> Hi David,
> 
> thanks for enlightening me. I always though, that "history -c" would clear 
> all 
> the history and its files as the help file says:
> 
> -cclear the history list by deleting all of the entries
> 
> So IMO this should delete all related history files, even bash_history. 

Sorry, but that wouldn't be how the English in that statement would
normally be understood.

> And as far as I remember, this did it do in former times. 

Not in bash 2.

> In my eyes this is a security hole, as someone, who gaines root somehow (what 
> already is bad eneough) might get more informations of commands, root did in 
> the past. 

If this concerns you, truncate ~/.bash_history and chmod a=r.

> As I said, history -c should delete ALL traces of history, just as the help 
> files tells, shouldn't it?

No. you lose functionality.

> As you confirmed, it does not and you also 
> confirmed, that this is normal behaviour. 

Yes, and it follows the documentation.

> In this case, I recommend this as a failure-by-design.

> Again, thanks for your clearence, I will file a bug report.

I would prefer you didn't.

> > On Sun 14 Jan 2018 at 14:07:01 (+0100), Hans wrote:
> > > Hi folks,
> > > 
> > > try this:
> > > 
> > > 1. login as normal user
> > > 
> > > 2. become root with "su -"
> > 
> > … which reads ~/.bash_history into what I call the command recall buffer.
> > 
> > > 3. delete history with "history -c"
> > 
> > … which deletes all the entries in the recall buffer, those just read
> >   in and those commands typed since logging in.
> > 
> > > 4. Check history, history is gone
> > 
> > Presumably you mean you just tried to recall a command and failed.
> > Make that command "ls -l ~/.bash_history" and you'll see the file
> > is still there.
> > 
> > > 5. logout from root by "CTL + D" or "exit"
> > > 
> > > 6. relogin as root with "su -"
> > 
> > … which reads ~/.bash_history.
> > 
> > > 7. Check history, voila, it appears again.
> > 
> > … as expected.
> > 
> > > What is wrong?
> > 
> > Distinguish between history list and history file.
> > 
> > To eliminate your history, you need to remove/empty the file and
> > also clear the list just before you logout.

Cheers,
David.



Re: history issue - bug?

2018-01-14 Thread Brian
On Sun 14 Jan 2018 at 18:25:09 +0100, Hans wrote:

> Am Sonntag, 14. Januar 2018, 12:14:47 CET schrieb bw:
> > On Sun, 14 Jan 2018, Hans wrote:
> > > Am Sonntag, 14. Januar 2018, 08:41:21 CET schrieb David Wright:
> > > Hi David,
> > > 
> > > thanks for enlightening me. I always though, that "history -c" would clear
> > > all the history and its files as the help file says:
> > > 
> > > -cclear the history list by deleting all of the entries
> > > 
> > > So IMO this should delete all related history files, even bash_history.
> > 
> > Shouldn't it do what it says it will do?
> > 
> > It says "clear... the list" it does not say delete files.  I can't answer
> > the question about how long it has been this way, but I'm sure it is
> > documented, so maybe look that up before fiing a bug about it?
> 
> It looks like we understand different. 

Indeed. It's not unusual for this to happen, even amongst native
speakers of English (or any other language, I presumme).
 
> -cclear the history list by deleting all of the entries
> 
> It says: .ALL of the entries

Correct.
 
> IMHO all means ALL, regardless in which file or if in memory.
> Otherwise this command would not make any sense, too.

You are the one who is imposing "...in which file or if in memory".
All does mean ALL (you're not a politician, are you :) ). The commands
used in a session are saved in memory in a *list* and written to a
*file* when you log out.
 
> Of course, one can see it in another way than me...

Search on "history list" in the bash manual.

-- 
Brian.


> Cheers
> 
> Hans
> 
> 
> 



Re: history issue - bug?

2018-01-14 Thread rhkramer
On Sunday, January 14, 2018 12:14:47 PM bw wrote:
> On Sun, 14 Jan 2018, Hans wrote:
> > Am Sonntag, 14. Januar 2018, 08:41:21 CET schrieb David Wright:
> > Hi David,
> > 
> > thanks for enlightening me. I always though, that "history -c" would
> > clear all the history and its files as the help file says:
> > 
> > -cclear the history list by deleting all of the entries
> > 
> > So IMO this should delete all related history files, even bash_history.
> 
> Shouldn't it do what it says it will do?
> 
> It says "clear... the list" it does not say delete files.  I can't answer
> the question about how long it has been this way, but I'm sure it is
> documented, so maybe look that up before fiing a bug about it?

I don't know if I want to comment or not.  To me, it takes a fairly savvy user 
to recognize that list and file are not synonymous--for many casual users 
(including me, and I consider myself generally as something more than just a 
casual user), that documentation is not sufficient.

At the risk of overkill, I would have written the documentation with a note to 
clarify exactly what I said above--something like (with a not full 
understanding of where / how the list is stored):

"clear ... the list, but please note that there is both a list with the 
command history, and a file.  History -c clears that list, but not the file, 
and 
when events occuur (like a new login), the history list is restored from the 
history file.  The history file is in , and if you want to eradicate 
most traces of the history file, you must also delete that file, and, 
potentially, if that critical, any backups.

To me, if it will not be considered a bug in the implementation of the history 
command, it is a bug in the documentation.  (Of course, I haven't gone looking 
for documentation on the history command, perhaps this behavior is reasonably 
documented.  I would think it should be covered under the -h option, or maybe 
if several options need to discuss the existence of the history file, at least 
a note under the -h option something like: : see  for discussion of 
the history file and the distinction between it and the history list.



Re: history issue - bug?

2018-01-14 Thread Hans
Am Sonntag, 14. Januar 2018, 12:14:47 CET schrieb bw:
> On Sun, 14 Jan 2018, Hans wrote:
> > Am Sonntag, 14. Januar 2018, 08:41:21 CET schrieb David Wright:
> > Hi David,
> > 
> > thanks for enlightening me. I always though, that "history -c" would clear
> > all the history and its files as the help file says:
> > 
> > -cclear the history list by deleting all of the entries
> > 
> > So IMO this should delete all related history files, even bash_history.
> 
> Shouldn't it do what it says it will do?
> 
> It says "clear... the list" it does not say delete files.  I can't answer
> the question about how long it has been this way, but I'm sure it is
> documented, so maybe look that up before fiing a bug about it?

It looks like we understand different. 

-cclear the history list by deleting all of the entries

It says: .ALL of the entries

IMHO all means ALL, regardless in which file or if in memory.
Otherwise this command would not make any sense, too.

Of course, one can see it in another way than me...

Cheers

Hans





Re: history issue - bug?

2018-01-14 Thread Felipe Salvador
On Sun, Jan 14, 2018 at 02:07:01PM +0100, Hans wrote:
> Hi folks, 
> 
> try this:
> 
> 1. login as normal user
> 
> 2. become root with "su -"
> 
> 3. delete history with "history -c"

Then run "history -w" to "write the current history to the history
file"

> 4. Check history, history is gone
> 
> 5. logout from root by "CTL + D" or "exit"
> 
> 6. relogin as root with "su -"
> 
> 7. Check history, voila, it appears again.
> 
> What is wrong? Is it a bug or am I doing the wrong way?
> 
> Any comment will help.
> 
> Best regards
> 
> Hans

Regards

-- 
Felipe Salvador



Re: history issue - bug?

2018-01-14 Thread Hans
Am Sonntag, 14. Januar 2018, 08:41:21 CET schrieb David Wright:
Hi David,

thanks for enlightening me. I always though, that "history -c" would clear all 
the history and its files as the help file says:

-cclear the history list by deleting all of the entries

So IMO this should delete all related history files, even bash_history. 

And as far as I remember, this did it do in former times. 

In my eyes this is a security hole, as someone, who gaines root somehow (what 
already is bad eneough) might get more informations of commands, root did in 
the past. 

As I said, history -c should delete ALL traces of history, just as the help 
files tells, shouldn't it? As you confirmed, it does not and you also 
confirmed, that this is normal behaviour. 

In this case, I recommend this as a failure-by-design.

Again, thanks for your clearence, I will file a bug report.

Best 

Hans
> On Sun 14 Jan 2018 at 14:07:01 (+0100), Hans wrote:
> > Hi folks,
> > 
> > try this:
> > 
> > 1. login as normal user
> > 
> > 2. become root with "su -"
> 
> … which reads ~/.bash_history into what I call the command recall buffer.
> 
> > 3. delete history with "history -c"
> 
> … which deletes all the entries in the recall buffer, those just read
>   in and those commands typed since logging in.
> 
> > 4. Check history, history is gone
> 
> Presumably you mean you just tried to recall a command and failed.
> Make that command "ls -l ~/.bash_history" and you'll see the file
> is still there.
> 
> > 5. logout from root by "CTL + D" or "exit"
> > 
> > 6. relogin as root with "su -"
> 
> … which reads ~/.bash_history.
> 
> > 7. Check history, voila, it appears again.
> 
> … as expected.
> 
> > What is wrong?
> 
> Distinguish between history list and history file.
> 
> To eliminate your history, you need to remove/empty the file and
> also clear the list just before you logout.
> 
> Cheers,
> David.




Re: history issue - bug?

2018-01-14 Thread David Wright
On Sun 14 Jan 2018 at 14:07:01 (+0100), Hans wrote:
> Hi folks, 
> 
> try this:
> 
> 1. login as normal user
> 
> 2. become root with "su -"

… which reads ~/.bash_history into what I call the command recall buffer.

> 3. delete history with "history -c"

… which deletes all the entries in the recall buffer, those just read
  in and those commands typed since logging in.

> 4. Check history, history is gone

Presumably you mean you just tried to recall a command and failed.
Make that command "ls -l ~/.bash_history" and you'll see the file
is still there.

> 5. logout from root by "CTL + D" or "exit"
> 
> 6. relogin as root with "su -"

… which reads ~/.bash_history.

> 7. Check history, voila, it appears again.

… as expected.

> What is wrong?

Distinguish between history list and history file.

To eliminate your history, you need to remove/empty the file and
also clear the list just before you logout.

Cheers,
David.