38 static char *pid_file = NULL;
46 if (fname == NULL || strlen(fname) == 0) {
51 if (access(fname, F_OK) == 0) {
54 if ((fpid = fopen(fname,
"r")) != NULL) {
57 if (fgets(buf,
sizeof (buf), fpid) != NULL) {
61 pid = strtol(buf, NULL, 10);
62 if (errno == 0 && pid > 0) {
63 if (kill(pid, 0) == 0)
76 "PID_FILE %s exists. Is there another ze-filter running ?",
82 if ((fpid = fopen(fname,
"w")) != NULL) {
83 fprintf(fpid,
"%d\n", (
int) getpid());
86 if (chmod(fname, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0)
89 pid_file = strdup(fname);
116 if (pid_file == NULL || strlen(pid_file) == 0)
122 if ((fpid = fopen(pid_file,
"r")) == NULL)
125 memset(buf, 0,
sizeof (buf));
126 if (fgets(buf,
sizeof (buf), fpid) == NULL);
130 if (atoi(buf) == pid)
151 if (strncasecmp(sock_file,
"unix:", strlen(
"unix:")) == 0)
152 sock_file += strlen(
"unix:");
154 if (strncasecmp(sock_file,
"local:", strlen(
"local:")) == 0)
155 sock_file += strlen(
"local:");
157 if (strlen(sock_file) > 0 && *sock_file ==
'/') {
160 if (lstat(sock_file, &buf) == 0) {
187 memset(sm_sock, 0,
sizeof (sm_sock));
190 if (sock != NULL && strlen(sock) > 0)
191 strlcpy(sm_sock, sock,
sizeof (sm_sock));
193 if ((sock = getenv(
"ZEFILTER_SOCKET")) != NULL)
194 strlcpy(sm_sock, sock,
sizeof (sm_sock));
197 snprintf(sm_sock,
sizeof (sm_sock),
"inet:%s@localhost", arg_i);
200 snprintf(sm_sock,
sizeof (sm_sock),
"local:%s", arg_u);
203 strlcpy(sm_sock, arg_p,
sizeof (sm_sock));
char * define_milter_sock(char *cf, char *arg_p, char *arg_u, char *arg_i)
#define ZE_LogMsgError(level,...)
bool zeStrRegex(char *, char *, long *, long *, bool)
bool create_pid_file(char *fname)
#define ZE_LogMsgDebug(level,...)
void remove_milter_sock()
#define ZE_MessageInfo(level,...)
#define ZE_MessageWarning(level,...)
#define ZE_LogSysError(...)
#define ZE_LogMsgWarning(level,...)