Skip to content

Commit 11329df

Browse files
committed
check one file for syntax and rm params fixes #223
1 parent 3fc67ef commit 11329df

File tree

3 files changed

+1
-71
lines changed

3 files changed

+1
-71
lines changed

REFERENCE.md

-32
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ The following parameters are available in the `sudo` class:
7373
* [`content_string`](#-sudo--content_string)
7474
* [`secure_path`](#-sudo--secure_path)
7575
* [`ldap_enable`](#-sudo--ldap_enable)
76-
* [`delete_on_error`](#-sudo--delete_on_error)
77-
* [`validate_single`](#-sudo--validate_single)
7876
* [`config_dir_keepme`](#-sudo--config_dir_keepme)
7977
* [`use_sudoreplay`](#-sudo--use_sudoreplay)
8078
* [`wheel_config`](#-sudo--wheel_config)
@@ -282,27 +280,6 @@ Enable ldap support on the package
282280

283281
Default value: `false`
284282

285-
##### <a name="-sudo--delete_on_error"></a>`delete_on_error`
286-
287-
Data type: `Boolean`
288-
289-
True if you want that the configuration is deleted on an error
290-
during a complete visudo -c run. If false it will just return
291-
an error and will add a comment to the sudoers configuration so
292-
that the resource will be checked at the following run.
293-
294-
Default value: `true`
295-
296-
##### <a name="-sudo--validate_single"></a>`validate_single`
297-
298-
Data type: `Boolean`
299-
300-
Do a validate on the "single" file in the sudoers.d directory.
301-
If the validate fail the file will not be saved or changed
302-
if a file already exist.
303-
304-
Default value: `false`
305-
306283
##### <a name="-sudo--config_dir_keepme"></a>`config_dir_keepme`
307284

308285
Data type: `Boolean`
@@ -456,7 +433,6 @@ The following parameters are available in the `sudo::conf` defined type:
456433
* [`template`](#-sudo--conf--template)
457434
* [`sudo_config_dir`](#-sudo--conf--sudo_config_dir)
458435
* [`sudo_file_name`](#-sudo--conf--sudo_file_name)
459-
* [`sudo_syntax_path`](#-sudo--conf--sudo_syntax_path)
460436

461437
##### <a name="-sudo--conf--ensure"></a>`ensure`
462438

@@ -516,14 +492,6 @@ Set a custom file name for the snippet
516492

517493
Default value: `undef`
518494

519-
##### <a name="-sudo--conf--sudo_syntax_path"></a>`sudo_syntax_path`
520-
521-
Data type: `Any`
522-
523-
Path to use for executing the sudo syntax check
524-
525-
Default value: `'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'`
526-
527495
## Functions
528496

529497
### <a name="sudo--defaults"></a>`sudo::defaults`

manifests/conf.pp

+1-26
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
# @param sudo_file_name
2727
# Set a custom file name for the snippet
2828
#
29-
# @param sudo_syntax_path
30-
# Path to use for executing the sudo syntax check
31-
#
3229
# @example
3330
# sudo::conf { 'admins':
3431
# source => 'puppet:///files/etc/sudoers.d/admins',
@@ -42,7 +39,6 @@
4239
$template = undef,
4340
$sudo_config_dir = undef,
4441
$sudo_file_name = undef,
45-
$sudo_syntax_path = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
4642
) {
4743
include sudo
4844

@@ -108,22 +104,8 @@
108104
}
109105

110106
if $ensure == 'present' {
111-
if $sudo::validate_single {
112-
$validate_cmd_real = 'visudo -c -f %'
113-
} else {
114-
$validate_cmd_real = undef
115-
}
116-
if $sudo::delete_on_error {
117-
$notify_real = Exec["sudo-syntax-check for file ${cur_file}"]
118-
$delete_cmd = "( rm -f '${cur_file_real}' && exit 1)"
119-
} else {
120-
$notify_real = Exec["sudo-syntax-check for file ${cur_file}"]
121-
$errormsg = "Error on global-syntax-check with file ${cur_file_real}"
122-
$delete_cmd = "( echo '${errormsg}' && echo '#${errormsg}' >>${cur_file_real} && exit 1)"
123-
}
107+
$validate_cmd_real = 'visudo -c -f %'
124108
} else {
125-
$delete_cmd = ''
126-
$notify_real = undef
127109
$validate_cmd_real = undef
128110
}
129111

@@ -135,14 +117,7 @@
135117
mode => $sudo::params::config_file_mode,
136118
source => $source,
137119
content => $content_real,
138-
notify => $notify_real,
139120
require => File[$sudo_config_dir_real],
140121
validate_cmd => $validate_cmd_real,
141122
}
142-
143-
exec { "sudo-syntax-check for file ${cur_file}":
144-
command => "visudo -c || ${delete_cmd}",
145-
refreshonly => true,
146-
path => $sudo_syntax_path,
147-
}
148123
}

manifests/init.pp

-13
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,6 @@
8686
# @param ldap_enable
8787
# Enable ldap support on the package
8888
#
89-
# @param delete_on_error
90-
# True if you want that the configuration is deleted on an error
91-
# during a complete visudo -c run. If false it will just return
92-
# an error and will add a comment to the sudoers configuration so
93-
# that the resource will be checked at the following run.
94-
#
95-
# @param validate_single
96-
# Do a validate on the "single" file in the sudoers.d directory.
97-
# If the validate fail the file will not be saved or changed
98-
# if a file already exist.
99-
#
10089
# @param config_dir_keepme
10190
# Add a .keep-me file to the config dir
10291
#
@@ -141,8 +130,6 @@
141130
Optional[String[1]] $content_string = undef,
142131
Optional[String[1]] $secure_path = $sudo::params::secure_path,
143132
Boolean $ldap_enable = false,
144-
Boolean $delete_on_error = true,
145-
Boolean $validate_single = false,
146133
Boolean $config_dir_keepme = $sudo::params::config_dir_keepme,
147134
Boolean $use_sudoreplay = false,
148135
Enum['absent','password','nopassword'] $wheel_config = $sudo::params::wheel_config,

0 commit comments

Comments
 (0)