/[mailutils]/mailutils/comsat/comsat.c
ViewVC logotype

Diff of /mailutils/comsat/comsat.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.26 by gray, Sun Sep 1 21:55:04 2002 UTC revision 1.27 by polak, Mon Dec 23 22:01:34 2002 UTC
# Line 1  Line 1 
1  /* GNU mailutils - a suite of utilities for electronic mail  /* GNU Mailutils -- a suite of utilities for electronic mail
2     Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.     Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3    
4     This program is free software; you can redistribute it and/or modify     GNU Mailutils is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2, or (at your option)     the Free Software Foundation; either version 2, or (at your option)
7     any later version.     any later version.
8    
9     This program is distributed in the hope that it will be useful,     GNU Mailutils is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.     GNU General Public License for more details.
13    
14     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software     along with GNU Mailutils; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
17    
18  #include "comsat.h"  #include "comsat.h"
# Line 55  static char doc[] = "GNU comsatd"; Line 55  static char doc[] = "GNU comsatd";
55    
56  static struct argp_option options[] =  static struct argp_option options[] =
57  {  {
58    {"config", 'c', "FILE", 0, "Read configuration from FILE", 0},    {"config", 'c', "FILE", 0, N_("Read configuration from FILE"), 0},
59    { NULL, 0, NULL, 0, NULL, 0 }    { NULL, 0, NULL, 0, NULL, 0 }
60  };  };
61    
# Line 136  main(int argc, char **argv) Line 136  main(int argc, char **argv)
136  {  {
137    int c;    int c;
138    
139      /* Native Language Support */
140      mu_init_nls ();
141    
142    mu_argp_parse (&argp, &argc, &argv, 0, comsat_argp_capa,    mu_argp_parse (&argp, &argc, &argv, 0, comsat_argp_capa,
143                   NULL, &daemon_param);                   NULL, &daemon_param);
144    
145    if (daemon_param.timeout > 0 && daemon_param.mode == MODE_DAEMON)    if (daemon_param.timeout > 0 && daemon_param.mode == MODE_DAEMON)
146      {      {
147        fprintf (stderr, "--timeout and --daemon are incompatible\n");        fprintf (stderr, _("--timeout and --daemon are incompatible\n"));
148        exit (EXIT_FAILURE);        exit (EXIT_FAILURE);
149      }      }
150    
# Line 175  main(int argc, char **argv) Line 178  main(int argc, char **argv)
178  static RETSIGTYPE  static RETSIGTYPE
179  sig_hup (int sig)  sig_hup (int sig)
180  {  {
181    syslog (LOG_NOTICE, "restarting");    syslog (LOG_NOTICE, _("restarting"));
182    
183    if (xargv[0][0] != '/')    if (xargv[0][0] != '/')
184      syslog (LOG_ERR, "can't restart: not started with absolute pathname");      syslog (LOG_ERR, _("can't restart: not started with absolute pathname"));
185    else    else
186      execvp (xargv[0], xargv);      execvp (xargv[0], xargv);
187    
# Line 212  comsat_daemon_init (void) Line 215  comsat_daemon_init (void)
215       first three one, in, out, err.  Do not do the chdir("/").   */       first three one, in, out, err.  Do not do the chdir("/").   */
216    if (daemon (1, 0) < 0)    if (daemon (1, 0) < 0)
217      {      {
218        perror ("failed to become a daemon:");        perror (_("failed to become a daemon:"));
219        exit (EXIT_FAILURE);        exit (EXIT_FAILURE);
220      }      }
221  }  }
# Line 256  comsat_daemon (int port) Line 259  comsat_daemon (int port)
259        exit (1);        exit (1);
260      }      }
261    
262    syslog (LOG_NOTICE, "GNU comsat started");    syslog (LOG_NOTICE, _("GNU comsat started"));
263    
264    last_request_time = last_overflow_time = time (NULL);    last_request_time = last_overflow_time = time (NULL);
265    while (1)    while (1)
# Line 283  comsat_daemon (int port) Line 286  comsat_daemon (int port)
286                unsigned delay;                unsigned delay;
287    
288                delay = overflow_delay_time << (overflow_count + 1);                delay = overflow_delay_time << (overflow_count + 1);
289                syslog (LOG_NOTICE, "too many requests: pausing for %u seconds",                syslog (LOG_NOTICE, _("too many requests: pausing for %u seconds"),
290                        delay);                        delay);
291                sleep (delay);                sleep (delay);
292                reqcount = 0;                reqcount = 0;
# Line 336  comsat_main (int fd) Line 339  comsat_main (int fd)
339    
340    if (acl_match (&sin_from))    if (acl_match (&sin_from))
341      {      {
342        syslog (LOG_ALERT, "DENIED attempt to connect from %s",        syslog (LOG_ALERT, _("DENIED attempt to connect from %s"),
343                inet_ntoa (sin_from.sin_addr));                inet_ntoa (sin_from.sin_addr));
344        return 1;        return 1;
345      }      }
346    
347    syslog (LOG_INFO, "%d bytes from %s", rdlen, inet_ntoa (sin_from.sin_addr));    syslog (LOG_INFO, _("%d bytes from %s"), rdlen, inet_ntoa (sin_from.sin_addr));
348    
349    buffer[rdlen] = 0;    buffer[rdlen] = 0;
350    
# Line 349  comsat_main (int fd) Line 352  comsat_main (int fd)
352    p = strchr (buffer, '@');    p = strchr (buffer, '@');
353    if (!p)    if (!p)
354      {      {
355        syslog (LOG_ERR, "malformed input: %s", buffer);        syslog (LOG_ERR, _("malformed input: %s"), buffer);
356        return 1;        return 1;
357      }      }
358    *p++ = 0;    *p++ = 0;
# Line 364  comsat_main (int fd) Line 367  comsat_main (int fd)
367        break;        break;
368      default:      default:
369        if (!isspace (*endp))        if (!isspace (*endp))
370          syslog (LOG_ERR, "malformed input: %s@%s (near %s)", buffer, p, endp);          syslog (LOG_ERR, _("malformed input: %s@%s (near %s)"), buffer, p, endp);
371      }      }
372    
373    if (find_user (buffer, tty) != SUCCESS)    if (find_user (buffer, tty) != SUCCESS)
# Line 429  notify_user (const char *user, const cha Line 432  notify_user (const char *user, const cha
432    change_user (user);    change_user (user);
433    if ((fp = fopen (device, "w")) == NULL)    if ((fp = fopen (device, "w")) == NULL)
434      {      {
435        syslog (LOG_ERR, "can't open device %s: %m", device);        syslog (LOG_ERR, _("can't open device %s: %m"), device);
436        exit (0);        exit (0);
437      }      }
438    
# Line 445  notify_user (const char *user, const cha Line 448  notify_user (const char *user, const cha
448    if ((status = mailbox_create (&mbox, path)) != 0    if ((status = mailbox_create (&mbox, path)) != 0
449        || (status = mailbox_open (mbox, MU_STREAM_READ)) != 0)        || (status = mailbox_open (mbox, MU_STREAM_READ)) != 0)
450      {      {
451        syslog (LOG_ERR, "can't open mailbox %s: %s",        syslog (LOG_ERR, _("can't open mailbox %s: %s"),
452                path, mu_errstring (status));                path, mu_errstring (status));
453        return;        return;
454      }      }
455    
456    if ((status = mailbox_get_stream (mbox, &stream)))    if ((status = mailbox_get_stream (mbox, &stream)))
457      {      {
458        syslog (LOG_ERR, "can't get stream for mailbox %s: %s",        syslog (LOG_ERR, _("can't get stream for mailbox %s: %s"),
459                path, mu_errstring (status));                path, mu_errstring (status));
460        return;        return;
461      }      }
462    
463    if ((status = stream_size (stream, (off_t *) &size)))    if ((status = stream_size (stream, (off_t *) &size)))
464      {      {
465        syslog (LOG_ERR, "can't get stream size (mailbox %s): %s",        syslog (LOG_ERR, _("can't get stream size (mailbox %s): %s"),
466                path, mu_errstring (status));                path, mu_errstring (status));
467        return;        return;
468      }      }
# Line 476  notify_user (const char *user, const cha Line 479  notify_user (const char *user, const cha
479    if ((status = mailbox_create (&tmp, "/dev/null")) != 0    if ((status = mailbox_create (&tmp, "/dev/null")) != 0
480        || (status = mailbox_open (tmp, MU_STREAM_READ)) != 0)        || (status = mailbox_open (tmp, MU_STREAM_READ)) != 0)
481      {      {
482        syslog (LOG_ERR, "can't create temporary mailbox: %s",        syslog (LOG_ERR, _("can't create temporary mailbox: %s"),
483                mu_errstring (status));                mu_errstring (status));
484        return;        return;
485      }      }
486    
487    if ((status = memory_stream_create (&stream, 0, 0)))    if ((status = memory_stream_create (&stream, 0, 0)))
488      {      {
489        syslog (LOG_ERR, "can't create temporary stream: %s",        syslog (LOG_ERR, _("can't create temporary stream: %s"),
490                mu_errstring (status));                mu_errstring (status));
491        return;        return;
492      }      }
# Line 530  find_user (const char *name, char *tty) Line 533  find_user (const char *name, char *tty)
533            if (strncmp (ftty, PATH_TTY_PFX, strlen (PATH_TTY_PFX)))            if (strncmp (ftty, PATH_TTY_PFX, strlen (PATH_TTY_PFX)))
534              {              {
535                /* An attempt to break security... */                /* An attempt to break security... */
536                syslog (LOG_ALERT, "bad line name in utmp record: %s", ftty);                syslog (LOG_ALERT, _("bad line name in utmp record: %s"), ftty);
537                return NOT_HERE;                return NOT_HERE;
538              }              }
539    
# Line 538  find_user (const char *name, char *tty) Line 541  find_user (const char *name, char *tty)
541              {              {
542                if (!S_ISCHR (statb.st_mode))                if (!S_ISCHR (statb.st_mode))
543                  {                  {
544                    syslog (LOG_ALERT, "not a character device: %s", ftty);                    syslog (LOG_ALERT, _("not a character device: %s"), ftty);
545                    return NOT_HERE;                    return NOT_HERE;
546                  }                  }
547    
# Line 571  change_user (const char *user) Line 574  change_user (const char *user)
574    pw = getpwnam (user);    pw = getpwnam (user);
575    if (!pw)    if (!pw)
576      {      {
577        syslog (LOG_CRIT, "no such user: %s", user);        syslog (LOG_CRIT, _("no such user: %s"), user);
578        exit (1);        exit (1);
579      }      }
580    
# Line 591  mailbox_path (const char *user) Line 594  mailbox_path (const char *user)
594    
595    if (!auth)    if (!auth)
596      {      {
597        syslog (LOG_ALERT, "user nonexistent: %s", user);        syslog (LOG_ALERT, _("user nonexistent: %s"), user);
598        return NULL;        return NULL;
599      }      }
600    
# Line 606  volatile int _st=0; Line 609  volatile int _st=0;
609  void  void
610  stop()  stop()
611  {  {
612    syslog (LOG_ALERT, "waiting for debug");    syslog (LOG_ALERT, _("waiting for debug"));
613    while (!_st)    while (!_st)
614      _st=_st;      _st=_st;
615  }  }

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26