opscode-cookbooks/sudo — pull request #45 by theckman (2014-05-01 01:30:29+00:00)
Title: [COOK-4612] Add support for the command alias (Cmnd_Alias) directive

This adds support for building a set of command aliases to use in your
sudoers file.

The Cmnd_Alias directive, in short, allows you to specify a list of
commands to allow (or disallow). You then provide the name of the
command alias entry in your commands Array. The alias name should be
capitalized-alphanumeric and may contain underscores[1]. This does
upcase the name within the template to ensure (to some degree) that the
alias name is proper.

There are two ways you can use command aliases in the provided patch.
The first is to specify the command aliases in your node attributes:

```Ruby
node.set['authorization']['sudo']['command_aliases'] =
[{ name: 'ALIAS', command_list:['/usr/bin/whoami'] }]
```

Assuming you include the default recipe, this will add the command
alias to your /etc/sudoers file. This can be used by any users or
groups in that file, or any inherited installed sudoers.d files by
referencing the alias in their command list.

The second is within the sudo LWRP by specifying the aliases you want:

```Ruby
sudo 'testgroup' do
action :create
group 'testgroup'
command_aliases [{ name: 'TEST_CMD', command_list: ['/bin/true'] }]
commands ['TEST_CMD']
end
```

When setting your command_aliases you want to provide a list of Hashes
with the following content:

* **name**: The uppercased string you want to call the alias
* **command_list**: An Array of Strings (commands) you want to include
in the alias while making sure to use the absolute path
for the executables.

To then reference this alias, you want to add the capitalized name of
the alias to the user or group's command list.

In addition to the functionality, the tests were updated to check for
these new behaviors. As a note, it appears that the tests on master are
currently failing due to a new version of Rubocop. I will be working on
a patch to fix the Rubocop tests. However, tests for this branch will
fail if you were to run them and have a newer version of Rubocop.

[1] http://www.sudo.ws/sudoers.man.html#x416c6961736573