Skip to content

Commit

Permalink
no more tmpdir
Browse files Browse the repository at this point in the history
  • Loading branch information
keeleysam committed Mar 27, 2018
1 parent c56c0f2 commit a27b19f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
8 changes: 1 addition & 7 deletions lib/facter/profiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@

require 'puppet/util/plist'
require 'time'
require 'tmpdir'

profiles = {}

if Facter.value(:os)['release']['major'].to_i >= 12

path = Dir.mktmpdir + '/profiles.plist'

# why????
Facter::Util::Resolution.exec(['/usr/bin/profiles', '-C', '-o', path].join(' '))

plist = Puppet::Util::Plist.read_plist_file(path)
plist = Puppet::Util::Plist.parse_plist(Facter::Util::Resolution.exec(['/usr/bin/profiles', '-C', '-o', 'stdout-xml'].join(' ')))

if plist.key?('_computerlevel')
for item in plist['_computerlevel']
Expand Down
7 changes: 2 additions & 5 deletions lib/puppet/provider/profile_manager/macos.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'puppet/util/plist'
require 'tmpdir'

Puppet::Type.type(:profile_manager).provide :macos do
desc 'Provides management of mobileconfig profiles on macOS.'
Expand Down Expand Up @@ -61,12 +60,10 @@ def writereceipt
end

def getinstalledstate
# profiles will only write to a nonexistant file, so we make a temp dir for it to write to.
path = Dir.mktmpdir + '/profiles.plist'

Puppet::Util::Execution.execute(['/usr/bin/profiles', '-C', '-o', path])
Puppet::Util::Execution.execute(['/usr/bin/profiles', '-C', '-o', 'stdout-xml'])

plist = Puppet::Util::Plist.read_plist_file(path)
plist = Puppet::Util::Plist.parse_plist(Puppet::Util::Execution.execute(['/usr/bin/profiles', '-C', '-o', 'stdout-xml']))

if plist.key?('_computerlevel')
for item in plist['_computerlevel']
Expand Down

0 comments on commit a27b19f

Please sign in to comment.