@@ -1170,6 +1170,46 @@ int main(int argc, char **argv)
11701170 if (chdir (workingdir ) == -1 )
11711171 eerror ("chdir: %s" , strerror (errno ));
11721172
1173+ /* Ok, we are ready to go, so setup selinux if applicable */
1174+ selinux_setup (argv );
1175+
1176+ deps = true;
1177+
1178+ /* Punt the first arg as its our service name */
1179+ argc -- ;
1180+ argv ++ ;
1181+
1182+ /* Right then, parse any options there may be */
1183+ while ((opt = getopt_long (argc , argv , getoptstring ,
1184+ longopts , (int * )0 )) != -1 )
1185+ switch (opt ) {
1186+ case 'd' :
1187+ setenv ("RC_DEBUG" , "YES" , 1 );
1188+ break ;
1189+ case 'l' :
1190+ exclusive_fd = atoi (optarg );
1191+ fcntl (exclusive_fd , F_SETFD ,
1192+ fcntl (exclusive_fd , F_GETFD , 0 ) | FD_CLOEXEC );
1193+ break ;
1194+ case 's' :
1195+ if (!(rc_service_state (service ) & RC_SERVICE_STARTED ))
1196+ exit (EXIT_FAILURE );
1197+ break ;
1198+ case 'S' :
1199+ if (!(rc_service_state (service ) & RC_SERVICE_STOPPED ))
1200+ exit (EXIT_FAILURE );
1201+ break ;
1202+ case 'D' :
1203+ deps = false;
1204+ break ;
1205+ case 'Z' :
1206+ dry_run = true;
1207+ break ;
1208+ case_RC_COMMON_GETOPT
1209+ }
1210+
1211+ atexit (cleanup );
1212+
11731213 if ((runlevel = xstrdup (getenv ("RC_RUNLEVEL" ))) == NULL ) {
11741214 env_filter ();
11751215 env_config ();
@@ -1213,46 +1253,6 @@ int main(int argc, char **argv)
12131253 eprefix (prefix );
12141254 }
12151255
1216- /* Ok, we are ready to go, so setup selinux if applicable */
1217- selinux_setup (argv );
1218-
1219- deps = true;
1220-
1221- /* Punt the first arg as its our service name */
1222- argc -- ;
1223- argv ++ ;
1224-
1225- /* Right then, parse any options there may be */
1226- while ((opt = getopt_long (argc , argv , getoptstring ,
1227- longopts , (int * )0 )) != -1 )
1228- switch (opt ) {
1229- case 'd' :
1230- setenv ("RC_DEBUG" , "YES" , 1 );
1231- break ;
1232- case 'l' :
1233- exclusive_fd = atoi (optarg );
1234- fcntl (exclusive_fd , F_SETFD ,
1235- fcntl (exclusive_fd , F_GETFD , 0 ) | FD_CLOEXEC );
1236- break ;
1237- case 's' :
1238- if (!(rc_service_state (service ) & RC_SERVICE_STARTED ))
1239- exit (EXIT_FAILURE );
1240- break ;
1241- case 'S' :
1242- if (!(rc_service_state (service ) & RC_SERVICE_STOPPED ))
1243- exit (EXIT_FAILURE );
1244- break ;
1245- case 'D' :
1246- deps = false;
1247- break ;
1248- case 'Z' :
1249- dry_run = true;
1250- break ;
1251- case_RC_COMMON_GETOPT
1252- }
1253-
1254- atexit (cleanup );
1255-
12561256 if (rc_yesno (getenv ("RC_NODEPS" )))
12571257 deps = false;
12581258
0 commit comments