.nf
.IR address-group " := " address-list
.RI " | < " file
-.RI " | = " Unix-group
-.RI " | + " Unix-group
.IR address-list " := " address
.RI " | " address-list ", " address
and
.I file
are Unix file names.
-.I Unix-group
-is a group name or number from
-the system's group database.
Alias file contents are case-insensitive, with the exception
of filesystem path names.
.PP
.I address-list
for the alias.
.PP
-If the
-.I address-group
-starts with an \*(lq=\*(rq, the
-system's group database
-is consulted for the Unix-group named after the \*(lq=\*(rq. Each login name
-occurring as a member of the group is added to the
-.I address-list
-for the alias.
-.PP
-In contrast, if the
-.I address-group
-starts with a \*(lq+\*(rq, the system's group database
-is consulted to determine the group-id of the
-Unix-group named after the \*(lq+\*(rq. Each login name occurring in the
-system's password database
-whose group-id is indicated by this group is
-added to the
-.I address-list
-for the alias.
-.PP
In match, a trailing \*(lq*\*(rq on an alias will match just about anything
appropriate.
.PP
fred: frated@UCI.example
b-people: Blind List: bill, betty
Unix\-committee: <unix.aliases
-staff: =staff
-wheels: +wheel
news.*: news
.fi
.RE
.B nmh
directory.
.PP
-\*(lqstaff\*(rq is defined as all users who are listed as members of the
-group \*(lqstaff\*(rq in the
-system's group database, and \*(lqwheels\*(rq
-is defined as all users whose group-id in
-the system's password database
-is equivalent to the \*(lqwheel\*(rq group.
-.PP
Lastly,
.RI \*(lqnews. anything \*(rq
is aliased to \*(lqnews\*(rq;
#include <h/aliasbr.h>
#include <h/addrsbr.h>
#include <h/utils.h>
-#include <grp.h>
#include <pwd.h>
static int akvis;
static char *getp (char *);
static char *seekp (char *, char *, char **);
static int addfile (struct aka *, char *);
-static int addgroup (struct aka *, char *);
-static int addmember (struct aka *, char *);
static char *getalias (char *);
static void add_aka (struct aka *, char *);
static struct aka *akalloc (char *);
}
break;
- case '=': /* UNIX group */
- if (!*(cp = getp (pp + 1))) {
- fclose (fp);
- return AK_ERROR;
- }
- if (!addgroup (ak, cp)) {
- fclose (fp);
- return AK_NOGROUP;
- }
- break;
-
- case '+': /* UNIX group members */
- if (!*(cp = getp (pp + 1))) {
- fclose (fp);
- return AK_ERROR;
- }
- if (!addmember (ak, cp)) {
- fclose (fp);
- return AK_NOGROUP;
- }
- break;
-
default: /* list */
while ((cp = getalias (pp)))
add_aka (ak, cp);
}
-static int
-addgroup (struct aka *ak, char *grp)
-{
- char *gp;
- struct group *gr = getgrnam (grp);
- struct home *hm = NULL;
-
- if (!gr)
- gr = getgrgid (atoi (grp));
- if (!gr) {
- akerrst = grp;
- return 0;
- }
-
- while ((gp = *gr->gr_mem++))
- {
- struct passwd *pw;
- for (hm = homehead; hm; hm = hm->h_next)
- if (!strcmp (hm->h_name, gp)) {
- add_aka (ak, hm->h_name);
- break;
- }
- if ((pw = getpwnam(gp)))
- {
- hmalloc(pw);
- add_aka (ak, gp);
- }
- }
-
- return 1;
-}
-
-
-static int
-addmember (struct aka *ak, char *grp)
-{
- gid_t gid;
- struct group *gr = getgrnam (grp);
- struct home *hm = NULL;
-
- if (gr)
- gid = gr->gr_gid;
- else {
- gid = atoi (grp);
- gr = getgrgid (gid);
- }
- if (!gr) {
- akerrst = grp;
- return 0;
- }
-
- init_pw ();
-
- for (hm = homehead; hm; hm = hm->h_next)
- if (hm->h_gid == gid)
- add_aka (ak, hm->h_name);
-
- return 1;
-}
-
-
static char *
getalias (char *addrs)
{