blob: 4edbed7576f877ff1472c863e2d861da6bb8700b [file] [log] [blame]
Ratan Guptae1f4db62019-04-11 18:57:42 +05301#include "ldap_config_mgr.hpp"
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -05002#include "ldap_configuration.hpp"
Ratan Gupta95a29312019-02-18 20:34:10 +05303#include "ldap_serialize.hpp"
Nagaraju Goruganti59287f02018-10-12 07:00:20 -05004#include "utils.hpp"
Ratan Gupta95a29312019-02-18 20:34:10 +05305#include <filesystem>
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -05006#include <fstream>
7#include <sstream>
8
9namespace phosphor
10{
11namespace ldap
12{
Ratan Guptae1f4db62019-04-11 18:57:42 +053013
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050014constexpr auto nslcdService = "nslcd.service";
Nagaraju Gorugantidccee2b2018-09-25 08:51:06 -050015constexpr auto nscdService = "nscd.service";
Nagaraju Goruganti59287f02018-10-12 07:00:20 -050016constexpr auto LDAPscheme = "ldap";
17constexpr auto LDAPSscheme = "ldaps";
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050018
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -050019using namespace phosphor::logging;
20using namespace sdbusplus::xyz::openbmc_project::Common::Error;
Ratan Gupta95a29312019-02-18 20:34:10 +053021namespace fs = std::filesystem;
Nagaraju Gorugantib26799a2018-09-28 13:12:19 -050022using Argument = xyz::openbmc_project::Common::InvalidArgument;
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -050023
24using Line = std::string;
25using Key = std::string;
26using Val = std::string;
27using ConfigInfo = std::map<Key, Val>;
28
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050029Config::Config(sdbusplus::bus::bus& bus, const char* path, const char* filePath,
Nagaraju Goruganti3b4d06a2018-11-08 03:13:38 -060030 const char* caCertFile, bool secureLDAP,
31 std::string lDAPServerURI, std::string lDAPBindDN,
32 std::string lDAPBaseDN, std::string&& lDAPBindDNPassword,
Ratan Guptaaeaf9412019-02-11 04:41:52 -060033 ConfigIface::SearchScope lDAPSearchScope,
34 ConfigIface::Type lDAPType, bool lDAPServiceEnabled,
35 std::string userNameAttr, std::string groupNameAttr,
36 ConfigMgr& parent) :
37 Ifaces(bus, path, true),
Ratan Gupta3a1c2742019-03-20 06:49:42 +053038 secureLDAP(secureLDAP), lDAPBindPassword(std::move(lDAPBindDNPassword)),
39 configFilePath(filePath), tlsCacertFile(caCertFile), bus(bus),
40 parent(parent)
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050041{
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050042 ConfigIface::lDAPServerURI(lDAPServerURI);
43 ConfigIface::lDAPBindDN(lDAPBindDN);
44 ConfigIface::lDAPBaseDN(lDAPBaseDN);
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050045 ConfigIface::lDAPSearchScope(lDAPSearchScope);
46 ConfigIface::lDAPType(lDAPType);
Ratan Guptaaeaf9412019-02-11 04:41:52 -060047 EnableIface::enabled(lDAPServiceEnabled);
48 ConfigIface::userNameAttribute(userNameAttr);
49 ConfigIface::groupNameAttribute(groupNameAttr);
Ratan Gupta3a1c2742019-03-20 06:49:42 +053050 // Don't update the bindDN password under ConfigIface::
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050051 writeConfig();
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050052 // Emit deferred signal.
53 this->emit_object_added();
Ratan Guptaaeaf9412019-02-11 04:41:52 -060054 parent.startOrStopService(nslcdService, enabled());
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050055}
56
Nagaraju Goruganti24194bd2018-09-18 09:55:09 -050057void Config::delete_()
58{
59 parent.deleteObject();
Nagaraju Gorugantidccee2b2018-09-25 08:51:06 -050060 try
61 {
Nagaraju Gorugantid514e5d2018-11-08 03:07:25 -060062 fs::path configDir = fs::path(configFilePath.c_str()).parent_path();
63
64 fs::copy_file(configDir / defaultNslcdFile, LDAP_CONFIG_FILE,
Nagaraju Gorugantidccee2b2018-09-25 08:51:06 -050065 fs::copy_options::overwrite_existing);
Nagaraju Gorugantidccee2b2018-09-25 08:51:06 -050066 }
67 catch (const std::exception& e)
68 {
69 log<level::ERR>("Failed to rename Config Files while deleting Object",
70 entry("ERR=%s", e.what()));
71 elog<InternalFailure>();
72 }
73
74 parent.restartService(nscdService);
75 parent.stopService(nslcdService);
Nagaraju Goruganti24194bd2018-09-18 09:55:09 -050076}
77
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050078void Config::writeConfig()
79{
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050080 std::stringstream confData;
Ratan Gupta9891f2f2018-10-06 12:07:35 +053081 auto isPwdTobeWritten = false;
Ratan Guptaaeaf9412019-02-11 04:41:52 -060082 std::string userNameAttr;
Ratan Gupta9891f2f2018-10-06 12:07:35 +053083
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -050084 confData << "uid root\n";
85 confData << "gid root\n\n";
86 confData << "ldap_version 3\n\n";
87 confData << "timelimit 30\n";
88 confData << "bind_timelimit 30\n";
89 confData << "pagesize 1000\n";
90 confData << "referrals off\n\n";
91 confData << "uri " << lDAPServerURI() << "\n\n";
92 confData << "base " << lDAPBaseDN() << "\n\n";
93 confData << "binddn " << lDAPBindDN() << "\n";
Ratan Gupta3a1c2742019-03-20 06:49:42 +053094 if (!lDAPBindPassword.empty())
Nagaraju Goruganti15675472018-10-05 07:03:05 -050095 {
Ratan Gupta3a1c2742019-03-20 06:49:42 +053096 confData << "bindpw " << lDAPBindPassword << "\n";
Ratan Gupta9891f2f2018-10-06 12:07:35 +053097 isPwdTobeWritten = true;
Nagaraju Goruganti15675472018-10-05 07:03:05 -050098 }
99 confData << "\n";
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500100 switch (lDAPSearchScope())
101 {
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600102 case ConfigIface::SearchScope::sub:
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500103 confData << "scope sub\n\n";
104 break;
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600105 case ConfigIface::SearchScope::one:
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500106 confData << "scope one\n\n";
107 break;
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600108 case ConfigIface::SearchScope::base:
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500109 confData << "scope base\n\n";
110 break;
111 }
112 confData << "base passwd " << lDAPBaseDN() << "\n";
113 confData << "base shadow " << lDAPBaseDN() << "\n\n";
Nagaraju Gorugantidb60f582018-11-08 03:14:48 -0600114 if (secureLDAP == true)
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500115 {
116 confData << "ssl on\n";
Nagaraju Goruganti3b4d06a2018-11-08 03:13:38 -0600117 confData << "tls_reqcert hard\n";
118 confData << "tls_cacertFile " << tlsCacertFile.c_str() << "\n";
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500119 }
120 else
121 {
Nagaraju Goruganti15675472018-10-05 07:03:05 -0500122 confData << "ssl off\n";
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500123 }
Nagaraju Goruganti15675472018-10-05 07:03:05 -0500124 confData << "\n";
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600125 if (lDAPType() == ConfigIface::Type::ActiveDirectory)
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500126 {
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600127 if (ConfigIface::userNameAttribute().empty())
128 {
129 ConfigIface::userNameAttribute("sAMAccountName");
130 }
131 if (ConfigIface::groupNameAttribute().empty())
132 {
133 ConfigIface::groupNameAttribute("primaryGroupID");
134 }
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500135 confData << "filter passwd (&(objectClass=user)(objectClass=person)"
136 "(!(objectClass=computer)))\n";
137 confData
138 << "filter group (|(objectclass=group)(objectclass=groupofnames) "
139 "(objectclass=groupofuniquenames))\n";
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600140 confData << "map passwd uid "
141 << ConfigIface::userNameAttribute() << "\n";
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500142 confData << "map passwd uidNumber "
143 "objectSid:S-1-5-21-3623811015-3361044348-30300820\n";
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600144 confData << "map passwd gidNumber "
145 << ConfigIface::groupNameAttribute() << "\n";
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500146 confData << "map passwd homeDirectory \"/home/$sAMAccountName\"\n";
147 confData << "map passwd gecos displayName\n";
148 confData << "map passwd loginShell \"/bin/bash\"\n";
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500149 confData << "map group gidNumber "
150 "objectSid:S-1-5-21-3623811015-3361044348-30300820\n";
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600151 confData << "map group cn "
152 << ConfigIface::userNameAttribute() << "\n";
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500153 }
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600154 else if (lDAPType() == ConfigIface::Type::OpenLdap)
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500155 {
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600156 if (ConfigIface::userNameAttribute().empty())
157 {
raviteja-bc3f56c52019-04-02 11:09:04 -0500158 ConfigIface::userNameAttribute("cn");
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600159 }
160 if (ConfigIface::groupNameAttribute().empty())
161 {
raviteja-bc3f56c52019-04-02 11:09:04 -0500162 ConfigIface::groupNameAttribute("gidNumber");
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600163 }
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500164 confData << "filter passwd (objectclass=*)\n";
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500165 confData << "map passwd gecos displayName\n";
Nagaraju Goruganti808eda42018-10-10 08:48:12 -0500166 confData << "filter group (objectclass=posixGroup)\n";
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600167 confData << "map passwd uid "
168 << ConfigIface::userNameAttribute() << "\n";
169 confData << "map passwd gidNumber "
170 << ConfigIface::groupNameAttribute() << "\n";
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500171 }
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500172 try
173 {
174 std::fstream stream(configFilePath.c_str(), std::fstream::out);
Ratan Gupta9891f2f2018-10-06 12:07:35 +0530175 // remove the read permission from others if password is being written.
176 // nslcd forces this behaviour.
177 auto permission = fs::perms::owner_read | fs::perms::owner_write |
178 fs::perms::group_read;
179 if (isPwdTobeWritten)
180 {
181 fs::permissions(configFilePath, permission);
182 }
183 else
184 {
185 fs::permissions(configFilePath,
186 permission | fs::perms::others_read);
187 }
188
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500189 stream << confData.str();
190 stream.flush();
191 stream.close();
192 }
193 catch (const std::exception& e)
194 {
195 log<level::ERR>(e.what());
196 elog<InternalFailure>();
197 }
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500198 return;
199}
200
Ratan Gupta3a1c2742019-03-20 06:49:42 +0530201std::string Config::lDAPBindDNPassword(std::string value)
202{
203 // Don't update the D-bus object, this is just to
204 // facilitate if user wants to change the bind dn password
205 // once d-bus object gets created.
206 lDAPBindPassword = value;
207 try
208 {
209 writeConfig();
210 parent.startOrStopService(nslcdService, enabled());
211 }
212 catch (const InternalFailure& e)
213 {
214 throw;
215 }
216 catch (const std::exception& e)
217 {
218 log<level::ERR>(e.what());
219 elog<InternalFailure>();
220 }
221 return value;
222}
223
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500224std::string Config::lDAPServerURI(std::string value)
225{
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500226 std::string val;
227 try
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500228 {
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500229 if (value == lDAPServerURI())
230 {
231 return value;
232 }
Nagaraju Goruganti59287f02018-10-12 07:00:20 -0500233 if (isValidLDAPURI(value, LDAPSscheme))
Nagaraju Gorugantib26799a2018-09-28 13:12:19 -0500234 {
Nagaraju Goruganti59287f02018-10-12 07:00:20 -0500235 secureLDAP = true;
236 }
237 else if (isValidLDAPURI(value, LDAPscheme))
238 {
239 secureLDAP = false;
Nagaraju Gorugantidb60f582018-11-08 03:14:48 -0600240 }
241 else
242 {
Nagaraju Goruganti59287f02018-10-12 07:00:20 -0500243 log<level::ERR>("bad LDAP Server URI",
244 entry("LDAPSERVERURI=%s", value.c_str()));
245 elog<InvalidArgument>(Argument::ARGUMENT_NAME("lDAPServerURI"),
246 Argument::ARGUMENT_VALUE(value.c_str()));
Nagaraju Gorugantib26799a2018-09-28 13:12:19 -0500247 }
Nagaraju Goruganti3b4d06a2018-11-08 03:13:38 -0600248
249 if (secureLDAP && !fs::exists(tlsCacertFile.c_str()))
250 {
251 log<level::ERR>("LDAP server's CA certificate not provided",
252 entry("TLSCACERTFILE=%s", tlsCacertFile.c_str()));
253 elog<NoCACertificate>();
254 }
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500255 val = ConfigIface::lDAPServerURI(value);
256 writeConfig();
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600257 parent.startOrStopService(nslcdService, enabled());
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500258 }
259 catch (const InternalFailure& e)
260 {
261 throw;
262 }
Nagaraju Goruganti59287f02018-10-12 07:00:20 -0500263 catch (const InvalidArgument& e)
264 {
265 throw;
266 }
Nagaraju Goruganti3b4d06a2018-11-08 03:13:38 -0600267 catch (const NoCACertificate& e)
268 {
269 throw;
270 }
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500271 catch (const std::exception& e)
272 {
273 log<level::ERR>(e.what());
274 elog<InternalFailure>();
275 }
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500276 return val;
277}
278
279std::string Config::lDAPBindDN(std::string value)
280{
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500281 std::string val;
282 try
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500283 {
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500284 if (value == lDAPBindDN())
285 {
286 return value;
287 }
288
Nagaraju Gorugantib26799a2018-09-28 13:12:19 -0500289 if (value.empty())
290 {
Nagaraju Goruganti59287f02018-10-12 07:00:20 -0500291 log<level::ERR>("Not a valid LDAP BINDDN",
292 entry("LDAPBINDDN=%s", value.c_str()));
Nagaraju Gorugantib26799a2018-09-28 13:12:19 -0500293 elog<InvalidArgument>(Argument::ARGUMENT_NAME("lDAPBindDN"),
294 Argument::ARGUMENT_VALUE(value.c_str()));
295 }
296
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500297 val = ConfigIface::lDAPBindDN(value);
298 writeConfig();
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600299 parent.startOrStopService(nslcdService, enabled());
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500300 }
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500301 catch (const InternalFailure& e)
302 {
303 throw;
304 }
Nagaraju Gorugantid514e5d2018-11-08 03:07:25 -0600305 catch (const InvalidArgument& e)
306 {
307 throw;
308 }
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500309 catch (const std::exception& e)
310 {
311 log<level::ERR>(e.what());
312 elog<InternalFailure>();
313 }
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500314 return val;
315}
316
317std::string Config::lDAPBaseDN(std::string value)
318{
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500319 std::string val;
320 try
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500321 {
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500322 if (value == lDAPBaseDN())
323 {
324 return value;
325 }
326
Nagaraju Gorugantib26799a2018-09-28 13:12:19 -0500327 if (value.empty())
328 {
Nagaraju Goruganti59287f02018-10-12 07:00:20 -0500329 log<level::ERR>("Not a valid LDAP BASEDN",
330 entry("BASEDN=%s", value.c_str()));
Nagaraju Gorugantib26799a2018-09-28 13:12:19 -0500331 elog<InvalidArgument>(Argument::ARGUMENT_NAME("lDAPBaseDN"),
332 Argument::ARGUMENT_VALUE(value.c_str()));
333 }
334
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500335 val = ConfigIface::lDAPBaseDN(value);
336 writeConfig();
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600337 parent.startOrStopService(nslcdService, enabled());
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500338 }
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500339 catch (const InternalFailure& e)
340 {
341 throw;
342 }
Nagaraju Gorugantid514e5d2018-11-08 03:07:25 -0600343 catch (const InvalidArgument& e)
344 {
345 throw;
346 }
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500347 catch (const std::exception& e)
348 {
349 log<level::ERR>(e.what());
350 elog<InternalFailure>();
351 }
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500352 return val;
353}
354
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600355ConfigIface::SearchScope Config::lDAPSearchScope(ConfigIface::SearchScope value)
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500356{
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600357 ConfigIface::SearchScope val;
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500358 try
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500359 {
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500360 if (value == lDAPSearchScope())
361 {
362 return value;
363 }
364
365 val = ConfigIface::lDAPSearchScope(value);
366 writeConfig();
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600367 parent.startOrStopService(nslcdService, enabled());
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500368 }
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500369 catch (const InternalFailure& e)
370 {
371 throw;
372 }
373 catch (const std::exception& e)
374 {
375 log<level::ERR>(e.what());
376 elog<InternalFailure>();
377 }
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500378 return val;
379}
380
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600381ConfigIface::Type Config::lDAPType(ConfigIface::Type value)
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500382{
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600383 ConfigIface::Type val;
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500384 try
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500385 {
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500386 if (value == lDAPType())
387 {
388 return value;
389 }
390
391 val = ConfigIface::lDAPType(value);
392 writeConfig();
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600393 parent.startOrStopService(nslcdService, enabled());
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500394 }
Nagaraju Gorugantif1940d92018-09-18 05:05:50 -0500395 catch (const InternalFailure& e)
396 {
397 throw;
398 }
399 catch (const std::exception& e)
400 {
401 log<level::ERR>(e.what());
402 elog<InternalFailure>();
403 }
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500404 return val;
405}
406
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600407bool Config::enabled(bool value)
408{
409 bool isEnable;
410 try
411 {
412 if (value == enabled())
413 {
414 return value;
415 }
416 isEnable = EnableIface::enabled(value);
Ratan Gupta95a29312019-02-18 20:34:10 +0530417 // save the enabled property.
418 serialize(*this, parent.dbusPersistentPath);
Ratan Guptaaeaf9412019-02-11 04:41:52 -0600419 parent.startOrStopService(nslcdService, value);
420 }
421 catch (const InternalFailure& e)
422 {
423 throw;
424 }
425 catch (const std::exception& e)
426 {
427 log<level::ERR>(e.what());
428 elog<InternalFailure>();
429 }
430 return isEnable;
431}
432
433std::string Config::userNameAttribute(std::string value)
434{
435 std::string val;
436 try
437 {
438 if (value == userNameAttribute())
439 {
440 return value;
441 }
442
443 val = ConfigIface::userNameAttribute(value);
444 writeConfig();
445 parent.startOrStopService(nslcdService, enabled());
446 }
447 catch (const InternalFailure& e)
448 {
449 throw;
450 }
451 catch (const std::exception& e)
452 {
453 log<level::ERR>(e.what());
454 elog<InternalFailure>();
455 }
456 return val;
457}
458
459std::string Config::groupNameAttribute(std::string value)
460{
461 std::string val;
462 try
463 {
464 if (value == groupNameAttribute())
465 {
466 return value;
467 }
468
469 val = ConfigIface::groupNameAttribute(value);
470 writeConfig();
471 parent.startOrStopService(nslcdService, enabled());
472 }
473 catch (const InternalFailure& e)
474 {
475 throw;
476 }
477 catch (const std::exception& e)
478 {
479 log<level::ERR>(e.what());
480 elog<InternalFailure>();
481 }
482 return val;
483}
484
Nagaraju Goruganti997f5e02018-08-30 03:05:11 -0500485} // namespace ldap
486} // namespace phosphor