/[smeserver]/rpms/e-smith-qmail/sme10/e-smith-qmail-2.6.0-bz8591-pseudonyms.patch
ViewVC logotype

Contents of /rpms/e-smith-qmail/sme10/e-smith-qmail-2.6.0-bz8591-pseudonyms.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Wed Apr 6 04:38:58 2022 UTC (2 years, 7 months ago) by jpp
Branch: MAIN
CVS Tags: e-smith-qmail-2_6_0-14_el7_sme, HEAD
* Tue Apr 05 2022 Jean-Philippe Pialasse <tests@pialasse.com> 2.6.0-14.sme
- fix multiple errors with pseudonyms in template [SME: 8591]
  orphaned pseudonyms are associated to admin
- repopulate qmail assign db and sighup qmail on group event  [SME: 11934]

1 diff -Nur --no-dereference e-smith-qmail-2.6.0.old/createlinks e-smith-qmail-2.6.0/createlinks
2 --- e-smith-qmail-2.6.0.old/createlinks 2022-04-05 23:12:26.684000000 -0400
3 +++ e-smith-qmail-2.6.0/createlinks 2022-04-06 00:15:28.727000000 -0400
4 @@ -82,6 +82,7 @@
5 #--------------------------------------------------
6 $event = "bootstrap-console-save";
7
8 +event_link("pseudonym-cleanup", $event, "03");
9 event_link("qmail-update-group", $event, "20");
10 event_link("qmail-update-user", $event, "55");
11 templates2events("/var/qmail/users/assign", $event);
12 @@ -121,7 +122,8 @@
13 #--------------------------------------------------
14 $event = "email-update";
15
16 -event_link("qmail-update-user", $event, "20");
17 +event_link("qmail-update-user", $event, "03");
18 +event_link("pseudonym-cleanup", $event, "30");
19
20 # If qmail-send is running, it will receive the SIGHUP and ignore the
21 # start command. If it is not running then the signal will be ignored
22 @@ -136,21 +138,33 @@
23 #--------------------------------------------------
24 $event = "group-create";
25
26 +event_link("pseudonym-cleanup", $event, "03");
27 event_link("qmail-update-group", $event, "20");
28 +templates2events("/var/qmail/users/assign", $event);
29 +safe_symlink("/var/qmail/bin/qmail-newu", "root/etc/e-smith/events/$event/S55email-assign");
30 +safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/qmail");
31
32 #--------------------------------------------------
33 # actions for group-delete event:
34 #--------------------------------------------------
35 $event = "group-delete";
36
37 +event_link("pseudonym-cleanup", $event, "03");
38 event_link("qmail-delete-group", $event, "20");
39 +templates2events("/var/qmail/users/assign", $event);
40 +safe_symlink("/var/qmail/bin/qmail-newu", "root/etc/e-smith/events/$event/S55email-assign");
41 +safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/qmail");
42
43 #--------------------------------------------------
44 # actions for group-modify event:
45 #--------------------------------------------------
46 $event = "group-modify";
47
48 +event_link("pseudonym-cleanup", $event, "03");
49 event_link("qmail-update-group", $event, "20");
50 +templates2events("/var/qmail/users/assign", $event);
51 +safe_symlink("/var/qmail/bin/qmail-newu", "root/etc/e-smith/events/$event/S55email-assign");
52 +safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/qmail");
53
54 #--------------------------------------------------
55 # actions for user-create event:
56 @@ -204,6 +218,7 @@
57 safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/qmail");
58 event_link("systemd-reload", $event, "89");
59 event_link("systemd-default", $event, "88");
60 +event_link("pseudonym-cleanup", $event, "03");
61
62 #--------------------------------------------------
63 # actions for pseudonym-{create,delete,modify}
64 @@ -212,6 +227,7 @@
65 user-create user-modify user-delete
66 ))
67 {
68 + event_link("pseudonym-cleanup", $event, "03");
69 templates2events("/var/qmail/control/virtualdomains", $event);
70 templates2events("/var/qmail/users/assign", $event);
71 safe_symlink("/var/qmail/bin/qmail-newu", "root/etc/e-smith/events/$event/S55email-assign");
72 diff -Nur --no-dereference e-smith-qmail-2.6.0.old/root/etc/e-smith/events/actions/pseudonym-cleanup e-smith-qmail-2.6.0/root/etc/e-smith/events/actions/pseudonym-cleanup
73 --- e-smith-qmail-2.6.0.old/root/etc/e-smith/events/actions/pseudonym-cleanup 1969-12-31 19:00:00.000000000 -0500
74 +++ e-smith-qmail-2.6.0/root/etc/e-smith/events/actions/pseudonym-cleanup 2022-04-05 23:45:01.430000000 -0400
75 @@ -0,0 +1,22 @@
76 +#!/usr/bin/perl -w
77 +
78 +use strict;
79 +use esmith::AccountsDB;
80 +use esmith::event;
81 +
82 +my $accounts = esmith::AccountsDB->open() or
83 + die "Unable to open accounts db: $!";
84 +
85 +my ($self, $account) = @ARGV;
86 +
87 +# Find all "pseudonyms" entries in the e-smith accounts database and
88 +# if the pseudonyms has an unexisting Account associated we change
89 +# it to user "admin".
90 +
91 +foreach my $pseudo ( $accounts->pseudonyms ) {
92 + unless ( $accounts->get($pseudo->prop('Account')) ) {
93 + $pseudo->set_prop( 'Account', 'admin' );
94 + print "orphaned pseudonym " . $pseudo->key. " has been associated to admin account"
95 + }
96 +}
97 +
98 diff -Nur --no-dereference e-smith-qmail-2.6.0.old/root/etc/e-smith/templates/var/qmail/control/virtualdomains/90pseudonyms e-smith-qmail-2.6.0/root/etc/e-smith/templates/var/qmail/control/virtualdomains/90pseudonyms
99 --- e-smith-qmail-2.6.0.old/root/etc/e-smith/templates/var/qmail/control/virtualdomains/90pseudonyms 2016-02-05 16:46:07.000000000 -0500
100 +++ e-smith-qmail-2.6.0/root/etc/e-smith/templates/var/qmail/control/virtualdomains/90pseudonyms 2022-04-05 23:45:01.922000000 -0400
101 @@ -13,7 +13,8 @@
102 {
103 next unless ($pseudo->key =~ /@/);
104
105 - my $account = $pseudo->prop("Account");
106 + my $account = $pseudo->prop("Account");
107 + $account = "admin" and warn $pseudo->prop("Account") . " is not a valid account, default to admin " unless $adb->get($account);
108 my $acct = $adb->get($account);
109 if ($acct->prop('type') eq "group")
110 {
111 diff -Nur --no-dereference e-smith-qmail-2.6.0.old/root/etc/e-smith/templates/var/qmail/users/assign/70pseudonyms e-smith-qmail-2.6.0/root/etc/e-smith/templates/var/qmail/users/assign/70pseudonyms
112 --- e-smith-qmail-2.6.0.old/root/etc/e-smith/templates/var/qmail/users/assign/70pseudonyms 2006-01-11 02:04:56.000000000 -0500
113 +++ e-smith-qmail-2.6.0/root/etc/e-smith/templates/var/qmail/users/assign/70pseudonyms 2022-04-05 23:45:01.678000000 -0400
114 @@ -61,23 +61,32 @@
115 unless ($account)
116 {
117 my $key = $pseudonym->key;
118 - warn "pseudonym $key has no account property";
119 - next;
120 + warn "pseudonym $key has no account property, default to admin";
121 + $account = $adb->get('admin');
122 + #next;
123 }
124 +
125 $account = $adb->get($pseudonym->prop('Account'));
126 - unless ($account)
127 - {
128 - my $key = $pseudonym->key;
129 - warn "pseudonym $key points to account which does not exist";
130 - next;
131 - }
132 + unless ($account)
133 + {
134 + my $key = $pseudonym->key;
135 + warn "pseudonym $key points to account which does not exist, default to admin";
136 + $account = $adb->get('admin');
137 + #next;
138 + }
139
140 - $account = $adb->get($account->prop('Account')) if ($account->prop('type') eq "pseudonym");
141 - unless ($account)
142 + my $i = 1;
143 + while ( $account->prop('type') eq "pseudonym")
144 {
145 - my $key = $pseudonym->key;
146 - warn "pseudonym $key points to pseudonym account which points to account which does not exist";
147 - next;
148 + $account = $adb->get($account->prop('Account'));
149 + unless ($account)
150 + {
151 + my $key = $pseudonym->key;
152 + warn "pseudonym $key points to account which does not exist, default to admin";
153 + $account = $adb->get('admin');
154 + last;
155 + }
156 + $i ++; last if $i>10;
157 }
158
159 if ($account->prop('type') eq "pseudonym")

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed