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
61                 default 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
90                           include 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
111                 attribute by the specified number.  Defaults to an increment
112                 of 1.
113
114     -m filter, --match=filter
115                 Only output rules that match the specified filter.  A filter
116                 expression is made up of one or more key = value pairs, sepa‐
117                 rated by a comma (‘,’).  The key may be “user”, “group” or
118                 “host”.  For example, user = operator or host = www.  An
119                 upper-case User_Alias or Host_Alias may be specified as the
120                 “user” or “host”.
121
122                 A matching sudoers rule may also include users, groups and
123                 hosts that are not part of the filter.  This can happen when
124                 a rule includes multiple users, groups or hosts.  To prune
125                 out any non-matching user, group or host from the rules, the
126                 -p option may be used.
127
128                 By default, the password and group databases are not con‐
129                 sulted when matching against the filter so the users and
130                 groups do not need to be present on the local system (see the
131                 -M option).  Only aliases that are referenced by the filtered
132                 policy rules will be displayed.
133
134     -M, --match-local
135                 When the -m option is also specified, use password and group
136                 database information when matching users and groups in the
137                 filter.  Only users and groups in the filter that exist on
138                 the local system will match, and a user's groups will auto‐
139                 matically be added to the filter.  If the -M is not speci‐
140                 fied, users and groups in the filter do not need to exist on
141                 the local system, but all groups used for matching must be
142                 explicitly listed in the filter.
143
144     -o output_file, --output=output_file
145                 Write the converted output to output_file.  If no output_file
146                 is specified, or if it is ‘-’, the converted sudoers policy
147                 will be written to the standard output.
148
149     -O start_point, --order-start=start_point
150                 When generating LDIF output, use the number specified by
151                 start_point in the sudoOrder attribute of the first sudoRole
152                 object.  Subsequent sudoRole object use a sudoOrder value
153                 generated by adding an increment, see the -I option for
154                 details.  Defaults to a starting point of 1.  A starting
155                 point of 0 will disable the generation of sudoOrder
156                 attributes in the resulting LDIF file.
157
158     -p, --prune-matches
159                 When the -m option is also specified, cvtsudoers will prune
160                 out non-matching users, groups and hosts from matching
161                 entries.
162
163     -P padding, --padding=padding
164                 When generating LDIF output, construct the initial sudoOrder
165                 value by concatenating order_start and increment, padding the
166                 increment with zeros until it consists of padding digits.
167                 For example, if order_start is 1027, padding is 3, and
168                 increment is 1, the value of sudoOrder for the first entry
169                 will be 1027000, followed by 1027001, 1027002, etc.  If the
170                 number of sudoRole entries is larger than the padding would
171                 allow, cvtsudoers will exit with an error.  By default, no
172                 padding is performed.
173
174     -s sections, --suppress=sections
175                 Suppress the output of specific sections of the security pol‐
176                 icy.  One or more section names may be specified, separated
177                 by a comma (‘,’).  The supported section name are: defaults,
178                 aliases and privileges (which may be shortened to privs).
179
180     -V, --version
181                 Print the cvtsudoers and sudoers grammar versions and exit.
182
183     Options in the form “keyword = value” may also be specified in a configu‐
184     ration file, /etc/cvtsudoers.conf by default.  The following keywords are
185     recognized:
186
187     defaults = deftypes
188           See the description of the -d command line option.
189
190     expand_aliases = yes | no
191           See the description of the -e command line option.
192
193     input_format = ldif | sudoers
194           See the description of the -i command line option.
195
196     match = filter
197           See the description of the -m command line option.
198
199     order_increment = increment
200           See the description of the -I command line option.
201
202     order_start = start_point
203           See the description of the -O command line option.
204
205     output_format = json | ldif | sudoers
206           See the description of the -f command line option.
207
208     padding = padding
209           See the description of the -P command line option.
210
211     prune_matches = yes | no
212           See the description of the -p command line option.
213
214     sudoers_base = dn
215           See the description of the -b command line option.
216
217     suppress = sections
218           See the description of the -s command line option.
219
220     Options on the command line will override values from the configuration
221     file.
222

FILES

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

EXAMPLES

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

SEE ALSO

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

AUTHORS

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

BUGS

266     If you feel you have found a bug in cvtsudoers, please submit a bug
267     report at https://bugzilla.sudo.ws/
268

SUPPORT

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

DISCLAIMER

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