va_end(msg);
buf[sizeof(buf) - 1] = '\0';
- syslog(LOG_DEBUG, buf);
+ syslog(LOG_MAIL|LOG_DEBUG, "[pam_smtpauth] %s", buf);
}
PAM_EXTERN int
Get configuration file name
*/
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth: pam_sm_authenticate()");
+ log_debug(DEBUG_1, "pam_sm_authenticate() start");
#endif
if(argc == 0) {
if((fd = open(SMTPAUTH_CONF, O_RDONLY)) != -1) {
strcpy(configfile, strtok(NULL, "="));
}
else {
- syslog(LOG_ERR, "pam_smtpauth: invalid module parameter.");
+ syslog(LOG_ERR, "[pam_smtpauth] invalid module parameter.");
}
}
*/
result = pam_get_user(pamh, &username, NULL);
if(result != PAM_SUCCESS || username == NULL) {
- syslog(LOG_ERR, "pam_smtpauth: no user specified.");
+ syslog(LOG_ERR, "[pam_smtpauth] no user specified.");
return PAM_USER_UNKNOWN;
}
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth: username=%s", username);
+ log_debug(DEBUG_1, "username=%s", username);
#endif
if((blockedfile = get_config(configfile, "BlockedUserListFile")) != NULL) {
regfree(®);
if(regsuccess == 0) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth: rejected username='%s' regex='%s'", username, line);
+ log_debug(DEBUG_1, "rejected username='%s' regex='%s'", username, line);
#endif
return PAM_AUTH_ERR;
}
*/
if(password != NULL) {
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth: password is not NULL.");
+ log_debug(DEBUG_5, "password is not NULL.");
#endif
pam_set_item(pamh, PAM_AUTHTOK, (const void**)&password);
}
}
result = pam_get_item(pamh, PAM_AUTHTOK, (const void **)&password);
if(password == NULL) {
- syslog(LOG_ERR, "pam_smtpauth: password is NULL.");
+ syslog(LOG_ERR, "[pam_smtpauth] password is NULL.");
+#ifdef DEBUG
+ log_debug(DEBUG_1, "password is NULL.");
+#endif
return PAM_AUTHINFO_UNAVAIL;
}
if(strcmp(password, "") == 0) {
- syslog(LOG_ERR, "pam_smtpauth: password is empty.");
+ syslog(LOG_ERR, "[pam_smtpauth] password is empty.");
+#ifdef DEBUG
+ log_debug(DEBUG_1, "password is empty.");
+#endif
return PAM_AUTH_ERR;
}
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth: password=%s", password);
+ log_debug(DEBUG_9, "password=%s", password);
#endif
if(!global.username) {
}
global.conn_timeout = conn_timeout;
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth: timeout: %d",timeout);
- log_debug(DEBUG_5, "pam_smtpauth: conn_timeout: %d",conn_timeout);
+ log_debug(DEBUG_5, "timeout: %d",timeout);
+ log_debug(DEBUG_5, "conn_timeout: %d",conn_timeout);
#endif
for(cnt=0;;cnt++) {
result = smtp_connect(cnt);
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth: smtp_connect cnt=%d result=%d", cnt, result);
+ log_debug(DEBUG_5, "smtp_connect cnt=%d result=%d", cnt, result);
#endif
if(result == SA_NO_SERVER_LEFT) {
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth: auth service cannot retrieve information.");
+ log_debug(DEBUG_5, "auth service cannot retrieve information.");
#endif
password = NULL;
global.password = NULL;
global.password = NULL;
return PAM_AUTH_ERR;
} else if(result == PAM_AUTH_ERR) {
- syslog(LOG_ERR, "pam_smtpauth: authentication error cnt=%d.", cnt);
+ syslog(LOG_ERR, "[pam_smtpauth] authentication error cnt=%d.", cnt);
+#ifdef DEBUG
+ log_debug(DEBUG_5, "authentication error cnt=%d.", cnt);
+#endif
password = NULL;
global.password = NULL;
return PAM_AUTH_ERR;
struct servent *se;
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth: smtp_connect num=%d", num);
+ log_debug(DEBUG_5, "smtp_connect num=%d", num);
#endif
strcpy(param, "SMTPServer_");
strcat(param, tnum);
smtp_server = get_config(configfile, param);
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth: smtp_server=%s", smtp_server);
+ log_debug(DEBUG_1, "smtp_server=%s", smtp_server);
#endif
if(smtp_server == NULL) {
if((strstr(smtp_server, "smtps:")) != NULL) {
#ifdef USE_SSL
- syslog(LOG_INFO, "pam_smtpauth: via smtps.");
+#ifdef DEBUG
+ log_debug(DEBUG_1, "use smtps");
+#endif
global.use_smtps = 1;
global.require_ssl = 1;
global.use_sslv2 = 1;
global.use_tlsv1 = 1;
global.certfile = get_config(configfile, "SSLCertificateFile");
#else
- syslog(LOG_INFO, "pam_smtpauth: smtps is not implemented.");
+ syslog(LOG_INFO, "[pam_smtpauth] smtps is not implemented.");
#endif
strtok(smtp_server, ":");
buffer = strtok(NULL, ":");
}
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth: global.host=%s", global.host);
- log_debug(DEBUG_5, "pam_smtpauth: global.port=%d", global.port);
- log_debug(DEBUG_5, "pam_smtpauth: global.username=%s", global.username);
- log_debug(DEBUG_9, "pam_smtpauth: global.password=%s", global.password);
+ log_debug(DEBUG_5, "global.host=%s", global.host);
+ log_debug(DEBUG_5, "global.port=%d", global.port);
+ log_debug(DEBUG_5, "global.username=%s", global.username);
+ log_debug(DEBUG_9, "global.password=%s", global.password);
#endif
smtp = (smtp_t *)smtp_auth(&global);
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth: smtp->error=%d", smtp->error);
+ log_debug(DEBUG_5, "smtp->error=%d", smtp->error);
#endif
//sleep(3);
if(smtp == 0) {
- syslog(LOG_ERR, "pam_smtpauth: mail_status -> FAIL");
+ syslog(LOG_ERR, "[pam_smtpauth] mail_status -> FAIL");
+#ifdef DEBUG
+ log_debug(DEBUG_1, "mail_status -> FAIL");
+#endif
return PAM_AUTH_ERR;
}
else if(smtp->error == 1) {
- syslog(LOG_WARNING, "pam_smtpauth: SERVER connection failure: %s:%d => %s", global.host, global.port, smtp->error_message);
+ syslog(LOG_WARNING, "[pam_smtpauth] SERVER connection failure: %s:%d => %s", global.host, global.port, smtp->error_message);
+#ifdef DEBUG
+ log_debug(DEBUG_1, "SERVER connection failure: %s:%d => %s", global.host, global.port, smtp->error_message);
+#endif
return SA_SERVER_CONNECT_FAILURE;
}
else if(smtp->error == 2) {
- syslog(LOG_ERR, "pam_smtpauth: LOGIN FAILURE user %s on %s:%d => %s", global.username, global.host, global.port, smtp->error_message);
+ syslog(LOG_ERR, "[pam_smtpauth] LOGIN FAILURE user %s on %s:%d => %s", global.username, global.host, global.port, smtp->error_message);
+#ifdef DEBUG
+ log_debug(DEBUG_1, "LOGIN FAILURE user %s on %s:%d => %s", global.username, global.host, global.port, smtp->error_message);
+#endif
return SA_SERVER_LOGIN_FAILURE;
}
else if(smtp->error == 0) {
- syslog(LOG_INFO, "pam_smtpauth: mail_status -> OK for %s", global.username);
+ syslog(LOG_INFO, "[pam_smtpauth] mail_status -> OK for %s", global.username);
+#ifdef DEBUG
+ log_debug(DEBUG_1, "mail_status -> OK for %s", global.username);
+#endif
return PAM_SUCCESS;
}
else {
result = conv->conv(nargs, (const struct pam_message **)msg, resp, conv->appdata_ptr);
if((result != PAM_SUCCESS) && (result != PAM_CONV_AGAIN)) {
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth: conversation failure [%s]", pam_strerror(pamh, result));
+ log_debug(DEBUG_5, "conversation failure [%s]", pam_strerror(pamh, result));
#endif
}
}
else {
- syslog(LOG_ERR, "pam_smtpauth: couldn't obtain coversation function [%s]", pam_strerror(pamh, result));
+ syslog(LOG_ERR, "[pam_smtpauth] couldn't obtain coversation function [%s]", pam_strerror(pamh, result));
}
return result;
}
int argc,
const char **argv)
{
- syslog(LOG_INFO, "pam_smtpauth: acct_mgmt called but not implemented.");
+ syslog(LOG_INFO, "[pam_smtpauth] acct_mgmt called but not implemented.");
return PAM_SUCCESS;
}
int argc,
const char **argv)
{
- syslog(LOG_INFO, "pam_smtpauth: setcred called but not implemented.");
+ syslog(LOG_INFO, "[pam_smtpauth] setcred called but not implemented.");
return PAM_SUCCESS;
}
int pam_sm_chauthtok(pam_handle_t *pamh,int flags,int argc
,const char **argv)
{
- syslog(LOG_INFO, "pam_smtpauth: chauthtok called but not implemented. \
+ syslog(LOG_INFO, "[pam_smtpauth] chauthtok called but not implemented. \
Password NOT CHANGED!");
return PAM_SUCCESS;
}
int argc,
const char **argv)
{
- syslog(LOG_INFO, "pam_smtpauth: open_session called but not implemented.");
+ syslog(LOG_INFO, "[pam_smtpauth] open_session called but not implemented.");
return PAM_SUCCESS;
}
int argc,
const char **argv)
{
- syslog(LOG_INFO, "pam_smtpauth: close_session called but not implemented.");
+ syslog(LOG_INFO, "[pam_smtpauth] close_session called but not implemented.");
return PAM_SUCCESS;
}
#include <ctype.h>
#include <assert.h>
#include <errno.h>
-#include <syslog.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
}
}
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): str=%s", str);
+ log_debug(DEBUG_9, "extract_token: str=%s", str);
#endif
return 0;
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): text=%s", text);
+ log_debug(DEBUG_9, "digest_md5: text=%s", text);
#endif
extract_token((const char *)text, "nonce=", nonce, DIGEST_MD5_NONCE_LEN);
sprintf(uri, "smtp/%s", realm);
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): realm=%s", realm);
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): nonce=%s", nonce);
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): qop=%s", qop);
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): cnonce=%s", cnonce);
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): uri=%s", uri);
+ log_debug(DEBUG_9, "digest_md5: realm=%s", realm);
+ log_debug(DEBUG_9, "digest_md5: nonce=%s", nonce);
+ log_debug(DEBUG_9, "digest_md5: qop=%s", qop);
+ log_debug(DEBUG_9, "digest_md5: cnonce=%s", cnonce);
+ log_debug(DEBUG_9, "digest_md5: uri=%s", uri);
#endif
/* A1 */
make_digest(hexA1, digest);
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): A1=%s", hexA1);
+ log_debug(DEBUG_9, "digest_md5: A1=%s", hexA1);
#endif
/* A2 */
make_digest(hexA2, digest);
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): A2=%s", hexA2);
+ log_debug(DEBUG_9, "digest_md5: A2=%s", hexA2);
#endif
/* response */
make_digest(resp, digest);
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): resp=%s", resp);
+ log_debug(DEBUG_9, "digest_md5: resp=%s", resp);
#endif
sprintf(response, "charset=utf-8,username=\"%s\",realm=\"%s\",nonce=\"%s\","
login, realm, nonce, cnonce, uri, qop, resp);
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): response:%s", response);
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): text:%s", text);
+ log_debug(DEBUG_9, "digest_md5: response:%s", response);
+ log_debug(DEBUG_9, "digest_md5: text:%s", text);
#endif
}
memset((char*)&taddr, 0, sizeof(taddr));
memcpy((char*)&taddr.sin_addr, he->h_addr_list[n], he->h_length);
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth(smtpauth): my ip: %s",
+ log_debug(DEBUG_5, "smtp_auth: my ip: %s",
inet_ntoa(((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr));
- log_debug(DEBUG_5, "pam_smtpauth(smtpauth): smtp ip: %s",
+ log_debug(DEBUG_5, "smtp_auth: smtp ip: %s",
inet_ntoa(taddr.sin_addr));
#endif
if(((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr.s_addr == taddr.sin_addr.s_addr) {
}
if(connect(s, (struct sockaddr *) &addr, sizeof(addr))) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): connection error = %s",strerror(errno));
+ log_debug(DEBUG_1, "smtp_auth: connection error = %s",strerror(errno));
#endif
smtp->error = 1;
strcpy(msgbuf, "Error: connecting to ");
}
#endif
- /* CLAIM: we now have a TCP connection to the remote SMTP server */
+ /* TCP connection to the remote SMTP server */
if(cfg->timeout > 0) {
set_timeout(cfg->timeout);
}
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): read (banner): %m");
+ log_debug(DEBUG_1, "smtp_auth: read (banner): %m");
#endif
smtp->error = 1;
strcpy(msgbuf, RESP_SYNCERROR);
if(strncmp(rbuf, "220 ", sizeof("220 ")-1)) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): unexpected response during initial handshake: %s", rbuf);
+ log_debug(DEBUG_1, "smtp_auth: unexpected response during initial handshake: %s", rbuf);
#endif
smtp->error = 1;
strcpy(msgbuf, RESP_UNEXPECTED);
iov[2].iov_len = sizeof("\r\n") - 1;
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): sending %s%s", EHLO_CMD, myhostname);
+ log_debug(DEBUG_9, "smtp_auth: sending %s%s", EHLO_CMD, myhostname);
#endif
if(cfg->timeout > 0) {
set_timeout(cfg->timeout);
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): writev: %m");
+ log_debug(DEBUG_1, "smtp_auth: writev: %m");
#endif
smtp->error = 1;
strcpy(msgbuf, RESP_IERROR);
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): read (response): %m");
+ log_debug(DEBUG_1, "smtp_auth: read (response): %m");
#endif
smtp->error = 1;
strcpy(msgbuf, RESP_IERROR);
if((tbuf = strstr(rbuf, "250-STARTTLS"))) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): STARTTLS not supported.");
+ log_debug(DEBUG_1, "smtp_auth: STARTTLS not supported.");
#endif
}
if(avail_auth_type == 0) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): smtp authentication is not implemented: %s", rbuf);
+ log_debug(DEBUG_1, "smtp_auth: smtp authentication is not implemented: %s", rbuf);
#endif
smtp->error = 1;
strcpy(msgbuf, RESP_UNEXPECTED);
goto bail;
}
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): auth_type: %d", avail_auth_type);
+ log_debug(DEBUG_1, "smtp_auth: auth_type=%d", avail_auth_type);
#endif
/* build the AUTH command */
}
else {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): smtp authentication is not implemented: %s", rbuf);
+ log_debug(DEBUG_1, "smtp_auth: smtp authentication is not implemented: %s", rbuf);
#endif
smtp->error = 1;
strcpy(msgbuf, RESP_UNEXPECTED);
}
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth(smtpauth) auth: [%d]", auth);
+ log_debug(DEBUG_5, "smtp_auth: auth=%d", auth);
#endif
if(auth == 0) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth) rejected: [%s]", global.username);
+ log_debug(DEBUG_1, "smtp_auth: rejected=%s", global.username);
#endif
smtp->error = 2;
strcpy(msgbuf, RESP_CREDERROR);
iov[1].iov_len = sizeof("\r\n") - 1;
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): sending %s", QUIT_CMD);
+ log_debug(DEBUG_9, "smtp_quit: sending %s", QUIT_CMD);
#endif
if(cfg->timeout > 0) {
set_timeout(cfg->timeout);
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): quit writev: %m");
+ log_debug(DEBUG_1, "smtp_quit: quit writev: %m");
#endif
}
(void)socket_close(sock);
char buf[RESP_LEN];
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): AUTH CRAM-MD5");
+ log_debug(DEBUG_1, "auth_cram_md5: AUTH CRAM-MD5");
#endif
iov[0].iov_base = AUTH_CMD;
iov[0].iov_len = sizeof(AUTH_CMD) - 1;
iov[2].iov_len = sizeof("\r\n") - 1;
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): sending %s%s", AUTH_CMD, "CRAM-MD5");
+ log_debug(DEBUG_9, "auth_cram_md5: sending %s%s", AUTH_CMD, "CRAM-MD5");
#endif
if(cfg->timeout > 0) {
set_timeout(cfg->timeout);
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): cram-md5 writev: %m");
+ log_debug(DEBUG_1, "auth_cram_md5: cram-md5 writev: %m");
#endif
return AUTH_NG;
}
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): read (response): %m");
+ log_debug(DEBUG_1, "auth_cram_md5: read (response): %m");
#endif
return AUTH_NG;
}
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth(smtpauth): read (response): %s",rbuf);
+ log_debug(DEBUG_5, "auth_cram_md5: read (response): %s",rbuf);
#endif
if(strncmp(rbuf, "334 ", sizeof("334 ")-1) == 0) {
char *response;
challengelen = base64_decode((char *)challenge, rbuf + 4, -1);
challenge[challengelen] = '\0';
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): challenge=%s", challenge);
+ log_debug(DEBUG_9, "auth_cram_md5: challenge=%s", challenge);
#endif
snprintf(buf, sizeof(buf), "%s", cfg->password);
iov[1].iov_len = sizeof("\r\n") - 1;
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): sending %s", response64);
+ log_debug(DEBUG_9, "auth_cram_md5: sending %s", response64);
#endif
if(cfg->timeout > 0) {
set_timeout(cfg->timeout);
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): cram-md5 writev: %m");
+ log_debug(DEBUG_1, "auth_cram_md5: cram-md5 writev: %m");
#endif
return AUTH_NG;
}
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): read (response): %m");
+ log_debug(DEBUG_1, "auth_cram_md5: read (response): %m");
#endif
return AUTH_NG;
}
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth(smtpauth): read (response): %s",rbuf);
+ log_debug(DEBUG_5, "auth_cram_md5: read (response): %s",rbuf);
#endif
if(strncmp(rbuf, "235 ", sizeof("235 ")-1) != 0) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): auth failure.");
+ log_debug(DEBUG_1, "auth_cram_md5: auth failure.");
#endif
return AUTH_NG;
}
free(response64);
} else {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): it seems cram-md5 mech is not implemented.");
+ log_debug(DEBUG_1, "auth_cram_md5: it seems cram-md5 mech is not implemented.");
#endif
return AUTH_NG;
}
char *buf;
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): AUTH LOGIN");
+ log_debug(DEBUG_1, "auth_login: AUTH LOGIN");
#endif
iov[0].iov_base = AUTH_CMD;
iov[0].iov_len = sizeof(AUTH_CMD) - 1;
iov[2].iov_len = sizeof("\r\n") - 1;
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): sending %s%s", AUTH_CMD, "LOGIN");
+ log_debug(DEBUG_9, "auth_login: sending %s%s", AUTH_CMD, "LOGIN");
#endif
if(cfg->timeout > 0) {
set_timeout(cfg->timeout);
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): login writev: %m");
+ log_debug(DEBUG_1, "auth_login: login writev: %m");
#endif
return AUTH_NG;
}
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): read (response): %m");
+ log_debug(DEBUG_1, "auth_login: read (response): %m");
#endif
return AUTH_NG;
}
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth(smtpauth): read (response): %s",rbuf);
+ log_debug(DEBUG_5, "auth_login: read (response): %s",rbuf);
#endif
if(strncmp(rbuf, "334 ", sizeof("334 ")-1) == 0) {
buf = malloc(sizeof(char)*128);
iov[1].iov_len = sizeof("\r\n") - 1;
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): sending %s", buf);
+ log_debug(DEBUG_9, "auth_login: sending %s", buf);
#endif
if(cfg->timeout > 0) {
set_timeout(cfg->timeout);
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): login writev: %m");
+ log_debug(DEBUG_1, "auth_login: login writev: %m");
#endif
return AUTH_NG;
}
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): read (response): %m");
+ log_debug(DEBUG_1, "auth_login: read (response): %m");
#endif
return AUTH_NG;
}
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth(smtpauth): read (response): %s",rbuf);
+ log_debug(DEBUG_5, "auth_login: read (response): %s",rbuf);
#endif
if(strncmp(rbuf, "334 ", sizeof("334 ")-1) == 0) {
buf = malloc(sizeof(char)*128);
iov[1].iov_len = sizeof("\r\n") - 1;
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): sending %s", buf);
+ log_debug(DEBUG_9, "auth_login: sending %s", buf);
#endif
if(cfg->timeout > 0) {
set_timeout(cfg->timeout);
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): login writev: %m");
+ log_debug(DEBUG_1, "auth_login: login writev: %m");
#endif
return AUTH_NG;
}
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): read (response): %m");
+ log_debug(DEBUG_1, "auth_login: read (response): %m");
#endif
return AUTH_NG;
}
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth(smtpauth): read (response): %s",rbuf);
+ log_debug(DEBUG_5, "auth_login: read (response): %s",rbuf);
#endif
if(strncmp(rbuf, "235 ", sizeof("235 ")-1) != 0) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): auth failure.");
+ log_debug(DEBUG_1, "auth_login: auth failure.");
#endif
return AUTH_NG;
}
} else {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): it seems login mech is not implemented.");
+ log_debug(DEBUG_1, "auth_login: it seems login mech is not implemented.");
#endif
return AUTH_NG;
}
} else {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): it seems login mech is not implemented.");
+ log_debug(DEBUG_1, "auth_login: it seems login mech is not implemented.");
#endif
return AUTH_NG;
}
char phrase[512];
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): AUTH PLAIN");
+ log_debug(DEBUG_1, "auth_plain: AUTH PLAIN");
#endif
sprintf(phrase,"%s^%s^%s", cfg->username, cfg->username, cfg->password);
len = strlen(phrase);
iov[3].iov_len = sizeof("\r\n") - 1;
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): sending %s%s %s", AUTH_CMD, "PLAIN", buf);
+ log_debug(DEBUG_9, "auth_plain: sending %s%s %s", AUTH_CMD, "PLAIN", buf);
#endif
if(cfg->timeout > 0) {
set_timeout(cfg->timeout);
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): plain writev: %m");
+ log_debug(DEBUG_1, "auth_plain: plain writev: %m");
#endif
return AUTH_NG;
}
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): read (response): %m");
+ log_debug(DEBUG_1, "auth_plain: read (response): %m");
#endif
return AUTH_NG;
}
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth(smtpauth): read (response): %s",rbuf);
+ log_debug(DEBUG_5, "auth_plain: read (response): %s",rbuf);
#endif
if(strncmp(rbuf, "235 ", sizeof("235 ")-1) != 0) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): auth failure.");
+ log_debug(DEBUG_1, "auth_plain: auth failure.");
#endif
return AUTH_NG;
}
char *buf;
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): AUTH DIGEST-MD5");
+ log_debug(DEBUG_1, "auth_digest_md5: AUTH DIGEST-MD5");
#endif
iov[0].iov_base = AUTH_CMD;
iov[2].iov_len = sizeof("\r\n") - 1;
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): sending %s%s", AUTH_CMD, "DIGEST-MD5");
+ log_debug(DEBUG_9, "auth_digest_md5: sending %s%s", AUTH_CMD, "DIGEST-MD5");
#endif
if(cfg->timeout > 0) {
set_timeout(cfg->timeout);
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): digest-md5 writev: %m");
+ log_debug(DEBUG_1, "auth_digest_md5: digest-md5 writev: %m");
#endif
return AUTH_NG;
}
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): read (response): %m");
+ log_debug(DEBUG_1, "auth_digest_md5: read (response): %m");
#endif
return AUTH_NG;
}
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth(smtpauth): read (response): %s",rbuf);
+ log_debug(DEBUG_5, "auth_digest_md5: read (response): %s",rbuf);
#endif
if(strncmp(rbuf, "334 ", sizeof("334 ")-1) == 0) {
char *response;
challengelen = base64_decode(challenge, rbuf + 4, -1);
challenge[challengelen] = '\0';
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): challenge=%s", challenge);
+ log_debug(DEBUG_9, "auth_digest_md5: challenge=%s", challenge);
#endif
digest_md5((char *)hexdigest, (unsigned char*)challenge, challengelen, cfg->username, cfg->password);
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): hexdigest=%s", hexdigest);
+ log_debug(DEBUG_9, "auth_digest_md5: hexdigest=%s", hexdigest);
#endif
response = malloc(sizeof(char)*256);
snprintf(response, 256, "%s", hexdigest);
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): response=%s", response);
+ log_debug(DEBUG_9, "auth_digest_md5: response=%s", response);
#endif
response64 = malloc((strlen(response) + 3) * 2 + 1);
base64_encode(response64, response, strlen(response));
free(response);
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): response64=%s", response64);
+ log_debug(DEBUG_9, "auth_digest_md5: response64=%s", response64);
#endif
iov[0].iov_base = response64;
iov[1].iov_len = sizeof("\r\n") - 1;
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): sending %s", response64);
+ log_debug(DEBUG_9, "auth_digest_md5: sending %s", response64);
#endif
if(cfg->timeout > 0) {
set_timeout(cfg->timeout);
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): digest-md5 writev: %m");
+ log_debug(DEBUG_1, "auth_digest_md5: digest-md5 writev: %m");
#endif
return AUTH_NG;
}
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): read (response): %m");
+ log_debug(DEBUG_1, "auth_digest_md5: read (response): %m");
#endif
return AUTH_NG;
}
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth(smtpauth): read (response): %s",rbuf);
+ log_debug(DEBUG_5, "auth_digest_md5: read (response): %s",rbuf);
#endif
if(strncmp(rbuf, "334 ", sizeof("334 ")-1) == 0) {
int buflen;
iov[1].iov_len = sizeof("\r\n") - 1;
#ifdef DEBUG
- log_debug(DEBUG_9, "pam_smtpauth(smtpauth): sending %s", buf);
+ log_debug(DEBUG_9, "auth_digest_md5: sending %s", buf);
#endif
if(cfg->timeout > 0) {
set_timeout(cfg->timeout);
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): digest-md5 writev: %m");
+ log_debug(DEBUG_1, "auth_digest_md5: digest-md5 writev: %m");
#endif
return AUTH_NG;
}
}
if(rc == -1) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): read (response): %m");
+ log_debug(DEBUG_1, "auth_digest_md5: read (response): %m");
#endif
return AUTH_NG;
}
#ifdef DEBUG
- log_debug(DEBUG_5, "pam_smtpauth(smtpauth): read (response): %s",rbuf);
+ log_debug(DEBUG_5, "auth_digest_md5: read (response): %s",rbuf);
#endif
if(strncmp(rbuf, "235 ", sizeof("235 ")-1) != 0) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): auth failure.");
+ log_debug(DEBUG_1, "auth_digest_md5: auth failure.");
#endif
return AUTH_NG;
}
} else {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): it seems digest-md5 mech is not implemented.");
+ log_debug(DEBUG_1, "auth_digest_md5: it seems digest-md5 mech is not implemented.");
#endif
return AUTH_NG;
}
free(response64);
} else {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): it seems digest-md5 mech is not implemented.");
+ log_debug(DEBUG_1, "auth_digest_md5: it seems digest-md5 mech is not implemented.");
#endif
return AUTH_NG;
}
cert = SSL_get_peer_certificate(ssl);
if(!cert) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): Error: no server certificate.");
+ log_debug(DEBUG_1, "verify_cert: Error: no server certificate.");
#endif
return -1;
}
}
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): Error: can't verify certificate: %s (%d).", X509_verify_cert_error_string(err), err);
+ log_debug(DEBUG_1, "verify_cert: Error: can't verify certificate: %s (%d).", X509_verify_cert_error_string(err), err);
#endif
X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf));
fprintf(stderr,"\nSubject: %s\n", buf);
if(!conf->certfile) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): Error: SSLCertificateFile not defined.");
+ log_debug(DEBUG_1, "init_ssl: Error: SSLCertificateFile not defined.");
#endif
return -1;
}
if(access(conf->certfile, F_OK)) {
if(errno != ENOENT) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): Error: SSLCertificateFile is not accessible.");
+ log_debug(DEBUG_1, "init_ssl: Error: SSLCertificateFile is not accessible.");
#endif
return -1;
}
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): Warning: SSLCertificateFile doesn't exist, can't verify server certificates.");
+ log_debug(DEBUG_1, "init_ssl: Warning: SSLCertificateFile doesn't exist, can't verify server certificates.");
#endif
} else if(!SSL_CTX_load_verify_locations(SSLContext, conf->certfile, NULL)) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): Error: SSL_CTX_load_verify_locations: %s.",ERR_error_string(ERR_get_error(), 0));
+ log_debug(DEBUG_1, "init_ssl: Error: SSL_CTX_load_verify_locations: %s.",ERR_error_string(ERR_get_error(), 0));
#endif
SSL_CTX_free(SSLContext);
return -1;
/* initialize SSL */
if(init_ssl(cfg)) {
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): failed to initialize ssl session.");
+ log_debug(DEBUG_1, "start_tls: failed to initialize ssl session.");
#endif
return 1;
}
if((ret = SSL_connect(smtp->sock->ssl)) <= 0) {
socket_perror("connect", smtp->sock, ret);
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): failed to connect ssl session.");
+ log_debug(DEBUG_1, "start_tls: failed to connect ssl session.");
#endif
return 1;
}
#endif
smtp->sock->use_ssl = 1;
#ifdef DEBUG
- log_debug(DEBUG_1, "pam_smtpauth(smtpauth): SSL support enabled.");
+ log_debug(DEBUG_1, "start_tls: SSL support enabled.");
#endif
return 0;
}