File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ platform/plat.a:
1919
2020ucentral-client : ucentral-client.o proto.o platform/plat.a \
2121 ucentral-json-parser.o ucentral-log.o router-utils.o base64.o
22- g++ -g -o $@ $^ -lcurl -lwebsockets -lcjson -lssl -lcrypto -lpthread -ljsoncpp -lresolv -lhiredis -ldbus-1
22+ g++ -g -o $@ $^ -lcurl -lwebsockets -lcjson -lssl -lcrypto -lpthread -ljsoncpp -lresolv -lhiredis -ldbus-1 -lcrypt
2323
2424test :
2525 @echo " ========= running unit tests ========="
Original file line number Diff line number Diff line change 33#include < utils.hpp>
44
55#define UC_LOG_COMPONENT UC_LOG_COMPONENT_PLAT
6- #include < ucentral-log.h>
6+
7+ #define HASH_SHA512_TYPE " $6$"
8+ #define HASH_SHA512_SALT " c53N"
9+ #define HASH_SHA512_CONFIG HASH_SHA512_TYPE HASH_SHA512_SALT
10+
11+ #include < crypt.h>
712#include < simppl/dispatcher.h>
813#include < simppl/stub.h>
14+ #include < ucentral-log.h>
915
1016namespace larch {
1117
@@ -15,13 +21,21 @@ void apply_system_password_config(struct plat_cfg *cfg)
1521 {
1622 try
1723 {
24+ struct crypt_data cd;
25+ memset (&cd, 0 , sizeof cd);
26+
27+ std::string hash = crypt_r (cfg->unit .system .password , HASH_SHA512_CONFIG, &cd);
28+
1829 simppl::dbus::Dispatcher disp{" bus:system" };
1930 simppl::dbus::Stub<org::SONiC::HostService::system_password> stub{
2031 disp,
2132 " org.SONiC.HostService" ,
2233 " /org/SONiC/HostService/system_password" };
2334
24- stub.update (cfg->unit .system .password );
35+ const auto ret = stub.update (hash);
36+ UC_LOG_INFO (" system_password update returned %d: %s" ,
37+ std::get<0 >(ret),
38+ std::get<1 >(ret).c_str ());
2539 }
2640 catch (const std::exception &ex)
2741 {
You can’t perform that action at this time.
0 commit comments