-
Notifications
You must be signed in to change notification settings - Fork 922
/
Copy path_pdnsutil.zsh_completion
324 lines (291 loc) · 14.1 KB
/
_pdnsutil.zsh_completion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
#compdef pdnsutil
#
# put file '_pdnsutil' somewhere into $fpath,
# e.g. /usr/share/zsh/vendor-completions/
#
# command completion for pdns-auth
#
(( $+functions[_pdnsutil_commands] )) ||
_pdnsutil_commands() {
local -a _pdnsutil_cmds
_pdnsutil_cmds=(
'activate-tsig-key:Enable TSIG authenticated AXFR using the key NAME for ZONE'
'activate-zone-key:Activate the key with key id KEY-ID in ZONE'
'add-record:Add one or more records to ZONE'
'add-autoprimary:Add a new autoprimary'
'remove-autoprimary:Remove an autoprimary'
'list-autoprimaries:List all autoprimaries'
'add-zone-key:Add a ZSK or KSK to zone and specify algo&bits'
'backend-cmd:Perform one or more backend commands'
'backend-lookup:Perform a backend record lookup'
'b2b-migrate:Move all data from one backend to another'
'bench-db:Bench database backend with queries, one zone per line'
'check-zone:Check a zone for correctness'
'check-all-zones:Check all zones for correctness'
'clear-zone:Clear all records of a zone, but keep everything else'
'create-bind-db:Create DNSSEC db for BIND backend (bind-dnssec-db)'
'create-secondary-zone:Create secondary zone ZONE with primary IP address primary-ip'
'change-secondary-zone-primary:Change secondary zone ZONE primary IP address to primary-ip'
'create-zone:Create empty zone ZONE'
'deactivate-tsig-key:Disable TSIG authenticated AXFR using the key NAME for ZONE'
'deactivate-zone-key:Deactivate the key with key id KEY-ID in ZONE'
'delete-rrset:Delete named RRSET from zone'
'delete-tsig-key:Delete TSIG key (warning! will not unmap key!)'
'delete-zone:Delete the zone'
'disable-dnssec:Deactivate all keys and unset PRESIGNED in ZONE'
'edit-zone:Edit zone contents using $EDITOR'
'export-zone-dnskey:Export to stdout the public DNSKEY described'
'export-zone-ds:Export to stdout all KSK DS records for ZONE'
'export-zone-key:Export to stdout the private key described'
'export-zone-key-pem:Export to stdout in PEM the private key described'
'generate-tsig-key:Generate new TSIG key'
'generate-zone-key:Generate a ZSK or KSK to stdout with specified ALGORITHM and BITS'
'get-meta:Get zone metadata. If no KIND given, lists all known'
'hash-password:Ask for a plaintext password or api key and output a hashed and salted version'
'hash-zone-record:Calculate the NSEC3 hash for RNAME in ZONE'
'increase-serial:Increases the SOA-serial by 1. Uses SOA-EDIT'
'import-tsig-key:Import TSIG key'
'import-zone-key:Import from a file a private key, ZSK or KSK'
'import-zone-key-pem:Import from a file a private key in PEM, ZSK or KSK'
'ipdecrypt:Decrypt IP address using passphrase or base64 key'
'ipencrypt:Encrypt IP address using passphrase or base64 key'
'load-zone:Load ZONE from FILE, possibly creating zone or atomically replacing contents'
'list-algorithms:List all DNSSEC algorithms supported, optionally also listing the crypto library used'
'list-keys:List DNSSEC keys for ZONE. When ZONE is unset, display all keys for all active zones'
'list-member-zones:List all members of catalog zone CATALOG'
'list-zone:List zone contents'
'list-all-zones:List all active zone names'
'list-tsig-keys:List all TSIG keys'
'publish-zone-key:Publish the zone key with key id KEY-ID in ZONE'
'rectify-zone:Fix up DNSSEC fields (order, auth)'
'rectify-all-zones:Rectify all zones. Optionally quiet output with errors only'
'remove-zone-key:Remove key with KEY-ID from ZONE'
'replace-rrset:Replace named RRSET from zone'
'secure-all-zones:Secure all zones without keys'
'secure-zone:Add DNSSEC to zone ZONE'
'set-kind:Change the kind of ZONE to KIND (priamry, secondary, native)'
'set-account:Change the account (owner) of ZONE to ACCOUNT'
'set-nsec3:Enable NSEC3 with PARAMS. Optionally narrow'
'set-presigned:Use presigned RRSIGs from storage'
'set-publish-cdnskey:Enable sending CDNSKEY responses for ZONE. Add "delete" to publish a CDNSKEY with a DNSSEC delete algorithm'
'set-publish-cds:Enable sending CDS responses for ZONE, using DIGESTALGOS as signature algorithms'
'add-meta:Add zone metadata, this adds to the existing KIND'
'set-meta:Set zone metadata, optionally providing a value. *No* value clears meta'
'show-zone:Show DNSSEC (public) key details about a zone'
'unpublish-zone-key:Unpublish the zone key with key id KEY-ID in ZONE'
'unset-nsec3:Switch back to NSEC'
'unset-presigned:No longer use presigned RRSIGs'
'unset-publish-cdnskey:Disable sending CDNSKEY responses for ZONE'
'unset-publish-cds:Disable sending CDS responses for ZONE'
'test-schema:Test DB schema - will create ZONE'
"raw-lua-from-content:Display record contents in a form suitable for dnsdist's \`SpoofRawAction\`"
'zonemd-verify-file:Validate ZONEMD for ZONE'
)
if (( CURRENT == 1 )); then
_describe -t commands 'pdnsutil command' _pdnsutil_cmds
else
local curcontext="$curcontext"
cmd="${${_pdnsutil_cmds[(r)$words[1]:*]%%:*}}"
# command dispatcher
case $cmd in
(activate-zone-key|add-record|check-zone|clear-zone|create-secondary-zone|change-secondary-zone-primary|create-zone|deactivate-zone-key|delete-rrset|delete-zone|disable-dnssec|edit-zone|export-zone-dnskey|export-zone-ds|export-zone-key|export-zone-key-pem|hash-zone-record|increase-serial|list-keys|list-zone|publish-zone-key|remove-zone-key|replace-rrset|set-account|set-nsec3|set-presigned|set-publish-cds|show-zone|unpublish-zone-key|unset-nsec3|unset-presigned|unset-publish-cdnskey|unset-publish-cds|test-schema)
_pdnsutil_cmd_singlezonearg
;;
(rectify-zone|secure-zone)
_pdnsutil_cmd_multizonearg
;;
(bench-db|create-bind-db)
_pdnsutil_cmd_filearg
;;
(activate-tsig-key|add-zone-key|check-all-zones|deactivate-tsig-key|delete-tsig-key|generate-tsig-key|generate-zone-key|get-meta|import-tsig-key|import-zone-key|import-zone-key-pem|load-zone|list-algorithms|list-all-zones|rectify-all-zones|secure-all-zones|set-kind|set-publish-cdnskey|add-meta|set-meta|zonemd-verify-file)
_pdnsutil_cmd_$cmd
;;
*)
# no completion for everything else
;;
esac
fi
}
# fetch available zones for completion
(( $+functions[_pdnsutil_zones] )) ||
_pdnsutil_zones() {
local -a _zones
_zones=( "${(f)$(pdnsutil list-all-zones 2> /dev/null)}" )
if [[ -n "$_zones" ]]; then
_describe -t zones 'zones' _zones
else
_message "no zones"
fi
}
# fetch available tsig keys for completion
(( $+functions[_pdnsutil_tsigkeys] )) ||
_pdnsutil_tsigkeys() {
local -a _tsigkeys
_tsigkeys=( ${"${(f)$(pdnsutil list-tsig-keys 2> /dev/null)}"%%. *} )
if [[ -n "$_tsigkeys" ]]; then
_describe -t tsigkeys 'tsigkeys' _tsigkeys
else
_message "no tsigkeys"
fi
}
# all subcommands with only a single zone argument to complete
(( $+functions[_pdnsutil_cmd_singlezonearg] )) ||
_pdnsutil_cmd_singlezonearg() {
_arguments ":zone:_pdnsutil_zones"
}
# all subcommands with multiple zones as argument to complete
(( $+functions[_pdnsutil_cmd_multizonearg] )) ||
_pdnsutil_cmd_multizonearg() {
_arguments "*:zone:_pdnsutil_zones"
}
# all subcommands with a filename as argument
(( $+functions[_pdnsutil_cmd_filearg] )) ||
_pdnsutil_cmd_filearg() {
_arguments ":filename:_files"
}
# command-specific functions below
#
(( $+functions[_pdnsutil_cmd_activate-tsig-key] )) ||
_pdnsutil_cmd_activate-tsig-key() {
_arguments \
':zone:_pdnsutil_zones' \
':key:_pdnsutil_tsigkeys' \
':type:(primary secondary)'
}
(( $+functions[_pdnsutil_cmd_add-zone-key] )) ||
_pdnsutil_cmd_add-zone-key() {
_arguments \
':zone:_pdnsutil_zones' \
':type:(zsk ksk)' \
':bits:' \
':state:(active inactive)' \
':pub:(published unpublished)' \
':algorithm:(rsasha1 rsasha1-nsec3-sha1 rsasha256 rsasha512 ecdsa256 ecdsa384 ed25519 ed448)'
}
(( $+functions[_pdnsutil_cmd_check-all-zones] )) ||
_pdnsutil_cmd_check-all-zones() {
_arguments \
':flag:(exit-on-error)'
}
(( $+functions[_pdnsutil_cmd_deactivate-tsig-key] )) ||
_pdnsutil_cmd_deactivate-tsig-key() {
_arguments \
':zone:_pdnsutil_zones' \
':key:_pdnsutil_tsigkeys' \
':type:(primary secondary)'
}
(( $+functions[_pdnsutil_cmd_delete-tsig-key] )) ||
_pdnsutil_cmd_delete-tsig-key() {
_arguments \
':key:_pdnsutil_tsigkeys'
}
(( $+functions[_pdnsutil_cmd_generate-tsig-key] )) ||
_pdnsutil_cmd_generate-tsig-key() {
_arguments \
':name:' \
':algorithm:(hmac-md5 hmac-sha1 hmac-sha224 hmac-sha256 hmac-sha384 hmac-sha512)'
}
(( $+functions[_pdnsutil_cmd_generate-zone-key] )) ||
_pdnsutil_cmd_generate-zone-key() {
_arguments \
':type:(zsk ksk)' \
':algorithm:(rsasha1 rsasha1-nsec3-sha1 rsasha256 rsasha512 ecdsa256 ecdsa384 ed25519 ed448)' \
':bits:'
}
(( $+functions[_pdnsutil_cmd_get-meta] )) ||
_pdnsutil_cmd_get-meta() {
_arguments \
':zone:_pdnsutil_zones' \
':kind:(ALLOW-AXFR-FROM API-RECTIFY AXFR-SOURCE ALLOW-DNSUPDATE-FROM TSIG-ALLOW-DNSUPDATE FORWARD-DNSUPDATE SOA-EDIT-DNSUPDATE NOTIFY-DNSUPDATE ALSO-NOTIFY AXFR-MASTER-TSIG GSS-ALLOW-AXFR-PRINCIPAL GSS-ACCEPTOR-PRINCIPAL IXFR LUA-AXFR-SCRIPT NSEC3NARROW NSEC3PARAM PRESIGNED PUBLISH-CDNSKEY PUBLISH-CDS SLAVE-RENOTIFY SOA-EDIT SOA-EDIT-API TSIG-ALLOW-AXFR TSIG-ALLOW-DNSUPDATE)'
}
(( $+functions[_pdnsutil_cmd_import-tsig-key] )) ||
_pdnsutil_cmd_import-tsig-key() {
_arguments \
':name:' \
':algorithm:(hmac-md5 hmac-sha1 hmac-sha224 hmac-sha256 hmac-sha384 hmac-sha512)' \
':key:'
}
(( $+functions[_pdnsutil_cmd_import-zone-key] )) ||
_pdnsutil_cmd_import-zone-key() {
_arguments \
':zone:_pdnsutil_zones' \
':filename:_files' \
':state:(active inactive)' \
':type:(zsk ksk)' \
':pub:(published unpublished)'
}
(( $+functions[_pdnsutil_cmd_import-zone-key-pem] )) ||
_pdnsutil_cmd_import-zone-key-pem() {
_arguments \
':zone:_pdnsutil_zones' \
':filename:_files' \
':algorithm:(rsasha1 rsasha1-nsec3-sha1 rsasha256 rsasha512 ecdsa256 ecdsa384 ed25519 ed448)' \
':type:(zsk ksk)'
}
(( $+functions[_pdnsutil_cmd_load-zone] )) ||
_pdnsutil_cmd_load-zone() {
_arguments \
':zone:_pdnsutil_zones' \
':filename:_files'
}
(( $+functions[_pdnsutil_cmd_list-algorithms] )) ||
_pdnsutil_cmd_list-algorithms() {
_arguments \
':flag:(with-backend)'
}
(( $+functions[_pdnsutil_cmd_list-all-zones] )) ||
_pdnsutil_cmd_list-all-zones() {
_arguments \
':type:(primary secondary native)'
}
(( $+functions[_pdnsutil_cmd_rectify-all-zones] )) ||
_pdnsutil_cmd_rectify-all-zones() {
_arguments \
':flag:(quiet)'
}
(( $+functions[_pdnsutil_cmd_secure-all-zones] )) ||
_pdnsutil_cmd_secure-all-zones() {
_arguments \
':flag:(increase-serial)'
}
(( $+functions[_pdnsutil_cmd_set-kind] )) ||
_pdnsutil_cmd_set-kind() {
_arguments \
':zone:_pdnsutil_zones' \
':type:(primary secondary native)'
}
(( $+functions[_pdnsutil_cmd_set-publish-cdnskey] )) ||
_pdnsutil_cmd_set-publish-cdnskey() {
_arguments \
':zone:_pdnsutil_zones' \
':flag:(delete)'
}
(( $+functions[_pdnsutil_cmd_add-meta] )) ||
_pdnsutil_cmd_add-meta() {
_arguments \
':zone:_pdnsutil_zones' \
':kind:(ALLOW-AXFR-FROM API-RECTIFY AXFR-SOURCE ALLOW-DNSUPDATE-FROM TSIG-ALLOW-DNSUPDATE FORWARD-DNSUPDATE SOA-EDIT-DNSUPDATE NOTIFY-DNSUPDATE ALSO-NOTIFY AXFR-MASTER-TSIG GSS-ALLOW-AXFR-PRINCIPAL GSS-ACCEPTOR-PRINCIPAL IXFR LUA-AXFR-SCRIPT NSEC3NARROW NSEC3PARAM PRESIGNED PUBLISH-CDNSKEY PUBLISH-CDS SLAVE-RENOTIFY SOA-EDIT SOA-EDIT-API TSIG-ALLOW-AXFR TSIG-ALLOW-DNSUPDATE)' \
'*:value:'
}
(( $+functions[_pdnsutil_cmd_set-meta] )) ||
_pdnsutil_cmd_set-meta() {
_arguments \
':zone:_pdnsutil_zones' \
':kind:(ALLOW-AXFR-FROM API-RECTIFY AXFR-SOURCE ALLOW-DNSUPDATE-FROM TSIG-ALLOW-DNSUPDATE FORWARD-DNSUPDATE SOA-EDIT-DNSUPDATE NOTIFY-DNSUPDATE ALSO-NOTIFY AXFR-MASTER-TSIG GSS-ALLOW-AXFR-PRINCIPAL GSS-ACCEPTOR-PRINCIPAL IXFR LUA-AXFR-SCRIPT NSEC3NARROW NSEC3PARAM PRESIGNED PUBLISH-CDNSKEY PUBLISH-CDS SLAVE-RENOTIFY SOA-EDIT SOA-EDIT-API TSIG-ALLOW-AXFR TSIG-ALLOW-DNSUPDATE)' \
'*:value:'
}
(( $+functions[_pdnsutil_cmd_zonemd-verify-file] )) ||
_pdnsutil_cmd_zonemd-verify-file() {
_arguments \
':zone:_pdnsutil_zones' \
':filename:_files'
}
# pre-subcmd arguments
_arguments \
'(- *)'{-h,--help}'[produce help message]' \
'(- *)--version[show version]' \
{-v,--verbose}'[be verbose]' \
'--force[force an action]' \
'--config-name[virtual configuration name]:filename:_files' \
'--config-dir[location of pdns.conf]:dirname:_files -/' \
'*::pdnsutil commands:_pdnsutil_commands'