-->

Previous | Table of Contents | Next

Page 950

EXAMPLES

One example of use is the following code, which simulates typing in the shell:


ls -l *.c ../*.c



glob_t globbuf;

globbuf.gl_offs = 2;

glob("*.c", GLOB_DOOFS, NULL, &globbuf);

glob("../*.c", GLOB_DOOFS | GLOB_APPEND, NULL, &globbuf);

globbuf.gl_pathv[0] = "ls";

globbuf.gl_pathv[1] = "-l";

execvp("ls", &globbuf.gl_pathv[0]);

CONFORMS TO

Proposed POSIX.2

BUGS

The glob()function may fail due to failure of underlying function calls, such as malloc() or opendir(). These will store their error code in errno.

POSIX.2 is not yet an approved standard; the information in this man page is subject to change.

SEE ALSO

ls(1), sh(1), exec(2), stat(2), malloc(3), opendir(3), readdir(3), wordexp(3), glob(7)

GNU, 13 May 1996

hosts_access, hosts_ctl

hosts_access, hosts_ctl—Access-control library functions

SYNOPSIS


#include "log_tcp.h"

extern int allow_severity;

extern int deny_severity;

int hosts_access(daemon, client)

char *daemon;

struct client_info *client;

int hosts_ctl(daemon, client_name, client_addr, client_user)

char *daemon;

char *client_name;

char *client_addr;

char *client_user;

DESCRIPTION

The routines described in this document are part of the libwrap.a library. They implement a pattern-based access-control language with optional shell commands that are executed when a pattern fires.

In all cases, the daemon argument should specify a daemon process name (argv[0] value). The client host address should be a valid address, or FROM_UNKNOWN if the address lookup failed. The client hostname and username should be empty strings if no information is available, FROM_UNKNOWN if the lookup failed, or an actual hostname or username.

hosts_access() consults the access-control tables described in the hosts_access(5) manual page. hosts_access() returns 0 if access should be denied.

hosts_ctl() is a wrapper around the hosts_access() routine with a perhaps more convenient interface (although it does not pass on enough information to support automated remote username lookups). hosts_ctl() returns 0 if access should be denied.

Page 951

The allow_severity and deny_severity variables determine how accepted and rejected requests can be logged. They must be provided by the caller and can be modified by rules in the access-control tables.

DIAGNOSTICS

Problems are reported via the syslog daemon.

SEE ALSO

hosts_access(5) (format of the access control tables), hosts_options(5), optional extensions to the base language

FILES

/etc/hosts.access, /etc/hosts.deny access-control tables

BUGS

The functions described here do not make copies of their string-valued arguments. Beware of data from functions that overwrite their results on each call.

hosts_access() uses the strtok() library function. This may interfere with other code that relies on strtok().

AUTHOR

Wietse Venema (wietse@wzv.win.tue.nl)
Department of Mathematics and Computing Science
Eindhoven University of Technology
Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands

hcreate, hdestroy, hsearch

hcreate, hdestroy, hsearch—Hash table management

SYNOPSIS


#include <search.h>

ENTRY *hsearch(ENTRY item, ACTION action);

int hcreate(unsigned nel);

void hdestroy(void);

DESCRIPTION

These three functions allow the user to create a hash table that associates a key with any data.

First, the table must be created with the function hcreate(). nel is an estimate of the number of entries in the table. hcreate() may adjust this value upward to improve the performance of the resulting hash table. The GNU implementation of hsearch() will also enlarge the table if it gets nearly full. malloc(3) is used to allocate space for the table.

The corresponding function hdestroy() frees the memory occupied by the hash table so that a new table can be constructed.

item is of type ENTRY, which is a typedef defined in <search.h> and includes these elements:


typedef struct entry

{

  char *key;

  char *data;

} ENTRY;

key points to the zero-terminated ASCII string that is the search key. data points to the data associated with that key. (A pointer to a type other than character should be cast to pointer-to-character.) hsearch()searches the hash table for an item with the same key as item, and if successful returns a pointer to it. action determines what hsearch() does after an unsuccessful search. A value of ENTER instructs it to insert the new item, whereas a value of FIND means to return NULL.

Previous | Table of Contents | Next