depot3 3.0.9 → 3.0.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3958145701408de91742321b631220d28616638
4
- data.tar.gz: 46cfaa84e02925dc7d3ea47d7616cb395ab4e2ab
3
+ metadata.gz: dd0846668a4adffcd65b2f18acb90ea9e2d358fc
4
+ data.tar.gz: 536dd741fc281d3a85f734338e9212c65c41c50f
5
5
  SHA512:
6
- metadata.gz: 3e37917a62941a884946bea3e32425d1a1731098c2f6d0b03aa6373e9375b1173bb4aaaa2dc2877e8739b28359513ce7ed8a8127540d4ec6ad57b96de4fd3f22
7
- data.tar.gz: bde22daae9f593443f68c4a71375e5e3624acebc38a639cded1159bc7440e014aa5d04ef9fbacca7cac0c10d8cb27eaeb12a3a98135eb32227a022254b061ae1
6
+ metadata.gz: d4bfebc0d804c371cae8e11a2e83acd62c5407a8165c55a7269dd0aa7ccf2370d27a56eb137c6c602d5ecbbb69aa9404a36d875e687fb8276594aacb8f31531f
7
+ data.tar.gz: cafd61d158574ebc192b34f0d8e3102e0929e28310cebccf75c870c21e1ef35019e217df45f3df6ace3f23a39d7e13b2f57f18e126702bd5e3096125e200f65b
data/bin/d3 CHANGED
@@ -243,6 +243,9 @@ class App
243
243
  when :thaw then
244
244
  D3::Client.thaw_receipts @targets
245
245
 
246
+ when :forget then
247
+ D3::Client.forget_receipts @targets
248
+
246
249
  when :list_available then
247
250
  D3::Client.list_available @options.force
248
251
 
@@ -261,6 +264,9 @@ class App
261
264
  when :list_puppies then
262
265
  D3::Client.list_pending_puppies
263
266
 
267
+ when :list_queue then
268
+ D3::Client.list_pending_puppies
269
+
264
270
  when :list_details then
265
271
  D3::Client.list_details @targets
266
272
 
@@ -305,8 +311,18 @@ end # class App
305
311
  ############
306
312
  # Do it
307
313
  ############
308
- stty_save = `stty -g`.chomp
309
- trap("SIGINT") { puts "\nCancelled! Woot!" ; system('stty', stty_save); exit 0 }
314
+
315
+
316
+ ### save terminal state incase user interrupts during readline or less
317
+ if $stdin.tty?
318
+ stty_save = `stty -g`.chomp
319
+ trap("SIGINT") do
320
+ puts "\nCancelled! Woot!"
321
+ system('stty', stty_save)
322
+ exit 0
323
+ end
324
+ end
325
+
310
326
 
311
327
  begin
312
328
  # if needed, set debugging even before we make the app
data/bin/d3admin CHANGED
@@ -57,8 +57,8 @@ class App
57
57
  ### parse the commandline
58
58
  parse_commandline
59
59
 
60
- # can't ever be run as root - no keychain, among other things
61
- raise "d3admin can't be run as root" if JSS.superuser? and (not @action =~ /^h/)
60
+ # can't be run as root other than help, search or report - no keychain, among other things
61
+ raise "d3admin can't make server changes as root" if JSS.superuser? and (not @action =~ /^[hsr]/)
62
62
 
63
63
  end #initialize
64
64
 
@@ -274,12 +274,12 @@ class App
274
274
  @options.oses = arg
275
275
  when '--expiration'
276
276
  @options.expiration = arg
277
- when '--expiration-path'
278
- @options.expiration_path = arg
277
+ when '--expiration-path', '--expiration_paths'
278
+ @options.expiration_paths = arg
279
279
 
280
280
  # delete
281
- when '--delete-scripts'
282
- @options.delete_scripts = 'y'
281
+ when '--keep-scripts'
282
+ @options.keep_scripts = 'y'
283
283
  when '--keep-in-jss'
284
284
  @options.keep_in_jss = 'y'
285
285
 
@@ -398,12 +398,21 @@ ENDVERS
398
398
 
399
399
  # via the commandline
400
400
  else
