Skip to content

Commit 8faa51e

Browse files
author
Dmitriy Nabok
committed
Change system password
1 parent 7386b93 commit 8faa51e

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-0
lines changed

src/ucentral-client/platform/larch-sonic/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ add_library(larch-sonic
3232
"state.cpp"
3333
"stp.cpp"
3434
"syslog.cpp"
35+
"system.cpp"
3536
"utils.cpp"
3637
"vlan.cpp"
3738
)

src/ucentral-client/platform/larch-sonic/host_service.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ INTERFACE(config)
1818
config() : INIT(reload), INIT(save) {}
1919
};
2020

21+
INTERFACE(system_password)
22+
{
23+
Method<simppl::dbus::in<std::string>, simppl::dbus::out<std::tuple<std::int32_t, std::string>>> update;
24+
25+
system_password() : INIT(update) {}
26+
};
27+
2128
} // namespace org::SONiC::HostService
2229

2330
#endif // !LARCH_PLATFORM_HOST_SERVICE_HPP_

src/ucentral-client/platform/larch-sonic/plat-larch.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <state.hpp>
77
#include <stp.hpp>
88
#include <syslog.hpp>
9+
#include <system.hpp>
910
#include <utils.hpp>
1011
#include <vlan.hpp>
1112

@@ -227,6 +228,7 @@ int plat_config_apply(struct plat_cfg *cfg, uint32_t id)
227228
apply_route_config(cfg);
228229
apply_stp_config(cfg);
229230
apply_services_config(cfg);
231+
apply_system_password_config(cfg);
230232
apply_vlan_ipv4_config(cfg);
231233
/* apply_syslog_config() call must always be the last one */
232234
apply_syslog_config(cfg->log_cfg, cfg->log_cfg_cnt);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <host_service.hpp>
2+
#include <system.hpp>
3+
#include <utils.hpp>
4+
5+
#define UC_LOG_COMPONENT UC_LOG_COMPONENT_PLAT
6+
#include <ucentral-log.h>
7+
#include <simppl/dispatcher.h>
8+
#include <simppl/stub.h>
9+
10+
namespace larch {
11+
12+
void apply_system_password_config(struct plat_cfg *cfg)
13+
{
14+
if (cfg->unit.system.password_changed)
15+
{
16+
try
17+
{
18+
simppl::dbus::Dispatcher disp{"bus:system"};
19+
simppl::dbus::Stub<org::SONiC::HostService::system_password> stub{
20+
disp,
21+
"org.SONiC.HostService",
22+
"/org/SONiC/HostService/system_password"};
23+
24+
stub.update(cfg->unit.system.password);
25+
}
26+
catch (const std::exception &ex)
27+
{
28+
UC_LOG_ERR("Failed to update system password: %s", ex.what());
29+
}
30+
31+
}
32+
}
33+
34+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef LARCH_PLATFORM_SYSTEM_HPP_
2+
#define LARCH_PLATFORM_SYSTEM_HPP_
3+
4+
#include <ucentral-platform.h>
5+
6+
namespace larch {
7+
8+
void apply_system_password_config(struct plat_cfg *cfg);
9+
10+
}
11+
12+
#endif // !LARCH_PLATFORM_SYSTEM_HPP_

0 commit comments

Comments
 (0)