*** gnats/ChangeLog Fri Dec 12 21:32:58 1997 --- gnats/ChangeLog Fri Dec 12 21:51:04 1997 *************** *** 1,3 **** --- 1,15 ---- + Tue Nov 24 16:00:00 1997 Abe Feldman + + * file-pr.c: (gnats) If submitter ID is null or default, call + defive_submitter. (derive_submitter) New function, looks for + end fragment of "From:" header in "addresses" file; returns + submitter ID if found, othewise returns the default submitter + * addresses: New file. Meant to contain mappings between submitter + IDs and incoming e-mail addresses. Template contains format + instructions for entries. Used by derive_submitter + * Makefile.in: Install addresses file in gnats-adm + * p-admin.texi: Documentation for new feature + Fri Oct 24 16:10:00 1997 Abe Feldman * query-pr.c: (main) Look for new qualifiers -M, -B, --modified-before, *** send-pr/ChangeLog Fri Dec 12 21:47:45 1997 --- send-pr/ChangeLog Fri Dec 12 21:51:47 1997 *************** *** 1,3 **** --- 1,8 ---- + Tue Nov 25 16:00:00 1997 Abe Feldman + + * s-usage.texi: Added note about deriving the submitter ID + from the "From:" header when incoming PR is unformatted + Fri Oct 31 17:00:00 1997 Abe Feldman * s-usage.texi: New node, "Submitting via e-mail" on how to submit *** gnats/Makefile.in Fri Dec 12 21:11:01 1997 --- gnats/Makefile.in Fri Dec 12 21:48:59 1997 *************** *** 198,204 **** LIBOBJS = edit.o files.o getdate.o headers.o internal.o misc.o pr.o xmalloc.o index.o lists.o query.o qvariable.o config.o version.o $(EXTRA_OBJS) DISTFILES= $(SOURCES) COPYING ChangeLog INSTALL Makefile.in README \ ! categories responsible submitters regex.c regex.h \ at-pr.sh config.h configure configure.in error.c files.h getdate.y \ getdate.c globals.h headers.h index.c mkcat.sh pathmax.h pr.h getclose.c \ pr-addr.c pr-age.c pr-mail.c pr-stat.c gnats-dirs.h gnats-el.in gnats.h \ --- 198,204 ---- LIBOBJS = edit.o files.o getdate.o headers.o internal.o misc.o pr.o xmalloc.o index.o lists.o query.o qvariable.o config.o version.o $(EXTRA_OBJS) DISTFILES= $(SOURCES) COPYING ChangeLog INSTALL Makefile.in README \ ! categories responsible submitters addresses regex.c regex.h \ at-pr.sh config.h configure configure.in error.c files.h getdate.y \ getdate.c globals.h headers.h index.c mkcat.sh pathmax.h pr.h getclose.c \ pr-addr.c pr-age.c pr-mail.c pr-stat.c gnats-dirs.h gnats-el.in gnats.h \ *************** *** 516,521 **** --- 516,527 ---- $(GNATS_ROOT)/gnats-adm/submitters ; \ $(INSTALL_DATA) -o $(GNATS_USER) $(srcdir)/gnatsd.conf \ $(GNATS_ROOT)/gnats-adm/gnatsd.conf ; \ + fi + @if [ -f $(GNATS_ROOT)/gnats-adm/addresses ]; then \ + echo "Not putting addresses file in gnats-adm, it's already there." ; \ + true ; \ + else \ + $(INSTALL_DATA) -o $(GNATS_USER) addresses $(GNATS_ROOT)/gnats-adm/addresses ; \ fi @if [ -f $(GNATS_ROOT)/gnats-adm/config ]; then \ echo "Not putting config file in gnats-adm, it's already there." ; \ *** gnats/file-pr.c Fri Dec 12 21:30:40 1997 --- gnats/file-pr.c Fri Dec 12 21:48:59 1997 *************** *** 29,34 **** --- 29,35 ---- static void create_report PARAMS((char *, int)); static int get_bug_number PARAMS((void)); static void notify_responsible PARAMS((char*, char*, char*, char*, char*, int, struct tm *)); + static char* derive_submitter PARAMS((void)); static struct bad_enum *bad_enums = NULL; *************** *** 50,55 **** --- 51,57 ---- char *subject = NULL, *synopsis = NULL; char *p; char message[STR_MAX]; + char *from_address; mode_t mode; struct stat sbuf; *************** *** 69,78 **** --- 71,90 ---- read_pr (fp, 0); fclose (fp); + /* If we don't have a valid submitter ID, try to get it from the "From:" + header. If that doesn't work, use the default from the config file. */ + site = field_value (SUBMITTER); + if ((find_submitter (&submitter, site) == -1) + || (strcmp (site, def_subm) == 0)) + { + site = derive_submitter (); + set_field (SUBMITTER, site); + } if (find_submitter (&submitter, site) == -1) { + log_msg (LOG_INFO, 1, "resetting to default submitter from:", site); site = def_subm; set_field (SUBMITTER, def_subm); *************** *** 462,468 **** return path; } ! /* Send a reply to the submitter of the bug. */ static void --- 474,560 ---- return path; } ! ! /* This function compares the e-mail address in the "From:" header of a new ! PR with entries in the "addresses" file. If there is a match, we return ! the submitter ID from "addresses", otherwise we return the default ! submitter. */ ! ! char * ! derive_submitter () ! { ! char *from_address; ! char from_string[STR_MAX]; ! char *token = (char *) xmalloc (STR_MAX); ! char path[STR_MAX]; ! char *compare; ! ! char *name, *alias, *s, *t; ! int i, start, end; ! ! FILE *fp; ! ! from_address = header_value (FROM); ! strcpy (from_string, from_address); ! ! if ((*from_string == '\0') || (*from_string == '\n')) ! { ! xfree (token); ! return def_subm; ! } ! ! s = from_string + strlen(from_string) - 2; ! if (*s == '>') ! { ! *s = '\0'; ! for (t = s; *t != '<'; t--) ! *t = toupper (*t); ! } ! else ! for (t = from_string; *t != '\0'; t++) ! { ! *t = toupper (*t); ! if ((*t == ' ') || (*t == '\n')) ! *t = '\0'; ! } ! sprintf (path, "%s/gnats-adm/addresses", gnats_root); ! if ((fp = fopen (path, "r")) == (FILE *) NULL) ! { ! xfree (token); ! return def_subm; ! } ! while ((fgets (token, STR_MAX, fp)) != NULL) ! if (*token != '#') ! { ! name = token; ! ! for (alias = token; (*alias != ':') && (*alias != '\0'); alias++); ! if (*alias == ':') ! { ! *alias = '\0'; ! if (*(++alias) != '\0') ! for (t = alias; *t != '\0'; t++) ! { ! *t = toupper (*t); ! if (*t == '\n') ! *t = '\0'; ! } ! } ! ! compare = from_string + strlen (from_string) - strlen (alias); ! if (strcmp (compare, alias) == 0) ! { ! fclose (fp); ! return name; ! } ! } ! ! xfree (token); ! fclose (fp); ! return def_subm; ! } ! ! /* Send a reply to the submitter of the bug. */ static void *************** *** 925,927 **** --- 1017,1020 ---- return bug_number; } + *** gnats/p-admin.texi Fri Dec 12 21:30:41 1997 --- gnats/p-admin.texi Fri Dec 12 21:48:59 1997 *************** *** 239,244 **** --- 239,251 ---- The list of Submitter Sites from whom @sc{gnats} accepts Problem Reports. This file is mandatory, although the feature it provides is not; see @ref{submitters,,The @code{submitters} file}. + + @cindex @code{addresses} file + @item addresses + Mappings between submitter IDs and submitters' e-mail addresses. Use of + this file is optional. If you get Problem reports where the + @samp{>Submitter} field is not filled in, @sc{gnats} will use entries in + this file to try to derive the submitter ID from the e-mail headers. @end table @menu *************** *** 247,252 **** --- 254,260 ---- * categories:: The `categories' file * responsible:: The `responsible' file * submitters:: The `submitters' file + * addresses:: The `addresses' file @end menu @node default behavior *************** *** 739,744 **** --- 747,816 ---- @samp{DEFAULT_SUBMITTER} value in the @file{config} file (@pxref{config,,The @code{config} file}), and instruct your submitters to ignore the field. + + @node addresses + @subsection The @code{addresses} file + @cindex @code{addresses} file + + This file contains mappings between submitter IDs and corresponding e-mail + addresses. + + When a PR comes in without a submitter ID (if someone sends umformatted e-mail + to the "bugs" address), @sc{gnats} will try to derive the submitter ID from the + address in the "From:" header. The entries in this file consist of two + fields, separated by a colon: + + @smallexample + @var{submitter-id}:@var{address-fragment} + @end smallexample + + @noindent + @table @var + @item @var{submitter-id} + A valid submitter ID + + @item @var{address-fragment} + Part of all of the e-mail address to be matched + @end table + + Here is an example of an @code{addresses} file: + + @smallexample + # Addresses for Yoyodine Inc + yoyodine:yoyodine.com + yoyodine:yoyodine.co.uk + # Addresses for Foobar Inc. + foobar1:sales.foobar.com + foobar2:admin.foobar.com + foobar3:clark@@research.foobar.com + @end smallexample + + @sc{gnats} checks each line in the @code{addresses} file, comparing + @var{address-fragment} to the end of the "From:" header, until it finds + a match. If no match is found, @sc{gnats} uses the default submitter ID. + + You can only have one address fragment per line, but you can have more than + one line for a given submitter ID. An address fragment can be a domain + (i.e. yoyodine.com), a machine location (admin.foobar.com), or a full e-mail + address (clark@@research.foobar.com). + + @sc{gnats} can match addresses in three e-mail formats: + + @table @var + @item From: name@@address.com + The address by itself without a full name, not enclosed in brackets + + @item From: Real Person + A full name (optional, with or without quotation marks), followed by the + address enclosed in angle brackets + + @item From: name@@address.com (Real Person) + An address, followed by a name or comment in parentheses + @end table + + If @sc{gnats} sees other e-mail address formats, it uses the default + submitter ID. Future version of this feature will account for other + valid e-mail address formats. @node Admin files @section Administrative data files *** send-pr/s-usage.texi Fri Dec 12 21:47:45 1997 --- send-pr/s-usage.texi Fri Dec 12 21:49:00 1997 *************** *** 480,486 **** @table @code @item Synopsis ! The @samp{>Synopsis} field is filled in by the @samp{Subject:} header @item Description All of the text in the body of the e-mail message is put into the --- 480,490 ---- @table @code @item Synopsis ! The @samp{>Synopsis} field is filled in by the @samp{Subject:} header. ! ! @item Submitter ID ! @sc{gnats} will try to derive the @samp{>Submitter} field from the address ! in the @samp{From:} header. @item Description All of the text in the body of the e-mail message is put into the *** gnats/addresses Sun Dec 14 00:44:07 1997 --- gnats/addresses Sun Nov 23 16:23:21 1997 *************** *** 0 **** --- 1,12 ---- + # Use this file to store mappings between submitter IDs and their + # senders' email addresses. + # + # Entries are of the form: + # + #submitter-id:address-fragment + # + # where submitter-id is a valid submitter ID, and address-fragment + # is a full or partial e-mail address. Fragments are compared to the + # end of the "From:" header of a Problem Report. GNATS ignores the + # trailing ">" of an incoming e-mail address, so you don't need to + # include it in an address fragment.