@@ -337,19 +337,7 @@ write_prefix(const char *buffer, size_t bytes, bool *prefixed)
337337}
338338
339339static int
340- openrc_sh_exec (const char * openrc_sh , const char * arg1 , const char * arg2 )
341- {
342- if (arg2 )
343- einfov ("Executing: %s %s %s %s %s" , openrc_sh , openrc_sh , service , arg1 , arg2 );
344- else
345- einfov ("Executing: %s %s %s %s" , openrc_sh , openrc_sh , service , arg1 );
346- execl (openrc_sh , openrc_sh , service , arg1 , arg2 , (char * ) NULL );
347- eerror ("%s: exec '%s': %s" , service , openrc_sh , strerror (errno ));
348- _exit (EXIT_FAILURE );
349- }
350-
351- static int
352- svc_exec (const char * arg1 , const char * arg2 )
340+ svc_exec (const char * command )
353341{
354342 int ret , fdout = fileno (stdout );
355343 struct termios tt ;
@@ -414,10 +402,14 @@ svc_exec(const char *arg1, const char *arg2)
414402 dup2 (slave_tty , STDERR_FILENO );
415403 }
416404
417- if (exists (openrc_sh ))
418- openrc_sh_exec (openrc_sh , arg1 , arg2 );
419- else
420- openrc_sh_exec (RC_LIBEXECDIR "/sh/openrc-run.sh" , arg1 , arg2 );
405+ if (!exists (openrc_sh ))
406+ openrc_sh = UNCONST (RC_LIBEXECDIR "/sh/openrc-run.sh" );
407+
408+ einfov ("Executing: %s %s %s" , openrc_sh , service , command );
409+
410+ execl (openrc_sh , openrc_sh , service , command , NULL );
411+ eerror ("%s: exec '%s': %s" , service , openrc_sh , strerror (errno ));
412+ _exit (EXIT_FAILURE );
421413
422414 /* UNREACHABLE */
423415 }
@@ -787,7 +779,7 @@ static void svc_start_real(void)
787779 hook_out = RC_HOOK_SERVICE_START_DONE ;
788780 rc_plugin_run (RC_HOOK_SERVICE_START_NOW , applet );
789781 skip_mark = false;
790- started = (svc_exec ("start" , NULL ) == 0 );
782+ started = (svc_exec ("start" ) == 0 );
791783 if (ibsave )
792784 unsetenv ("IN_BACKGROUND" );
793785
@@ -993,7 +985,7 @@ svc_stop_real(void)
993985 hook_out = RC_HOOK_SERVICE_STOP_DONE ;
994986 rc_plugin_run (RC_HOOK_SERVICE_STOP_NOW , applet );
995987 skip_mark = false;
996- stopped = (svc_exec ("stop" , NULL ) == 0 );
988+ stopped = (svc_exec ("stop" ) == 0 );
997989 if (ibsave )
998990 unsetenv ("IN_BACKGROUND" );
999991
@@ -1270,7 +1262,7 @@ int main(int argc, char **argv)
12701262 char * save = prefix ;
12711263 eprefix (NULL );
12721264 prefix = NULL ;
1273- svc_exec (optarg , NULL );
1265+ svc_exec (optarg );
12741266 eprefix (save );
12751267 prefix = save ;
12761268 } else if (strcmp (optarg , "ineed" ) == 0 ||
@@ -1307,7 +1299,7 @@ int main(int argc, char **argv)
13071299 } else if (strcmp (optarg , "status" ) == 0 ) {
13081300 eprefix (NULL );
13091301 prefix = NULL ;
1310- retval = svc_exec ("status" , NULL );
1302+ retval = svc_exec ("status" );
13111303 } else {
13121304 if (strcmp (optarg , "conditionalrestart" ) == 0 ||
13131305 strcmp (optarg , "condrestart" ) == 0 )
@@ -1346,7 +1338,7 @@ int main(int argc, char **argv)
13461338 strerror (errno ));
13471339 unhotplug ();
13481340 } else
1349- retval = svc_exec (optarg , NULL );
1341+ retval = svc_exec (optarg );
13501342
13511343 /* We should ensure this list is empty after
13521344 * an action is done */
0 commit comments