Reading crontab of non-root unix user should read as that user

Crontab on Solaris and Illumos systems with auditing enabled tries to audit attempts by root to read non-root user crontabs. If chef-client runs without an auditing context (as happens by default when running in SMF), these crontab calls will fails with exit status 1.

By switching to the non-root user first (which somehow does not require auditing), we should be able to read user crontabs without an auditing context.

Note that I'm doing some jank at the end to ensure the existing crontab has a trailing newline. I'm open to suggestions if there's a less janky and preferred alternative.
Will do!

On Tue, Sep 23, 2014 at 10:36 PM, lamont-granquist <notifications@github.com
> wrote:

> In lib/chef/provider/cron/unix.rb:
>
> > @@ -29,14 +29,12 @@ class Unix < Chef::Provider::Cron
> >          private
> >
> >          def read_crontab
> > -          crontab = nil
> > -          status = popen4("crontab -l #{@new_resource.user}") do |pid, stdin, stdout, stderr|
> > -            crontab = stdout.read
> > -          end
> > +          status, crontab, stderr = run_command_and_return_stdout_stderr(:command => "/usr/bin/crontab -l",:user => @new_resource.user)
>
> oh run_command and friends is super deprecated, and I'd like to rip it out
> for Chef-12 completely, can you change this to the shell_out mixin?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/opscode/chef/pull/2107/files#r17954728>.
>



-- 
----
e s