401
- # for any options that weren't given on the commandline, use the defaults
402
- default_options.each_pair do |opt, val|
403
- next if @options[opt]
404
- @options[opt] = val
401
+
402
+ # if we were given a new version but not a new revision,
403
+ # set the new revision to 1
404
+ if @options[:version] and @options[:version] != default_options[:version]
405
+ @options[:revision] ||= 1
406
+ @options[:edition] ||= "#{@options.basename}-#{@options[:version]}-#{@options[:revision]}"
407
+ @options.package_name ||= @options[:edition]
408
+ @options.filename ||= "#{@options[:edition]}.#{default_options.package_build_type}"
409
+
405
410
  end
406
411
 
412
+ # for any options that weren't given on the commandline, use the defaults
413
+ default_options.each_pair { |opt, val| @options[opt] ||= val }
414
+
415
+
407
416
  new_package_options = D3::Admin::Add.add_pilot_cli(@options)
408
417
 
409
418
  ##########################
@@ -594,17 +603,21 @@ ENDVERS
594
603
 
595
604
  got_scripts = (not pkg.script_ids.values.empty?)
596
605
 
597
- if @options.walkthru
598
- @options.delete_scripts = D3::Admin::Interactive.get_value(:get_delete_scripts, default = 'n', check_method = :validate_yes_no)
599
- @options.keep_in_jss = D3::Admin::Interactive.get_value(:get_keep_in_jss, default = 'n', check_method = :validate_yes_no)
600
- end
601
-
602
606
  if got_scripts
603
- if @options.delete_scripts
604
- deets = " - Deleting pre- or post- scripts not in use elsewhere"
605
- else
607
+
608
+ if @options.walkthru
609
+ @options.keep_scripts = D3::Admin::Interactive.get_value(:get_keep_scripts, default = 'n', check_method = :validate_yes_no)
610
+
611
+ @options.keep_in_jss = D3::Admin::Interactive.get_value(:get_keep_in_jss, default = 'n', check_method = :validate_yes_no)
612
+ end # if @options.walkthru
613
+
614
+
615
+ if @options.keep_scripts
606
616
  deets = " - Keeping pre- or post- scripts in the JSS"
607
- end # if @options.delete_scripts
617
+ else
618
+ deets = " - Deleting pre- or post- scripts not used elsewhere"
619
+ end # if @options.keep_scripts
620
+
608
621
  else
609
622
  deets = " - No pre- or post- scripts to delete"
610
623
  end # if got_scripts
@@ -617,13 +630,13 @@ ENDVERS
617
630
 
618
631
  confirm "DELETE #{pkg.edition}, JSS id #{pkg.id}\nDist.Point Filename: #{pkg.filename}", deets
619
632
 
620
- if @options.delete_scripts && got_scripts
633
+ if @options.keep_scripts && got_scripts
621
634
  puts "Scanning for other packages or policies using pre- or post- scripts before deleting..."
622
635
  end
623
636
 
624
637
  script_actions = pkg.delete(
625
638
  admin: @admin,
626
- delete_scripts: @options.delete_scripts,
639
+ keep_scripts: @options.keep_scripts,
627
640
  keep_in_jss: @options.keep_in_jss,
628
641
  rwpw: D3::Admin::Auth.rw_credentials(:dist)[:password]
629
642
  )
@@ -646,11 +659,11 @@ ENDVERS
646
659
  if script_ids.empty?
647
660
  deets = " - No pre- or post- scripts to delete"
648
661
  else
649
- if @options.delete_scripts
650
- deets = " - Deleting pre- or post- scripts not in use elsewhere"
651
- else
662
+ if @options.keep_scripts
652
663
  deets = " - Keeping pre- or post- scripts in the JSS"
653
- end # if @options.delete_scripts
664
+ else
665
+ deets = " - Deleting pre- or post- scripts not in use elsewhere"
666
+ end # if @options.keep_scripts
654
667
  end # if script_ids.empty?
655
668
 
656
669
  confirm "DELETE #{pkg_data[:edition]}\n** Already missing from the JSS **", deets
@@ -658,7 +671,7 @@ ENDVERS
658
671
  JSS::DB_CNX.db.query "DELETE FROM #{D3::Database::PACKAGE_TABLE[:table_name]} WHERE package_id = #{pkgid}"
659
672
  puts "Package #{pkg_data[:edition]} deleted."
660
673
 
661
- if @options.delete_scripts && (not script_ids.empty?)
674
+ if (not @options.keep_scripts) && (not script_ids.empty?)
662
675
  puts "Scanning for other packages or policies using pre- or post- scripts before deleting..."
663
676
  policy_scripts = D3.policy_scripts
664
677
  script_ids.each do |victim_script_id|
