Mercurial > dovecot > core-2.2
annotate src/config/settings-get.pl @ 23017:c1d36f2575c7 default tip
lib-imap: Fix "Don't accept strings with NULs" cherry-pick
author | Timo Sirainen <timo.sirainen@open-xchange.com> |
---|---|
date | Thu, 29 Aug 2019 09:55:25 +0300 |
parents | 0dc214cf2e30 |
children |
rev | line source |
---|---|
9002 | 1 #!/usr/bin/env perl |
2 use strict; | |
3 | |
4 print '#include "lib.h"'."\n"; | |
9011
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
5 print '#include "array.h"'."\n"; |
13060
99da5f4f375d
master: Fail at startup if default_login_user or default_internal_user doesn't exist.
Timo Sirainen <tss@iki.fi>
parents:
12312
diff
changeset
|
6 print '#include "ipwd.h"'."\n"; |
9177
e4cc93190ec3
Moved pop3_uidl_format checking to mail-storage-settings.
Timo Sirainen <tss@iki.fi>
parents:
9159
diff
changeset
|
7 print '#include "var-expand.h"'."\n"; |
9434
e374a365521d
Initial commit for making mail_storage:mailbox_list to be from 1:1 to n:n.
Timo Sirainen <tss@iki.fi>
parents:
9179
diff
changeset
|
8 print '#include "file-lock.h"'."\n"; |
11634
7f19062f58fd
Renamed fsync_disable to mail_fsync=optimized|always|never.
Timo Sirainen <tss@iki.fi>
parents:
11007
diff
changeset
|
9 print '#include "fsync-mode.h"'."\n"; |
12312
28eaaa23f2c6
lib-storage: Added support for saving mail attachments separately via filesystem API.
Timo Sirainen <tss@iki.fi>
parents:
11634
diff
changeset
|
10 print '#include "hash-format.h"'."\n"; |
15187
02451e967a06
Renamed network.[ch] to net.[ch].
Timo Sirainen <tss@iki.fi>
parents:
14159
diff
changeset
|
11 print '#include "net.h"'."\n"; |
13793
ee783a878120
Moved autocreate plugin functionality into lib-storage.
Timo Sirainen <tss@iki.fi>
parents:
13060
diff
changeset
|
12 print '#include "unichar.h"'."\n"; |
20419
0dc214cf2e30
auth-policy: Add policy implementation
Aki Tuomi <aki.tuomi@dovecot.fi>
parents:
19920
diff
changeset
|
13 print '#include "hash-method.h"'."\n"; |
9002 | 14 print '#include "settings-parser.h"'."\n"; |
15 print '#include "all-settings.h"'."\n"; | |
16 print '#include <stddef.h>'."\n"; | |
9011
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
17 print '#include <unistd.h>'."\n"; |
9002 | 18 print '#define CONFIG_BINARY'."\n"; |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
19 print 'extern buffer_t config_all_services_buf;'; |
9002 | 20 |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
21 my @services = (); |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
22 my @service_ifdefs = (); |
9002 | 23 my %parsers = {}; |
24 | |
25 foreach my $file (@ARGV) { | |
26 my $f; | |
27 open($f, $file) || die "Can't open $file: $@"; | |
28 | |
29 my $state = 0; | |
30 my $file_contents = ""; | |
31 my $externs = ""; | |
9011
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
32 my $code = ""; |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
33 my %funcs; |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
34 my $cur_name = ""; |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
35 my $ifdef = ""; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
36 my $state_ifdef = 0; |
9002 | 37 |
38 while (<$f>) { | |
39 my $write = 0; | |
40 if ($state == 0) { | |
19920
c1b70b76f9bb
config: Escape regexps properly in settings-get.pl to avoid warnings with new Perl
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
17397
diff
changeset
|
41 if (/struct .*_settings \{/ || |
c1b70b76f9bb
config: Escape regexps properly in settings-get.pl to avoid warnings with new Perl
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
17397
diff
changeset
|
42 /struct setting_define.*\{/ || |
c1b70b76f9bb
config: Escape regexps properly in settings-get.pl to avoid warnings with new Perl
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
17397
diff
changeset
|
43 /struct .*_default_settings = \{/) { |
9002 | 44 $state++; |
19920
c1b70b76f9bb
config: Escape regexps properly in settings-get.pl to avoid warnings with new Perl
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
17397
diff
changeset
|
45 } elsif (/^struct service_settings (.*) = \{/) { |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
46 $state++; |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
47 if ($ifdef eq "") { |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
48 $state_ifdef = 0; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
49 } else { |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
50 $_ = $ifdef."\n".$_; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
51 $state_ifdef = 1; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
52 } |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
53 push @services, $1; |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
54 push @service_ifdefs, $ifdef; |
19920
c1b70b76f9bb
config: Escape regexps properly in settings-get.pl to avoid warnings with new Perl
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
17397
diff
changeset
|
55 } elsif (/^(static )?const struct setting_parser_info (.*) = \{/) { |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
56 $cur_name = $2; |
10177
d589d568a19d
Changed all settings related structs to const and changed APIs to make it work.
Timo Sirainen <tss@iki.fi>
parents:
10107
diff
changeset
|
57 $state++ if ($cur_name !~ /^\*default_/); |
d589d568a19d
Changed all settings related structs to const and changed APIs to make it work.
Timo Sirainen <tss@iki.fi>
parents:
10107
diff
changeset
|
58 } elsif (/^extern const struct setting_parser_info (.*);/) { |
d589d568a19d
Changed all settings related structs to const and changed APIs to make it work.
Timo Sirainen <tss@iki.fi>
parents:
10107
diff
changeset
|
59 $externs .= "extern const struct setting_parser_info $1;\n"; |
9011
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
60 } elsif (/\/\* <settings checks> \*\//) { |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
61 $state = 4; |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
62 $code .= $_; |
9002 | 63 } |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
64 |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
65 if (/(^#ifdef .*)$/ || /^(#if .*)$/) { |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
66 $ifdef = $1; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
67 } else { |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
68 $ifdef = ""; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
69 } |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
70 |
9159
6324a79d3ee1
Initial commit for v2.0 master rewrite. Several features are still missing.
Timo Sirainen <tss@iki.fi>
parents:
9011
diff
changeset
|
71 if (/#define.*DEF/ || /^#undef.*DEF/ || /ARRAY_DEFINE_TYPE.*_settings/) { |
9002 | 72 $write = 1; |
73 $state = 2 if (/\\$/); | |
74 } | |
75 } elsif ($state == 2) { | |
76 $write = 1; | |
77 $state = 0 if (!/\\$/); | |
9011
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
78 } elsif ($state == 4) { |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
79 $code .= $_; |
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
80 $state = 0 if (/\/\* <\/settings checks> \*\//); |
9002 | 81 } |
82 | |
83 if ($state == 1 || $state == 3) { | |
84 if ($state == 1) { | |
10411
3448f1bc6966
Changed settings-get.pl to understand the MEMBER() macro removal.
Timo Sirainen <tss@iki.fi>
parents:
10336
diff
changeset
|
85 if (/\.module_name = "(.*)"/) { |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
86 $parsers{$cur_name} = $1; |
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
87 } |
9002 | 88 if (/DEFLIST.*".*",(.*)$/) { |
89 my $value = $1; | |
90 if ($value =~ /.*&(.*)\)/) { | |
91 $parsers{$1} = 0; | |
10177
d589d568a19d
Changed all settings related structs to const and changed APIs to make it work.
Timo Sirainen <tss@iki.fi>
parents:
10107
diff
changeset
|
92 $externs .= "extern const struct setting_parser_info $1;\n"; |
9002 | 93 } else { |
94 $state = 3; | |
95 } | |
96 } | |
97 } elsif ($state == 3) { | |
98 if (/.*&(.*)\)/) { | |
99 $parsers{$1} = 0; | |
100 } | |
101 } | |
102 | |
10336
e18645b47984
config: Allow settings plugins to specify also new default services.
Timo Sirainen <tss@iki.fi>
parents:
10181
diff
changeset
|
103 s/^static const (struct master_settings master_default_settings)/$1/; |
e18645b47984
config: Allow settings plugins to specify also new default services.
Timo Sirainen <tss@iki.fi>
parents:
10181
diff
changeset
|
104 |
9002 | 105 $write = 1; |
106 if (/};/) { | |
107 $state = 0; | |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
108 if ($state_ifdef) { |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
109 $_ .= "#endif\n"; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
110 $state_ifdef = 0; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
111 } |
9002 | 112 } |
113 } | |
114 | |
115 $file_contents .= $_ if ($write); | |
116 } | |
117 | |
118 print "/* $file */\n"; | |
119 print $externs; | |
9011
c37f7113b1ee
doveconf now checks that all settings are ok by calling check functions.
Timo Sirainen <tss@iki.fi>
parents:
9002
diff
changeset
|
120 print $code; |
9002 | 121 print $file_contents; |
122 | |
123 close $f; | |
124 } | |
125 | |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
126 print "static struct service_settings *config_all_services[] = {\n"; |
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
127 |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
128 for (my $i = 0; $i < scalar(@services); $i++) { |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
129 my $ifdef = $service_ifdefs[$i]; |
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
130 print "$ifdef\n" if ($ifdef ne ""); |
11007
2178c4569f38
config: Fixed all-settings building script.
Timo Sirainen <tss@iki.fi>
parents:
10986
diff
changeset
|
131 print "\t&".$services[$i].",\n"; |
10986
b218d4ec6996
config: Parser script now supports preserving #ifdefs around service_settings.
Timo Sirainen <tss@iki.fi>
parents:
10411
diff
changeset
|
132 print "#endif\n" if ($ifdef ne ""); |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
133 } |
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
134 print "};\n"; |
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
135 print "buffer_t config_all_services_buf = {\n"; |
17397
f373df52082a
treewide - mass cleanup of 0 used to end a settings list
Phil Carmody <phil@dovecot.fi>
parents:
15213
diff
changeset
|
136 print "\tconfig_all_services, sizeof(config_all_services), { NULL, }\n"; |
10179
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
137 print "};\n"; |
afe52d60989c
Moved default service settings from master.conf to source code.
Timo Sirainen <tss@iki.fi>
parents:
10177
diff
changeset
|
138 |
10181
4dc080520769
config: Added support for dynamically loaded settings.
Timo Sirainen <tss@iki.fi>
parents:
10179
diff
changeset
|
139 print "const struct setting_parser_info *all_default_roots[] = {\n"; |
15213
78749ae0c9c2
config: Added lib-master's settings parsers back to config's knowledge
Timo Sirainen <tss@iki.fi>
parents:
15187
diff
changeset
|
140 print "\t&master_service_setting_parser_info,\n"; |
78749ae0c9c2
config: Added lib-master's settings parsers back to config's knowledge
Timo Sirainen <tss@iki.fi>
parents:
15187
diff
changeset
|
141 print "\t&master_service_ssl_setting_parser_info,\n"; |
9002 | 142 foreach my $name (keys %parsers) { |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
143 my $module = $parsers{$name}; |
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
144 next if (!$module); |
9002 | 145 |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
146 print "\t&".$name.", \n"; |
9002 | 147 } |
10107
dcda7c495eb6
struct setting_parser_info now specifies the module name.
Timo Sirainen <tss@iki.fi>
parents:
9793
diff
changeset
|
148 print "\tNULL\n"; |
9002 | 149 print "};\n"; |
10181
4dc080520769
config: Added support for dynamically loaded settings.
Timo Sirainen <tss@iki.fi>
parents:
10179
diff
changeset
|
150 print "const struct setting_parser_info *const *all_roots = all_default_roots;\n"; |
10336
e18645b47984
config: Allow settings plugins to specify also new default services.
Timo Sirainen <tss@iki.fi>
parents:
10181
diff
changeset
|
151 print "ARRAY_TYPE(service_settings) *default_services = &master_default_settings.services;\n"; |