1CVTSUDOERS(1)             BSD General Commands Manual            CVTSUDOERS(1)
2

NAME

4     cvtsudoers — convert between sudoers file formats
5

SYNOPSIS

7     cvtsudoers [-ehMpV] [-b dn] [-c conf_file] [-d deftypes]
8                [-f output_format] [-i input_format] [-I increment]
9                [-m filter] [-o output_file] [-O start_point] [-P padding]
10                [-s sections] [input_file]
11

DESCRIPTION

13     cvtsudoers can be used to convert between sudoers security policy file
14     formats.  The default input format is sudoers.  The default output format
15     is LDIF.  It is only possible to convert a sudoers file that is syntacti‐
16     cally correct.
17
18     If no input_file is specified, or if it is ‘-’, the policy is read from
19     the standard input.  By default, the result is written to the standard
20     output.
21
22     The options are as follows:
23
24     -b dn, --base=dn
25                 The base DN (distinguished name) that will be used when per‐
26                 forming LDAP queries.  Typically this is of the form
27                 ou=SUDOers,dc=my-domain,dc=com for the domain my-domain.com.
28                 If this option is not specified, the value of the
29                 SUDOERS_BASE environment variable will be used instead.  Only
30                 necessary when converting to LDIF format.
31
32     -c conf_file, --config=conf_file
33                 Specify the path to the configuration file.  Defaults to
34                 /etc/cvtsudoers.conf.
35
36     -d deftypes, --defaults=deftypes
37                 Only convert Defaults entries of the specified types.  One or
38                 more Defaults types may be specified, separated by a comma
39                 (‘,’).  The supported types are:
40
41                 all       All Defaults entries.
42
43                 global    Global Defaults entries that are applied regardless
44                           of user, runas, host or command.
45
46                 user      Per-user Defaults entries.
47
48                 runas     Per-runas user Defaults entries.
49
50                 host      Per-host Defaults entries.
51
52                 command   Per-command Defaults entries.
53
54                 See the Defaults section in sudoers(5) for more information.
55
56                 If the -d option is not specified, all Defaults entries will
57                 be converted.
58
59     -e, --expand-aliases
60                 Expand aliases in input_file.  Aliases are preserved by de‐
61                 fault when the output format is JSON or sudoers.
62
63     -f output_format, --output-format=output_format
64                 Specify the output format (case-insensitive).  The following
65                 formats are supported:
66
67                 JSON      JSON (JavaScript Object Notation) files are usually
68                           easier for third-party applications to consume than
69                           the traditional sudoers format.  The various values
70                           have explicit types which removes much of the ambi‐
71                           guity of the sudoers format.
72
73                 LDIF      LDIF (LDAP Data Interchange Format) files can be
74                           imported into an LDAP server for use with
75                           sudoers.ldap(5).
76
77                           Conversion to LDIF has the following limitations:
78
79                           Command, host, runas and user-specific Defaults
80                              lines cannot be translated as they don't have an
81                              equivalent in the sudoers LDAP schema.
82
83                           Command, host, runas and user aliases are not
84                              supported by the sudoers LDAP schema so they are
85                              expanded during the conversion.
86
87                 sudoers   Traditional sudoers format.  A new sudoers file
88                           will be reconstructed from the parsed input file.
89                           Comments are not preserved and data from any in‐
90                           clude files will be output inline.
91
92     -h, --help  Display a short help message to the standard output and exit.
93
94     -i input_format, --input-format=input_format
95                 Specify the input format.  The following formats are sup‐
96                 ported:
97
98                 LDIF      LDIF (LDAP Data Interchange Format) files can be
99                           exported from an LDAP server to convert security
100                           policies used by sudoers.ldap(5).  If a base DN
101                           (distinguished name) is specified, only sudoRole
102                           objects that match the base DN will be processed.
103                           Not all sudoOptions specified in a sudoRole can be
104                           translated from LDIF to sudoers format.
105
106                 sudoers   Traditional sudoers format.  This is the default
107                           input format.
108
109     -I increment, --increment=increment
110                 When generating LDIF output, increment each sudoOrder attri‐
111                 bute by the specified number.  Defaults to an increment of 1.
112
113     -m filter, --match=filter
114                 Only output rules that match the specified filter.  A filter
115                 expression is made up of one or more key = value pairs, sepa‐
116                 rated by a comma (‘,’).  The key may be “user”, “group” or
117                 “host”.  For example, user = operator or host = www.  An up‐
118                 per-case User_Alias or Host_Alias may be specified as the
119                 “user” or “host”.
120
121                 A matching sudoers rule may also include users, groups and
122                 hosts that are not part of the filter.  This can happen when
123                 a rule includes multiple users, groups or hosts.  To prune
124                 out any non-matching user, group or host from the rules, the
125                 -p option may be used.
126
127                 By default, the password and group databases are not con‐
128                 sulted when matching against the filter so the users and
129                 groups do not need to be present on the local system (see the
130                 -M option).  Only aliases that are referenced by the filtered
131                 policy rules will be displayed.
132
133     -M, --match-local
134                 When the -m option is also specified, use password and group
135                 database information when matching users and groups in the
136                 filter.  Only users and groups in the filter that exist on
137                 the local system will match, and a user's groups will auto‐
138                 matically be added to the filter.  If the -M is not speci‐
139                 fied, users and groups in the filter do not need to exist on
140                 the local system, but all groups used for matching must be
141                 explicitly listed in the filter.
142
143     -o output_file, --output=output_file
144                 Write the converted output to output_file.  If no output_file
145                 is specified, or if it is ‘-’, the converted sudoers policy
146                 will be written to the standard output.
147
148     -O start_point, --order-start=start_point
149                 When generating LDIF output, use the number specified by
150                 start_point in the sudoOrder attribute of the first sudoRole
151                 object.  Subsequent sudoRole object use a sudoOrder value
152                 generated by adding an increment, see the -I option for de‐
153                 tails.  Defaults to a starting point of 1.  A starting point
154                 of 0 will disable the generation of sudoOrder attributes in
155                 the resulting LDIF file.
156
157     -p, --prune-matches
158                 When the -m option is also specified, cvtsudoers will prune
159                 out non-matching users, groups and hosts from matching en‐
160                 tries.
161
162     -P padding, --padding=padding
163                 When generating LDIF output, construct the initial sudoOrder
164                 value by concatenating order_start and increment, padding the
165                 increment with zeros until it consists of padding digits.
166                 For example, if order_start is 1027, padding is 3, and
167                 increment is 1, the value of sudoOrder for the first entry
168                 will be 1027000, followed by 1027001, 1027002, etc.  If the
169                 number of sudoRole entries is larger than the padding would
170                 allow, cvtsudoers will exit with an error.  By default, no
171                 padding is performed.
172
173     -s sections, --suppress=sections
174                 Suppress the output of specific sections of the security pol‐
175                 icy.  One or more section names may be specified, separated
176                 by a comma (‘,’).  The supported section name are: defaults,
177                 aliases and privileges (which may be shortened to privs).
178
179     -V, --version
180                 Print the cvtsudoers and sudoers grammar versions and exit.
181
182     Options in the form “keyword = value” may also be specified in a configu‐
183     ration file, /etc/cvtsudoers.conf by default.  The following keywords are
184     recognized:
185
186     defaults = deftypes
187           See the description of the -d command line option.
188
189     expand_aliases = yes | no
190           See the description of the -e command line option.
191
192     input_format = ldif | sudoers
193           See the description of the -i command line option.
194
195     match = filter
196           See the description of the -m command line option.
197
198     order_increment = increment
199           See the description of the -I command line option.
200
201     order_start = start_point
202           See the description of the -O command line option.
203
204     output_format = json | ldif | sudoers
205           See the description of the -f command line option.
206
207     padding = padding
208           See the description of the -P command line option.
209
210     prune_matches = yes | no
211           See the description of the -p command line option.
212
213     sudoers_base = dn
214           See the description of the -b command line option.
215
216     suppress = sections
217           See the description of the -s command line option.
218
219     Options on the command line will override values from the configuration
220     file.
221