@@ -679,7 +692,7 @@ ENDVERS
679
692
  puts "Deleted script '#{victim_script_name}'"
680
693
  end
681
694
  end # do script id
682
- end # if @options.delete_scripts && (not script_ids.empty?)
695
+ end # if @options.keep_scripts && (not script_ids.empty?)
683
696
 
684
697
  end # delete_missing_package (pkgid)
685
698
 
@@ -837,13 +850,6 @@ ENDDEETS
837
850
  end # @targets.each do |search_target|
838
851
  end # def search
839
852
 
840
- ### show a list of packges on the server
841
- def show_package_list (basename, statuses)
842
-
843
- D3::Admin::Report.show_list basename, @options.status
844
-
845
- end # show_package_list
846
-
847
853
  ### show a report
848
854
  ###
849
855
  ### @return [void]
@@ -923,6 +929,9 @@ ENDDEETS
923
929
  end
924
930
 
925
931
  end # if reporting puppies
932
+
933
+ # blank line between reports, for clarity
934
+ puts
926
935
  end # targets each
927
936
  end # show_report
928
937
 
@@ -941,73 +950,34 @@ ENDDEETS
941
950
  else
942
951
  D3::Admin::Prefs.config @targets, @options
943
952
  end
944
-
945
- # if @options.walkthru
946
- # tgt = D3::Admin::Interactive.get_value :get_config_target, "all"
947
- # @targets = [tgt]
948
- # end
949
- #
950
- # if @targets.empty? or @targets.include?("all")
951
- # @targets = D3::Admin::CONFIG_TARGETS - ["all"]
952
- # end
953
- #
954
- # @targets.each do |target|
955
- # case target
956
- # when"jss"
957
- # puts "******** JSS-API LOCATION AND READ-WRITE CREDENTIALS ********"
958
- # D3::Admin::Auth.ask_for_rw_credentials :jss
959
- #
960
- # when "db"
961
- # puts "******** JSS MYSQL LOCATION AND READ-WRITE CREDENTIALS ********"
962
- # D3::Admin::Auth.ask_for_rw_credentials :db
963
- #
964
- # when "dist"
965
- # puts "******** MASTER DIST-POINT READ-WRITE PASSWORD ********"
966
- # D3::Admin::Auth.ask_for_rw_credentials :dist
967
- #
968
- # when "workspace"
969
- # puts "******** LOCAL PKG/DMG BUILD WORKSPACE ********"
970
- # pth = D3::Admin::Interactive.get_value :workspace, D3::Admin::Prefs.prefs[:workspace]
971
- # D3::Admin::Prefs.set_pref :workspace, pth
972
- # D3::Admin::Prefs.save_prefs
973
- # puts "Thank you, the path has been saved in your d3admin prefs"
974
- # puts
975
- #
976
- # when "pkg-id-prefix"
977
- # puts "******** .PKG IDENTIFIER PREFIX ********"
978
- # pfx = D3::Admin::Interactive.get_value(:get_pkg_identifier_prefix, D3::Admin::Prefs.prefs[:apple_pkg_id_prefix], :validate_package_identifier_prefix)
979
- # D3::Admin::Prefs.set_pref :apple_pkg_id_prefix, pfx
980
- # D3::Admin::Prefs.save_prefs
981
- # puts "Thank you, the prefix has been saved in your d3admin prefs"
982
- # puts
983
- # else
984
- # puts "(skipping unknown config setting: #{target}"
985
- # end # case
986
- # end # targets.each
987
953
  end # config
988
954
 
989
955
 
990
956
  end # class App
991
957
 
992
958
 
993
- ### Create and run the application
994
959
 
995
- # save terminal state incase user interrupts during readline or less
996
- stty_save = `stty -g`.chomp
997
- trap("SIGINT") { puts "\nCancelled! Woot!" ; system('stty', stty_save); exit 0 }
960
+
961
+ ### save terminal state incase user interrupts during readline or less
962
+ if $stdin.tty?
963
+ stty_save = `stty -g`.chomp
964
+ trap("SIGINT") do
965
+ puts "\nCancelled! Woot!"
966
+ system('stty', stty_save)
967
+ exit 0
968
+ end
969
+ end
998
970
 
999
971
  begin
1000
972
  app = App.new
1001
973
  app.run
1002
974
  rescue
1003
- # handle exceptions
1004
975
  puts "An error occurred: #{$!.class}: #{$!}"
