ruby-jss 0.6.3 → 0.6.4
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/data/ruby-jss.conf.example +181 -0
- data/lib/jss.rb +9 -0
- data/lib/jss/api_object/distribution_point.rb +1 -1
- data/lib/jss/api_object/osx_configuration_profile.rb +59 -60
- data/lib/jss/api_object/package.rb +17 -2
- data/lib/jss/api_object/self_servable.rb +54 -55
- data/lib/jss/configuration.rb +41 -29
- data/lib/jss/db_connection.rb +24 -20
- data/lib/jss/utility.rb +4 -2
- data/lib/jss/version.rb +1 -1
- data/lib/ruby-jss.rb +2 -0
- metadata +28 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6681d7531f34a10d2ba31f13428c9391446a15ec
|
4
|
+
data.tar.gz: 80fae35e805326660e8cf0372ba14fd3bb3652f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd89d7e838147899adcbed3042d795a632e182428567bb675965fa3850eb3956a30b4c8e975b453f77ac52e5ba97ada2cbdb950ac3ae1b409b8414ca898a30de
|
7
|
+
data.tar.gz: f755fabd0f11caddb9d20291842f774d141aa51c935d7e9cb0bacf5a0db58a1270aa7195546d8211c20f8d00786cc5f2e52265ca4d730210aaf439a387500018
|
@@ -0,0 +1,181 @@
|
|
1
|
+
#####################
|
2
|
+
#
|
3
|
+
# ruby-jss configuration.
|
4
|
+
#
|
5
|
+
# This file should be stored at /etc/ruby-jss.conf
|
6
|
+
# on all machines that use ruby-jss
|
7
|
+
#
|
8
|
+
# A personal copy can also be stored in your home folder as
|
9
|
+
# ~/.ruby-jss.conf and the settings there will override those
|
10
|
+
# from the system-wide file in /etc.
|
11
|
+
#
|
12
|
+
# When the JSS module is loaded, the conf files are read into
|
13
|
+
# an instance of JSS::Configuration, and stored in the constant JSS::CONFIG
|
14
|
+
#
|
15
|
+
# The values loaded are used by default for making API and database connections.
|
16
|
+
# However, they can be overridden per-connection by specifying values when
|
17
|
+
# calling the #connect methods.
|
18
|
+
#
|
19
|
+
# The file format is one attribute per line, thus:
|
20
|
+
#
|
21
|
+
# attr_name: value
|
22
|
+
#
|
23
|
+
# Lines that don't start with a known attribute name followed by a colon
|
24
|
+
# are ignored. If an attribute is defined more than once, the last one wins.
|
25
|
+
#
|
26
|
+
# Known attributes are listed and defined in the ruby-jss.conf.default file
|
27
|
+
# in the rubygem folder's data folder
|
28
|
+
# (e.g. /Library/Ruby/Gems/2.0.0/gems/ruby-jss-0.6.3/data/ruby-jss.conf.default )
|
29
|
+
#
|
30
|
+
# The conf file may be edited with any text editor, however developers should
|
31
|
+
# look at the manipulation methods in the JSS::Configuration class.
|
32
|
+
#
|
33
|
+
|
34
|
+
### - api_server_name
|
35
|
+
### The hostname of the server for JSS REST API connections.
|
36
|
+
###
|
37
|
+
### *** REQUIRED ***
|
38
|
+
###
|
39
|
+
### NOTE, this is the (fully-qualified) hostname, e.g.
|
40
|
+
### 'casper.myorg.org'. Don't use a URL.
|
41
|
+
###
|
42
|
+
### If you leave this blank:
|
43
|
+
### d3 will not work, nor any other code that expects a
|
44
|
+
### configured hostname
|
45
|
+
###
|
46
|
+
api_server_name:
|
47
|
+
|
48
|
+
### - api_server_port
|
49
|
+
### The port for connecting to the JSS REST API
|
50
|
+
###
|
51
|
+
### If you leave this blank:
|
52
|
+
### Defaults to 8443
|
53
|
+
###
|
54
|
+
api_server_port:
|
55
|
+
|
56
|
+
### - api_ssl_version
|
57
|
+
### The SSL version to use for the API connection
|
58
|
+
###
|
59
|
+
### If you leave this blank:
|
60
|
+
### Defaults to 'TLSv1'
|
61
|
+
###
|
62
|
+
api_ssl_version:
|
63
|
+
|
64
|
+
### - api_verify_cert
|
65
|
+
### Should the API connections require a verifiable/trusted certificate?
|
66
|
+
### If you are using a self-signed cert. for your JSS, and have not
|
67
|
+
### deployed it as a trusted cert on all your clients, you should
|
68
|
+
### set this to 'false', and be aware of the risks.
|
69
|
+
###
|
70
|
+
### If you leave this blank:
|
71
|
+
### Defaults to true
|
72
|
+
###
|
73
|
+
api_verify_cert:
|
74
|
+
|
75
|
+
### - api_username
|
76
|
+
### The username to use when making an API connection.
|
77
|
+
###
|
78
|
+
### *** REQUIRED ***
|
79
|
+
###
|
80
|
+
### Note that the passwords are not storeable here!!
|
81
|
+
### see https://github.com/PixarAnimationStudios/ruby-jss/blob/master/README.md#passwords
|
82
|
+
###
|
83
|
+
### If you leave this blank:
|
84
|
+
### d3 may break, as well as any other code that
|
85
|
+
### expects a configured api user name
|
86
|
+
###
|
87
|
+
api_username:
|
88
|
+
|
89
|
+
### - api_timeout_open
|
90
|
+
### The timeout (in seconds) for connecting to the API
|
91
|
+
###
|
92
|
+
### If you leave this blank:
|
93
|
+
### Defaults to 60
|
94
|
+
###
|
95
|
+
api_timeout_open:
|
96
|
+
|
97
|
+
### - api_timeout
|
98
|
+
### The response timeout (in seconds) for API requests
|
99
|
+
###
|
100
|
+
### If you leave this blank:
|
101
|
+
### Defaults to 60
|
102
|
+
###
|
103
|
+
api_timeout:
|
104
|
+
|
105
|
+
### - db_server_name
|
106
|
+
### The hostname of the server for JSS MySQL connections.
|
107
|
+
###
|
108
|
+
###
|
109
|
+
### *** REQUIRED for d3 ***
|
110
|
+
###
|
111
|
+
### Note: if you aren't accessing the database directly,
|
112
|
+
### you don't need this. However, if you're using d3
|
113
|
+
### you will need this.
|
114
|
+
###
|
115
|
+
### NOTE, this is the (fully-qualified) hostname, e.g.
|
116
|
+
### 'casper.myorg.org'. Don't provide a URL.
|
117
|
+
###
|
118
|
+
### If you leave this blank:
|
119
|
+
### d3 will break, and any other code that expects a
|
120
|
+
### configured database server name
|
121
|
+
###
|
122
|
+
db_server_name:
|
123
|
+
|
124
|
+
### - db_server_port
|
125
|
+
### The port for MySQL connections
|
126
|
+
###
|
127
|
+
### If you leave this blank:
|
128
|
+
### Defaults defaults to 3306
|
129
|
+
###
|
130
|
+
db_server_port:
|
131
|
+
|
132
|
+
### - db_server_socket
|
133
|
+
### The MySQL socket path, if needed for local connections
|
134
|
+
###
|
135
|
+
### If you leave this blank:
|
136
|
+
### Defaults to '/var/mysql/mysql.sock'
|
137
|
+
###
|
138
|
+
db_server_socket:
|
139
|
+
|
140
|
+
### - db_username
|
141
|
+
### The username for MySQL connections
|
142
|
+
###
|
143
|
+
### If you leave this blank:
|
144
|
+
### d3 might break, as well as any other code that expiects
|
145
|
+
### a configured db user name
|
146
|
+
###
|
147
|
+
db_username:
|
148
|
+
|
149
|
+
### - db_name
|
150
|
+
###
|
151
|
+
###
|
152
|
+
### The name of the MySQL database that holds JSS data
|
153
|
+
###
|
154
|
+
### If you leave this blank:
|
155
|
+
### Defaults to 'jamfsoftware'
|
156
|
+
###
|
157
|
+
db_name:
|
158
|
+
|
159
|
+
### - db_connect_timeout
|
160
|
+
### The timeout (in seconds) for connecting to the database
|
161
|
+
###
|
162
|
+
### If you leave this blank:
|
163
|
+
### Defaults to 60
|
164
|
+
###
|
165
|
+
db_connect_timeout:
|
166
|
+
|
167
|
+
### - db_read_timeout
|
168
|
+
### The timeout (in seconds) for reading results from the database
|
169
|
+
###
|
170
|
+
### If you leave this blank:
|
171
|
+
### Defaults to 60
|
172
|
+
###
|
173
|
+
db_read_timeout:
|
174
|
+
|
175
|
+
### - db_write_timeout
|
176
|
+
### The timeout (in seconds) for writing to the database
|
177
|
+
###
|
178
|
+
### If you leave this blank:
|
179
|
+
### Defaults to 60
|
180
|
+
###
|
181
|
+
db_write_timeout:
|
data/lib/jss.rb
CHANGED
@@ -27,6 +27,13 @@
|
|
27
27
|
###
|
28
28
|
module JSS
|
29
29
|
|
30
|
+
### The minimum Ruby version that works with this gem
|
31
|
+
MINIMUM_RUBY_VERSION = "2.0.0"
|
32
|
+
|
33
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new(MINIMUM_RUBY_VERSION)
|
34
|
+
raise "Can't use the JSS module, ruby itself must be version #{MINIMUM_RUBY_VERSION} or greater."
|
35
|
+
end
|
36
|
+
|
30
37
|
#####################################
|
31
38
|
### Required Libraries, etc
|
32
39
|
#####################################
|
@@ -61,6 +68,8 @@ module JSS
|
|
61
68
|
### in the deprecated 'jssuser' resource
|
62
69
|
MINIMUM_SERVER_VERSION = "9.4"
|
63
70
|
|
71
|
+
|
72
|
+
|
64
73
|
### The current local UTC offset as a fraction of a day (Time.now.utc_offset is the offset in seconds,
|
65
74
|
### 60*60*24 is the seconds in a day)
|
66
75
|
TIME_ZONE_OFFSET = Rational(Time.now.utc_offset, 60*60*24)
|
@@ -483,7 +483,7 @@ module JSS
|
|
483
483
|
###
|
484
484
|
def unmount
|
485
485
|
return nil unless mounted?
|
486
|
-
if system "umount '#{@mountpoint}'"
|
486
|
+
if system "/sbin/umount '#{@mountpoint}'"
|
487
487
|
@mountpoint.rmdir if @mountpoint.directory? and (not @mountpoint.mountpoint?)
|
488
488
|
@mounted = false
|
489
489
|
else
|
@@ -1,31 +1,30 @@
|
|
1
1
|
### Copyright 2016 Pixar
|
2
|
-
###
|
2
|
+
###
|
3
3
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
4
|
### with the following modification; you may not use this file except in
|
5
5
|
### compliance with the Apache License and the following modification to it:
|
6
6
|
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
-
###
|
7
|
+
###
|
8
8
|
### 6. Trademarks. This License does not grant permission to use the trade
|
9
9
|
### names, trademarks, service marks, or product names of the Licensor
|
10
10
|
### and its affiliates, except as required to comply with Section 4(c) of
|
11
11
|
### the License and to reproduce the content of the NOTICE file.
|
12
|
-
###
|
12
|
+
###
|
13
13
|
### You may obtain a copy of the Apache License at
|
14
|
-
###
|
14
|
+
###
|
15
15
|
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
-
###
|
16
|
+
###
|
17
17
|
### Unless required by applicable law or agreed to in writing, software
|
18
18
|
### distributed under the Apache License with the above modification is
|
19
19
|
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
20
|
### KIND, either express or implied. See the Apache License for the specific
|
21
21
|
### language governing permissions and limitations under the Apache License.
|
22
|
-
###
|
22
|
+
###
|
23
23
|
###
|
24
24
|
|
25
|
-
|
26
25
|
###
|
27
26
|
module JSS
|
28
|
-
|
27
|
+
|
29
28
|
#####################################
|
30
29
|
### Module Variables
|
31
30
|
#####################################
|
@@ -34,103 +33,103 @@ module JSS
|
|
34
33
|
### Module Methods
|
35
34
|
#####################################
|
36
35
|
|
37
|
-
|
36
|
+
|
38
37
|
#####################################
|
39
38
|
### Classes
|
40
39
|
#####################################
|
41
40
|
|
42
|
-
###
|
41
|
+
###
|
43
42
|
### An OS X Configuration Profile in the JSS.
|
44
43
|
###
|
45
44
|
### Note that the profile payloads and the profile UUID cannot be edited or updated with this via this class.
|
46
45
|
### Use the web UI.
|
47
46
|
###
|
48
47
|
### @see JSS::APIObject
|
49
|
-
###
|
48
|
+
###
|
50
49
|
class OSXConfigurationProfile < JSS::APIObject
|
51
|
-
|
50
|
+
|
52
51
|
#####################################
|
53
52
|
### Mix-Ins
|
54
53
|
#####################################
|
55
54
|
include JSS::Updatable
|
56
55
|
include JSS::Scopable
|
57
56
|
include JSS::SelfServable
|
58
|
-
|
57
|
+
|
59
58
|
#####################################
|
60
59
|
### Class Methods
|
61
60
|
#####################################
|
62
|
-
|
61
|
+
|
63
62
|
#####################################
|
64
63
|
### Class Constants
|
65
64
|
#####################################
|
66
|
-
|
65
|
+
|
67
66
|
### The base for REST resources of this class
|
68
67
|
RSRC_BASE = "osxconfigurationprofiles"
|
69
|
-
|
68
|
+
|
70
69
|
### the hash key used for the JSON list output of all objects in the JSS
|
71
70
|
RSRC_LIST_KEY = :os_x_configuration_profiles
|
72
|
-
|
71
|
+
|
73
72
|
### The hash key used for the JSON object output.
|
74
73
|
### It's also used in various error messages
|
75
74
|
RSRC_OBJECT_KEY = :os_x_configuration_profile
|
76
|
-
|
75
|
+
|
77
76
|
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
78
77
|
VALID_DATA_KEYS = [:distribution_method, :scope, :redeploy_on_update]
|
79
|
-
|
78
|
+
|
80
79
|
### Our scopes deal with computers
|
81
80
|
SCOPE_TARGET_KEY = :computers
|
82
|
-
|
81
|
+
|
83
82
|
### Our SelfService happens on OSX
|
84
83
|
SELF_SERVICE_TARGET = :osx
|
85
|
-
|
84
|
+
|
86
85
|
### Our SelfService deploys profiles
|
87
86
|
SELF_SERVICE_PAYLOAD = :profile
|
88
|
-
|
87
|
+
|
89
88
|
### The possible values for the :distribution_method
|
90
89
|
DISTRIBUTION_METHODS = ["Install Automatically", "Make Available in Self Service"]
|
91
|
-
|
90
|
+
|
92
91
|
SELF_SERVICE_DIST_METHOD = "Make Available in Self Service"
|
93
|
-
|
92
|
+
|
94
93
|
### The possible values for :level
|
95
94
|
LEVELS = ["user", "computer"]
|
96
|
-
|
97
|
-
|
95
|
+
|
96
|
+
|
98
97
|
#####################################
|
99
98
|
### Attributes
|
100
99
|
#####################################
|
101
|
-
|
100
|
+
|
102
101
|
### @return [String] the description of this profile
|
103
102
|
attr_reader :description
|
104
|
-
|
103
|
+
|
105
104
|
### @return [String] the distribution_method of this profile
|
106
105
|
attr_reader :distribution_method
|
107
|
-
|
106
|
+
|
108
107
|
### @return [Boolean] can the user remove this profile
|
109
108
|
attr_reader :user_removable
|
110
|
-
|
109
|
+
|
111
110
|
### @return [String] the level (user/computer) of this profile
|
112
111
|
attr_reader :level
|
113
|
-
|
112
|
+
|
114
113
|
### @return [String] the uuid of this profile. NOT Updatable
|
115
114
|
attr_reader :uuid
|
116
|
-
|
115
|
+
|
117
116
|
### @return [Boolean] Should this profile be redeployed when an inventory update happens?
|
118
117
|
attr_reader :redeploy_on_update
|
119
|
-
|
118
|
+
|
120
119
|
### @return [String] the plist containing the payloads for this profile. NOT Updatable
|
121
120
|
attr_reader :payloads
|
122
|
-
|
121
|
+
|
123
122
|
#####################################
|
124
|
-
### Constructor
|
123
|
+
### Constructor
|
125
124
|
#####################################
|
126
|
-
|
125
|
+
|
127
126
|
###
|
128
127
|
### See JSS::APIObject#initialize
|
129
128
|
###
|
130
129
|
def initialize (args = {})
|
131
|
-
|
130
|
+
|
132
131
|
super
|
133
|
-
|
132
|
+
|
134
133
|
@description = @main_subset[:description]
|
135
134
|
@distribution_method = @main_subset[:distribution_method]
|
136
135
|
@user_removable = @main_subset[:user_removable]
|
@@ -138,10 +137,10 @@ module JSS
|
|
138
137
|
@uuid = @main_subset[:uuid]
|
139
138
|
@redeploy_on_update = @main_subset[:redeploy_on_update]
|
140
139
|
@payloads = @main_subset[:payloads]
|
141
|
-
|
140
|
+
|
142
141
|
self.parse_scope
|
143
142
|
self.parse_self_service
|
144
|
-
|
143
|
+
|
145
144
|
end
|
146
145
|
|
147
146
|
#####################################
|
@@ -158,8 +157,8 @@ module JSS
|
|
158
157
|
@description = new_val.strip!
|
159
158
|
@need_to_update = true
|
160
159
|
end
|
161
|
-
|
162
|
-
|
160
|
+
|
161
|
+
|
163
162
|
###
|
164
163
|
### @param new_val[String] how should this be distributed to clients?
|
165
164
|
###
|
@@ -171,7 +170,7 @@ module JSS
|
|
171
170
|
@distribution_method = new_val
|
172
171
|
@need_to_update = true
|
173
172
|
end
|
174
|
-
|
173
|
+
|
175
174
|
###
|
176
175
|
### @param new_val[Boolean] should the user be able to remove this?
|
177
176
|
###
|
@@ -184,7 +183,7 @@ module JSS
|
|
184
183
|
@user_removable = new_val
|
185
184
|
@need_to_update = true
|
186
185
|
end
|
187
|
-
|
186
|
+
|
188
187
|
###
|
189
188
|
### @param new_val[String] the new level for this profile (user/computer)
|
190
189
|
###
|
@@ -196,53 +195,53 @@ module JSS
|
|
196
195
|
@level = new_val
|
197
196
|
@need_to_update = true
|
198
197
|
end
|
199
|
-
|
200
|
-
|
198
|
+
|
199
|
+
|
201
200
|
###
|
202
201
|
### @return [Boolean] is this profile available in Self Service?
|
203
202
|
###
|
204
203
|
def in_self_service?
|
205
204
|
@distribution_method == SELF_SERVICE_DIST_METHOD
|
206
205
|
end
|
207
|
-
|
208
|
-
|
206
|
+
|
207
|
+
|
209
208
|
###
|
210
209
|
### @return [Boolean] is this profile removable by the user?
|
211
210
|
###
|
212
211
|
def user_removable?
|
213
212
|
@user_removable
|
214
213
|
end
|
215
|
-
|
216
|
-
|
217
|
-
###
|
214
|
+
|
215
|
+
|
216
|
+
###
|
218
217
|
### @return [Hash] The payload plist parsed into a Ruby hash
|
219
218
|
###
|
220
219
|
def parsed_payloads
|
221
220
|
Plist.parse_xml @payloads
|
222
221
|
end
|
223
|
-
|
222
|
+
|
224
223
|
###
|
225
224
|
### @return [Array<Hash>] the individual payloads from the payload Plist
|
226
225
|
###
|
227
226
|
def payload_content
|
228
227
|
parsed_payloads['PayloadContent']
|
229
228
|
end
|
230
|
-
|
229
|
+
|
231
230
|
###
|
232
231
|
### @return [Array<String>] the PayloadType of each payload (e.g. com.apple.caldav.account)
|
233
232
|
###
|
234
233
|
def payload_types
|
235
234
|
payload_content.map{|p| p['PayloadType'] }
|
236
235
|
end
|
237
|
-
|
236
|
+
|
238
237
|
#####################################
|
239
238
|
### Private Instance Methods
|
240
239
|
#####################################
|
241
240
|
private
|
242
|
-
|
241
|
+
|
243
242
|
def rest_xml
|
244
243
|
doc = REXML::Document.new
|
245
|
-
|
244
|
+
|
246
245
|
obj = doc.add_element RSRC_OBJECT_KEY.to_s
|
247
246
|
gen = obj.add_element('general')
|
248
247
|
gen.add_element('description').text = @description
|
@@ -250,13 +249,13 @@ module JSS
|
|
250
249
|
gen.add_element('user_removable').text = @user_removable
|
251
250
|
gen.add_element('level').text = @level
|
252
251
|
gen.add_element('redeploy_on_update').text = @redeploy_on_update
|
253
|
-
|
252
|
+
|
254
253
|
obj << @scope.scope_xml
|
255
254
|
obj << self_service_xml
|
256
|
-
|
255
|
+
|
257
256
|
return doc.to_s
|
258
257
|
end
|
259
|
-
|
258
|
+
|
260
259
|
end # class OSXConfigurationProfile
|
261
|
-
|
260
|
+
|
262
261
|
end # module
|
@@ -572,7 +572,7 @@ module JSS
|
|
572
572
|
mdp.unmount if unmount
|
573
573
|
end # upload
|
574
574
|
|
575
|
-
|
575
|
+
|
576
576
|
### Delete the filename from the master distribution point, if it exists.
|
577
577
|
###
|
578
578
|
### If you'll be uploading several files you can specify unmount as false, and do it manually when all
|
@@ -587,7 +587,7 @@ module JSS
|
|
587
587
|
###
|
588
588
|
def delete_master_file (rw_pw, unmount = true)
|
589
589
|
mdp = JSS::DistributionPoint.master_distribution_point
|
590
|
-
file = mdp.mount(rw_pw, :rw) +"#{DIST_POINT_PKGS_FOLDER}/#{@filename}"
|
590
|
+
file = mdp.mount(rw_pw, :rw) + "#{DIST_POINT_PKGS_FOLDER}/#{@filename}"
|
591
591
|
if file.exist?
|
592
592
|
file.delete
|
593
593
|
did_it = true
|
@@ -599,6 +599,21 @@ module JSS
|
|
599
599
|
end # delete master file
|
600
600
|
|
601
601
|
|
602
|
+
### Delete this package from the JSS, optionally
|
603
|
+
### deleting the master dist point file also.
|
604
|
+
###
|
605
|
+
### @param delete_file[Boolean] should the master dist point file be deleted?
|
606
|
+
###
|
607
|
+
### @param rw_pw[String] the password for the read/write account on the master Distribution Point
|
608
|
+
### or :prompt, or :stdin# where # is the line of stdin containing the password. See {JSS::DistributionPoint#mount}
|
609
|
+
###
|
610
|
+
### @param unmount[Boolean] whether or not ot unount the distribution point when finished.
|
611
|
+
###
|
612
|
+
def delete (delete_file: false, rw_pw: nil, unmount: true)
|
613
|
+
super()
|
614
|
+
delete_master_file(rw_pw, unmount) if delete_file
|
615
|
+
end
|
616
|
+
|
602
617
|
### Install this package via the jamf binary 'install' command from the
|
603
618
|
### distribution point for this machine.
|
604
619
|
### See {JSS::DistributionPoint.my_distribution_point}
|
@@ -1,25 +1,25 @@
|
|
1
1
|
### Copyright 2016 Pixar
|
2
|
-
###
|
2
|
+
###
|
3
3
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
4
|
### with the following modification; you may not use this file except in
|
5
5
|
### compliance with the Apache License and the following modification to it:
|
6
6
|
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
-
###
|
7
|
+
###
|
8
8
|
### 6. Trademarks. This License does not grant permission to use the trade
|
9
9
|
### names, trademarks, service marks, or product names of the Licensor
|
10
10
|
### and its affiliates, except as required to comply with Section 4(c) of
|
11
11
|
### the License and to reproduce the content of the NOTICE file.
|
12
|
-
###
|
12
|
+
###
|
13
13
|
### You may obtain a copy of the Apache License at
|
14
|
-
###
|
14
|
+
###
|
15
15
|
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
-
###
|
16
|
+
###
|
17
17
|
### Unless required by applicable law or agreed to in writing, software
|
18
18
|
### distributed under the Apache License with the above modification is
|
19
19
|
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
20
|
### KIND, either express or implied. See the Apache License for the specific
|
21
21
|
### language governing permissions and limitations under the Apache License.
|
22
|
-
###
|
22
|
+
###
|
23
23
|
###
|
24
24
|
|
25
25
|
###
|
@@ -41,19 +41,19 @@ module JSS
|
|
41
41
|
###
|
42
42
|
### The JSS objects that have Self Service data return it in a :self_service subset,
|
43
43
|
### which all have similar data, a hash with at least these keys:
|
44
|
-
### - :self_service_description
|
45
|
-
### - :self_service_icon
|
44
|
+
### - :self_service_description
|
45
|
+
### - :self_service_icon
|
46
46
|
###
|
47
47
|
### Most also have:
|
48
48
|
### - :feature_on_main_page
|
49
49
|
### - :self_service_categories
|
50
50
|
###
|
51
|
-
### iOS Profiles in self service have this key:
|
52
|
-
### - :security
|
51
|
+
### iOS Profiles in self service have this key:
|
52
|
+
### - :security
|
53
53
|
###
|
54
54
|
### Additionally, items that apper in OS X SlfSvc have these keys:
|
55
55
|
### - :install_button_text
|
56
|
-
### - :force_users_to_view_description
|
56
|
+
### - :force_users_to_view_description
|
57
57
|
###
|
58
58
|
### See the attribute definitions for details of these values and structures.
|
59
59
|
###
|
@@ -71,14 +71,14 @@ module JSS
|
|
71
71
|
### - Define the constant SELF_SERVICE_PAYLOAD which contains one of :policy, :profile, or :app
|
72
72
|
### - Call {#parse_self_service} in the subclass's constructor after calling super
|
73
73
|
### - Include the result of {#self_service_xml} in their #rest_xml output
|
74
|
-
### - Define the method #in_self_service? which returns a Boolean indicating that the item is
|
74
|
+
### - Define the method #in_self_service? which returns a Boolean indicating that the item is
|
75
75
|
### available in self service. Different API objects indicate this in different ways.
|
76
76
|
### - Define the method #user_removable? which returns Boolean indicating that the item (a profile)
|
77
77
|
### can be removed by the user in SSvc. OS X profiles store this in the :user_removable key of the
|
78
78
|
### :general subset as a boolean, whereas iOS profiles stor it in :security as one of 3 strings
|
79
79
|
###
|
80
80
|
###
|
81
|
-
### Notes:
|
81
|
+
### Notes:
|
82
82
|
### - Self service icons cannot be modified via this code. Use the Web UI.
|
83
83
|
### - There an API bug in handling categories, and all but the last one are ommitted. Until this is fixed, categories
|
84
84
|
### cannot be saved via this code since that would cause data-loss when more than one category is applied.
|
@@ -90,19 +90,19 @@ module JSS
|
|
90
90
|
#####################################
|
91
91
|
|
92
92
|
SELF_SERVABLE = true
|
93
|
-
|
93
|
+
|
94
94
|
IOS_PROFILE_REMOVAL_OPTIONS = ["Always", "With Authorization", "Never"]
|
95
|
-
|
95
|
+
|
96
96
|
#####################################
|
97
97
|
### Variables
|
98
98
|
#####################################
|
99
|
-
|
100
|
-
|
99
|
+
|
100
|
+
|
101
101
|
#####################################
|
102
102
|
### Attribtues
|
103
103
|
#####################################
|
104
104
|
|
105
|
-
|
105
|
+
|
106
106
|
### @return [String] The verbage that appears in SelfSvc for this item
|
107
107
|
attr_reader :self_service_description
|
108
108
|
|
@@ -127,7 +127,7 @@ module JSS
|
|
127
127
|
### - :display_in => [Boolean] should the item be displayed in this category in SSvc? (OSX SSvc only)
|
128
128
|
### - :feature_in => [Boolean] should the item be featured in this category in SSVC? (OSX SSvc only)
|
129
129
|
###
|
130
|
-
### NOTE: as of Casper 9.61 there's a bug in the JSON output from the API, and only the last
|
130
|
+
### NOTE: as of Casper 9.61 there's a bug in the JSON output from the API, and only the last
|
131
131
|
### category is returned, if more than one are set.
|
132
132
|
###
|
133
133
|
attr_reader :self_service_categories
|
@@ -145,7 +145,7 @@ module JSS
|
|
145
145
|
|
146
146
|
### @return [String] The text label on the install button in SSvc (OSX SSvc only)
|
147
147
|
attr_reader :self_service_install_button_text
|
148
|
-
|
148
|
+
|
149
149
|
### @return [Boolean] Should an extra window appear before the user can install the item? (OSX SSvc only)
|
150
150
|
attr_reader :self_service_force_users_to_view_description
|
151
151
|
|
@@ -165,32 +165,32 @@ module JSS
|
|
165
165
|
def parse_self_service
|
166
166
|
@init_data[:self_service] ||= {}
|
167
167
|
ss_data = @init_data[:self_service]
|
168
|
-
|
168
|
+
|
169
169
|
@self_service_description = ss_data[:self_service_description]
|
170
170
|
@self_service_icon = ss_data[:self_service_icon]
|
171
|
-
|
171
|
+
|
172
172
|
@self_service_feature_on_main_page = ss_data[:feature_on_main_page]
|
173
|
-
|
173
|
+
|
174
174
|
# TEMPORARY - until JAMF fixes the category data in JSON
|
175
175
|
@self_service_categories = [
|
176
176
|
ss_data[:self_service_categories][:category]
|
177
177
|
]
|
178
|
-
|
178
|
+
|
179
179
|
# make this an empty hash if needed
|
180
180
|
@self_service_security = ss_data[:security] || {}
|
181
|
-
|
182
|
-
# if this is an osx profile, set @self_service_security[:removal_disallowed] to "Always" or "Never"
|
181
|
+
|
182
|
+
# if this is an osx profile, set @self_service_security[:removal_disallowed] to "Always" or "Never"
|
183
183
|
# to indicate the boolean :user_removable
|
184
184
|
if @init_data[:general].keys.include? :user_removable
|
185
185
|
@self_service_security[:removal_disallowed] = @init_data[:general][:user_removable] ? "Always" : "Never"
|
186
186
|
end
|
187
|
-
|
187
|
+
|
188
188
|
@self_service_install_button_text = ss_data[:install_button_text]
|
189
189
|
@self_service_force_users_to_view_description = ss_data[:force_users_to_view_description]
|
190
190
|
|
191
191
|
end
|
192
192
|
|
193
|
-
|
193
|
+
|
194
194
|
###
|
195
195
|
###
|
196
196
|
### Setters
|
@@ -218,9 +218,9 @@ module JSS
|
|
218
218
|
@self_service_install_button_text = new_val.strip
|
219
219
|
@need_to_update = true
|
220
220
|
end
|
221
|
-
|
221
|
+
|
222
222
|
###
|
223
|
-
### @param new_val[Boolean] should this appear on the main SelfSvc page?
|
223
|
+
### @param new_val[Boolean] should this appear on the main SelfSvc page?
|
224
224
|
###
|
225
225
|
### @return [void]
|
226
226
|
###
|
@@ -230,9 +230,9 @@ module JSS
|
|
230
230
|
@self_service_feature_on_main_page = new_val
|
231
231
|
@need_to_update = true
|
232
232
|
end
|
233
|
-
|
233
|
+
|
234
234
|
###
|
235
|
-
### @param new_val[Boolean] should this appear on the main SelfSvc page?
|
235
|
+
### @param new_val[Boolean] should this appear on the main SelfSvc page?
|
236
236
|
###
|
237
237
|
### @return [void]
|
238
238
|
###
|
@@ -243,7 +243,7 @@ module JSS
|
|
243
243
|
@self_service_force_users_to_view_description = new_val
|
244
244
|
@need_to_update = true
|
245
245
|
end
|
246
|
-
|
246
|
+
|
247
247
|
###
|
248
248
|
### Add or change one of the categories for this item in SSvc.
|
249
249
|
###
|
@@ -260,21 +260,21 @@ module JSS
|
|
260
260
|
raise JSS::NoSuchItemError, "No category '#{new_cat}' in the JSS" unless JSS::Category.all_names(:refresh).include? new_cat
|
261
261
|
raise JSS::InvalidDataError, "display_in must be true or false" unless JSS::TRUE_FALSE.include? display_in
|
262
262
|
raise JSS::InvalidDataError, "feature_in must be true or false" unless JSS::TRUE_FALSE.include? feature_in
|
263
|
-
|
263
|
+
|
264
264
|
new_data = {:name => new_cat, :display_in => display_in, :feature_in => feature_in }
|
265
|
-
|
265
|
+
|
266
266
|
# see if this category is already among our categories.
|
267
267
|
idx = @self_service_categories.index{|c| c[new_cat]}
|
268
|
-
|
269
|
-
if idx
|
268
|
+
|
269
|
+
if idx
|
270
270
|
@self_service_categories[idx] = new_data
|
271
271
|
else
|
272
272
|
@self_service_categories << new_data
|
273
273
|
end
|
274
|
-
|
274
|
+
|
275
275
|
@need_to_update = true
|
276
276
|
end
|
277
|
-
|
277
|
+
|
278
278
|
###
|
279
279
|
### Remove a category from those for this item in SSvc
|
280
280
|
###
|
@@ -296,18 +296,17 @@ module JSS
|
|
296
296
|
### @return [void]
|
297
297
|
###
|
298
298
|
def profile_can_be_removed (new_val)
|
299
|
-
|
300
|
-
new_val = "Always" if new_val === true
|
299
|
+
|
300
|
+
new_val = "Always" if new_val === true
|
301
301
|
new_val = "Never" if new_val === false
|
302
|
-
|
302
|
+
|
303
303
|
return nil if new_val == @self_service_security[:removal_disallowed]
|
304
304
|
raise JSS::InvalidDataError, "" unless IOS_PROFILE_REMOVAL_OPTIONS.include? new_val
|
305
|
-
|
305
|
+
|
306
306
|
@self_service_security[:removal_disallowed] = new_val
|
307
307
|
end
|
308
|
-
|
309
|
-
|
310
|
-
|
308
|
+
|
309
|
+
|
311
310
|
###
|
312
311
|
### @api private
|
313
312
|
###
|
@@ -318,16 +317,16 @@ module JSS
|
|
318
317
|
### @return [REXML::Element]
|
319
318
|
###
|
320
319
|
def self_service_xml
|
321
|
-
|
320
|
+
|
322
321
|
ssvc = REXML::Element.new('self_service')
|
323
|
-
|
322
|
+
|
324
323
|
return ssvc unless self.in_self_service?
|
325
|
-
|
324
|
+
|
326
325
|
ssvc.add_element('self_service_description').text = @self_service_description
|
327
326
|
ssvc.add_element('feature_on_main_page').text = @self_service_feature_on_main_page
|
328
|
-
|
327
|
+
|
329
328
|
### TEMPORARY - re-enable this when the category bug is fixed.
|
330
|
-
|
329
|
+
|
331
330
|
# cats = ssvc.add_element('self_service_categories')
|
332
331
|
# @self_service_categories.each do |cat|
|
333
332
|
# catelem = cats.add_element('category')
|
@@ -335,22 +334,22 @@ module JSS
|
|
335
334
|
# catelem.add_element('display_in').text = cat[:display_in] if cat.keys.include? :display_in
|
336
335
|
# catelem.add_element('feature_in').text = cat[:feature_in] if cat.keys.include? :feature_in
|
337
336
|
# end
|
338
|
-
|
337
|
+
|
339
338
|
unless @self_service_security.empty?
|
340
339
|
sec = ssvc.add_element('security')
|
341
340
|
sec.add_element('removal_disallowed').text = @self_service_security[:removal_disallowed] if @self_service_security[:removal_disallowed]
|
342
341
|
sec.add_element('password').text = @self_service_security[:password] if @self_service_security[:password]
|
343
342
|
end
|
344
|
-
|
343
|
+
|
345
344
|
ssvc.add_element('install_button_text').text = @self_service_install_button_text if @self_service_install_button_text
|
346
345
|
ssvc.add_element('force_users_to_view_description').text = @self_service_force_users_to_view_description unless @self_service_force_users_to_view_description.nil?
|
347
346
|
|
348
347
|
return ssvc
|
349
348
|
end
|
350
|
-
|
349
|
+
|
351
350
|
### aliases
|
352
351
|
alias change_self_service_category add_self_service_category
|
353
|
-
|
352
|
+
|
354
353
|
end # module SelfServable
|
355
354
|
|
356
355
|
end # module JSS
|
data/lib/jss/configuration.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
### Copyright 2016 Pixar
|
2
|
-
###
|
2
|
+
###
|
3
3
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
4
|
### with the following modification; you may not use this file except in
|
5
5
|
### compliance with the Apache License and the following modification to it:
|
6
6
|
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
-
###
|
7
|
+
###
|
8
8
|
### 6. Trademarks. This License does not grant permission to use the trade
|
9
9
|
### names, trademarks, service marks, or product names of the Licensor
|
10
10
|
### and its affiliates, except as required to comply with Section 4(c) of
|
11
11
|
### the License and to reproduce the content of the NOTICE file.
|
12
|
-
###
|
12
|
+
###
|
13
13
|
### You may obtain a copy of the Apache License at
|
14
|
-
###
|
14
|
+
###
|
15
15
|
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
-
###
|
16
|
+
###
|
17
17
|
### Unless required by applicable law or agreed to in writing, software
|
18
18
|
### distributed under the Apache License with the above modification is
|
19
19
|
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
20
|
### KIND, either express or implied. See the Apache License for the specific
|
21
21
|
### language governing permissions and limitations under the Apache License.
|
22
|
-
###
|
22
|
+
###
|
23
23
|
###
|
24
24
|
|
25
25
|
###
|
@@ -98,14 +98,17 @@ module JSS
|
|
98
98
|
### Class Constants
|
99
99
|
#####################################
|
100
100
|
|
101
|
-
### The filename for storing the
|
102
|
-
|
101
|
+
### The filename for storing the config, globally or user-level.
|
102
|
+
### The first matching file is used - the array provides
|
103
|
+
### backward compatibility with earlier versions.
|
104
|
+
### Saving will always happen to the first filename
|
105
|
+
CONF_FILES = [ "ruby-jss.conf", "jss_gem.conf"]
|
103
106
|
|
104
107
|
### The Pathname to the machine-wide preferences plist
|
105
|
-
|
108
|
+
GLOBAL_CONFS = CONF_FILES.map{|cf| Pathname.new "/etc/#{cf}"}
|
106
109
|
|
107
110
|
### The Pathname to the user-specific preferences plist
|
108
|
-
|
111
|
+
USER_CONFS = CONF_FILES.map{|cf| ENV["HOME"] ? Pathname.new("~/.#{cf}").expand_path : nil }.compact
|
109
112
|
|
110
113
|
### The attribute keys we maintain, and the type they should be stored as
|
111
114
|
CONF_KEYS = {
|
@@ -175,7 +178,12 @@ module JSS
|
|
175
178
|
### @return [void]
|
176
179
|
###
|
177
180
|
def read_global
|
178
|
-
|
181
|
+
GLOBAL_CONFS.each { |gcf|
|
182
|
+
if gcf.file? and gcf.readable?
|
183
|
+
read gcf
|
184
|
+
return
|
185
|
+
end
|
186
|
+
}
|
179
187
|
end
|
180
188
|
|
181
189
|
###
|
@@ -184,8 +192,12 @@ module JSS
|
|
184
192
|
### @return [void]
|
185
193
|
###
|
186
194
|
def read_user
|
187
|
-
|
188
|
-
|
195
|
+
USER_CONFS.each { |ucf|
|
196
|
+
if ucf.file? and ucf.readable?
|
197
|
+
read ucf
|
198
|
+
return
|
199
|
+
end
|
200
|
+
}
|
189
201
|
end
|
190
202
|
|
191
203
|
|
@@ -217,37 +229,37 @@ module JSS
|
|
217
229
|
###
|
218
230
|
def save(file)
|
219
231
|
path = case file
|
220
|
-
when :global then
|
221
|
-
when :user then
|
232
|
+
when :global then GLOBAL_CONFS.first
|
233
|
+
when :user then USER_CONFS.first
|
222
234
|
else Pathname.new(file)
|
223
235
|
end
|
224
|
-
|
236
|
+
|
225
237
|
raise JSS::MissingDataError, "No HOME environment variable, can't write to user conf file." if path.nil?
|
226
|
-
|
238
|
+
|
227
239
|
# file already exists? read it in and update the values.
|
228
240
|
if path.readable?
|
229
241
|
data = path.read
|
230
|
-
|
242
|
+
|
231
243
|
# go thru the known attributes/keys
|
232
|
-
CONF_KEYS.keys.sort.each do |k|
|
233
|
-
|
244
|
+
CONF_KEYS.keys.sort.each do |k|
|
245
|
+
|
234
246
|
# if the key exists, update it.
|
235
|
-
if data =~ /^#{k}:/
|
236
|
-
data.sub!(/^#{k}:.*$/, "#{k}: #{self.send k}")
|
237
|
-
|
247
|
+
if data =~ /^#{k}:/
|
248
|
+
data.sub!(/^#{k}:.*$/, "#{k}: #{self.send k}")
|
249
|
+
|
238
250
|
# if not, add it to the end unless it's nil
|
239
251
|
else
|
240
252
|
data += "\n#{k}: #{self.send k}" unless self.send(k).nil?
|
241
|
-
end # if data =~ /^#{k}:/
|
242
|
-
end #each do |k|
|
243
|
-
|
253
|
+
end # if data =~ /^#{k}:/
|
254
|
+
end #each do |k|
|
255
|
+
|
244
256
|
else # not readable, make a new file
|
245
257
|
data = ""
|
246
|
-
CONF_KEYS.keys.sort.each do |k|
|
247
|
-
data << "#{k}: #{self.send k}\n" unless self.send(k).nil?
|
258
|
+
CONF_KEYS.keys.sort.each do |k|
|
259
|
+
data << "#{k}: #{self.send k}\n" unless self.send(k).nil?
|
248
260
|
end
|
249
261
|
end # if path readable
|
250
|
-
|
262
|
+
|
251
263
|
# make sure we end with a newline, the save it.
|
252
264
|
data << "\n" unless data.end_with?("\n")
|
253
265
|
path.jss_save data
|
data/lib/jss/db_connection.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
### Copyright 2016 Pixar
|
2
|
-
###
|
2
|
+
###
|
3
3
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
4
|
### with the following modification; you may not use this file except in
|
5
5
|
### compliance with the Apache License and the following modification to it:
|
6
6
|
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
-
###
|
7
|
+
###
|
8
8
|
### 6. Trademarks. This License does not grant permission to use the trade
|
9
9
|
### names, trademarks, service marks, or product names of the Licensor
|
10
10
|
### and its affiliates, except as required to comply with Section 4(c) of
|
11
11
|
### the License and to reproduce the content of the NOTICE file.
|
12
|
-
###
|
12
|
+
###
|
13
13
|
### You may obtain a copy of the Apache License at
|
14
|
-
###
|
14
|
+
###
|
15
15
|
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
-
###
|
16
|
+
###
|
17
17
|
### Unless required by applicable law or agreed to in writing, software
|
18
18
|
### distributed under the Apache License with the above modification is
|
19
19
|
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
20
|
### KIND, either express or implied. See the Apache License for the specific
|
21
21
|
### language governing permissions and limitations under the Apache License.
|
22
|
-
###
|
22
|
+
###
|
23
23
|
###
|
24
24
|
|
25
25
|
###
|
@@ -78,16 +78,19 @@ module JSS
|
|
78
78
|
### The name of the JSS database on the mysql server
|
79
79
|
DEFAULT_DB_NAME = "jamfsoftware"
|
80
80
|
|
81
|
-
### give the connection a
|
81
|
+
### give the connection a 60 second timeout, for really slow
|
82
82
|
### net connections (like... from airplanes)
|
83
|
-
DFT_TIMEOUT =
|
83
|
+
DFT_TIMEOUT = 60
|
84
84
|
|
85
85
|
###
|
86
86
|
DFT_SOCKET = '/var/mysql/mysql.sock'
|
87
|
-
|
87
|
+
|
88
88
|
### the default MySQL port
|
89
89
|
DFT_PORT = 3306
|
90
|
-
|
90
|
+
|
91
|
+
### The default encoding in the tables - JAMF wisely uses UTF-8
|
92
|
+
DFT_CHARSET = "utf8"
|
93
|
+
|
91
94
|
### the strftime format for reading/writing dates in the db
|
92
95
|
SQL_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
|
93
96
|
|
@@ -147,7 +150,7 @@ module JSS
|
|
147
150
|
# if not given in the args, use #hostname to figure out
|
148
151
|
# which
|
149
152
|
@server = args[:server] ? args[:server] : hostname
|
150
|
-
|
153
|
+
|
151
154
|
# settings from config if they aren't in the args
|
152
155
|
args[:port] ||= JSS::CONFIG.db_server_port
|
153
156
|
args[:socket] ||= JSS::CONFIG.db_server_socket
|
@@ -169,6 +172,7 @@ module JSS
|
|
169
172
|
args[:port] ||= Mysql::MYSQL_TCP_PORT
|
170
173
|
args[:socket] ||= DFT_SOCKET
|
171
174
|
args[:db_name] ||= DEFAULT_DB_NAME
|
175
|
+
args[:charset] ||= DFT_CHARSET
|
172
176
|
|
173
177
|
begin
|
174
178
|
@mysql.close if connected?
|
@@ -205,7 +209,7 @@ module JSS
|
|
205
209
|
@mysql.options Mysql::OPT_CONNECT_TIMEOUT, @connect_timeout
|
206
210
|
@mysql.options Mysql::OPT_READ_TIMEOUT, @read_timeout
|
207
211
|
@mysql.options Mysql::OPT_WRITE_TIMEOUT, @write_timeout
|
208
|
-
|
212
|
+
@mysql.charset = args[:charset]
|
209
213
|
@mysql.connect @server, @user , @pw , @mysql_name, @port, @socket
|
210
214
|
|
211
215
|
@connected = true
|
@@ -224,7 +228,7 @@ module JSS
|
|
224
228
|
### it'll have to be re-connected before using again
|
225
229
|
###
|
226
230
|
def disconnect
|
227
|
-
@mysql.close if
|
231
|
+
@mysql.close if @mysql.protocol
|
228
232
|
@server = nil
|
229
233
|
@port = nil
|
230
234
|
@socket = nil
|
@@ -235,7 +239,7 @@ module JSS
|
|
235
239
|
@connected = false
|
236
240
|
nil
|
237
241
|
end # disconnect
|
238
|
-
|
242
|
+
|
239
243
|
### Test that a given hostname is a MySQL server
|
240
244
|
###
|
241
245
|
### @param server[String] The hostname to test
|
@@ -245,13 +249,13 @@ module JSS
|
|
245
249
|
def valid_server? (server, port = DFT_PORT)
|
246
250
|
mysql = Mysql.init
|
247
251
|
mysql.options Mysql::OPT_CONNECT_TIMEOUT, 5
|
248
|
-
|
252
|
+
|
249
253
|
begin
|
250
254
|
# this connection should get an access denied error if there is
|
251
255
|
# a mysql server there. I'm assuming no one will use this username
|
252
256
|
# and pw for anything real
|
253
257
|
mysql.connect server, "notArealUser", "definatelyNotA#{$$}password", "not_a_db", port
|
254
|
-
|
258
|
+
|
255
259
|
rescue Mysql::ServerError::AccessDeniedError
|
256
260
|
return true
|
257
261
|
rescue
|
@@ -259,8 +263,8 @@ module JSS
|
|
259
263
|
end
|
260
264
|
return false
|
261
265
|
end
|
262
|
-
|
263
|
-
### The server to which we are connected, or will
|
266
|
+
|
267
|
+
### The server to which we are connected, or will
|
264
268
|
### try connecting to if none is specified with the
|
265
269
|
### call to #connect
|
266
270
|
###
|
@@ -275,8 +279,8 @@ module JSS
|
|
275
279
|
srvr ||= JSS::Client.jss_server
|
276
280
|
return srvr
|
277
281
|
end
|
278
|
-
|
279
|
-
|
282
|
+
|
283
|
+
|
280
284
|
#### Aliases
|
281
285
|
|
282
286
|
alias connected? connected
|
data/lib/jss/utility.rb
CHANGED
@@ -118,7 +118,7 @@ module JSS
|
|
118
118
|
### This method tests a given OS, against a requirement list
|
119
119
|
### to see if the requirement is met.
|
120
120
|
###
|
121
|
-
### @param requirement[String] The os requirement list, a comma-seprated string
|
121
|
+
### @param requirement[String,Array] The os requirement list, a comma-seprated string
|
122
122
|
### or array of strings of allows OSes. e.g. 10.7, 10.8.5 or 10.9.x
|
123
123
|
###
|
124
124
|
### @param processor[String] the os to check, defaults to
|
@@ -128,8 +128,10 @@ module JSS
|
|
128
128
|
### given?
|
129
129
|
###
|
130
130
|
def self.os_ok? (requirement, os_to_check = nil)
|
131
|
-
return true if requirement.to_s
|
131
|
+
return true if requirement.to_s =~ /none/i
|
132
|
+
return true if requirement.to_s == 'n'
|
132
133
|
requirement = JSS.to_s_and_a(requirement)[:arrayform]
|
134
|
+
return true if requirement.empty?
|
133
135
|
|
134
136
|
os_to_check ||= `/usr/bin/sw_vers -productVersion`.chomp
|
135
137
|
|
data/lib/jss/version.rb
CHANGED
data/lib/ruby-jss.rb
ADDED
metadata
CHANGED
@@ -1,71 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lasell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plist
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ruby-mysql
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.9'
|
31
34
|
- - '>='
|
32
35
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
36
|
+
version: 2.9.12
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.9'
|
38
44
|
- - '>='
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
46
|
+
version: 2.9.12
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: rest-client
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.7'
|
45
54
|
- - '>='
|
46
55
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.7.
|
56
|
+
version: 1.7.2
|
48
57
|
type: :runtime
|
49
58
|
prerelease: false
|
50
59
|
version_requirements: !ruby/object:Gem::Requirement
|
51
60
|
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1.7'
|
52
64
|
- - '>='
|
53
65
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.7.
|
66
|
+
version: 1.7.2
|
55
67
|
- !ruby/object:Gem::Dependency
|
56
68
|
name: net-ldap
|
57
69
|
requirement: !ruby/object:Gem::Requirement
|
58
70
|
requirements:
|
59
|
-
- -
|
71
|
+
- - ~>
|
60
72
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
73
|
+
version: '0.8'
|
62
74
|
type: :runtime
|
63
75
|
prerelease: false
|
64
76
|
version_requirements: !ruby/object:Gem::Requirement
|
65
77
|
requirements:
|
66
|
-
- -
|
78
|
+
- - ~>
|
67
79
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
80
|
+
version: '0.8'
|
69
81
|
description: |2
|
70
82
|
The ruby-jss gem provides the JSS module, a framework for interacting with the REST API
|
71
83
|
of the JAMF Software Server (JSS), the core of the Casper Suite, an enterprise/education
|
@@ -90,6 +102,7 @@ files:
|
|
90
102
|
- THANKS.md
|
91
103
|
- bin/cgrouper
|
92
104
|
- bin/subnet-update
|
105
|
+
- data/ruby-jss.conf.example
|
93
106
|
- lib/jss-api.rb
|
94
107
|
- lib/jss.rb
|
95
108
|
- lib/jss/api_connection.rb
|
@@ -154,6 +167,7 @@ files:
|
|
154
167
|
- lib/jss/server.rb
|
155
168
|
- lib/jss/utility.rb
|
156
169
|
- lib/jss/version.rb
|
170
|
+
- lib/ruby-jss.rb
|
157
171
|
homepage: http://pixaranimationstudios.github.io/ruby-jss/
|
158
172
|
licenses:
|
159
173
|
- Apache-2.0 WITH Modifications
|