Wydawca (split by section):   Section:   Chapter:FastBack: configuring   Up: configuring   FastForward: wydawca.conf   Contents: Table of ContentsIndex: Concept Index

4.9 Dictionaries

A dictionary defines the ways to retrieve user information necessary to verify the submission. This information can be, for example, the user’s PGP key or his permissions on a project.

A dictionary is defined in configuration file using the following syntax:

Config: dictionary { … }
dictionary dict-id {
  type type;
  query string;
  params (param1,param2,…);
}

The dictionary statement can appear either in the global scope of the configuration file, or inside a spool statement (see spool). Global definitions affect all spools in the configuration file, and ones inside a spool statement override them for that particular spool.

There are two dictionaries, identified by the value of dict-id tag:

project-owner

Keeps email addresses and real names of administrators (or owners) of a project. It may return any number of rows, each one consisting of two columns: an email address and a user name, in this order.

project-uploader

Keeps system user names, real names, emails and GPG keys of the users that are allowed to make uploads for the project.

The sub-statements of dictionary are:

Config: dictionary: type name

Defines the type of this dictionary. Name is one of the following:

builtin

The data are supplied in the configuration file.

sql

Retrieve data from an SQL database. Currently only MySQL is supported.

external

Retrieve data using an external program. This dictionary type is reserved for future use.

See below for a detailed description of these dictionary types.

Config: dictionary: query string

Sets the query used for retrieving the data. The string is subject to variable expansion (see variable expansion). The following variables are defined in this context:

project

The system name of the project for which the triplet is submitted. The project name is obtained from the directory directive. If the value of this directive contains subdirectories, the first (topmost) directory is used as ‘project’.

spool

The name of the distribution spool where this upload originates (see spool).

url

The URL of the spool, as set in the url statement of the spool block (see url).

dir

Directory (relative to the project distribution root) where the files are going to be uploaded.

dest_dir

Spool destination directory (see destination).

source_dir

Spool source directory (see source).

user
user:name

The system name of the user that submitted the triplet. This is defined only for ‘project-owner’ dictionaries.

comment

The value of the ‘comment’ field from the directive file.

Config: dictionary: params (param1, param2, …)

Supplies additional parameters.

4.9.1 SQL Dictionary

Dictionaries of ‘sql’ type retrieve information from an SQL database (as of version 4.0.3, only ‘MySQL’ databases are supported).

The query statement supplies the SQL query to execute. Normally, it should be a SELECT query.

The params statement must supply a single parameter – the identifier of one of the preceding sql blocks (see sql), which determines database name and user credentials needed to access it.

The following sub-nodes contain sample definitions for the sql dictionaries. They are based on the database structure used in Savane system.

4.9.1.1 Project-owner: an SQL Implementation

This dictionary retrieves email addresses and real names of administrators (or owners) of a project. It may return any number of rows, each one consisting of two columns: an email address and a user name, in this order.

dictionary project-owner {
  type sql;
  params (default);
  query   "SELECT user.email, user.realname "
          "FROM user,user_group,groups "
          "WHERE user_group.user_id=user.user_id "
          "AND user_group.group_id=groups.group_id "
          "AND user_group.admin_flags = 'A' "
          "AND groups.unix_group_name = '${project}'";
}

4.9.1.2 Project-uploader: an SQL Implementation

This dictionary assumes that the ‘user’ table has a special column, ‘upload_flags’, whose value is ‘Y’ for those users who can do uploads for this project:

dictionary project-uploader {
  type sql;
  params (default);
  query   "SELECT user.email, user.realname "
          "FROM user,user_group,groups "
          "WHERE user_group.user_id=user.user_id "
          "AND user_group.group_id=groups.group_id "
          "AND user_group.upload_flags = 'Y' "
          "AND groups.unix_group_name = '${project}'";
}

4.9.2 Built-in Dictionary

Builtin dictionaries are small dictionaries that keep all data in their params list. They are designed mainly for testing purposes.

Look ups in builtin dictionaries are performed as follows: The query value is expanded (see query). The resulting value is used as a key for lookup in params list. The list scanned as follows:

  1. INIT

    Let i be the index of the current element in params. Set i to 0.

  2. GETEL

    Get the ith element.

  3. If it begins with a slash, interpret it as comparison type indicator. Its possible values are:
    /exact

    Exact comparison. The key must be exactly equivalent to the dictionary field.

    /fnmatch

    Dictionary field is treated as an fnmatch globbing pattern. See globbing pattern in glob man page.

    /regex

    Dictionary field is treated as a regular expression. Unless configured otherwise by flags (see below), POSIX extended regular expressions are used (see Extended regular expressions in GNU sed).

    If that word ends with a comma, the characters following it are flags, defining the type of matching. Allowed flags are:

    FlagMeaning
    iIgnore case
    bUse basic regular expressions

    For example, the string ‘/exact,i’ specifies case-insensitive exact comparison, the string ‘/regex,bi’ specifies case-insensitive basic regular expression matching, etc.

    Go to step ‘INCR’.

  4. COMP

    Compare the element with the key, using currently selected comparison method.

  5. If the element matches the key, add elements i+1 through i+n to the result set. The value for n is selected as follows:
    Dictionaryn
    project-owner2
    project-uploader4
  6. Set i = i + n
  7. INCR

    Set i = i + 1.

  8. LOOP

    If i is greater than the number of elements in param, then stop. Otherwise, go to step ‘GETEL’.

For example, the following defines the ‘project-owner’ dictionary, containing data for projects ‘foo’ and ‘bar’:

dictionary project-owner {
  type builtin;
  query "${project}";
  params ("/exact",
          "foo", "foo-owner@domain.net", "Foo Admin",
          "bar", "smith@other.net", "John Smith");
}

4.9.3 External Dictionary

As of version 4.0.3 this dictionary is not yet implemented.

Wydawca (split by section):   Section:   Chapter:FastBack: configuring   Up: dictionaries   FastForward: wydawca.conf   Contents: Table of ContentsIndex: Concept Index