1005
976
  puts $@ if D3::Admin.debug
1006
977
  exit 1
1007
978
  ensure
1008
- # cleanup
1009
- if JSS::API.connected?
1010
- JSS::DistributionPoint.master_distribution_point.unmount if JSS::DistributionPoint.master_distribution_point.mounted?
979
+ if D3::Admin::Auth.connected?
980
+ # JSS::DistributionPoint.master_distribution_point.unmount if JSS::DistributionPoint.master_distribution_point.mounted?
1011
981
  D3::Admin::Auth.disconnect
1012
982
  end
1013
983
  end # begin
data/bin/d3helper CHANGED
@@ -325,7 +325,7 @@ Watch a parade of cute puppies while these items are installed:
325
325
  :installed_at => jss_rcpt.mtime,
326
326
  :removable => d3_pkg.removable,
327
327
  :expiration => d3_pkg.expiration,
328
- :expiration_path => d3_pkg.expiration_path,
328
+ :expiration_paths => d3_pkg.expiration_paths,
329
329
  :prohibiting_process => d3_pkg.prohibiting_process,
330
330
  :pre_remove_script_id => d3_pkg.pre_remove_script_id,
331
331
  :post_remove_script_id => d3_pkg.post_remove_script_id
data/lib/d3/admin/add.rb CHANGED
@@ -54,7 +54,7 @@ module D3
54
54
  pre_remove
55
55
  post_remove
56
56
  expiration
57
- expiration_path
57
+ expiration_paths
58
58
  source_path
59
59
  }.map{|i| i.to_sym}
60
60
 
@@ -115,6 +115,7 @@ END_HEADER
115
115
  # Here the value we're actually editing
116
116
  current_opt_value = options[chosen_opt]
117
117
 
118
+
118
119
  # if we're editing version or revision, and the current pkg or filenames are
119
120
  # based on them then make a note to update the names when we get the new values
120
121
  if chosen_opt == :basename or chosen_opt == :version or chosen_opt == :revision
@@ -137,6 +138,14 @@ END_HEADER
137
138
  # prompt for a new value and put it in place
138
139
  options[chosen_opt] = D3::Admin::Interactive.get_value(chosen_opt, current_opt_value, nil)
139
140
 
141
+ # if we changed the version, reset the revision to 1 and update values as needed
142
+ if chosen_opt == :version and options[chosen_opt] != current_opt_value
143
+ options[:revision] = 1
144
+ update_edition = true
145
+ update_pkg_name = options.package_name.start_with? options.edition
146
+ update_filename = options.filename.start_with? options.edition
147
+ end
148
+
140
149
  # if we edited the version or revision, we might need to update names and edition
141
150
  options.edition = "#{options.basename}-#{options.version}-#{options.revision}" if update_edition
142
151
  options.package_name = "#{options.edition}.#{options.package_build_type}" if update_pkg_name
@@ -271,7 +280,7 @@ END_HEADER
271
280
 
272
281
  # expiration path if expiration
273
282
  if options_from_user[:expiration] > 0
274
- errors << "expiration path cannot be empty if expiration is > 0 ." unless options_from_user[:expiration_path]
283
+ errors << "expiration path cannot be empty if expiration is > 0 ." unless options_from_user[:expiration_paths]
275
284
  end
276
285
  return [options_from_user, errors]
277
286
  end # validate_all_new_package_options
data/lib/d3/admin/auth.rb CHANGED
@@ -50,6 +50,9 @@ module D3
50
50
  KEYCHAIN_DIST_SERVICE = KEYCHAIN_SERVICE_BASE + ".distribution"
51
51
  KEYCHAIN_DIST_LABEL = KEYCHAIN_LABEL_BASE + ".distribution"
52
52
 
53
+ @@connected = false
54
+
55
+
53
56
  ### Connect to the JSS API and MySQL DB
54
57
  ### with admin credentials from the keychain
55
58
  ###
@@ -62,15 +65,31 @@ module D3
62
65
  JSS::DB_CNX.connect :user => db[:user], :pw => db[:password], :connect_timeout => 10
63
66
  JSS::API.connect :user => api[:user], :pw => api[:password], :open_timeout => 10
64
67
  D3::Database.check_schema_version
68
+
69
+ @@connected = true
70
+
65
71
  return JSS::API.cnx.options[:server]
66
72
  end
67
73
 