FILES

223     /etc/cvtsudoers.conf      default configuration for cvtsudoers
224

EXAMPLES

226     Convert /etc/sudoers to LDIF (LDAP Data Interchange Format) where the
227     ldap.conf file uses a sudoers_base of my-domain,dc=com, storing the re‐
228     sult in sudoers.ldif:
229
230           $ cvtsudoers -b ou=SUDOers,dc=my-domain,dc=com -o sudoers.ldif \
231                        /etc/sudoers
232
233     Convert /etc/sudoers to JSON format, storing the result in sudoers.json:
234
235           $ cvtsudoers -f json -o sudoers.json /etc/sudoers
236
237     Parse /etc/sudoers and display only rules that match user ambrose on host
238     hastur:
239
240           $ cvtsudoers -f sudoers -m user=ambrose,host=hastur /etc/sudoers
241
242     Same as above, but expand aliases and prune out any non-matching users
243     and hosts from the expanded entries.
244
245           $ cvtsudoers -ep -f sudoers -m user=ambrose,host=hastur /etc/sudoers
246
247     Convert sudoers.ldif from LDIF to traditional sudoers format:
248
249           $ cvtsudoers -i ldif -f sudoers -o sudoers.new sudoers.ldif
250

SEE ALSO

252     sudoers(5), sudoers.ldap(5), sudo(8)
253

AUTHORS

255     Many people have worked on sudo over the years; this version consists of
256     code written primarily by:
257
258           Todd C. Miller
259
260     See the CONTRIBUTORS file in the sudo distribution
261     (https://www.sudo.ws/contributors.html) for an exhaustive list of people
262     who have contributed to sudo.
263

BUGS

265     If you feel you have found a bug in cvtsudoers, please submit a bug re‐
266     port at https://bugzilla.sudo.ws/
267

SUPPORT

269     Limited free support is available via the sudo-users mailing list, see
270     https://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search
271     the archives.
272

DISCLAIMER

274     cvtsudoers is provided “AS IS” and any express or implied warranties, in‐
275     cluding, but not limited to, the implied warranties of merchantability
276     and fitness for a particular purpose are disclaimed.  See the LICENSE
277     file distributed with sudo or https://www.sudo.ws/license.html for com‐
278     plete details.
279
280Sudo 1.9.7p2                   December 11, 2018                  Sudo 1.9.7p2
Impressum