@@ -398,16 +398,18 @@ DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(machine_open_mode, MachineOpenMod
398398static JSON_DISPATCH_ENUM_DEFINE (json_dispatch_machine_open_mode , MachineOpenMode , machine_open_mode_from_string ) ;
399399
400400typedef struct MachineOpenParameters {
401- const char * name , * user ;
401+ const char * name ;
402+ const char * user ;
402403 PidRef pidref ;
403404 MachineOpenMode mode ;
404- char * path , * * args , * * env ;
405+ const char * path ;
406+ char * * args ;
407+ char * * env ;
405408} MachineOpenParameters ;
406409
407410static void machine_open_paramaters_done (MachineOpenParameters * p ) {
408411 assert (p );
409412 pidref_done (& p -> pidref );
410- free (p -> path );
411413 strv_free (p -> args );
412414 strv_free (p -> env );
413415}
@@ -453,7 +455,7 @@ int vl_method_open(sd_varlink *link, sd_json_variant *parameters, sd_varlink_met
453455 VARLINK_DISPATCH_MACHINE_LOOKUP_FIELDS (MachineOpenParameters ),
454456 { "mode" , SD_JSON_VARIANT_STRING , json_dispatch_machine_open_mode , offsetof(MachineOpenParameters , mode ), SD_JSON_MANDATORY },
455457 { "user" , SD_JSON_VARIANT_STRING , json_dispatch_const_user_group_name , offsetof(MachineOpenParameters , user ), SD_JSON_RELAX },
456- { "path" , SD_JSON_VARIANT_STRING , json_dispatch_path , offsetof(MachineOpenParameters , path ), 0 },
458+ { "path" , SD_JSON_VARIANT_STRING , json_dispatch_const_path , offsetof(MachineOpenParameters , path ), 0 },
457459 { "args" , SD_JSON_VARIANT_ARRAY , sd_json_dispatch_strv , offsetof(MachineOpenParameters , args ), 0 },
458460 { "environment" , SD_JSON_VARIANT_ARRAY , json_dispatch_strv_environment , offsetof(MachineOpenParameters , env ), 0 },
459461 VARLINK_DISPATCH_POLKIT_FIELD ,
@@ -486,7 +488,7 @@ int vl_method_open(sd_varlink *link, sd_json_variant *parameters, sd_varlink_met
486488
487489 if (p .mode == MACHINE_OPEN_MODE_SHELL ) {
488490 /* json_dispatch_const_user_group_name() does valid_user_group_name(p.user) */
489- /* json_dispatch_path () does path_is_absolute(p.path) */
491+ /* json_dispatch_const_path () does path_is_absolute(p.path) */
490492 /* json_dispatch_strv_environment() does validation of p.env */
491493
492494 user = p .user ?: "root" ;
@@ -733,8 +735,8 @@ int vl_method_map_to(sd_varlink *link, sd_json_variant *parameters, sd_varlink_m
733735typedef struct MachineMountParameters {
734736 const char * name ;
735737 PidRef pidref ;
736- char * src ;
737- char * dest ;
738+ const char * src ;
739+ const char * dest ;
738740 bool read_only ;
739741 bool mkdir ;
740742} MachineMountParameters ;
@@ -743,15 +745,13 @@ static void machine_mount_paramaters_done(MachineMountParameters *p) {
743745 assert (p );
744746
745747 pidref_done (& p -> pidref );
746- free (p -> src );
747- free (p -> dest );
748748}
749749
750750int vl_method_bind_mount (sd_varlink * link , sd_json_variant * parameters , sd_varlink_method_flags_t flags , void * userdata ) {
751751 static const sd_json_dispatch_field dispatch_table [] = {
752752 VARLINK_DISPATCH_MACHINE_LOOKUP_FIELDS (MachineOpenParameters ),
753- { "source" , SD_JSON_VARIANT_STRING , json_dispatch_path , offsetof(MachineMountParameters , src ), SD_JSON_MANDATORY },
754- { "destination" , SD_JSON_VARIANT_STRING , json_dispatch_path , offsetof(MachineMountParameters , dest ), 0 },
753+ { "source" , SD_JSON_VARIANT_STRING , json_dispatch_const_path , offsetof(MachineMountParameters , src ), SD_JSON_MANDATORY },
754+ { "destination" , SD_JSON_VARIANT_STRING , json_dispatch_const_path , offsetof(MachineMountParameters , dest ), 0 },
755755 { "readOnly" , SD_JSON_VARIANT_BOOLEAN , sd_json_dispatch_stdbool , offsetof(MachineMountParameters , read_only ), 0 },
756756 { "mkdir" , SD_JSON_VARIANT_BOOLEAN , sd_json_dispatch_stdbool , offsetof(MachineMountParameters , mkdir ), 0 },
757757 VARLINK_DISPATCH_POLKIT_FIELD ,
@@ -760,7 +760,7 @@ int vl_method_bind_mount(sd_varlink *link, sd_json_variant *parameters, sd_varli
760760
761761 Manager * manager = ASSERT_PTR (userdata );
762762 _cleanup_ (machine_mount_paramaters_done ) MachineMountParameters p = {
763- .pidref = PIDREF_NULL
763+ .pidref = PIDREF_NULL ,
764764 };
765765 MountInNamespaceFlags mount_flags = 0 ;
766766 uid_t uid_shift ;
@@ -773,7 +773,7 @@ int vl_method_bind_mount(sd_varlink *link, sd_json_variant *parameters, sd_varli
773773 if (r != 0 )
774774 return r ;
775775
776- /* There is no need for extra validation since json_dispatch_path () does path_is_valid() and path_is_absolute().*/
776+ /* There is no need for extra validation since json_dispatch_const_path () does path_is_valid() and path_is_absolute().*/
777777 const char * dest = p .dest ?: p .src ;
778778
779779 Machine * machine ;
0 commit comments