Bacula-users

Re: [Bacula-users] Help cmd in a restricted console

2016-01-18 12:33:14
Subject: Re: [Bacula-users] Help cmd in a restricted console
From: Peter Keller <pkeller AT sift DOT net>
To: Kern Sibbald <kern AT sibbald DOT com>, Bacula Users List <bacula-users AT lists.sourceforge DOT net>
Date: Mon, 18 Jan 2016 11:29:18 -0600
Hello!

On 12/29/2015 03:12 AM, Kern Sibbald wrote:
> The only current possibility is to not permit the help command. Making the 
> help
> command recognized which commands are permitted would be a significant project
> which is not currently on our task list.  However, it would be nice if someone
> would contribute it :-)

I have written the patch and would like to contribute it. I'll give a summary
of the output of the patch and then attach the patch itself. I have also sent
in the CAA document.

I noticed that bconsole takes a lot of its direction from the Director in a
pleasant manner. So, this patch is only in the Director sources and it is
against the 7.2.0 sources.

Here is an example of the regular 'help' command, printed out in full. The
! denotes a command which is NOT available to you in this particular
console, and notice that the help told you that you were in a restricted
console as well.

*help
  Command       Description
  =======       ===========
! add           Add media to a pool
  autodisplay   Autodisplay console messages
! automount     Automount after label
! cancel        Cancel a job
! create        Create DB Pool from resource
! delete        Delete volume, pool or job
! disable       Disable a job, attributes batch process
! enable        Enable a job, attributes batch process
! estimate      Performs FileSet estimate, listing gives full listing
! exit          Terminate Bconsole session
! gui           Non-interactive gui mode
  help          Print help on specific command
! label         Label a tape
  list          List objects from catalog
  llist         Full or long list like list command
  messages      Display pending messages
! memory        Print current memory usage
! mount         Mount storage
! prune         Prune expired records from catalog
! purge         Purge records from catalog
  quit          Terminate Bconsole session
! query         Query catalog
  restore       Restore files
! relabel       Relabel a tape
! release       Release storage
! reload        Reload conf file
  run           Run a job
! restart       Restart a job
! resume        Resume a job
  status        Report status
! stop          Stop a job
! setdebug      Sets debug level
! setbandwidth  Sets bandwidth
! snapshot      Handle snapshots
! setip         Sets new client address -- if authorized
  show          Show resource records
! sqlquery      Use SQL to query catalog
! time          Print current time
! trace         Turn on/off trace to file
! truncate      Truncate one or more Volumes
! unmount       Unmount storage
! umount        Umount - for old-time Unix guys, see unmount
! update        Update volume, pool or stats
! use           Use catalog xxx
! var           Does variable expansion
! version       Print Director version
! wait          Wait until no jobs are running

This is a restricted console. Commands marked with ! are invalid.

When at a prompt, entering a period cancels the command.
*


If you ask for help on a specific item, you get this:

*help time
  Command       Description
  =======       ===========
! time          Print current time

Arguments:


This is a restricted console. Commands marked with ! are invalid.

When at a prompt, entering a period cancels the command.
*


I also noticed there is a dot command set and I fixed that too. I understand
though that my changes here might be tweaked a little since it is a scripting
interface.

But, I'll demonstrate that this looks like too (but here I'll summarize
appropriately):

*.help all
!add
autodisplay
!automount
!cancel
!create
!delete
!disable
!enable
!estimate
!exit
!gui
help
!label
list
llist
messages
!memory
!mount
!prune
!purge
quit
!query
restore
!relabel
!release
!reload
run
!restart
!resume
status
!stop
!setdebug
!setbandwidth
!snapshot
!setip
show
!sqlquery
!time
!trace
!truncate
!unmount
!umount
!update
!use
!var
!version
!wait


* .help
[snip]
!reload Reload conf file --
run Run a job -- job=<job-name> client=<client-name>
        fileset=<FileSet-name> level=<level-keyword>
        storage=<storage-name> where=<directory-prefix>
        when=<universal-time-specification> pool=<pool-name>
         nextpool=<next-pool-name> comment=<text> accurate=<bool>
spooldata=<bool> yes
!restart Restart a job -- incomplete job=<job-name> client=<client-name>
        fileset=<FileSet-name> level=<level-keyword>
        storage=<storage-name>when=<universal-time-specification>
        comment=<text> spooldata=<bool> jobid=<jobid>
[snip]

*.help item=reload

The command 'reload' is invalid in this restricted console.

*



So, I figure that it might be requested that I change the dot help command to
have the new feature only in the '.help all' case as opposed to changing
output in the other variants of .help.


Anyways, please let me know if I need to make changes The most important change
for me was the regular help command fixes with which humans interact but it is
pretty nice to have the scriptable interface realize it can't do something too.

I've attached the patch.

Thank you!

-pete


Attachment: restricted-console-7.2.0.patch
Description: Text Data

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users
<Prev in Thread] Current Thread [Next in Thread>