milter-greylist.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. Index: milter-greylist.8
  2. --- milter-greylist.8.orig 2006-08-30 22:50:42 +0200
  3. +++ milter-greylist.8 2006-12-31 09:57:22 +0100
  4. @@ -46,7 +46,7 @@
  5. [\fB-r\fR]
  6. [\fB-S\fR]
  7. [\fB-T\fR]
  8. -[\fB-u \fIusername\fR]
  9. +[\fB-u \fIusername\fR[:\fIgroupname\fR]]
  10. [\fB-v\fR]
  11. [\fB-w \fIgreylist_delay\fR]
  12. [\fB-L \fIcidrmask\fR]
  13. @@ -235,10 +235,12 @@
  14. .I rcpt
  15. lines have been deprecated in favor of ACL, so do not use it.
  16. .TP
  17. -.B -u \fIusername\fR
  18. +.B -u \fIusername\fR[:\fIgroupname\fR]
  19. Drop root privileges and switch to
  20. .I username
  21. -credentials. Make sure this user has write access to
  22. +(and optionally
  23. +.IR groupname )
  24. +credentials. Make sure this user (and group) has write access to
  25. .I greylist.db\fR.
  26. Equivalent to the
  27. .I user
  28. @@ -308,6 +310,7 @@
  29. Alexandre Cherif,
  30. Eugene Crosser,
  31. Elrond,
  32. +Ralf S. Engelschall,
  33. Cyril Guibourg,
  34. Klas Heggemann,
  35. Matthieu Herrb,
  36. Index: milter-greylist.c
  37. --- milter-greylist.c.orig 2006-12-29 19:32:44 +0100
  38. +++ milter-greylist.c 2006-12-31 09:58:12 +0100
  39. @@ -1313,6 +1313,11 @@
  40. */
  41. if (conf.c_user != NULL) {
  42. struct passwd *pw = NULL;
  43. + struct group *gr = NULL;
  44. + char *c_group = NULL;
  45. +
  46. + if ((c_group = strchr(conf.c_user, ':')) != NULL)
  47. + *c_group++ = '\0';
  48. if ((pw = getpwnam(conf.c_user)) == NULL) {
  49. mg_log(LOG_ERR, "%s: cannot get user %s data: %s",
  50. @@ -1320,6 +1325,15 @@
  51. exit(EX_OSERR);
  52. }
  53. + if (c_group != NULL) {
  54. + if ((gr = getgrnam(c_group)) == NULL) {
  55. + mg_log(LOG_ERR, "%s: cannot get group %s data: %s",
  56. + argv[0], c_group, strerror(errno));
  57. + exit(EX_OSERR);
  58. + }
  59. + pw->pw_gid = gr->gr_gid;
  60. + }
  61. +
  62. #ifdef HAVE_INITGROUPS
  63. if (initgroups(conf.c_user, pw->pw_gid) != 0) {
  64. mg_log(LOG_ERR, "%s: cannot change "
  65. @@ -1370,6 +1384,9 @@
  66. * Here we go!
  67. */
  68. conf_release();
  69. + umask(S_IWOTH);
  70. + smfi_opensocket(1);
  71. + umask(S_IWGRP|S_IWOTH);
  72. exitval = smfi_main();
  73. mg_log(LOG_ERR, "smfi_main() returned %d", exitval);
  74. @@ -1396,7 +1413,7 @@
  75. mg_log(LOG_ERR,
  76. " [-f configfile] [-h] [-l] [-q] [-r] [-S] [-T]");
  77. mg_log(LOG_ERR,
  78. - " [-u username] [-v] [-w greylist_delay] [-L cidrmask]");
  79. + " [-u username[:groupname]] [-v] [-w greylist_delay] [-L cidrmask]");
  80. mg_log(LOG_ERR,
  81. " [-M prefixlen] [-P pidfile] -p socket");
  82. exit(EX_USAGE);