depot3 3.0.9 → 3.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/d3 +18 -2
- data/bin/d3admin +55 -85
- data/bin/d3helper +1 -1
- data/lib/d3/admin/add.rb +11 -2
- data/lib/d3/admin/auth.rb +20 -3
- data/lib/d3/admin/edit.rb +1 -1
- data/lib/d3/admin/help.rb +13 -12
- data/lib/d3/admin/interactive.rb +17 -17
- data/lib/d3/admin/options.rb +10 -10
- data/lib/d3/admin/report.rb +23 -6
- data/lib/d3/admin/validate.rb +12 -0
- data/lib/d3/basename.rb +16 -1
- data/lib/d3/client/auth.rb +2 -2
- data/lib/d3/client/class_methods.rb +83 -45
- data/lib/d3/client/cli.rb +11 -0
- data/lib/d3/client/help.rb +1 -0
- data/lib/d3/client/receipt.rb +25 -22
- data/lib/d3/database.rb +10 -5
- data/lib/d3/log.rb +34 -38
- data/lib/d3/package/constructor.rb +4 -1
- data/lib/d3/package/getters.rb +1 -1
- data/lib/d3/package/private_methods.rb +1 -1
- data/lib/d3/package/questions.rb +1 -1
- data/lib/d3/package/server_actions.rb +9 -9
- data/lib/d3/package/setters.rb +37 -10
- data/lib/d3/package/validate.rb +25 -6
- data/lib/d3/version.rb +1 -1
- metadata +2 -2
data/lib/d3/package/getters.rb
CHANGED
@@ -110,7 +110,7 @@ Installation prohibited by process: #{@prohibiting_process or 'None'}
|
|
110
110
|
Auto installed for groups: #{auto_disp.empty? ? 'None' : auto_disp}
|
111
111
|
Excluded for groups: #{excl_disp.empty? ? 'None' : excl_disp}
|
112
112
|
Expiration period: #{@expiration.to_i} days
|
113
|
-
Expiration path: #{@
|
113
|
+
Expiration path(s): #{D3::Database::ARRAY_OF_PATHNAMES_TO_COMMA_STRING.call @expiration_paths}
|
114
114
|
Released by: #{@released_by or '-'}
|
115
115
|
Release date: #{@release_date ? @release_date.strftime('%Y-%m-%d') : '-'}
|
116
116
|
END_DEETS
|
@@ -77,7 +77,7 @@ module D3
|
|
77
77
|
:pre_remove_script_id => @pre_remove_script_id,
|
78
78
|
:post_remove_script_id => @post_remove_script_id,
|
79
79
|
:expiration => @expiration_to_apply.to_i,
|
80
|
-
:
|
80
|
+
:expiration_paths => @expiration_paths,
|
81
81
|
:custom_expiration => @custom_expiration,
|
82
82
|
:prohibiting_process => @prohibiting_process)
|
83
83
|
|
data/lib/d3/package/questions.rb
CHANGED
@@ -81,7 +81,7 @@ module D3
|
|
81
81
|
### @return [Boolean] Does this pkg expire by default?
|
82
82
|
###
|
83
83
|
def expires?
|
84
|
-
@expiration.to_i > 0 && @
|
84
|
+
@expiration.to_i > 0 && @expiration_paths
|
85
85
|
end
|
86
86
|
|
87
87
|
### @return [Boolean] Is this pkg 'indexed' in the jss, so that it can be removable?
|
@@ -328,7 +328,7 @@ INSERT INTO #{P_TABLE[:table_name]} (
|
|
328
328
|
#### First the deprecated pkgs
|
329
329
|
|
330
330
|
# the id's of the deprecated pkgs for this basename, in numerical order
|
331
|
-
# the last ones are the newest.
|
331
|
+
# the last ones are the newest.
|
332
332
|
deprecated_ids = D3::Package.deprecated_data.values.select{|dp| dp[:basename] == @basename}
|
333
333
|
deprecated_ids.map!{|dp| dp[:id] }.sort!
|
334
334
|
|
@@ -342,14 +342,14 @@ INSERT INTO #{P_TABLE[:table_name]} (
|
|
342
342
|
deprecated_ids_to_keep = []
|
343
343
|
number_deprecated_to_keep.times{ deprecated_ids_to_keep << deprecated_ids.pop }
|
344
344
|
deprecated_ids_to_keep.compact!
|
345
|
-
|
345
|
+
|
346
346
|
# delete them if we should
|
347
347
|
deprecated_ids.each do |id|
|
348
348
|
next if deprecated_ids_to_keep.include? id
|
349
349
|
victim = D3::Package.new(:id => id)
|
350
350
|
victim.delete(
|
351
351
|
admin: admin,
|
352
|
-
|
352
|
+
keep_scripts: false,
|
353
353
|
keep_in_jss: false,
|
354
354
|
rwpw: D3::Admin::Auth.rw_credentials(:dist)[:password]
|
355
355
|
)
|
@@ -381,7 +381,7 @@ INSERT INTO #{P_TABLE[:table_name]} (
|
|
381
381
|
victim = D3::Package.new(:id => id)
|
382
382
|
victim.delete(
|
383
383
|
admin: admin,
|
384
|
-
|
384
|
+
keep_scripts: false,
|
385
385
|
keep_in_jss: false,
|
386
386
|
rwpw: D3::Admin::Auth.rw_credentials(:dist)[:password]
|
387
387
|
)
|
@@ -395,7 +395,7 @@ INSERT INTO #{P_TABLE[:table_name]} (
|
|
395
395
|
###
|
396
396
|
### @param keep_in_jss[Boolean] should we keep the JSS package around? defaults to false
|
397
397
|
###
|
398
|
-
### @param
|
398
|
+
### @param keep_scripts[Boolean] should the related scripts be kept in the JSS?
|
399
399
|
###
|
400
400
|
### @param admin[String] who's doing this?
|
401
401
|
###
|
@@ -403,9 +403,9 @@ INSERT INTO #{P_TABLE[:table_name]} (
|
|
403
403
|
###
|
404
404
|
### @return [Array<String>] a textual list of scripts delted and not
|
405
405
|
### deleted because they're in use by other d3 pkgs or casper policies
|
406
|
-
### (empty if
|
406
|
+
### (empty if keep_scripts is true)
|
407
407
|
###
|
408
|
-
def delete (keep_in_jss: false,
|
408
|
+
def delete (keep_in_jss: false, keep_scripts: false, admin: @admin, rwpw: nil)
|
409
409
|
|
410
410
|
unless keep_in_jss
|
411
411
|
# raise an exception if any polcies are using this pkg.
|
@@ -419,8 +419,8 @@ INSERT INTO #{P_TABLE[:table_name]} (
|
|
419
419
|
# use @ admin if its defined and needed
|
420
420
|
admin ||= @admin
|
421
421
|
|
422
|
-
#
|
423
|
-
script_actions =
|
422
|
+
# delete scripts or not? the result is an array of what happened.
|
423
|
+
script_actions = keep_scripts ? [] : delete_pkg_scripts
|
424
424
|
|
425
425
|
# delete it from the pakcages table
|
426
426
|
stmt = JSS::DB_CNX.db.prepare "DELETE FROM #{P_TABLE[:table_name]} WHERE #{P_FIELDS[:id][:field_name]} = '#{@id}'"
|
data/lib/d3/package/setters.rb
CHANGED
@@ -93,7 +93,7 @@ module D3
|
|
93
93
|
|
94
94
|
### Set the expiration period for all installs of this pkg.
|
95
95
|
### Once installed, if this many days go by without
|
96
|
-
### the @
|
96
|
+
### the @expiration_paths being launched, as noted by d3repoman, the pkg
|
97
97
|
### will be silently uninstalled.
|
98
98
|
###
|
99
99
|
### Use nil, false, or 0 (the default) to prevent expiration.
|
@@ -115,24 +115,51 @@ module D3
|
|
115
115
|
@need_to_update_d3 = true unless @initializing
|
116
116
|
end # expiration =
|
117
117
|
|
118
|
-
### Set the expiration
|
119
|
-
###
|
120
|
-
### at least once every @expiration days to prevent
|
118
|
+
### Set the expiration paths for this pkg.
|
119
|
+
### These are abosulute paths to executables one of which must be brought to the
|
120
|
+
### foreground at least once every @expiration days to prevent
|
121
121
|
### silent un-installing of this package.
|
122
122
|
###
|
123
|
-
###
|
124
|
-
### @example "/Applications/FileMaker Pro 11/FileMaker Pro.app"
|
123
|
+
### The paths are those recorded in d3RepoMan's timestamp plists.
|
124
|
+
### @example "/Applications/FileMaker Pro 11/FileMaker Pro.app/Contents/MacOS/Filemaker Pro"
|
125
125
|
###
|
126
|
-
### @param new_val[String] The
|
126
|
+
### @param new_val[String,Pathname,Array<String,Pathname>] The expiration paths.
|
127
|
+
### A Pathname for a single path, a String for single, or multiple
|
128
|
+
### (comma-separated) or an Array of Strings or Pathnames for single paths.
|
129
|
+
### Each path must be an absolute path starting with a /
|
127
130
|
###
|
128
131
|
### @return [void]
|
129
132
|
###
|
130
|
-
def
|
131
|
-
return @
|
132
|
-
@
|
133
|
+
def expiration_paths= (new_val = @expiration_paths)
|
134
|
+
return @expiration_paths if new_val == @expiration_paths
|
135
|
+
@expiration_paths = validate_expiration_paths (new_val)
|
133
136
|
@need_to_update_d3 = true unless @initializing
|
134
137
|
end # expiration =
|
135
138
|
|
139
|
+
### Add a path to expiration_paths
|
140
|
+
### @param new_val[String,Pathname]
|
141
|
+
###
|
142
|
+
### The paths are those recorded in d3RepoMan's timestamp plists.
|
143
|
+
### @example "/Applications/FileMaker Pro 11/FileMaker Pro.app/Contents/MacOS/Filemaker Pro"
|
144
|
+
###
|
145
|
+
def add_expiration_path (path)
|
146
|
+
path = validate_expiration_path(path)
|
147
|
+
@expiration_paths << path
|
148
|
+
@need_to_update_d3 = true unless @initializing
|
149
|
+
end # add_expiration_path
|
150
|
+
|
151
|
+
### Remove a path from expiration_paths
|
152
|
+
### @param new_val[String,Pathname]
|
153
|
+
###
|
154
|
+
### The paths are those recorded in d3RepoMan's timestamp plists.
|
155
|
+
### @example "/Applications/FileMaker Pro 11/FileMaker Pro.app/Contents/MacOS/Filemaker Pro"
|
156
|
+
###
|
157
|
+
def remove_expiration_path (path)
|
158
|
+
@expiration_paths.delete Pathname.new(path)
|
159
|
+
@need_to_update_d3 = true unless @initializing
|
160
|
+
end # remove_expiration_path
|
161
|
+
|
162
|
+
|
136
163
|
### Set the prohibiting process for this installer.
|
137
164
|
###
|
138
165
|
### The value of this attribute is compared at install time to the lines output
|
data/lib/d3/package/validate.rb
CHANGED
@@ -346,7 +346,7 @@ module D3
|
|
346
346
|
### @return [Symbol] the valid CPU type
|
347
347
|
###
|
348
348
|
def validate_cpu_type (type)
|
349
|
-
type = JSS::Package::
|
349
|
+
type = JSS::Package::DEFAULT_PROCESSOR if type.to_s.empty?
|
350
350
|
type = "None" if type =~ /^n(one)?$/i
|
351
351
|
type = "x86" if type.casecmp('intel') == 0
|
352
352
|
type = "ppc" if type.casecmp('ppc') == 0
|
@@ -428,21 +428,40 @@ module D3
|
|
428
428
|
exp.to_i
|
429
429
|
end
|
430
430
|
|
431
|
+
### Confirm the validity of one or more expiration paths.
|
432
|
+
### Any string that starts with a / is valid.
|
433
|
+
### The strings "n" or "none" returns an empty array.
|
434
|
+
###
|
435
|
+
### @param paths[Pathname, String, Array<String,Pathname>] the path(s) to check
|
436
|
+
###
|
437
|
+
### @return [Array<Pathname>] the valid path
|
438
|
+
###
|
439
|
+
def validate_expiration_paths (paths)
|
440
|
+
return [] if paths.to_s.empty? or paths.to_s =~ /^n(one)?$/i
|
441
|
+
|
442
|
+
paths = paths.chomp.split(/\s*,\s*/) if paths.is_a? String
|
443
|
+
|
444
|
+
if paths.is_a? Array
|
445
|
+
return paths.map!{|p| validate_expiration_path p}
|
446
|
+
else
|
447
|
+
return [validate_expiration_path(paths)]
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
431
451
|
### Confirm the validity of an expiration path.
|
432
|
-
###
|
452
|
+
### Any string that starts with a / is valid, d3 can't confirm
|
453
|
+
### the paths existing on client machines.
|
433
454
|
###
|
434
|
-
### @param
|
455
|
+
### @param paths[Pathname, String] the path to check
|
435
456
|
###
|
436
|
-
### @return [Pathname
|
457
|
+
### @return [Pathname] the valid path
|
437
458
|
###
|
438
459
|
def validate_expiration_path (path)
|
439
460
|
path = path.to_s
|
440
|
-
return nil if path.empty?
|
441
461
|
raise JSS::InvalidDataError, "Expiration Path must be a full path starting with /." unless path.start_with? "/"
|
442
462
|
Pathname.new path
|
443
463
|
end
|
444
464
|
|
445
|
-
|
446
465
|
end # module Validate
|
447
466
|
|
448
467
|
end # class package
|
data/lib/d3/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: depot3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.11
|
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-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-keychain
|