int submit_fork(char **args, char **env, void (*func)(const char *)) { size_t i, j; const char *p=config_get_local_vhost(); char **newargs; int rc; char *q=0; if (!p || !*p) return submit_fork_virtual(args, env, func); for (i=0; args[i]; ++i) ; newargs=malloc((i+2)*sizeof(char *)); for (i=j=0; (newargs[j]=args[i]) != 0; ++i, ++j) { if (i == 0) { ++j; strcat(strcpy((q=newargs[j]= malloc(strlen(p)+10)), "-vhost="), p); } } rc=submit_fork_virtual(newargs, env, func); free(newargs); if (q) free(q); return rc; }
void SubmitFile::closectl() { const char *p=config_get_local_vhost(); static const char *env_vars[]={ "RELAYCLIENT", "TCPREMOTEIP", 0, }; if (p && *p) ctlfile << COMCTLFILE_VHOST << p << std::endl; if (security.size() > 0) ctlfile << COMCTLFILE_SECURITY << security << std::endl; if (verpflag) ctlfile << COMCTLFILE_VERP << std::endl; if (warntime == 0) ctlfile << COMCTLFILE_WARNINGSENT << std::endl; if (authname) ctlfile << COMCTLFILE_AUTHNAME << authname << std::endl; for (size_t i=0; env_vars[i]; ++i) { const char *p=getenv(env_vars[i]); if (p) ctlfile << COMCTLFILE_ENVVAR << env_vars[i] << "=" << p << std::endl; } ctlfile << COMCTLFILE_MSGSOURCE << msgsource << std::endl << COMCTLFILE_EXPIRES << submit_time + queuetime << std::endl << COMCTLFILE_FAXEXPIRES << submit_time + faxqueuetime << std::endl << COMCTLFILE_WARNING << submit_time + warntime << std::endl << std::flush; if (suppressbackscatter) ctlfile << COMCTLFILE_TRACK << std::endl; if (ctlfile.fail()) clog_msg_errno(); #if EXPLICITSYNC ctlfile.sync(); fsync(ctlfile.fd()); #endif ctlfile.close(); if (ctlfile.fail()) clog_msg_errno(); }