CVTSUDOERS(1) | User Commands | CVTSUDOERS(1) |
cvtsudoers
—
cvtsudoers |
[-ehMpV ] [-b
dn] [-c
conf_file] [-d
deftypes] [-f
output_format] [-i
input_format] [-I
increment] [-l
log_file] [-m
filter] [-o
output_file] [-O
start_point] [-P
padding] [-s
sections] [input_file
...] |
cvtsudoers
utility accepts one or more security
policies in either sudoers or LDIF format as input, and
generates a single policy of the specified format as output. The default input
format is sudoers. The default output format is LDIF. It is
only possible to convert a policy file that is syntactically correct.
If no input_file is specified, or if it is
‘-
’, the policy is read from the
standard input. Input files may be optionally prefixed with a host name
followed by a colon (‘:
’) to make the
policy rules specific to a host when merging multiple files. By default, the
result is written to the standard output.
The options are as follows:
-b
dn,
--base
=dnou=SUDOers,dc=my-domain,dc=com
for the domain
my-domain.com
. If this option is not specified,
the value of the SUDOERS_BASE
environment variable
will be used instead. Only necessary when converting to LDIF format.-c
conf_file,
--config
=conf_file-d
deftypes,
--defaults
=deftypesDefaults
entries of the specified
types. One or more Defaults
types may be
specified, separated by a comma
(‘,
’). The supported types are:
See the Defaults section in sudoers(5) for more information.
If the -d
option is not specified, all
Defaults
entries will be converted.
-e
,
--expand-aliases
-f
output_format,
--output-format
=output_formatcvtsudoers
double quotes strings that contain commas. For each literal double
quote character present inside the string, two double quotes are
output. This method of quoting commas is compatible with most
spreadsheet programs.Conversion to LDIF has the following limitations:
--group-file
=file-M
option is also specified, perform
group queries using file instead of the system group
database.-h
,
--help
-i
input_format,
--input-format
=input_format-I
increment,
--increment
=increment-l
log_file,
--logfile
=log_file-m
filter,
--match
=filter,
’). The
key may be “cmnd” (or
“cmd”), “host”, “group”, or
“user”. For example, user
= operator or
host =
www. An upper-case Cmnd_Alias, Host_alias, or
Host_Alias may be specified as the “cmnd”,
“host”, or “user”.
A matching sudoers rule may also include
users, groups, and hosts that are not part of the
filter. This can happen when a rule includes
multiple users, groups, or hosts. To prune out any non-matching user,
group, or host from the rules, the -p
option may
be used.
By default, the password and group databases are not consulted
when matching against the filter so the users and groups do not need to
be present on the local system (see the -M
option). Only aliases that are referenced by the filtered policy rules
will be displayed.
-M
,
--match-local
-m
option is also specified, use password
and group database information when matching users and groups in the
filter. Only users and groups in the filter that exist on the local system
will match, and a user's groups will automatically be added to the filter.
If the -M
is not specified,
users and groups in the filter do not need to exist on the local system,
but all groups used for matching must be explicitly listed in the
filter.-o
output_file,
--output
=output_file-
’, the converted
sudoers policy will be written to the standard
output.-O
start_point,
--order-start
=start_point-I
option for details. Defaults to a starting
point of 1. A starting point of 0 will disable the generation of sudoOrder
attributes in the resulting LDIF file.--passwd-file
=file-M
option is also specified, perform
passwd queries using file instead of the system
passwd database.-p
,
--prune-matches
-m
option is also specified,
cvtsudoers
will prune out non-matching users,
groups, and hosts from matching entries.-P
padding,
--padding
=paddingcvtsudoers
will exit with an error. By default, no
padding is performed.-s
sections,
--suppress
=sections,
’). The supported section
name are: defaults, aliases and
privileges (which may be shortened to
privs).-V
,
--version
cvtsudoers
and sudoers
grammar versions and exit.cvtsudoers
will
attempt to merge them into a single policy file. It is assumed that user and
group names are consistent among the policy files to be merged. For example,
user “bob” on one host is the same as user “bob”
on another host.
When merging policy files, it is possible to prefix the input file
name with a host name, separated by a colon
(‘:
’). When the files are merged, the
host name will be used to restrict the policy rules to that specific host
where possible.
The merging process is performed as follows:
_
’). For example, if
there are two different aliases named SERVERS
, the
first will be left as-is and the second will be renamed
SERVERS_1
. References to the renamed alias are
also updated in the policy file. Duplicate aliases (those with identical
contents) are pruned.cvtsudoers
will change the global Defaults
settings in that file to be host-specific. A warning is emitted for
command, user, or runas-specific Defaults settings which cannot be made
host-specific.cvtsudoers
will
change rules that specify a host name of ALL
to
the host name associated with the policy file being merged. The merging of
rules is currently fairly simplistic but will be improved in a later
release.It is possible to merge policy files with differing formats.
-d
command line
option.-e
command line
option.--group-file
command
line option.-i
command line
option.-m
command line
option.-M
command line
option.-I
command line
option.-O
command line
option.-f
command line
option.-P
command line
option.--passwd-file
command
line option.-p
command line
option.-b
command line
option.-s
command line
option.Options on the command line will override values from the configuration file.
$ cvtsudoers -b ou=SUDOers,dc=my-domain,dc=com -o sudoers.ldif \ /etc/sudoers
Convert /etc/sudoers to JSON format, storing the result in sudoers.json:
$ cvtsudoers -f json -o sudoers.json /etc/sudoers
Parse /etc/sudoers and display only rules that match user ambrose on host hastur:
$ cvtsudoers -f sudoers -m user=ambrose,host=hastur /etc/sudoers
Same as above, but expand aliases and prune out any non-matching users and hosts from the expanded entries.
$ cvtsudoers -ep -f sudoers -m user=ambrose,host=hastur /etc/sudoers
Convert sudoers.ldif from LDIF to traditional sudoers format:
$ cvtsudoers -i ldif -f sudoers -o sudoers.new sudoers.ldif
Merge a global sudoers file with two host-specific policy files from the hosts “xyzzy” and “plugh”:
$ cvtsudoers -f sudoers -o sudoers.merged sudoers \ xyzzy:sudoers.xyzzy plugh:sudoers.plugh
sudo
over the years; this
version consists of code written primarily by:
See the CONTRIBUTORS.md file in the sudo
distribution (https://www.sudo.ws/about/contributors/) for an exhaustive
list of people who have contributed to sudo
.
cvtsudoers
, you
can submit a bug report at https://bugzilla.sudo.ws/
cvtsudoers
is provided “AS IS” and any
express or implied warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose are
disclaimed. See the LICENSE.md file distributed with
sudo
or https://www.sudo.ws/about/license/ for
complete details.
February 16, 2022 | Sudo 1.9.11p3 |