{
    "mode": "man",
    "parameter": "CVTSUDOERS",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/man/CVTSUDOERS/json",
    "generated": "2026-10-22T12:45:28Z",
    "synopsis": "cvtsudoers [-ehMpV] [-b dn] [-c conffile] [-d deftypes] [-f outputformat] [-i inputformat]\n[-I  increment]  [-l  logfile]  [-m  filter]  [-o  outputfile]  [-O startpoint]\n[-P padding] [-s sections] [inputfile ...]",
    "sections": {
        "NAME": {
            "content": "cvtsudoers — convert between sudoers file formats\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "cvtsudoers [-ehMpV] [-b dn] [-c conffile] [-d deftypes] [-f outputformat] [-i inputformat]\n[-I  increment]  [-l  logfile]  [-m  filter]  [-o  outputfile]  [-O startpoint]\n[-P padding] [-s sections] [inputfile ...]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The cvtsudoers utility accepts one or more security policies in either sudoers or LDIF format\nas input, and generates a single policy of the specified format as output.  The default input\nformat is sudoers. The default output format is LDIF.  It is only possible to convert a  pol‐\nicy file that is syntactically correct.\n\nIf  no  inputfile is specified, or if it is ‘-’, the policy is read from the standard input.\nInput files may be optionally prefixed with a host name followed by a colon (‘:’) to make the\npolicy rules specific to a host when merging multiple files.  By default, the result is writ‐\nten to the standard output.\n\nThe options are as follows:\n",
            "subsections": [
                {
                    "name": "-b _ --base",
                    "content": "The base DN (distinguished name) that will be  used  when  performing  LDAP  queries.\nTypically  this is of the form “ou=SUDOers,dc=my-domain,dc=com” for the domain my-do‐\nmain.com.  If this option is not specified, the value of the SUDOERSBASE environment\nvariable will be used instead.  Only necessary when converting to LDIF format.\n",
                    "flag": "-b",
                    "long": "--base"
                },
                {
                    "name": "-c _ --config",
                    "content": "Specify the path to the configuration file.  Defaults to /etc/cvtsudoers.conf.\n",
                    "flag": "-c",
                    "long": "--config"
                },
                {
                    "name": "-d _ --defaults",
                    "content": "Only convert Defaults entries of the specified types.  One or more Defaults types may\nbe specified, separated by a comma (‘,’).  The supported types are:\n\nall      All Defaults entries.\n\nglobal   Global Defaults entries that are applied regardless of user, runas, host, or\ncommand.\n\nuser     Per-user Defaults entries.\n\nrunas    Per-runas user Defaults entries.\n\nhost     Per-host Defaults entries.\n\ncommand  Per-command Defaults entries.\n\nSee the Defaults section in sudoers(5) for more information.\n\nIf the -d option is not specified, all Defaults entries will be converted.\n",
                    "flag": "-d",
                    "long": "--defaults"
                },
                {
                    "name": "-e --expand-aliases",
                    "content": "Expand aliases in inputfile.  Aliases are  preserved  by  default  when  the  output\nformat is JSON or sudoers.\n",
                    "flag": "-e",
                    "long": "--expand-aliases"
                },
                {
                    "name": "-f _ --output-format",
                    "content": "Specify the output format (case-insensitive).  The following formats are supported:\n\nCSV      CSV  (comma-separated value) files are often used by spreadsheets and report\ngenerators.  See “CSV output format” for more details.\n\nJSON     JSON (JavaScript Object Notation) files are usually easier  for  third-party\napplications  to  consume  than the traditional sudoers format.  The various\nvalues have explicit types which  removes  much  of  the  ambiguity  of  the\nsudoers format.  See “JSON output format” for more details.\n\nLDIF     LDIF  (LDAP  Data  Interchange  Format)  files  can be imported into an LDAP\nserver for use with sudoers.ldap(5).\n\nConversion to LDIF has the following limitations:\n\n•  Command, host, runas, and user-specific Defaults lines cannot  be  trans‐\nlated as they don't have an equivalent in the sudoers LDAP schema.\n\n•  Command,  host,  runas, and user aliases are not supported by the sudoers\nLDAP schema so they are expanded during the conversion.\n\nsudoers  Traditional sudoers format.  A new sudoers file will be  reconstructed  from\nthe parsed input file.  Comments are not preserved and data from any include\nfiles will be output inline.\n\n--group-file=file\nWhen the -M option is also specified, perform group queries using file instead of the\nsystem group database.\n",
                    "flag": "-f",
                    "long": "--output-format"
                },
                {
                    "name": "-h --help",
                    "content": "Display a short help message to the standard output and exit.\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-i _ --input-format",
                    "content": "Specify the input format.  The following formats are supported:\n\nLDIF     LDIF  (LDAP  Data  Interchange  Format)  files  can be exported from an LDAP\nserver to convert security policies used by sudoers.ldap(5).  If a  base  DN\n(distinguished name) is specified, only sudoRole objects that match the base\nDN  will  be  processed.  Not all sudoOptions specified in a sudoRole can be\ntranslated from LDIF to sudoers format.\n\nsudoers  Traditional sudoers format.  This is the default input format.\n",
                    "flag": "-i",
                    "long": "--input-format"
                },
                {
                    "name": "-I _ --increment",
                    "content": "When generating LDIF output, increment each sudoOrder attribute by the specified num‐\nber.  Defaults to an increment of 1.\n",
                    "flag": "-I",
                    "long": "--increment"
                },
                {
                    "name": "-l _ --logfile",
                    "content": "Log conversion warnings to logfile instead of to the standard error.  This  is  par‐\nticularly useful when merging multiple sudoers files, which can generate a large num‐\nber of warnings.\n",
                    "flag": "-l",
                    "long": "--logfile"
                },
                {
                    "name": "-m _ --match",
                    "content": "Only output rules that match the specified filter.  A filter expression is made up of\none or more key = value pairs, separated by a comma (‘,’).  The key may be “cmnd” (or\n“cmd”),  “host”, “group”, or “user”.  For example, user = operator or host = www.  An\nupper-case CmndAlias, Hostalias, or UserAlias may  be  specified  as  the  “cmnd”,\n“host”, or “user”.\n\nA  matching  sudoers rule may also include users, groups, and hosts that are not part\nof the filter.  This can happen when a  rule  includes  multiple  users,  groups,  or\nhosts.  To prune out any non-matching user, group, or host from the rules, the -p op‐\ntion may be used.\n\nBy  default, the password and group databases are not consulted when matching against\nthe filter so the users and groups do not need to be present on the local system (see\nthe -M option).  Only aliases that are referenced by the filtered policy  rules  will\nbe displayed.\n",
                    "flag": "-m",
                    "long": "--match"
                },
                {
                    "name": "-M --match-local",
                    "content": "When  the  -m  option  is also specified, use password and group database information\nwhen matching users and groups in the filter.  Only users and groups  in  the  filter\nthat  exist on the local system will match, and a user's groups will automatically be\nadded to the filter.  If the -M is not specified, users and groups in the  filter  do\nnot  need  to exist on the local system, but all groups used for matching must be ex‐\nplicitly listed in the filter.\n",
                    "flag": "-M",
                    "long": "--match-local"
                },
                {
                    "name": "-o _ --output",
                    "content": "Write the converted output to outputfile.  If no outputfile is specified, or if  it\nis ‘-’, the converted sudoers policy will be written to the standard output.\n",
                    "flag": "-o",
                    "long": "--output"
                },
                {
                    "name": "-O _ --order-start",
                    "content": "When generating LDIF output, use the number specified by startpoint in the sudoOrder\nattribute  of  the first sudoRole object.  Subsequent sudoRole object use a sudoOrder\nvalue generated by adding an increment, see the -I option for details.  Defaults to a\nstarting point of 1.  A starting point of 0 will disable the generation of  sudoOrder\nattributes in the resulting LDIF file.\n\n--passwd-file=file\nWhen  the  -M  option is also specified, perform passwd queries using file instead of\nthe system passwd database.\n",
                    "flag": "-O",
                    "long": "--order-start"
                },
                {
                    "name": "-p --prune-matches",
                    "content": "When the -m option is also specified, cvtsudoers will prune out  non-matching  users,\ngroups, and hosts from matching entries.\n",
                    "flag": "-p",
                    "long": "--prune-matches"
                },
                {
                    "name": "-P _ --padding",
                    "content": "When  generating  LDIF output, construct the initial sudoOrder value by concatenating\norderstart and increment, padding the increment with  zeros  until  it  consists  of\npadding  digits.  For example, if orderstart is 1027, padding is 3, and increment is\n1, the value of sudoOrder for the first entry will be 1027000, followed  by  1027001,\n1027002, etc.  If the number of sudoRole entries is larger than the padding would al‐\nlow, cvtsudoers will exit with an error.  By default, no padding is performed.\n",
                    "flag": "-P",
                    "long": "--padding"
                },
                {
                    "name": "-s _ --suppress",
                    "content": "Suppress the output of specific sections of the security policy.  One or more section\nnames  may be specified, separated by a comma (‘,’).  The supported section name are:\ndefaults, aliases and privileges (which may be shortened to privs).\n",
                    "flag": "-s",
                    "long": "--suppress"
                },
                {
                    "name": "-V --version",
                    "content": "Print the cvtsudoers and sudoers grammar versions and exit.\n",
                    "flag": "-V",
                    "long": "--version"
                },
                {
                    "name": "Merging multiple files",
                    "content": "When multiple input files are specified, cvtsudoers will attempt to merge them into a  single\npolicy  file.   It is assumed that user and group names are consistent among the policy files\nto be merged.  For example, user “bob” on one host is the same as user “bob” on another host.\n\nWhen merging policy files, it is possible to prefix the input file name  with  a  host  name,\nseparated  by  a  colon  (‘:’).  When the files are merged, the host name will be used to re‐\nstrict the policy rules to that specific host where possible.\n\nThe merging process is performed as follows:\n\n•  Each input file is parsed into internal sudoers data structures.\n\n•  Aliases are merged and renamed as necessary to avoid conflicts.  In the event  of  a  con‐\nflict, the first alias found is left as-is and subsequent aliases of the same name are re‐\nnamed  with a numeric suffix separated with a underscore (‘’).  For example, if there are\ntwo different aliases named SERVERS, the first will be left as-is and the second  will  be\nrenamed  SERVERS1.   References to the renamed alias are also updated in the policy file.\nDuplicate aliases (those with identical contents) are pruned.\n\n•  Defaults settings are merged and duplicates are removed.  If there are  conflicts  in  the\nDefaults  settings,  a  warning is emitted for each conflict.  If a host name is specified\nwith the input file, cvtsudoers will change the global Defaults settings in that  file  to\nbe host-specific.  A warning is emitted for command, user, or runas-specific Defaults set‐\ntings which cannot be made host-specific.\n\n•  Per-user  rules  are  merged and duplicates are removed.  If a host name is specified with\nthe input file, cvtsudoers will change rules that specify a host name of ALL to  the  host\nname  associated  with  the  policy  file being merged.  The merging of rules is currently\nfairly simplistic but will be improved in a later release.\n\nIt is possible to merge policy files with differing formats.\n"
                },
                {
                    "name": "The cvtsudoers.conf file",
                    "content": "Options in the form “keyword =  value”  may  also  be  specified  in  a  configuration  file,\n/etc/cvtsudoers.conf by default.  The following keywords are recognized:\n\ndefaults = deftypes\nSee the description of the -d command line option.\n\nexpandaliases = yes | no\nSee the description of the -e command line option.\n\ngroupfile = file\nSee the description of the --group-file command line option.\n\ninputformat = ldif | sudoers\nSee the description of the -i command line option.\n\nmatch = filter\nSee the description of the -m command line option.\n\nmatchlocal = yes | no\nSee the description of the -M command line option.\n\norderincrement = increment\nSee the description of the -I command line option.\n\norderstart = startpoint\nSee the description of the -O command line option.\n\noutputformat = csv | json | ldif | sudoers\nSee the description of the -f command line option.\n\npadding = padding\nSee the description of the -P command line option.\n\npasswdfile = file\nSee the description of the --passwd-file command line option.\n\nprunematches = yes | no\nSee the description of the -p command line option.\n\nsudoersbase = dn\nSee the description of the -b command line option.\n\nsuppress = sections\nSee the description of the -s command line option.\n\nOptions on the command line will override values from the configuration file.\n"
                },
                {
                    "name": "JSON output format",
                    "content": "The sudoers JSON format may contain any of the following top-level objects:\n\nDefaults\nAn array of objects, each containing an Options array and an optional Binding array.\n\nThe  Options array consists of one or more objects, each containing a “name:value” pair\nthat corresponds to a sudoers Defaults setting.  Options that operate on  a  list  will\nalso  include  an operation entry in the object, with a value of “listassign” for ‘=’,\n“listadd” for ‘+=’, or “listremove” for ‘-=’.\n\nThe optional Binding  array  consists  of  one  or  more  objects,  each  containing  a\n“name:value”  pair and an optional negated entry, which will negate any comparison per‐\nformed with the object.  If a Binding is present, the setting will only take effect  if\none   of   the   specified   command,   hostname,  netgroup,  networkaddr,  nonunixgid,\nnonunixgroup, usergid, usergroup, userid, username, or alias entries match.\n\nFor example, the following sudoers entry:\n\nDefaults@somehost sethome, envkeep += DISPLAY\n\nconverts to:\n\n\"Defaults\": [\n{\n\"Binding\": [\n{ \"hostname\": \"somehost\" }\n],\n\"Options\": [\n{ \"sethome\": true },\n{\n\"operation\": \"listadd\",\n\"envkeep\": [\n\"DISPLAY\"\n]\n}\n]\n}\n]\n\nUserAliases\nA JSON object containing one or more sudoers UserAlias entries where each named  alias\nhas  as  its  value  an  array  containing one or more objects.  Each object contains a\n“name:value” pair and an optional negated entry, which will negate any comparison  per‐\nformed  with  the  object.   The name may be one of netgroup, nonunixgid, nonunixgroup,\nuseralias, usergid, usergroup, userid, or username.\n\nFor example, the following sudoers entry:\n\nUserAlias SYSADMIN = will, %wheel, +admin\n\nconverts to:\n\n\"UserAliases\": {\n\"SYSADMIN\": [\n{ \"username\": \"will\" },\n{ \"usergroup\": \"wheel\" },\n{ \"netgroup\": \"admin\" }\n]\n}\n\nRunasAliases\nA JSON object containing one or more sudoers  RunasAlias  entries,  where  each  named\nalias has as its value an array containing one or more objects.  Each object contains a\n“name:value”  pair and an optional negated entry, which will negate any comparison per‐\nformed with the object.  The name may be one  of  netgroup,  nonunixgid,  nonunixgroup,\nrunasalias, usergid, usergroup, userid, or username.\n\nFor example, the following sudoers entry:\n\nRunasAlias DB = oracle, sybase : OP = root, operator\n\nconverts to:\n\n\"RunasAliases\": {\n\"DB\": [\n{ \"username\": \"oracle\" },\n{ \"username\": \"sybase\" }\n],\n\"OP\": [\n{ \"username\": \"root\" },\n{ \"username\": \"operator\" }\n]\n}\n\nHostAliases\nA  JSON object containing one or more sudoers HostAlias entries where each named alias\nhas as its value an array containing one or  more  objects.   Each  object  contains  a\n“name:value”  pair and an optional negated entry, which will negate any comparison per‐\nformed with the object.  The name may be  one  of  hostalias,  hostname,  netgroup,  or\nnetworkaddr.\n\nFor example, the following sudoers entries:\n\nHostAlias DORMNET = 128.138.243.0, 128.138.204.0/24\nHostAlias SERVERS = boulder, refuge\n\nconvert to:\n\n\"HostAliases\": {\n\"DORMNET\": [\n{ \"networkaddr\": \"128.138.243.0\" },\n{ \"networkaddr\": \"128.138.204.0/24\" }\n],\n\"SERVERS\": [\n{ \"hostname\": \"boulder\" },\n{ \"hostname\": \"refuge\" }\n]\n}\n\nCmndAliases\nA  JSON object containing one or more sudoers CmndAlias entries where each named alias\nhas as its value an array containing one or  more  objects.   Each  object  contains  a\n“name:value”  pair and an optional negated entry, which will negate any comparison per‐\nformed with the object.  The name may be either another cmndalias or  a  command.   For\nexample, the following sudoers entries:\n\nCmndAlias SHELLS = /bin/bash, /bin/csh, /bin/sh, /bin/zsh\nCmndAlias VIPW = /usr/bin/chpass, /usr/bin/chfn, /usr/bin/chsh, \\\n/usr/bin/passwd, /usr/sbin/vigr, /usr/sbin/vipw\n\nconvert to:\n\n\"CmndAliases\": {\n\"SHELLS\": [\n{ \"command\": \"/bin/bash\" },\n{ \"command\": \"/bin/csh\" },\n{ \"command\": \"/bin/sh\" },\n{ \"command\": \"/bin/zsh\" }\n],\n\"VIPW\": [\n{ \"command\": \"/usr/bin/chpass\" },\n{ \"command\": \"/usr/bin/chfn\" },\n{ \"command\": \"/usr/bin/chsh\" },\n{ \"command\": \"/usr/bin/passwd\" },\n{ \"command\": \"/usr/sbin/vigr\" },\n{ \"command\": \"/usr/sbin/vipw\" }\n]\n}\n\nUserSpecs\nA  JSON  array  containing  one or more objects, each representing a sudoers UserSpec.\nEach object in the UserSpecs array should contain a UserList array, a HostList array\nand a CmndSpecs array.\n\nA UserList consists of one or more objects.  Each object contains a “name:value”  pair\nand  an optional negated entry, which will negate any comparison performed with the ob‐\nject.  The name may be one of netgroup, nonunixgid, nonunixgroup,  useralias,  usergid,\nusergroup,  userid,  or username.  If username is set to the special value ALL, it will\nmatch any user.\n\nA HostList consists of one or more objects.  Each object contains a “name:value”  pair\nand  an optional negated entry, which will negate any comparison performed with the ob‐\nject.  The name may be one  of  hostalias,  hostname,  netgroup,  or  networkaddr.   If\nhostname is set to the special value ALL, it will match any host.\n\nThe CmndSpecs array consists of one or more JSON objects describing a command that may\nbe  run.  Each CmndSpecs is made up of a Commands array, an optional runasusers array,\nan optional runasgroups array, and an optional Options array.\n\nThe Commands array consists of one or more objects containing  “name:value”  pair  ele‐\nments.  The following names and values are supported:\n\ncommand  A  string  containing the command to run.  The special value ALL it will match\nany command.\n\nnegated  A boolean value that, if true, will negate any comparison performed  with  the\nobject.\n\nsha224   A string containing the SHA224 digest of the command.\n\nsha256   A string containing the SHA256 digest of the command.\n\nsha384   A string containing the SHA384 digest of the command.\n\nsha512   A string containing the SHA512 digest of the command.\n\nThe  runasusers  array  consists of objects describing users the command may be run as.\nEach object contains a “name:value” pair and an  optional  negated  entry,  which  will\nnegate  any  comparison  performed  with  the object.  The name may be one of netgroup,\nnonunixgid, nonunixgroup, runasalias, usergid,  usergroup,  userid,  or  username.   If\nusername  is  set to the special value ALL, it will match any user.  If username is set\nto the empty string “”, it will match the invoking user.\n\nThe runasgroups array consists of objects describing groups the command may be run  as.\nEach  object  contains  a  “name:value”  pair and an optional negated entry, which will\nnegate any comparison performed with the object.  The name may be  one  of  runasalias,\nusergid, or usergroup.  If usergroup is set to the special value ALL, it will match any\ngroup.\n\nThe  Options  array  is  of  the  same  format  as the one in the Defaults object.  Any\nTagSpec entries in sudoers are converted to Options.  A user with  “sudo  ALL”  privi‐\nleges  will automatically have the setenv option enabled to match the implicit behavior\nprovided by sudoers.\n\nFor example, the following sudoers entry:\n\nmillert ALL = (ALL : ALL) NOPASSWD: ALL, !/usr/bin/id\n\nconverts to:\n\n\"UserSpecs\": [\n{\n\"UserList\": [\n{ \"username\": \"millert\" }\n],\n\"HostList\": [\n{ \"hostname\": \"ALL\" }\n],\n\"CmndSpecs\": [\n{\n\"runasusers\": [\n{ \"username\": \"ALL\" }\n],\n\"runasgroups\": [\n{ \"usergroup\": \"ALL\" }\n],\n\"Options\": [\n{ \"authenticate\": false },\n{ \"setenv\": true }\n],\n\"Commands\": [\n{ \"command\": \"ALL\" },\n{\n\"command\": \"/usr/bin/id\",\n\"negated\": true\n}\n]\n}\n]\n}\n]\n"
                },
                {
                    "name": "CSV output format",
                    "content": "CSV (comma-separated value) files are often used by spreadsheets and report generators.   For\nCSV  output,  cvtsudoers  double quotes strings that contain commas.  For each literal double\nquote character present inside the string, two double quotes  are  output.   This  method  of\nquoting commas is compatible with most spreadsheet programs.\n\nThere are three possible sections in cvtsudoers's CSV output, each separated by a blank line:\n\ndefaults\nThis  section  includes  any Defaults settings in sudoers.  The defaults section begins\nwith the following heading:\n\ndefaultstype,binding,name,operator,value\n\nThe fields are as follows:\n\ndefaultstype\nThe type of Defaults setting; one of defaults,  defaultscommand,  defaultshost,\ndefaultsrunas, or defaultsuser.\n\nbinding\nFor  defaultscommand,  defaultshost,  defaultsrunas, and defaultsuser this is\nthe value that must match for the setting to be applied.\n\nname  The name of the Defaults setting.\n\noperator\nThe operator determines how the value is applied to the setting.  It may  be  ei‐\nther ‘=’ (assignment), ‘+=’ (append), or ‘-=’ (remove).\n\nvalue\nThe setting's value, usually a string or, for settings used in a boolean context,\ntrue or false.\n\naliases\nThis  section  includes  any CmndAlias HostAlias, RunasAlias, or UserAlias, entries\nfrom sudoers.  The aliases section begins with the following heading:\n\naliastype,aliasname,members\n\nThe fields are as follows:\n\naliastype\nThe type of alias; one of CmndAlias, HostAlias, RunasAlias, or UserAlias.\n\naliasname\nThe name of the alias; a string starting with an upper-case letter that  consists\nof upper-case letters, digits, or underscores.\n\nmembers\nA comma-separated list of members belonging to the alias.  Due to the use of com‐\nmas, members is surrounded by double quotes if it contains more than one member.\n\nrules\nThis  section  includes the sudoers rules that grant privileges.  The rules section be‐\ngins with the following heading:\n\nrule,user,host,runusers,rungroups,options,command\n\nThe fields are as follows:\n\nrule  This field indicates a sudoers rule entry.\n\nuser  The user the rule applies to.  This may also be a Unix group (preceded by  a  ‘%’\ncharacter),  a non-Unix group (preceded by ‘%:’) or a netgroup (preceded by a ‘+’\ncharacter) or a UserAlias.  If set to the special value ALL, it will  match  any\nuser.\n\nhost  The  host  the  rule  applies to.  This may also be a netgroup (preceded by a ‘+’\ncharacter) or a HostAlias.  If set to the special value ALL, it will  match  any\nhost.\n\nrunusers\nAn  optional  comma-separated list of users (or RunasAliases) the command may be\nrun as.  If it contains more than one member, the value is surrounded  by  double\nquotes.   If set to the special value ALL, it will match any user.  If empty, the\nroot user is assumed.\n\nrungroups\nAn optional comma-separated list of groups (or RunasAliases) the command may  be\nrun  as.   If it contains more than one member, the value is surrounded by double\nquotes.  If set to the special value ALL, it will match any group.  If empty, the\nrunuser's group is used.\n\noptions\nAn optional list of Defaults settings to apply to the command.  Any TagSpec  en‐\ntries in sudoers are converted to options.\n\ncommands\nA list of commands, with optional arguments, that the user is allowed to run.  If\nset to the special value ALL, it will match any command.\n\nFor example, the following sudoers entry:\n\nmillert ALL = (ALL : ALL) NOPASSWD: ALL, !/usr/bin/id\n\nconverts to:\n\nrule,millert,ALL,ALL,ALL,\"!authenticate\",\"ALL,!/usr/bin/id\"\n"
                }
            ]
        },
        "FILES": {
            "content": "/etc/cvtsudoers.conf      default configuration for cvtsudoers\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Convert  /etc/sudoers  to LDIF (LDAP Data Interchange Format) where the ldap.conf file uses a\nsudoersbase of my-domain,dc=com, storing the result in sudoers.ldif:\n\n$ cvtsudoers -b ou=SUDOers,dc=my-domain,dc=com -o sudoers.ldif \\\n/etc/sudoers\n\nConvert /etc/sudoers to JSON format, storing the result in sudoers.json:\n\n$ cvtsudoers -f json -o sudoers.json /etc/sudoers\n\nParse /etc/sudoers and display only rules that match user ambrose on host hastur:\n\n$ cvtsudoers -f sudoers -m user=ambrose,host=hastur /etc/sudoers\n\nSame as above, but expand aliases and prune out any non-matching users and hosts from the ex‐\npanded entries.\n\n$ cvtsudoers -ep -f sudoers -m user=ambrose,host=hastur /etc/sudoers\n\nConvert sudoers.ldif from LDIF to traditional sudoers format:\n\n$ cvtsudoers -i ldif -f sudoers -o sudoers.new sudoers.ldif\n\nMerge a global sudoers file with two host-specific policy files from the  hosts  “xyzzy”  and\n“plugh”:\n\n$ cvtsudoers -f sudoers -o sudoers.merged sudoers \\\nxyzzy:sudoers.xyzzy plugh:sudoers.plugh\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "sudoers(5), sudoers.ldap(5), sudo(8)\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Many people have worked on sudo over the years; this version consists of code written primar‐\nily by:\n\nTodd C. Miller\n\nSee  the  CONTRIBUTORS.md  file in the sudo distribution (https://www.sudo.ws/about/contribu‐\ntors/) for an exhaustive list of people who have contributed to sudo.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "If you believe you have  found  a  bug  in  cvtsudoers,  you  can  submit  a  bug  report  at\nhttps://bugzilla.sudo.ws/\n",
            "subsections": []
        },
        "SUPPORT": {
            "content": "Limited    free    support    is   available   via   the   sudo-users   mailing   list,   see\nhttps://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search the archives.\n",
            "subsections": []
        },
        "DISCLAIMER": {
            "content": "cvtsudoers is provided “AS IS” and any express or implied warranties, including, but not lim‐\nited to, the implied warranties of merchantability and fitness for a particular  purpose  are\ndisclaimed.   See  the LICENSE.md file distributed with sudo or https://www.sudo.ws/about/li‐\ncense/ for complete details.\n\nSudo 1.9.15p5                             January 16, 2023                             CVTSUDOERS(1)",
            "subsections": []
        }
    },
    "summary": "cvtsudoers — convert between sudoers file formats",
    "flags": [
        {
            "flag": "-b",
            "long": "--base",
            "arg": null,
            "description": "The base DN (distinguished name) that will be used when performing LDAP queries. Typically this is of the form “ou=SUDOers,dc=my-domain,dc=com” for the domain my-do‐ main.com. If this option is not specified, the value of the SUDOERSBASE environment variable will be used instead. Only necessary when converting to LDIF format."
        },
        {
            "flag": "-c",
            "long": "--config",
            "arg": null,
            "description": "Specify the path to the configuration file. Defaults to /etc/cvtsudoers.conf."
        },
        {
            "flag": "-d",
            "long": "--defaults",
            "arg": null,
            "description": "Only convert Defaults entries of the specified types. One or more Defaults types may be specified, separated by a comma (‘,’). The supported types are: all All Defaults entries. global Global Defaults entries that are applied regardless of user, runas, host, or command. user Per-user Defaults entries. runas Per-runas user Defaults entries. host Per-host Defaults entries. command Per-command Defaults entries. See the Defaults section in sudoers(5) for more information. If the -d option is not specified, all Defaults entries will be converted."
        },
        {
            "flag": "-e",
            "long": "--expand-aliases",
            "arg": null,
            "description": "Expand aliases in inputfile. Aliases are preserved by default when the output format is JSON or sudoers."
        },
        {
            "flag": "-f",
            "long": "--output-format",
            "arg": null,
            "description": "Specify the output format (case-insensitive). The following formats are supported: CSV CSV (comma-separated value) files are often used by spreadsheets and report generators. See “CSV output format” for more details. JSON JSON (JavaScript Object Notation) files are usually easier for third-party applications to consume than the traditional sudoers format. The various values have explicit types which removes much of the ambiguity of the sudoers format. See “JSON output format” for more details. LDIF LDIF (LDAP Data Interchange Format) files can be imported into an LDAP server for use with sudoers.ldap(5). Conversion to LDIF has the following limitations: • Command, host, runas, and user-specific Defaults lines cannot be trans‐ lated as they don't have an equivalent in the sudoers LDAP schema. • Command, host, runas, and user aliases are not supported by the sudoers LDAP schema so they are expanded during the conversion. sudoers Traditional sudoers format. A new sudoers file will be reconstructed from the parsed input file. Comments are not preserved and data from any include files will be output inline. --group-file=file When the -M option is also specified, perform group queries using file instead of the system group database."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "Display a short help message to the standard output and exit."
        },
        {
            "flag": "-i",
            "long": "--input-format",
            "arg": null,
            "description": "Specify the input format. The following formats are supported: LDIF LDIF (LDAP Data Interchange Format) files can be exported from an LDAP server to convert security policies used by sudoers.ldap(5). If a base DN (distinguished name) is specified, only sudoRole objects that match the base DN will be processed. Not all sudoOptions specified in a sudoRole can be translated from LDIF to sudoers format. sudoers Traditional sudoers format. This is the default input format."
        },
        {
            "flag": "-I",
            "long": "--increment",
            "arg": null,
            "description": "When generating LDIF output, increment each sudoOrder attribute by the specified num‐ ber. Defaults to an increment of 1."
        },
        {
            "flag": "-l",
            "long": "--logfile",
            "arg": null,
            "description": "Log conversion warnings to logfile instead of to the standard error. This is par‐ ticularly useful when merging multiple sudoers files, which can generate a large num‐ ber of warnings."
        },
        {
            "flag": "-m",
            "long": "--match",
            "arg": null,
            "description": "Only output rules that match the specified filter. A filter expression is made up of one or more key = value pairs, separated by a comma (‘,’). The key may be “cmnd” (or “cmd”), “host”, “group”, or “user”. For example, user = operator or host = www. An upper-case CmndAlias, Hostalias, or UserAlias 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 op‐ tion 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."
        },
        {
            "flag": "-M",
            "long": "--match-local",
            "arg": null,
            "description": "When the -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 ex‐ plicitly listed in the filter."
        },
        {
            "flag": "-o",
            "long": "--output",
            "arg": null,
            "description": "Write the converted output to outputfile. If no outputfile is specified, or if it is ‘-’, the converted sudoers policy will be written to the standard output."
        },
        {
            "flag": "-O",
            "long": "--order-start",
            "arg": null,
            "description": "When generating LDIF output, use the number specified by startpoint in the sudoOrder attribute of the first sudoRole object. Subsequent sudoRole object use a sudoOrder value generated by adding an increment, see the -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 When the -M option is also specified, perform passwd queries using file instead of the system passwd database."
        },
        {
            "flag": "-p",
            "long": "--prune-matches",
            "arg": null,
            "description": "When the -m option is also specified, cvtsudoers will prune out non-matching users, groups, and hosts from matching entries."
        },
        {
            "flag": "-P",
            "long": "--padding",
            "arg": null,
            "description": "When generating LDIF output, construct the initial sudoOrder value by concatenating orderstart and increment, padding the increment with zeros until it consists of padding digits. For example, if orderstart is 1027, padding is 3, and increment is 1, the value of sudoOrder for the first entry will be 1027000, followed by 1027001, 1027002, etc. If the number of sudoRole entries is larger than the padding would al‐ low, cvtsudoers will exit with an error. By default, no padding is performed."
        },
        {
            "flag": "-s",
            "long": "--suppress",
            "arg": null,
            "description": "Suppress the output of specific sections of the security policy. One or more section names may be specified, separated by a comma (‘,’). The supported section name are: defaults, aliases and privileges (which may be shortened to privs)."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "Print the cvtsudoers and sudoers grammar versions and exit."
        }
    ],
    "examples": [
        "Convert  /etc/sudoers  to LDIF (LDAP Data Interchange Format) where the ldap.conf file uses a",
        "sudoersbase of my-domain,dc=com, storing the result in sudoers.ldif:",
        "$ 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 ex‐",
        "panded 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"
    ],
    "see_also": [
        {
            "name": "sudoers",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/sudoers/5/json"
        },
        {
            "name": "sudoers.ldap",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/sudoers.ldap/5/json"
        },
        {
            "name": "sudo",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/sudo/8/json"
        }
    ]
}