[rt-users] Object permissions from the command line

Iain Georgeson iain.georgeson at kaust.edu.sa
Sat Oct 20 09:17:50 EDT 2012


On 15 October 2012 23:56, Thomas Sibley <trs at bestpractical.com> wrote:
> You can use the Perl API by calling GrantRight/RevokeRight on the
> RT::Principals you want to grant rights to.  Arguments are the right
> name and the target object on which the right should be granted (for
> your case, likely a loaded RT::Queue or RT::System for global).

Hi,

Let me add that quite a neat way of managing local rules is with code
in RT_SiteConfig.pm. My instance sets a few aspects of queues
automatically on queue creation (whether that's with the web interface
or commandline or whereever). Skipping a few steps here, but you get
the idea:


* Wrap RT::Queue::Create() in RT/Queue_Local.pm:

ref $RT::PostQueueCreate eq 'CODE' and
    wrap Create => post => sub { $RT::PostQueueCreate->(@_) };


* And then in RT_SiteConfig.pm (again, skipping the boring bits) I have:

Set($PostQueueCreate, sub
{
    my %args = @_;	# The sub we're wrapping shifts $self, curse it.

    my $newqueue = new RT::Queue($SystemUser);
    $newqueue->Load($args{Name});

    # Then you can do stuff like

    $newqueue->SetCorrespondAddress
	(lc($args{Name}). '@'. RT->Config->Get('MailDomain'));

    $my_group->Principal->GrantRight(Object => $newqueue,
					Right  => 'SeeQueue');
});

    Iain.

-- 
Systems Engineer
KAUST Visualisation Laboratory

-- 

------------------------------
This message and its contents, including attachments are intended solely 
for the original recipient. If you are not the intended recipient or have 
received this message in error, please notify me immediately and delete 
this message from your computer system. Any unauthorized use or 
distribution is prohibited. Please consider the environment before printing 
this email.



More information about the rt-users mailing list