ruby-jss 1.5.3 → 1.6.0b1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGES.md +25 -0
- data/THANKS.md +3 -2
- data/lib/jamf.rb +0 -1
- data/lib/jamf/api/base_classes/collection_resource.rb +5 -5
- data/lib/jamf/client.rb +3 -3
- data/lib/jamf/client/management_action.rb +2 -3
- data/lib/jamf/composer.rb +2 -2
- data/lib/jamf/utility.rb +35 -7
- data/lib/jss.rb +0 -1
- data/lib/jss/api_connection.rb +1 -0
- data/lib/jss/api_object/configuration_profile.rb +2 -2
- data/lib/jss/api_object/network_segment.rb +6 -5
- data/lib/jss/api_object/policy.rb +50 -0
- data/lib/jss/api_object/script.rb +242 -352
- data/lib/jss/api_object/user.rb +1 -1
- data/lib/jss/client/management_action.rb +1 -2
- data/lib/jss/composer.rb +2 -2
- data/lib/jss/utility.rb +116 -53
- data/lib/jss/version.rb +1 -1
- metadata +7 -7
data/lib/jss/api_object/user.rb
CHANGED
@@ -168,7 +168,7 @@ module JSS
|
|
168
168
|
@phone_number = @init_data[:phone_number]
|
169
169
|
@position = @init_data[:position]
|
170
170
|
@ldap_server = JSS::APIObject.get_name @init_data[:ldap_server]
|
171
|
-
@ldap_server_id = @init_data[:ldap_server][:id]
|
171
|
+
@ldap_server_id = @init_data[:ldap_server][:id] unless @init_data[:ldap_server].nil?
|
172
172
|
@sites = @init_data[:sites] ? @init_data[:sites] : []
|
173
173
|
|
174
174
|
if @init_data[:links]
|
@@ -103,8 +103,7 @@ module JSS
|
|
103
103
|
orig_flags = flags
|
104
104
|
prefs['apps'] << { 'bundle-id' => MGMT_ACTION_BUNDLE_ID, 'flags' => flags }
|
105
105
|
end
|
106
|
-
|
107
|
-
plist.open('w') { |f| f.write prefs.to_plist }
|
106
|
+
plist.open('w') { |f| f.write JSS.xml_plist_from(prefs) }
|
108
107
|
system HUP_NOTIF_CTR_CMD if hup
|
109
108
|
orig_flags
|
110
109
|
end
|
data/lib/jss/composer.rb
CHANGED
@@ -126,7 +126,7 @@ module JSS
|
|
126
126
|
###
|
127
127
|
comp_plist_out = Pathname.new "/tmp/#{PKG_BUNDLE_ID_PFX}-#{pkg_filename}.plist"
|
128
128
|
system "#{PKGBUILD} --analyze --root '#{root}' '#{comp_plist_out}'"
|
129
|
-
comp_plist =
|
129
|
+
comp_plist = JSS.parse_plist comp_plist_out
|
130
130
|
|
131
131
|
### if the plist is empty, there are no bundles in the pkg
|
132
132
|
if comp_plist[0].nil?
|
@@ -141,7 +141,7 @@ module JSS
|
|
141
141
|
bndl['BundleHasStrictIdentifier'] = false
|
142
142
|
end
|
143
143
|
### write out the edits
|
144
|
-
comp_plist_out.open('w') { |f| f.write comp_plist
|
144
|
+
comp_plist_out.open('w') { |f| f.write JSS.xml_plist_from(comp_plist) }
|
145
145
|
comp_plist_arg = "--component-plist '#{comp_plist_out}'"
|
146
146
|
end
|
147
147
|
|
data/lib/jss/utility.rb
CHANGED
@@ -50,8 +50,7 @@ module JSS
|
|
50
50
|
12 => 6,
|
51
51
|
13 => 6,
|
52
52
|
14 => 6,
|
53
|
-
15 => 7
|
54
|
-
16 => 12
|
53
|
+
15 => 7
|
55
54
|
}
|
56
55
|
|
57
56
|
# Hash of 'major' => 'minor'
|
@@ -59,7 +58,7 @@ module JSS
|
|
59
58
|
# e.g. the highest release of 11 is 11.12
|
60
59
|
#
|
61
60
|
# 12 is the default for the current OS and higher
|
62
|
-
# (and hoping apple doesn't release 11.13)
|
61
|
+
# (and hoping apple doesn't release, e.g., 11.13)
|
63
62
|
MAC_OS_MAXS = {
|
64
63
|
11 => 12,
|
65
64
|
12 => 12,
|
@@ -74,13 +73,13 @@ module JSS
|
|
74
73
|
}
|
75
74
|
|
76
75
|
# Converts an OS Version into an Array of equal or higher OS versions, up to
|
77
|
-
# some non-existant max, hopefully far in the future, currently 20.12
|
76
|
+
# some non-existant max, hopefully far in the future, currently 20.12.10
|
78
77
|
#
|
79
78
|
# This array can then be joined with commas and used as the value of the
|
80
79
|
# os_requirements for Packages and Scripts.
|
81
80
|
#
|
82
81
|
# It's unlikely that this method, as written, will still be in use by
|
83
|
-
# the release of macOS 20.12, but currently thats the upper limit.
|
82
|
+
# the release of macOS 20.12.10, but currently thats the upper limit.
|
84
83
|
#
|
85
84
|
# Hopefully well before then JAMF will implement a "minimum OS" in Jamf Pro
|
86
85
|
# itself, then we could avoid the inherant limitations in using a method like
|
@@ -93,13 +92,13 @@ module JSS
|
|
93
92
|
# Apple has never released more than 11 updates to a version of macOS
|
94
93
|
# (that being 10.4), so hopefully 12 is enough
|
95
94
|
#
|
96
|
-
# Since Big Sur might report itself as either '10.16
|
95
|
+
# Since Big Sur might report itself as either '10.16' or '11.x.x', this method
|
97
96
|
# will allow for both possibilities, and the array will contain whatever
|
98
97
|
# iterations needed for both version numbers
|
99
98
|
#
|
100
99
|
# @param min_os [String] the mimimum OS version to expand, e.g. ">=10.9.4" or "11.1"
|
101
100
|
#
|
102
|
-
# @return [Array] Nearly all potential OS versions from the minimum to 20.12
|
101
|
+
# @return [Array] Nearly all potential OS versions from the minimum to 20.12.10
|
103
102
|
#
|
104
103
|
# @example
|
105
104
|
# JSS.expand_min_os ">=10.9.4" # => returns this array
|
@@ -119,63 +118,100 @@ module JSS
|
|
119
118
|
|
120
119
|
# split the version into major, minor and maintenance release numbers
|
121
120
|
major, minor, maint = min_os.split('.')
|
121
|
+
minor = 'x' if minor.nil? || minor == '0'
|
122
122
|
maint = 'x' if maint.nil? || maint == '0'
|
123
123
|
|
124
124
|
ok_oses = []
|
125
125
|
|
126
|
-
# if major == 11 e.g. big sur, e.g. 10.16,
|
127
|
-
# reset major & min so that we get coverage for both
|
128
|
-
# 10.16 and 11, since clients may report it as either
|
129
|
-
if major == '11'
|
130
|
-
major = '10'
|
131
|
-
maint = minor
|
132
|
-
minor = '16'
|
133
|
-
end
|
134
|
-
|
135
126
|
# Deal with 10.x.x up to 10.16
|
136
127
|
if major == '10'
|
137
|
-
# if the maint release number is an "x" just start the list of OK OS's with it
|
138
|
-
if maint == 'x'
|
139
|
-
ok_oses << min_os
|
140
|
-
|
141
|
-
# otherwise, start with it and explicitly add all maint releases for
|
142
|
-
# that maint version. if unknown because its a current or future OS,
|
143
|
-
# go as h
|
144
|
-
else
|
145
|
-
max_maint_for_minor = OS_TEN_MAXS[minor.to_i]
|
146
|
-
(maint.to_i..max_maint_for_minor).each do |m|
|
147
|
-
ok_oses << "#{major}.#{minor}.#{m}"
|
148
|
-
end # each m
|
149
|
-
end
|
150
128
|
|
151
|
-
#
|
152
|
-
#
|
153
|
-
|
154
|
-
|
155
|
-
|
129
|
+
# In big sur with SYSTEM_VERSION_COMPAT
|
130
|
+
# set, it will only ever report as `10.16`
|
131
|
+
# So if major is 10 and minor is 16, ignore maint
|
132
|
+
# and start explicitly at '10.16'
|
133
|
+
if minor == '16'
|
134
|
+
ok_oses << '10.16'
|
156
135
|
|
157
|
-
#
|
136
|
+
# But for Catalina and below, we need to
|
137
|
+
# expand things out
|
138
|
+
else
|
139
|
+
# e.g. 10.14.x
|
140
|
+
# doesn't expand to anything
|
141
|
+
if maint == 'x'
|
142
|
+
ok_oses << "10.#{minor}.x"
|
143
|
+
|
144
|
+
# e.g. 10.15.5
|
145
|
+
# expand to 10.15.5, 10.15.6, 10.15.7
|
146
|
+
else
|
147
|
+
max_maint_for_minor = OS_TEN_MAXS[minor.to_i]
|
148
|
+
|
149
|
+
(maint.to_i..max_maint_for_minor).each do |m|
|
150
|
+
ok_oses << "#{major}.#{minor}.#{m}"
|
151
|
+
end # each m
|
152
|
+
end # if maint == x
|
153
|
+
|
154
|
+
# now if we started below catalina, account for everything
|
155
|
+
# up to 10.15.x
|
156
|
+
if minor.to_i < 15
|
157
|
+
((minor.to_i + 1)..15).each { |v| ok_oses << "10.#{v}.x" }
|
158
|
+
end
|
159
|
+
|
160
|
+
# and add big sur with SYSTEM_VERSION_COMPAT
|
161
|
+
ok_oses << '10.16'
|
162
|
+
end # if minor == 16
|
163
|
+
|
164
|
+
# now reset these so we can go higher
|
158
165
|
major = '11'
|
159
|
-
minor =
|
166
|
+
minor = 'x'
|
167
|
+
maint = 'x'
|
160
168
|
end # if major == 10
|
161
169
|
|
162
|
-
#
|
170
|
+
# if the min os is 11.0.0 or equiv, and we aven't added 10.16
|
171
|
+
# for SYSTEM_VERSION_COMPAT, add it now
|
172
|
+
if ['11', '11.x', '11.x.x', '11.0', '11.0.0'].include?(min_os) && !ok_oses.include?('10.16')
|
173
|
+
ok_oses << '10.16'
|
174
|
+
end
|
175
|
+
|
176
|
+
# e.g. 11.x, or 11.x.x
|
177
|
+
# expand to 11.x, 12.x, 13.x, ... 20.x
|
163
178
|
if minor == 'x'
|
164
|
-
ok_oses << "#{
|
165
|
-
|
179
|
+
((major.to_i)..20).each { |v| ok_oses << "#{v}.x" }
|
180
|
+
|
181
|
+
# e.g. 11.2.x
|
182
|
+
# expand to 11.2.x, 11.3.x, ... 11.12.x,
|
183
|
+
# 12.x, 13.x, ... 20.x
|
184
|
+
elsif maint == 'x'
|
185
|
+
# first expand the minors out to their max
|
186
|
+
# e.g. 11.2.x, 11.3.x, ... 11.12.x
|
166
187
|
max_minor_for_major = MAC_OS_MAXS[major.to_i]
|
167
|
-
(minor.to_i..max_minor_for_major).each do |m|
|
168
|
-
ok_oses << "#{major}.#{m}"
|
188
|
+
((minor.to_i)..max_minor_for_major).each do |m|
|
189
|
+
ok_oses << "#{major}.#{m}.x"
|
169
190
|
end # each m
|
170
|
-
end # if minor == x
|
171
191
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
192
|
+
# then add the majors out to 20
|
193
|
+
((major.to_i + 1)..20).each { |v| ok_oses << "#{v}.x" }
|
194
|
+
|
195
|
+
# e.g. 11.2.3
|
196
|
+
# expand to 11.2.3, 11.2.4, ... 11.2.10,
|
197
|
+
# 11.3.x, 11.4.x, ... 11.12.x,
|
198
|
+
# 12.x, 13.x, ... 20.x
|
199
|
+
else
|
200
|
+
# first expand the maints out to 10
|
201
|
+
# e.g. 11.2.3, 11.2.4, ... 11.2.10
|
202
|
+
((maint.to_i)..10).each { |mnt| ok_oses << "#{major}.#{minor}.#{mnt}" }
|
203
|
+
|
204
|
+
# then expand the minors out to their max
|
205
|
+
# e.g. 11.3.x, ... 11.12.x
|
206
|
+
max_minor_for_major = MAC_OS_MAXS[major.to_i]
|
207
|
+
((minor.to_i + 1)..max_minor_for_major).each { |min| ok_oses << "#{major}.#{min}.x" }
|
208
|
+
|
209
|
+
# then add the majors out to 20
|
210
|
+
((major.to_i + 1)..20).each { |v| ok_oses << "#{v}.x" }
|
211
|
+
end
|
176
212
|
|
177
213
|
ok_oses
|
178
|
-
end
|
214
|
+
end # def self.expand_min_os(min_os)
|
179
215
|
|
180
216
|
# Scripts and packages can have processor limitations.
|
181
217
|
# This method tests a given processor, against a requirement
|
@@ -274,19 +310,25 @@ module JSS
|
|
274
310
|
{ stringform: valstr, arrayform: valarr }
|
275
311
|
end # to_s_and_a
|
276
312
|
|
277
|
-
# Parse a plist into a Ruby data structure.
|
278
|
-
#
|
279
|
-
#
|
313
|
+
# Parse a plist into a Ruby data structure. The plist parameter may be
|
314
|
+
# a String containing an XML plist, or a path to a plist file, or it may be
|
315
|
+
# a Pathname object pointing to a plist file. The plist files may be XML or
|
316
|
+
# binary.
|
280
317
|
#
|
281
318
|
# @param plist[Pathname, String] the plist XML, or the path to a plist file
|
282
319
|
#
|
320
|
+
# @param symbol_keys[Boolean] should any Hash keys in the result be converted
|
321
|
+
# into Symbols rather than remain as Strings?
|
322
|
+
#
|
283
323
|
# @return [Object] the parsed plist as a ruby hash,array, etc.
|
284
324
|
#
|
285
|
-
def self.parse_plist(plist)
|
325
|
+
def self.parse_plist(plist, symbol_keys: false)
|
326
|
+
require 'cfpropertylist'
|
327
|
+
|
286
328
|
# did we get a string of xml, or a string pathname?
|
287
329
|
case plist
|
288
330
|
when String
|
289
|
-
return
|
331
|
+
return CFPropertyList.native_types(CFPropertyList::List.new(data: plist).value, symbol_keys) if plist.include? '</plist>'
|
290
332
|
|
291
333
|
plist = Pathname.new plist
|
292
334
|
when Pathname
|
@@ -298,9 +340,30 @@ module JSS
|
|
298
340
|
# if we're here, its a Pathname
|
299
341
|
raise JSS::MissingDataError, "No such file: #{plist}" unless plist.file?
|
300
342
|
|
301
|
-
|
343
|
+
CFPropertyList.native_types(CFPropertyList::List.new(file: plist).value, symbol_keys)
|
302
344
|
end # parse_plist
|
303
345
|
|
346
|
+
# Convert any ruby data to an XML plist.
|
347
|
+
#
|
348
|
+
# NOTE: Binary data is tricky. Easiest way is to pass in a
|
349
|
+
# Pathname or IO object (anything that responds to `read` and
|
350
|
+
# returns a bytestring)
|
351
|
+
# and then the CFPropertyList.guess method will read it and
|
352
|
+
# convert it to a Plist <data> element with base64 encoded
|
353
|
+
# data.
|
354
|
+
# For more info, see CFPropertyList.guess
|
355
|
+
#
|
356
|
+
# @param data [Object] the data to be converted, usually a Hash
|
357
|
+
#
|
358
|
+
# @return [String] the object converted into an XML plist
|
359
|
+
#
|
360
|
+
def self.xml_plist_from(data)
|
361
|
+
require 'cfpropertylist'
|
362
|
+
plist = CFPropertyList::List.new
|
363
|
+
plist.value = CFPropertyList.guess(data, convert_unknown_to_string: true)
|
364
|
+
plist.to_str(CFPropertyList::List::FORMAT_XML)
|
365
|
+
end
|
366
|
+
|
304
367
|
# Converts anything that responds to #to_s to a Time, or nil
|
305
368
|
#
|
306
369
|
# Return nil if the item is nil, 0 or an empty String.
|
data/lib/jss/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0b1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lasell
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-05-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: CFPropertyList
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '3.
|
20
|
+
version: '3.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '3.
|
27
|
+
version: '3.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: ruby-mysql
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -392,9 +392,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
392
392
|
version: 2.3.0
|
393
393
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
394
394
|
requirements:
|
395
|
-
- - "
|
395
|
+
- - ">"
|
396
396
|
- !ruby/object:Gem::Version
|
397
|
-
version:
|
397
|
+
version: 1.3.1
|
398
398
|
requirements: []
|
399
399
|
rubygems_version: 3.0.3
|
400
400
|
signing_key:
|