Skip to content

Commit

Permalink
Merge pull request #25 from jordiprats/master
Browse files Browse the repository at this point in the history
improved regex
  • Loading branch information
jordiprats authored Dec 9, 2019
2 parents e518038 + 6bcf321 commit 2a43a2b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.1.31

* improved regex for sudoers.d files

## 0.1.30

* bugfix: sudo files cannot contain dots
Expand Down
2 changes: 1 addition & 1 deletion manifests/cmdalias.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#TODO: refer per tindre dependencies automatiques
include ::sudoers

$cmdname_cleanup = regsubst($cmdname, '[^a-zA-Z]+', '_')
$cmdname_cleanup = regsubst($cmdname, '[^a-zA-Z0-9]+', '_', 'G')

file { "/etc/sudoers.d/${order}_00_cmdalias_${cmdname_cleanup}":
owner => 'root',
Expand Down
4 changes: 2 additions & 2 deletions manifests/defaults.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

include ::sudoers

$username_cleanup = regsubst($username, '[^a-zA-Z]+', '_')
$defaults_cleanup = regsubst($default_name, '[^a-zA-Z]+', '_')
$username_cleanup = regsubst($username, '[^a-zA-Z0-9]+', '_', 'G')
$defaults_cleanup = regsubst($default_name, '[^a-zA-Z0-9]+', '_', 'G')

# Defaults:nrpe !requiretty
file { "/etc/sudoers.d/${order}_defaults_${defaults_cleanup}_${username_cleanup}":
Expand Down
2 changes: 1 addition & 1 deletion manifests/sudo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
) {
include ::sudoers

$name_cleanup = regsubst($name, '[^a-zA-Z]+', '_')
$name_cleanup = regsubst($name, '[^a-zA-Z0-9]+', '_', 'G')

file { "/etc/sudoers.d/${order}_10_sudo_${name_cleanup}":
ensure => $ensure,
Expand Down
6 changes: 3 additions & 3 deletions manifests/useralias.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#TODO: refer per tindre dependencies automatiques
include ::sudoers

validate_array($users)

#NAME ::= [A-Z]([A-Z][0-9]_)*
validate_re($useraliasname, '[A-Z]([A-Z][0-9]_)*')

file { "/etc/sudoers.d/${order}_00_useralias_${useraliasname}":
$useraliasname_cleanup = regsubst($useraliasname, '[^A-Z0-9]+', '_', 'G')

file { "/etc/sudoers.d/${order}_00_useralias_${useraliasname_cleanup}":
owner => 'root',
group => 'root',
mode => '0440',
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eyp-sudoers",
"version": "0.1.30",
"version": "0.1.31",
"author": "eyp",
"summary": "manages sudoers",
"license": "Apache-2.0",
Expand Down

0 comments on commit 2a43a2b

Please sign in to comment.