masqmail
diff src/local.c @ 205:4fd237550525
REMOVED MAILDIR SUPPORT
if you want to deliver to maildir, use an MDA like procmail
masqmail can pass mail to an MDA by setting `mda' in masqmail.conf
author | meillo@marmaro.de |
---|---|
date | Fri, 16 Jul 2010 16:38:50 +0200 |
parents | d1c53e76096f |
children | 996b53a50f55 |
line diff
1.1 --- a/src/local.c Fri Jul 16 15:38:53 2010 +0200 1.2 +++ b/src/local.c Fri Jul 16 16:38:50 2010 +0200 1.3 @@ -144,132 +144,6 @@ 1.4 return ok; 1.5 } 1.6 1.7 -#ifdef ENABLE_MAILDIR 1.8 -gboolean 1.9 -maildir_out(message * msg, GList * hdr_list, gchar * user, guint flags) 1.10 -{ 1.11 - struct passwd *pw; 1.12 - gboolean ok = FALSE; 1.13 - 1.14 - /* headers may be special for a local delivery */ 1.15 - if (hdr_list == NULL) 1.16 - hdr_list = msg->hdr_list; 1.17 - 1.18 - if ((pw = getpwnam(user))) { 1.19 - uid_t saved_uid = geteuid(); 1.20 - gid_t saved_gid = getegid(); 1.21 - gboolean uid_ok = TRUE, gid_ok = TRUE; 1.22 - 1.23 - if (!conf.run_as_user) { 1.24 - uid_ok = (seteuid(0) == 0); 1.25 - if (uid_ok) { 1.26 - gid_ok = (setegid(conf.mail_gid) == 0); 1.27 - uid_ok = (seteuid(pw->pw_uid) == 0); 1.28 - } 1.29 - } 1.30 - 1.31 - DEBUG(5) debugf("running as euid %d, egid %d\n", geteuid(), getegid()); 1.32 - 1.33 - if (uid_ok && gid_ok) { 1.34 - char *path = g_strdup_printf("%s/Maildir", pw->pw_dir); 1.35 - struct stat statbuf; 1.36 - int ret; 1.37 - 1.38 - DEBUG(5) debugf(" path = %s\n", path); 1.39 - 1.40 - ok = TRUE; 1.41 - ret = stat(path, &statbuf); 1.42 - if (ret != 0) { 1.43 - ok = FALSE; 1.44 - if (errno == ENOENT) { 1.45 - logwrite(LOG_NOTICE, "directory %s does not exist, creating\n", path); 1.46 - if (mkdir(path, 0700) == 0) 1.47 - ok = TRUE; 1.48 - } else 1.49 - logwrite(LOG_ALERT, "stat of %s failed: %s\n", path, strerror(errno)); 1.50 - } 1.51 - if (ok) { 1.52 - ok = FALSE; 1.53 - ret = stat(path, &statbuf); 1.54 - if (S_ISDIR(statbuf.st_mode)) { 1.55 - gchar *subdirs[] = { "tmp", "new", "cur" }; 1.56 - int i; 1.57 - for (i = 0; i < 3; i++) { 1.58 - char *path1 = g_strdup_printf("%s/%s", path, subdirs[i]); 1.59 - ret = stat(path1, &statbuf); 1.60 - if (ret != 0) { 1.61 - if (errno == ENOENT) { 1.62 - logwrite(LOG_NOTICE, "directory %s does not exist, creating\n", path1); 1.63 - if (mkdir(path1, 0700) != 0) 1.64 - break; 1.65 - } 1.66 - } 1.67 - g_free(path1); 1.68 - } 1.69 - if (i == 3) { 1.70 - FILE *out; 1.71 - mode_t saved_mode = umask(066); 1.72 - /* the qmail style unique works only if delivering with different process. 1.73 - We do not fork for each delivery, so our uid is more unique. 1.74 - Hope it is compatible with all MUAs. 1.75 - */ 1.76 - gchar *filename = g_strdup_printf("%s/tmp/%s.%s", path, msg->uid, conf.host_name); 1.77 - 1.78 - DEBUG(5) debugf("filename = %s\n", filename); 1.79 - 1.80 - if ((out = fopen(filename, "w"))) { 1.81 - gchar *newname = g_strdup_printf("%s/new/%s.%s", path, msg->uid, conf.host_name); 1.82 - message_stream(out, msg, hdr_list, flags); 1.83 - ok = TRUE; 1.84 - if (fflush(out) == EOF) 1.85 - ok = FALSE; 1.86 - else if (fdatasync(fileno(out)) != 0) { 1.87 - if (errno != EINVAL) 1.88 - /* some fs do not support this.. I hope this also means that it is not necessary */ 1.89 - ok = FALSE; 1.90 - } 1.91 - fclose(out); 1.92 - if (rename(filename, newname) != 0) { 1.93 - ok = FALSE; 1.94 - logwrite(LOG_ALERT, "moving %s to %s failed: %s", filename, newname, strerror(errno)); 1.95 - } 1.96 - g_free(newname); 1.97 - } 1.98 - umask(saved_mode); 1.99 - g_free(filename); 1.100 - } 1.101 - } else { 1.102 - logwrite(LOG_ALERT, "%s is not a directory\n", path); 1.103 - errno = ENOTDIR; 1.104 - } 1.105 - } 1.106 - if (!conf.run_as_user) { 1.107 - uid_ok = (seteuid(0) == 0); 1.108 - if (uid_ok) { 1.109 - gid_ok = (setegid(saved_gid) == 0); 1.110 - uid_ok = (seteuid(saved_uid) == 0); 1.111 - } 1.112 - } 1.113 - if (!uid_ok || !gid_ok) { 1.114 - /* FIXME: if this fails we HAVE to exit, because we shall not run 1.115 - with some users id. But we do not return, and so this message 1.116 - will not be finished, so the user will get the message again 1.117 - next time a delivery is attempted... */ 1.118 - logwrite(LOG_ALERT, "could not set back uid or gid after local delivery: %s\n", strerror(errno)); 1.119 - exit(EXIT_FAILURE); 1.120 - } 1.121 - g_free(path); 1.122 - } else { 1.123 - logwrite(LOG_ALERT, "could not set uid or gid for local delivery, uid = %d: %s\n", pw->pw_uid, strerror(errno)); 1.124 - } 1.125 - } else { 1.126 - logwrite(LOG_ALERT, "could not find password entry for user %s\n", user); 1.127 - errno = ENOENT; /* getpwnam does not set errno correctly */ 1.128 - } 1.129 - return ok; 1.130 -} 1.131 -#endif 1.132 - 1.133 gboolean 1.134 pipe_out(message * msg, GList * hdr_list, address * rcpt, gchar * cmd, guint flags) 1.135 {