68
- # Disconnect admin credentials from the JSS API and MySQL DB
74
+ ### Disconnect admin credentials from the JSS API and MySQL DB
75
+ ###
76
+ ### @return [void]
77
+ ###
69
78
  def disconnect
70
79
  JSS::API.disconnect if JSS::API.connected?
71
80
  JSS::DB_CNX.disconnect if JSS::DB_CNX.connected?
81
+ @@connected = false
72
82
  end
73
83
 
84
+ ### Are we currently connected as an admin?
85
+ ###
86
+ ### return [Boolean]
87
+ ###
88
+ def connected?
89
+ @@connected
90
+ end
91
+
92
+
74
93
  ### Fetch read-write credentials from the login keychain
75
94
  ###
76
95
  ### If the login keychain is locked, the user will be prompted
@@ -449,8 +468,6 @@ module D3
449
468
  raise JSS::AuthenticationError, "Three incorrect attempts to unlock keychain" if tries == 3
450
469
  return true
451
470
  end # unlock keychain
452
-
453
-
454
471
  end # module Auth
455
472
 
456
473
  ### @see D3::Admin::Auth.connect
data/lib/d3/admin/edit.rb CHANGED
@@ -53,7 +53,7 @@ module D3
53
53
  pre_remove
54
54
  post_remove
55
55
  expiration
56
- expiration_path
56
+ expiration_paths
57
57
  description
58
58
  }.map{|i| i.to_sym}
59
59
 
data/lib/d3/admin/help.rb CHANGED
@@ -92,11 +92,12 @@ Action add and edit:
92
92
  -c, --cpu <type> Limit installation to 'intel' or 'ppc'
93
93
  -C, --category <category> The JSS Category for this package
94
94
  -X, --expiration <days> Auto-uninstall if unused for <days>
95
- -P, --expiration-path <path> Path to executable that must be used
95
+ -P, --expiration-path(s) <path> Path(s) to executable(s) that must be used
96
+ (Multiple paths should be comma separated)
96
97
 
97
98
  Action delete:
98
- --delete-scripts Delete scripts associated with this pkg
99
- --keep-in-jss Delete from d3 but leave in the JSS
99
+ --keep-scripts Keep pre-/post- scripts in Casper
100
+ --keep-in-jss Delete pkg from d3 but leave in Casper
100
101
 
101
102
  Action search or report:
102
103
  -S, --status <status> Limit package list to this status
@@ -347,18 +348,19 @@ Action add and edit:
347
348
  and expiration must be allowed in the
348
349
  client config.
349
350
 
350
- -P, --expiration-path <path> The path to the executable the must be used
351
- within the expiration period to avoid
352
- being uninstalled
351
+ -P, --expiration-path(s) <path> The path(s) to the executable(s) the must
352
+ be used within the expiration period to
353
+ avoid being uninstalled
353
354
 
354
355
  Action delete:
355
356
 
356
- --delete-scripts Delete any scripts associated with this pkg
357
- if they aren't in use elsewhere. Those in
358
- use will be reported.
357
+ --keep-scripts Keep any scripts associated with this pkg
358
+ in Casper. Note: scripts used by other
359
+ packages or polices are never deleted.
359
360
 
360
- --keep-in-jss Leave the package in the JSS after deleting
361
- it from d3
361
+ --keep-in-jss Leave the package in Casper after deleting
362
+ it from d3. Note: packages used by
363
+ policies are never deleted from Casper.
362
364
 
363
365
 
364
366
  Action search:
@@ -394,4 +396,3 @@ ENDHELP
394
396
  end # module help
395
397
  end # module admin
396
398
  end # module D3
397
-
@@ -830,37 +830,38 @@ Enter the number of days, or 0 for no expiration.
830
830
  prompt_for_data(desc: desc, prompt: "Expiration days", default: default, required: true)
831
831
  end
832
832
 
833
- ### Get the path to the application to monitor for expiration
833
+ ### Get the path to the executable(s) to monitor for expiration
834
834
  ###
835
- ### @param default[Pathname, String] the default choice when typing return
835
+ ### @param default[String, Pathname, Array<String,Pathname>] the path(s)
836
836
  ###
837
- ### @return [Pathname] the path to the application
837
+ ### @return [Array<Pathname>] the path(s) to the executable
838
838
  ###
839
- def get_expiration_path (default = 'n')
839
+ def get_expiration_paths (default = 'n')
840
840
  desc = <<-END_DESC
