Class: MacAdmin::DSLocalNode
- Inherits:
-
Object
- Object
- MacAdmin::DSLocalNode
- Defined in:
- lib/macadmin/dslocal/dslocalnode.rb
Overview
DSLocalNode
-
constructs and manages Local OpenDirectory nodes
-
takes one parameter: name
-
if no name param is passed, ‘Default’ node is used
Constant Summary collapse
- SANDBOX_FILE =
'/System/Library/Sandbox/Profiles/com.apple.opendirectoryd.sb'
- PREFERENCES =
'/Library/Preferences/OpenDirectory/Configurations/Search.plist'
- PREFERENCES_LEGACY =
'/Library/Preferences/DirectoryService/SearchNodeConfig.plist'
- CHILD_DIRS =
['aliases', 'computer_lists', 'computergroups', 'computers', 'config', 'groups', 'networks', 'users']
- DSLOCAL_ROOT =
'/private/var/db/dslocal/nodes'
- DIRMODE =
16832
- FILEMODE =
33152
- OWNER =
0
- GROUP =
0
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#activate ⇒ Object
Add the node to the list of searchable directory services - also: add a sandbox configuration if required.
-
#active? ⇒ Boolean
Test whether or not the node is in the search path - also: test the sandbox configuration if required.
-
#create ⇒ Object
Create the directory structure.
-
#create_and_activate ⇒ Object
Compound method: create and then activate the node.
-
#cspsearchpath ⇒ Object
Returns the search path array.
-
#cspsearchpath=(array) ⇒ Object
Replaces the search path array.
-
#deactivate ⇒ Object
Remove the node to the list of searchable directory services - also: remove a sandbox configuration if required.
-
#destroy ⇒ Object
Destroy the directory structure.
-
#destroy_and_deactivate ⇒ Object
Compound method: destroy and then deactivate the node.
-
#exists? ⇒ Boolean
Does the directory structure exist?.
-
#exists_and_active? ⇒ Boolean
Compound method: does the node exist and is it active?.
-
#initialize(name = 'Default') ⇒ DSLocalNode
constructor
A new instance of DSLocalNode.
-
#searchpolicy ⇒ Object
Returns the search policy.
-
#searchpolicy=(val) ⇒ Object
Replaces the search policy.
Constructor Details
#initialize(name = 'Default') ⇒ DSLocalNode
Returns a new instance of DSLocalNode.
26 27 28 29 30 31 32 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 26 def initialize(name='Default') @name = name @label = "/Local/#{name}" @root = "#{DSLOCAL_ROOT}/#{name}" load_configuration_file self end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
24 25 26 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 24 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 24 def name @name end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
24 25 26 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 24 def root @root end |
Instance Method Details
#activate ⇒ Object
Add the node to the list of searchable directory services
-
also: add a sandbox configuration if required
88 89 90 91 92 93 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 88 def activate activate_sandbox if needs_sandbox? insert_node set_custom_searchpolicy save_config end |
#active? ⇒ Boolean
Test whether or not the node is in the search path
-
also: test the sandbox configuration if required
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 58 def active? if needs_sandbox? return false unless sandbox_active? end load_configuration_file if self.name.eql? 'Default' case policy = self.searchpolicy when Integer return true if policy < 3 else return true if policy =~ /\AdsAttrTypeStandard:[LN]SPSearchPath\z/ end end return false if cspsearchpath.nil? return false unless searchpolicy_is_custom? cspsearchpath.member?(@label) end |
#create ⇒ Object
Create the directory structure
77 78 79 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 77 def create create_directories end |
#create_and_activate ⇒ Object
Compound method: create and then activate the node
35 36 37 38 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 35 def create_and_activate create activate end |
#cspsearchpath ⇒ Object
Returns the search path array
118 119 120 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 118 def cspsearchpath eval @paths_key end |
#cspsearchpath=(array) ⇒ Object
Replaces the search path array
123 124 125 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 123 def cspsearchpath=(array) eval @paths_key+"= array" end |
#deactivate ⇒ Object
Remove the node to the list of searchable directory services
-
also: remove a sandbox configuration if required
97 98 99 100 101 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 97 def deactivate deactivate_sandbox if needs_sandbox? remove_node save_config end |
#destroy ⇒ Object
Destroy the directory structure
82 83 84 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 82 def destroy FileUtils.rm_rf @root end |
#destroy_and_deactivate ⇒ Object
Compound method: destroy and then deactivate the node
41 42 43 44 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 41 def destroy_and_deactivate destroy deactivate end |
#exists? ⇒ Boolean
Does the directory structure exist?
52 53 54 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 52 def exists? validate_directory_structure end |
#exists_and_active? ⇒ Boolean
Compound method: does the node exist and is it active?
47 48 49 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 47 def exists_and_active? exists? and active? end |
#searchpolicy ⇒ Object
Returns the search policy
104 105 106 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 104 def searchpolicy eval @policy_key end |
#searchpolicy=(val) ⇒ Object
Replaces the search policy
109 110 111 112 113 114 115 |
# File 'lib/macadmin/dslocal/dslocalnode.rb', line 109 def searchpolicy=(val) if val.is_a?(String) eval @policy_key+"= val" else eval @policy_key+"= #{val}" end end |