-- $Id: db-users.sql,v 1.1 2002/03/18 22:43:04 fpmip Exp $

-- Author : Tycho Fruru <tycho@fruru.com>
-- Copyright (C) 2001 Tycho Fruru <tycho@fruru.com>
-- Copyright (C) 2001 Conostix S.A. Luxembourg - Tycho Fruru <tycho@conostix.com>

-- This program is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; either version 2 of the License, or (at your
-- option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-- for more details.

-- here we define access privileges for the different database users
-- you should call this script with psql connecting as the database owner

create table ipfc_schema
(
	component	text,
	version		text,
	id		text,
	date		timestamp default now()
);

insert into ipfc_schema (component,version,id) 
	values ('db-users',
		'20020207-01',
		'$Id: db-users.sql,v 1.1 2002/03/18 22:43:04 fpmip Exp $');

create group dbbackend;
create group dbwrapnet;
create group webserver;
create group alerter;

grant select on table
	ipfc_schema
to group dbbackend, group dbwrapnet, group webserver, group alerter;

grant select on table 
	users, agent_types, agents, agent_group_descriptions,
	agent_groups, user_rights, table_names,
	logfiles,
	events,
	attributes,
	text_ref,
	attr_text,
	attr_int8,
	attr_int,
	attr_timestamp,
	attr_date,
	attr_bytea,
	attr_boolean,
	attr_numeric,
	attr_null,
	attr_hash
to group webserver, group alerter;

grant select on table
	agent_types, agents, agent_group_descriptions,
	agent_groups, table_names, attributes
to group dbbackend;

grant select,insert on table
	logfiles
to group dbbackend;

grant all on
	logfile_id_seq,
	event_id_seq,
	text_ref_id_seq
to group dbbackend;

grant insert on table
	alert_queue,
	events,
	attr_text,
	attr_int8,
	attr_int,
	attr_timestamp,
	attr_date,
	attr_bytea,
	attr_boolean,
	attr_numeric,
	attr_null
to group dbbackend;

grant select,insert on table
	text_ref
to group dbbackend;

grant select on table
	text_ref
to group alerter;
	
grant select on table
	agent_types, agents, agent_url_ids
to group dbwrapnet;

grant select,delete on table
	alert_queue
to group alerter;

grant insert,select,delete on table
	alert_queue_finished
to group alerter;

create user dbbackend in group dbbackend;
create user dbwrapnet in group dbwrapnet;
create user webserver in group webserver;
create user alerter   in group alerter;
