source: trunk/athena/bin/get_message/view_message_by_zephyr.c @ 14063

Revision 14063, 1.7 KB checked in by danw, 25 years ago (diff)
get_message, formerly in athena/bin/gms
Line 
1/* Copyright 1988, 1998 by the Massachusetts Institute of Technology.
2 *
3 * Permission to use, copy, modify, and distribute this
4 * software and its documentation for any purpose and without
5 * fee is hereby granted, provided that the above copyright
6 * notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting
8 * documentation, and that the name of M.I.T. not be used in
9 * advertising or publicity pertaining to distribution of the
10 * software without specific, written prior permission.
11 * M.I.T. makes no representations about the suitability of
12 * this software for any purpose.  It is provided "as is"
13 * without express or implied warranty.
14 */
15
16static const char rcsid[] = "$Id: view_message_by_zephyr.c,v 1.1 1999-12-08 22:06:46 danw Exp $";
17
18#include "globalmessage.h"
19#include <pwd.h>
20#include <stdio.h>
21#include <stdlib.h>
22#include <syslog.h>
23#include <unistd.h>
24#include <com_err.h>
25
26void view_message_by_zephyr(char *message)
27{
28  char *whoami;
29  char *ptr;
30 
31  whoami = getenv("USER");
32 
33  if(!whoami)
34    whoami = getlogin();
35 
36  if(!whoami) {
37    struct passwd *pw;
38    pw = getpwuid(getuid());
39    if(pw) {
40      whoami = pw->pw_name;
41    } else {
42      fprintf(stderr,
43              "get_message: couldn't find username to send zephyr notice\n");
44      exit(2);
45    }
46  }
47  /* skip magic headers */
48  ptr = strchr(message, '\n')+1;
49 
50  /* check that there is *something* after the headers */
51  if(*ptr) {
52    /* don't even fork... this just exits anyway... */
53    execl("/usr/athena/bin/zwrite",
54          "zwrite", "-d", "-q", "-n",  whoami, "-m", ptr, 0);
55    /* put logging here in case the exec fails. */
56    syslog(LOG_INFO, "GMS client execl of zwrite failed [%s]",
57           error_message(errno));
58  }
59}
Note: See TracBrowser for help on using the repository browser.