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