open_directory_utils 0.1.3 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/open_directory_utils/connection.rb +13 -19
- data/lib/open_directory_utils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c37dea537a3c3bc485752eda8c5ffc5ae651ba59abeb19ed797c9361337eca77
|
4
|
+
data.tar.gz: 9acd8a277cd637a83fa5e2c378f58542b2ca8a64498ad80cabc2848ad1dddd47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2e8b07003c61f730a5f1559737cfb7e20740694981ebba75afd3aadcb32973931e3b357705ee1b52c8cd0f0e32ac098ff335145bbf4639b2982c8b838edf628
|
7
|
+
data.tar.gz: 153f9fc11e4951844fb27a20d462abb1035416cecec907a60573940fd43308d13d4a68e4c881276982ad47c4856167b9b3622be5d88f3d002b7fa6b8a39c6db2
|
data/README.md
CHANGED
@@ -7,6 +7,7 @@ One can also build custom DSCL commands and send them to the server as needed to
|
|
7
7
|
|
8
8
|
## Change Log
|
9
9
|
|
10
|
+
* **v0.1.4** - 2018-06-13 - changed the return hash to {response: xxx, status: 'success'}
|
10
11
|
* **v0.1.3** - 2018-06-13 - able to sync all fields in typcial OD
|
11
12
|
- refactored results code (ssh_cmds have redacted passwords)
|
12
13
|
- finished adding pre-built od commands for users - good for syncing accounts
|
@@ -42,6 +42,7 @@ module OpenDirectoryUtils
|
|
42
42
|
# @command [Symbol] - required -- to choose the action wanted
|
43
43
|
# @params [Hash] - required -- necessary information to accomplish action
|
44
44
|
# @output [String] - optional -- 'xml' or 'plist' will return responses using xml format
|
45
|
+
# response [Hash] - { response: results, status: status, command: command, attributes: params, dscl_cmds: ssh_clean }
|
45
46
|
def run(command:, params:, output: nil)
|
46
47
|
answer = {}
|
47
48
|
params[:format] = output
|
@@ -54,7 +55,7 @@ module OpenDirectoryUtils
|
|
54
55
|
answer = process_results(results, command, params, ssh_cmds )
|
55
56
|
return answer
|
56
57
|
rescue ArgumentError, NoMethodError => error
|
57
|
-
format_results(error.message, command, params, ssh_cmds,
|
58
|
+
format_results(error.message, command, params, ssh_cmds, 'error')
|
58
59
|
end
|
59
60
|
|
60
61
|
private
|
@@ -78,7 +79,7 @@ module OpenDirectoryUtils
|
|
78
79
|
if missing_resource?(results)
|
79
80
|
results = ["Resource not found", results]
|
80
81
|
# report lack of success
|
81
|
-
return format_results(results, command, params, ssh_cmds,
|
82
|
+
return format_results(results, command, params, ssh_cmds, 'error')
|
82
83
|
end
|
83
84
|
if command.eql?(:user_password_verified?) or command.eql?(:user_password_ok?)
|
84
85
|
return report_password_check(results, command, params, ssh_cmds)
|
@@ -91,35 +92,28 @@ module OpenDirectoryUtils
|
|
91
92
|
end
|
92
93
|
if results.to_s.include? 'attribute status: eDSNoStdMappingAvailable'
|
93
94
|
results = ["Bad Attribute Description", results]
|
94
|
-
format_results(results, command, params, ssh_cmds,
|
95
|
+
format_results(results, command, params, ssh_cmds, 'error')
|
95
96
|
end
|
96
97
|
if missed_errors?(results)
|
97
98
|
results = ["Unexpected Error", results]
|
98
|
-
format_results(results, command, params, ssh_cmds,
|
99
|
+
format_results(results, command, params, ssh_cmds, 'error')
|
99
100
|
end
|
100
101
|
# return any general success answers
|
101
|
-
format_results(results, command, params, ssh_cmds, success
|
102
|
+
format_results(results, command, params, ssh_cmds, 'success')
|
102
103
|
end
|
103
104
|
|
104
|
-
def format_results(results, command, params, ssh_cmds,
|
105
|
+
def format_results(results, command, params, ssh_cmds, status)
|
105
106
|
ssh_clean = ssh_cmds.to_s
|
106
107
|
ssh_clean = ssh_clean.gsub(/-[p] ".+"/, '-p "************"')
|
107
108
|
ssh_clean = ssh_clean.gsub(/-[P] ".+"/, '-P "************"')
|
108
|
-
|
109
|
-
|
110
|
-
when true
|
111
|
-
return { success:{response: results, command: command,
|
112
|
-
attributes: params, dscl_cmds: ssh_clean} }
|
113
|
-
else
|
114
|
-
return { error: {response: results, command: command,
|
115
|
-
attributes: params, dscl_cmds: ssh_clean} }
|
116
|
-
end
|
109
|
+
{ response: results, status: status, command: command,
|
110
|
+
attributes: params, dscl_cmds: ssh_clean }
|
117
111
|
end
|
118
112
|
|
119
113
|
def report_existence(results, command, params, ssh_cmds)
|
120
114
|
results = [false, results] if results.to_s.include?('eDSRecordNotFound')
|
121
115
|
results = [true, results] unless results.to_s.include?('eDSRecordNotFound')
|
122
|
-
return format_results(results, command, params, ssh_cmds, success
|
116
|
+
return format_results(results, command, params, ssh_cmds, 'success')
|
123
117
|
end
|
124
118
|
|
125
119
|
def missing_resource?(results)
|
@@ -135,7 +129,7 @@ module OpenDirectoryUtils
|
|
135
129
|
def report_password_check(results, command, params, ssh_cmds)
|
136
130
|
results = [false, results] if results.to_s.include?('eDSAuthFailed')
|
137
131
|
results = [true, results] unless results.to_s.include?('eDSAuthFailed')
|
138
|
-
return format_results(results, command, params, ssh_cmds, success
|
132
|
+
return format_results(results, command, params, ssh_cmds, 'success')
|
139
133
|
end
|
140
134
|
|
141
135
|
def missed_errors?(results)
|
@@ -149,14 +143,14 @@ module OpenDirectoryUtils
|
|
149
143
|
results = [false, results] if results.to_s.include?('account is disabled')
|
150
144
|
results = [true, results] unless results.to_s.include?('isDisabled=1') or
|
151
145
|
results.to_s.include?('account is disabled')
|
152
|
-
return format_results(results, command, params, ssh_cmds, success
|
146
|
+
return format_results(results, command, params, ssh_cmds, 'success')
|
153
147
|
end
|
154
148
|
|
155
149
|
def report_in_group(results, command, params, ssh_cmds)
|
156
150
|
username = params[:value]
|
157
151
|
results = [true, results] if results.to_s.include?( username )
|
158
152
|
results = [false, results] unless results.to_s.include?( username )
|
159
|
-
return format_results(results, command, params, ssh_cmds, success
|
153
|
+
return format_results(results, command, params, ssh_cmds, 'success')
|
160
154
|
end
|
161
155
|
|
162
156
|
def defaults
|