@@ -746,6 +746,25 @@ static int property_get_log_extra_fields(
746746 return sd_bus_message_close_container (reply );
747747}
748748
749+ static int property_get_root_hash (
750+ sd_bus * bus ,
751+ const char * path ,
752+ const char * interface ,
753+ const char * property ,
754+ sd_bus_message * reply ,
755+ void * userdata ,
756+ sd_bus_error * error ) {
757+
758+ ExecContext * c = userdata ;
759+
760+ assert (bus );
761+ assert (c );
762+ assert (property );
763+ assert (reply );
764+
765+ return sd_bus_message_append_array (reply , 'y' , c -> root_hash , c -> root_hash_size );
766+ }
767+
749768const sd_bus_vtable bus_exec_vtable [] = {
750769 SD_BUS_VTABLE_START (0 ),
751770 SD_BUS_PROPERTY ("Environment" , "as" , NULL , offsetof(ExecContext , environment ), SD_BUS_VTABLE_PROPERTY_CONST ),
@@ -788,6 +807,9 @@ const sd_bus_vtable bus_exec_vtable[] = {
788807 SD_BUS_PROPERTY ("WorkingDirectory" , "s" , property_get_working_directory , 0 , SD_BUS_VTABLE_PROPERTY_CONST ),
789808 SD_BUS_PROPERTY ("RootDirectory" , "s" , NULL , offsetof(ExecContext , root_directory ), SD_BUS_VTABLE_PROPERTY_CONST ),
790809 SD_BUS_PROPERTY ("RootImage" , "s" , NULL , offsetof(ExecContext , root_image ), SD_BUS_VTABLE_PROPERTY_CONST ),
810+ SD_BUS_PROPERTY ("RootHash" , "ay" , property_get_root_hash , 0 , SD_BUS_VTABLE_PROPERTY_CONST ),
811+ SD_BUS_PROPERTY ("RootHashPath" , "s" , NULL , offsetof(ExecContext , root_hash_path ), SD_BUS_VTABLE_PROPERTY_CONST ),
812+ SD_BUS_PROPERTY ("RootVerity" , "s" , NULL , offsetof(ExecContext , root_verity ), SD_BUS_VTABLE_PROPERTY_CONST ),
791813 SD_BUS_PROPERTY ("OOMScoreAdjust" , "i" , property_get_oom_score_adjust , 0 , SD_BUS_VTABLE_PROPERTY_CONST ),
792814 SD_BUS_PROPERTY ("CoredumpFilter" , "t" , property_get_coredump_filter , 0 , SD_BUS_VTABLE_PROPERTY_CONST ),
793815 SD_BUS_PROPERTY ("Nice" , "i" , property_get_nice , 0 , SD_BUS_VTABLE_PROPERTY_CONST ),
@@ -1258,6 +1280,55 @@ int bus_exec_context_set_transient_property(
12581280 if (streq (name , "RootImage" ))
12591281 return bus_set_transient_path (u , name , & c -> root_image , message , flags , error );
12601282
1283+ if (streq (name , "RootHash" )) {
1284+ const void * roothash_decoded ;
1285+ size_t roothash_decoded_size ;
1286+
1287+ r = sd_bus_message_read_array (message , 'y' , & roothash_decoded , & roothash_decoded_size );
1288+ if (r < 0 )
1289+ return r ;
1290+
1291+ if (!UNIT_WRITE_FLAGS_NOOP (flags )) {
1292+ _cleanup_free_ char * encoded = NULL ;
1293+
1294+ if (roothash_decoded_size == 0 ) {
1295+ c -> root_hash_path = mfree (c -> root_hash_path );
1296+ c -> root_hash = mfree (c -> root_hash );
1297+ c -> root_hash_size = 0 ;
1298+
1299+ unit_write_settingf (u , flags , name , "RootHash=" );
1300+ } else {
1301+ _cleanup_free_ void * p ;
1302+
1303+ encoded = hexmem (roothash_decoded , roothash_decoded_size );
1304+ if (!encoded )
1305+ return - ENOMEM ;
1306+
1307+ p = memdup (roothash_decoded , roothash_decoded_size );
1308+ if (!p )
1309+ return - ENOMEM ;
1310+
1311+ free_and_replace (c -> root_hash , p );
1312+ c -> root_hash_size = roothash_decoded_size ;
1313+ c -> root_hash_path = mfree (c -> root_hash_path );
1314+
1315+ unit_write_settingf (u , flags , name , "RootHash=%s" , encoded );
1316+ }
1317+ }
1318+
1319+ return 1 ;
1320+ }
1321+
1322+ if (streq (name , "RootHashPath" )) {
1323+ c -> root_hash_size = 0 ;
1324+ c -> root_hash = mfree (c -> root_hash );
1325+
1326+ return bus_set_transient_path (u , "RootHash" , & c -> root_hash_path , message , flags , error );
1327+ }
1328+
1329+ if (streq (name , "RootVerity" ))
1330+ return bus_set_transient_path (u , name , & c -> root_verity , message , flags , error );
1331+
12611332 if (streq (name , "RootDirectory" ))
12621333 return bus_set_transient_path (u , name , & c -> root_directory , message , flags , error );
12631334
0 commit comments