1.1 --- a/prototyp/prototyp.sql Mon Sep 01 15:36:16 2014 +0200
1.2 +++ b/prototyp/prototyp.sql Mon Sep 01 15:56:05 2014 +0200
1.3 @@ -2,6 +2,9 @@
1.4
1.5 SET search_path TO unix_sql_api;
1.6
1.7 +
1.8 +-- fstab: --------------------------------------------------------------------
1.9 +
1.10 DROP VIEW IF EXISTS fstab;
1.11 DROP FUNCTION IF EXISTS fstab();
1.12 DROP TYPE IF EXISTS unix_sql_api_fstab;
1.13 @@ -55,4 +58,40 @@
1.14
1.15 CREATE OR REPLACE VIEW fstab AS
1.16 SELECT * FROM fstab()
1.17 -;
1.18 +;
1.19 +
1.20 +
1.21 +-- user groups: --------------------------------------------------------------
1.22 +
1.23 +DROP VIEW IF EXISTS user_group;
1.24 +DROP FUNCTION IF EXISTS user_group();
1.25 +DROP TYPE IF EXISTS unix_sql_api_user_group;
1.26 +
1.27 +CREATE TYPE unix_sql_api_user_group AS (
1.28 + id INTEGER,
1.29 + name VARCHAR,
1.30 + members VARCHAR[]
1.31 +);
1.32 +
1.33 +CREATE OR REPLACE FUNCTION user_group()
1.34 +RETURNS SETOF unix_sql_api_user_group AS $$
1.35 + use strict;
1.36 + use warnings;
1.37 +
1.38 + use User::grent;
1.39 +
1.40 + while (my $group = getgrent) {
1.41 + return_next({
1.42 + id => $group->gid,
1.43 + name => $group->name,
1.44 + members => [@{$group->members}]
1.45 + });
1.46 + }
1.47 +
1.48 + return undef;
1.49 +$$ LANGUAGE plperlu;
1.50 +
1.51 +CREATE OR REPLACE VIEW user_group AS
1.52 + SELECT * FROM user_group()
1.53 +;
1.54 +