841
- EXPIRATION PATH
842
- Enter the path to a the application that must be used
843
- to prevent expiration.
844
- E.g. /Applications/Google Chrome.app
841
+ EXPIRATION PATH(S)
842
+ Enter the path(s) to the executable(s) that must be used
843
+ to prevent expiration. Multiple paths should be separated by commas, spaces
844
+ should not be escaped. E.g.
845
+ /Applications/Google Chrome.app/Contents/MacOS/Google Chrome, /Applications/Firefox.app/Contents/MacOS/firefox
845
846
  Enter 'n' for none
846
847
  END_DESC
847
- prompt_for_data(desc: desc, prompt: "Expiration Path", default: default, required: true)
848
+ prompt_for_data(desc: desc, prompt: "Expiration Path(s)", default: default, required: true)
848
849
  end
849
850
 
850
- ### when deleting a pkg, should its pre- and post- scripts be deleted
851
+ ### when deleting a pkg, should its pre- and post- scripts be kept?
851
852
  ###
852
853
  ### @param default[String] the default answer when user hits return
853
854
  ###
854
855
  ### @return [String] the users response
855
856
  ###
856
- def get_delete_scripts (default = 'n')
857
+ def get_keep_scripts (default = 'n')
857
858
  desc = <<-END_DESC
858
- DELETE ASSOCIATED SCRIPTS?
859
+ KEEP ASSOCIATED SCRIPTS IN CASPER?
859
860
  When deleting a package, should any associated scripts
860
- (pre-install, post-install, pre-remove, post-remove) also be deleted?
861
+ (pre-install, post-install, pre-remove, post-remove) be kept in Casper?
861
862
 
862
863
  NOTE: If any other d3 packages or policies are using the scripts
863
- they won't be deleted, but the other users will be reported.
864
+ they won't be deleted. The other users of the scripts will be reported.
864
865
  Enter 'y' or 'n'
865
866
  END_DESC
866
867
  prompt_for_data(desc: desc, prompt: "Delete Scripts? (y/n)", default: default, required: true)
@@ -874,8 +875,8 @@ Enter 'y' or 'n'
874
875
  ###
875
876
  def get_keep_in_jss (default = 'n')
876
877
  desc = <<-END_DESC
877
- KEEP THE PACKAGE IN THE JSS?
878
- When deleting a package, should it be kept as a JSS package
878
+ KEEP THE PACKAGE IN CASPER?
879
+ When deleting a package, should it be kept as a Casper package
879
880
  and only deleted from d3?
880
881
  Enter 'y' or 'n'
881
882
  END_DESC
@@ -970,4 +971,3 @@ END_DESC
970
971
  end # module
971
972
  end # module Admin
972
973
  end # module D3
973
-
@@ -348,14 +348,14 @@ module D3
348
348
  :unsetable => true,
349
349
  :validate => :validate_expiration
350
350
  },
