saz / puppet-sudo

Manage sudo with Puppet on Debian-, RedHat- and SUSE-based linux distributions and some BSDs
Other
107 stars 215 forks source link

Add prefix parameter to prefix all sudoers.d entries #261

Closed traylenator closed 1 year ago

traylenator commented 3 years ago

A previous attempt in

https://github.com/saz/puppet-sudo/pull/248

to allow only files created with the suffix _puppet to be purged is faulty. In particular with

class{'sudo':
  suffix              => '_puppet',
  purge_ignore => '*[!_puppet]',
}

Does not work as files names shorter than the length of string _puppet are not ignored and so are deleted.

Switching to prefix

class{'sudo':
  prefix             => 'puppet_',
  purge_ignore => '[!puppet_]*',
}

Gives the desired result.


irb(main):001:0> Dir.glob('[!puppet_]*')
=> ["short", "longfilename"]

So the files `short` and `longfilename` will be ignored correctly.
zilchms commented 3 years ago

Looks good! Should it be added in a new major release in your opinion? Since these changes break functionality as it is now for some cases?

traylenator commented 3 years ago

Thanks for the reply.

What's the change in behaviour ?

zilchms commented 3 years ago

Maybe i am wrong, but by changing from suffix to prefix, i think we break working configurations. Or am i misreading this? Do we still retain the suffix parameter? If so, the previous behaviour is still retained and there should be no issue. Edit: Had another look at it, should be completely fine.

traylenator commented 3 years ago

Yeah just the documentation advice changes and as you it's a new paramter , the old useless for my usecase suffix is still there which is fine.

saz commented 3 years ago

@traylenator Please rebase and squash commits. Thanks!

saz commented 2 years ago

@traylenator Any news on this?

traylenator commented 2 years ago

Will sort out in couple of weeks time.

traylenator commented 2 years ago

Now to understand what I was trying to do with these tests .....

traylenator commented 2 years ago

@saz there I hope. Rebased , the acceptance tests were essentially rewritten as turned out to be easier.

Also it seems that visudo is now slightly stricter so needed some chmod 0400 for the non-puppet created sudo entries.

traylenator commented 2 years ago

@saz ?