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 49const 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. */ 62 tag = var_syslog_name ? var_syslog_name : 63 mail_conf_eval(DEF_SYSLOG_NAME); 64 vstring_sprintf(canon_name, "%s/%s", tag, argv0); 65 return (vstring_str(canon_name)); 66} 67