Postfix3.3.1
全て データ構造 ファイル 関数 変数 型定義 マクロ定義
mail_task.c
[詳解]
1 /*++
2 /* NAME
3 /* mail_task 3
4 /* SUMMARY
5 /* set task name for logging purposes
6 /* SYNOPSIS
7 /* #include <mail_task.h>
8 /*
9 /* const char *mail_task(argv0)
10 /* const char *argv0;
11 /* DESCRIPTION
12 /* mail_task() enforces consistent naming of mailer processes.
13 /* It strips pathname information from the process name, and
14 /* prepends the name of the mail system so that logfile entries
15 /* are easier to recognize. The mail system name is specified
16 /* with the "syslog_name" configuration parameter.
17 /*
18 /* The result is volatile. Make a copy of the result if it is
19 /* to be used for any appreciable amount of time.
20 /* LICENSE
21 /* .ad
22 /* .fi
23 /* The Secure Mailer license must be distributed with this software.
24 /* AUTHOR(S)
25 /* Wietse Venema
26 /* IBM T.J. Watson Research
27 /* P.O. Box 704
28 /* Yorktown Heights, NY 10598, USA
29 /*--*/
30 
31 /* System library. */
32 
33 #include <sys_defs.h>
34 #include <string.h>
35 
36 /* Utility library. */
37 
38 #include <vstring.h>
39 #include <safe.h>
40 
41 /* Global library. */
42 
43 #include "mail_params.h"
44 #include "mail_conf.h"
45 #include "mail_task.h"
46 
47 /* mail_task - clean up and decorate the process name */
48 
49 const char *mail_task(const char *argv0)
50 {
51  static VSTRING *canon_name;
52  const char *slash;
53  const char *tag;
54 
55  if (canon_name == 0)
56  canon_name = vstring_alloc(10);
57  if ((slash = strrchr(argv0, '/')) != 0 && slash[1])
58  argv0 = slash + 1;
59  /* Setenv()-ed from main.cf, or inherited from master. */
60  if ((tag = safe_getenv(CONF_ENV_LOGTAG)) == 0)
61  /* Check main.cf settings directly, in case set-gid. */
64  vstring_sprintf(canon_name, "%s/%s", tag, argv0);
65  return (vstring_str(canon_name));
66 }
const char * mail_task(const char *argv0)
Definition: mail_task.c:49
#define vstring_str(vp)
Definition: vstring.h:71
const char * mail_conf_eval(const char *string)
Definition: mail_conf.c:237
char * var_syslog_name
Definition: mail_params.c:232
#define CONF_ENV_LOGTAG
Definition: mail_conf.h:25
char * safe_getenv(const char *)
Definition: safe_getenv.c:38
VSTRING * vstring_alloc(ssize_t len)
Definition: vstring.c:353
VSTRING * vstring_sprintf(VSTRING *vp, const char *format,...)
Definition: vstring.c:602
#define DEF_SYSLOG_NAME
Definition: mail_params.h:2562