351
- expiration_path: {
351
+ expiration_paths: {
352
352
  :default => nil,
353
- :cli => [ '--expiration-path', '-P', GetoptLong::REQUIRED_ARGUMENT ],
354
- :label=> "Expiration Path",
355
- :display_conversion => DISPLAY_DFT_NONE,
356
- :get => :get_expiration_path,
353
+ :cli => [ '--expiration-path', '--expiration-paths', '-P', GetoptLong::REQUIRED_ARGUMENT ],
354
+ :label=> "Expiration Path(s)",
355
+ :display_conversion => D3::Database::ARRAY_OF_PATHNAMES_TO_COMMA_STRING ,
356
+ :get => :get_expiration_paths,
357
357
  :unsetable => true,
358
- :validate => :validate_expiration_path
358
+ :validate => :validate_expiration_paths
359
359
  },
360
360
  description: {
361
361
  :default => '',
@@ -415,12 +415,12 @@ module D3
415
415
 
416
416
 
417
417
  # Delete
418
- delete_scripts: {
418
+ keep_scripts: {
419
419
  :default => nil,
420
- :cli => [ '--delete-scripts', GetoptLong::NO_ARGUMENT ],
421
- :label => "Delete associated scripts",
420
+ :cli => [ '--keep-scripts', GetoptLong::NO_ARGUMENT ],
421
+ :label => "Keep associated scripts in Casper",
422
422
  :display_conversion => DISPLAY_TRUE_FALSE,
423
- :get => :get_delete_scripts,
423
+ :get => :get_keep_scripts,
424
424
  :validate => :validate_yes_no
425
425
  },
426
426
  keep_in_jss: {
@@ -522,14 +522,33 @@ module D3
522
522
  ###### Data gathering
523
523
 
524
524
  ### Reconnect to both the API and DB with a much larger timeout, and
525
- ### using an alternate DB server if one is defined.
525
+ ### using an alternate DB server if one is defined. Also connect with
526
+ ### the read-only accts, since rw isn't needed, retrieving the pws
527
+ ### requires an admin keychain, which makes automated reporting
528
+ ### unpleasant.
526
529
  ###
527
530
  ### @return [Hash<String>] the hostnames of the connected JSS & MySQL servers
528
531
  ###
529
532
  def connect_for_reports
530
- api = D3::Admin::Auth.rw_credentials :jss
531
- db = D3::Admin::Auth.rw_credentials :db
532
- D3.connect_for_reports api[:user], api[:password], db[:user], db[:password]
533
+ if JSS.superuser?
534
+ jss_user = D3::CONFIG.client_jss_ro_user
535
+ jss_user ||= JSS::CONFIG.api_username
536
+ jss_pw = D3::Client.get_ro_pass(:jss)
537
+
538
+ db_user = D3::CONFIG.client_db_ro_user
539
+ db_user ||= JSS::CONFIG.db_username
540
+ db_pw = D3::Client.get_ro_pass(:db)
541
+
542
+ else
543
+ api = D3::Admin::Auth.rw_credentials :jss
544
+ jss_user = api[:user]
545
+ jss_pw = api[:password]
546
+
547
+ db = D3::Admin::Auth.rw_credentials :db
548
+ db_user = db[:user]
549
+ db_pw = db[:password]
550
+ end
551
+ D3.connect_for_reports jss_user, jss_pw, db_user, db_pw
533
552
  end # connect for report
534
553
 
535
554
  ### Get the raw data for a client-install report, from the EA if available
@@ -541,8 +560,6 @@ module D3
541
560
  ### @return [Array<Hash>] The data for doing client install reports
542
561
  ###
543
562
  def computer_receipts_data
544
- puts "Querying Casper for receipt data..."
545
-
546
563
  the_data = computer_receipts_ea_data
547
564
  return the_data if the_data
548
565
  return computer_receipts_jamf_data
@@ -397,6 +397,18 @@ module D3
397
397
  D3::Package::Validate.validate_expiration exp
398
398
  end
399
399
 
400
+ ### Confirm the validity of one or more expiration paths.
401
+ ### Any string that starts with a / is valid.
402
+ ### The strings "n" or "none" returns an empty array.
403
+ ###
404
+ ### @param paths[Pathname, String, Array<String,Pathname>] the path(s) to check
405
+ ###
406
+ ### @return [Array<Pathname>] the valid path
407
+ ###
408
+ def validate_expiration_paths (paths)
409
+ D3::Package::Validate.validate_expiration_paths paths
410
+ end
411
+
400
412
  ### Confirm the validity of an expiration path.
401
413
  ### any string that starts with a / is valid.
402
414
  ###
data/lib/d3/basename.rb CHANGED
@@ -121,7 +121,7 @@ module D3
121
121
  attr_reader :expiration
122
122
 
123
123
  # @return [String] the path to the executable that needs come to the foreground to prevent expiration
124
- attr_reader :expiration_path
124
+ attr_reader :expiration_paths
125
125
 
126
126
 
127
127
  ################# Public Instance Methods #################
@@ -213,6 +213,21 @@ module D3
213
213
  raise JSS::InvalidDataError, "status must be one of :#{STATUSES.join(', :')}" unless STATUSES.include? new_status
214
214
  @status = new_status
215
215
  end
216
+
217
+ ### Does a given array of pathnames have the same elements as
218
+ ### @expiration_paths regardless of order?
219
+ ###
220
+ ### This is generally used to compare two @expiration_paths
221
+ ### arrays for "equality"
222
+ ###
223
+ ### @param other_exp_paths[Array] An array if Pathnames to compare to @expiration_paths
224
+ ###
225
+ ### @return [Boolean] Are they the same aside from order?
226
+ ###
227
+ def expiration_paths_match?(other_exp_paths)
228
+ return false unless @expiration_paths.length == other_exp_paths.length
229
+ (@expiration_paths - other_exp_paths).empty?
230
+ end
216
231
 
217
232
  end # module Basename
218
233
  end # module PixD3