DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

dbAddDbPriv(3dba)


dbAddDbPriv -- grant a user access to a specific EELS databases

Synopsis

cc [flag ...] file ... -kthread -leels [library] ...
#include <eelsdba.h>

int dbAddDbPriv( char *host, char *user, char *database, unsigned int privs);

Description

dbAddDbPriv grants a user privileges to a specific database. Privileges set using this routine will override the global privileges set using dbAddUserPriv(3dba).

When an application connects to a database using dbConnect(3dba) the username is sent to the database server for authentication. In the case of mySQL this is the login user name. If a user logs into a machine and uses su(1M) to log in as another user, the username that the user used to login is sent to the database server. This should be kept in mind when diagnosing problems with database privileges.

A user can be granted a number of privileges to EELS databases. Privileges are passed to this routine in the form of a bitmask. The bitmask is made up by OR'ing together one or more of the privilege bits defined in the table below.

User privilege bitmask values

Value Description
DB_SELECT_PRIV Allow records to be read from a database
DB_INSERT_PRIV Allow records to be written to a database
DB_UPDATE_PRIV Allow records to be modified in a database.
DB_DELETE_PRIV Allow records to be deleted from a database
DB_CREATE_PRIV Allow tables to be created in a database
DB_DROP_PRIV Allow tables to be dropped from a database

 +---------------+---------------------------------------------+
 |Value          | Description                                 |
 +---------------+---------------------------------------------+
 |DB_SELECT_PRIV | Allow records to be read from a database    |
 +---------------+---------------------------------------------+
 |DB_INSERT_PRIV | Allow records to be written to a database   |
 +---------------+---------------------------------------------+
 |DB_UPDATE_PRIV | Allow records to be modified in a database. |
 +---------------+---------------------------------------------+
 |DB_DELETE_PRIV | Allow records to be deleted from a database |
 +---------------+---------------------------------------------+
 |DB_CREATE_PRIV | Allow tables to be created in a database    |
 +---------------+---------------------------------------------+
 |DB_DROP_PRIV   | Allow tables to be dropped from a database  |
 +---------------+---------------------------------------------+
If a user is going to be given privileges to add and delete tables from a database (that is, DB_CREATE_PRIV and DB_DROP_PRIV), then the user also needs to be granted access to the EELS administrative database. This can be done by using dbAddDbPriv to grant the user access to the EELS_Admin database. For example, to grant user ``foo'' access to the EELS_Admin database call dbAddDbPriv as follows:
dbAddDbPriv( "localhost",
	"foo",
	"EELS_Admin",
	DB_SELECT_PRIV|DB_INSERT_PRIV|DB_DELETE_PRIV);
This enables user ``foo'' to select, insert, and delete records from the EELS_Admin databases. This is necessary because routines such as dbCreateDatabase(3dba) and dbCreateTable(3dba) modify the EELS_Admin database.

Arguments


host
(Input) IP/Hostname from which the user is connecting to the database

user
(Input) The name of the user that is being granted database privileges.

database
(Input) The name of the database to which the user will be granted privileges.

privs
(Input) Bitmask defining privileges granted to the user.

Return values

dbAddUserPriv returns 0 if successful. Otherwise, it returns -1.

References

dbAddUserPriv(3dba), dbConnect(3dba), dbCreateDatabase(3dba), dbCreateTable(3dba), Intro(3dba), su(1M)


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004