/[baselayout]/trunk/src/runscript.c
Gentoo

Diff of /trunk/src/runscript.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2547 Revision 2549
163 if ((mtime = get_mtime (mtime_test, false)) == 0) 163 if ((mtime = get_mtime (mtime_test, false)) == 0)
164 return (false); 164 return (false);
165 165
166 while (tests[i]) 166 while (tests[i])
167 { 167 {
168 path = rc_strcatpaths (RC_SVCDIR, tests[i], applet, NULL); 168 path = rc_strcatpaths (RC_SVCDIR, tests[i], applet, (char *) NULL);
169 if (rc_exists (path)) 169 if (rc_exists (path))
170 { 170 {
171 int m = get_mtime (path, false); 171 int m = get_mtime (path, false);
172 if (mtime < m && m != 0) 172 if (mtime < m && m != 0)
173 { 173 {
182 return (true); 182 return (true);
183} 183}
184 184
185static void uncoldplug (char *service) 185static void uncoldplug (char *service)
186{ 186{
187 char *cold = rc_strcatpaths (RC_SVCDIR "coldplugged", basename (service), NULL); 187 char *cold = rc_strcatpaths (RC_SVCDIR "coldplugged", basename (service),
188 (char *) NULL);
188 if (rc_exists (cold) && unlink (cold) != 0) 189 if (rc_exists (cold) && unlink (cold) != 0)
189 eerror ("%s: unlink `%s': %s", applet, cold, strerror (errno)); 190 eerror ("%s: unlink `%s': %s", applet, cold, strerror (errno));
190 free (cold); 191 free (cold);
191} 192}
192 193
281 if (arg2) 282 if (arg2)
282 myarg2 = rc_xstrdup (arg2); 283 myarg2 = rc_xstrdup (arg2);
283 284
284 if (rc_exists (RC_SVCDIR "runscript.sh")) 285 if (rc_exists (RC_SVCDIR "runscript.sh"))
285 { 286 {
286 execl (RC_SVCDIR "runscript.sh", mycmd, mycmd, myarg1, myarg2, NULL); 287 execl (RC_SVCDIR "runscript.sh", mycmd, mycmd, myarg1, myarg2,
288 (char *) NULL);
287 eerrorx ("%s: exec `" RC_SVCDIR "runscript.sh': %s", 289 eerrorx ("%s: exec `" RC_SVCDIR "runscript.sh': %s",
288 service, strerror (errno)); 290 service, strerror (errno));
289 } 291 }
290 else 292 else
291 { 293 {
292 execl (RC_LIBDIR "sh/runscript.sh", mycmd, mycmd, myarg1, myarg2, NULL); 294 execl (RC_LIBDIR "sh/runscript.sh", mycmd, mycmd, myarg1, myarg2,
295 (char *) NULL);
293 eerrorx ("%s: exec `" RC_LIBDIR "sh/runscript.sh': %s", 296 eerrorx ("%s: exec `" RC_LIBDIR "sh/runscript.sh': %s",
294 service, strerror (errno)); 297 service, strerror (errno));
295 } 298 }
296 } 299 }
297 300
362 char *path; 365 char *path;
363 int i; 366 int i;
364 367
365 /* We create a fifo so that other services can wait until we complete */ 368 /* We create a fifo so that other services can wait until we complete */
366 if (! exclusive) 369 if (! exclusive)
367 exclusive = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, NULL); 370 exclusive = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, (char *) NULL);
368 371
369 if (mkfifo (exclusive, 0600) != 0 && errno != EEXIST && 372 if (mkfifo (exclusive, 0600) != 0 && errno != EEXIST &&
370 (errno != EACCES || geteuid () == 0)) 373 (errno != EACCES || geteuid () == 0))
371 eerrorx ("%s: unable to create fifo `%s': %s", 374 eerrorx ("%s: unable to create fifo `%s': %s",
372 applet, exclusive, strerror (errno)); 375 applet, exclusive, strerror (errno));
373 376
374 path = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, NULL); 377 path = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, (char *) NULL);
375 i = strlen (path) + 16; 378 i = strlen (path) + 16;
376 mtime_test = rc_xmalloc (sizeof (char *) * i); 379 mtime_test = rc_xmalloc (sizeof (char *) * i);
377 snprintf (mtime_test, i, "%s.%d", path, getpid ()); 380 snprintf (mtime_test, i, "%s.%d", path, getpid ());
378 free (path); 381 free (path);
379 382
852 atexit (cleanup); 855 atexit (cleanup);
853 856
854 /* Show help if insufficient args */ 857 /* Show help if insufficient args */
855 if (argc < 3) 858 if (argc < 3)
856 { 859 {
857 execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, NULL); 860 execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL);
858 eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s", 861 eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s",
859 applet, strerror (errno)); 862 applet, strerror (errno));
860 } 863 }
861 864
862#ifdef __linux__ 865#ifdef __linux__
865 if (rc_exists ("/dev/.rcsysinit")) 868 if (rc_exists ("/dev/.rcsysinit"))
866 { 869 {
867 eerror ("%s: cannot run until sysvinit completes", applet); 870 eerror ("%s: cannot run until sysvinit completes", applet);
868 if (mkdir ("/dev/.rcboot", 0755) != 0 && errno != EEXIST) 871 if (mkdir ("/dev/.rcboot", 0755) != 0 && errno != EEXIST)
869 eerrorx ("%s: mkdir `/dev/.rcboot': %s", applet, strerror (errno)); 872 eerrorx ("%s: mkdir `/dev/.rcboot': %s", applet, strerror (errno));
870 tmp = rc_strcatpaths ("/dev/.rcboot", applet, NULL); 873 tmp = rc_strcatpaths ("/dev/.rcboot", applet, (char *) NULL);
871 symlink (service, tmp); 874 symlink (service, tmp);
872 exit (EXIT_FAILURE); 875 exit (EXIT_FAILURE);
873 } 876 }
874#endif 877#endif
875 878
930 { 933 {
931 char ebname[PATH_MAX]; 934 char ebname[PATH_MAX];
932 char *eb; 935 char *eb;
933 936
934 snprintf (ebname, sizeof (ebname), "%s.%s", applet, pid); 937 snprintf (ebname, sizeof (ebname), "%s.%s", applet, pid);
935 eb = rc_strcatpaths (RC_SVCDIR "ebuffer", ebname, NULL); 938 eb = rc_strcatpaths (RC_SVCDIR "ebuffer", ebname, (char *) NULL);
936 setenv ("RC_EBUFFER", eb, 1); 939 setenv ("RC_EBUFFER", eb, 1);
937 free (eb); 940 free (eb);
938 } 941 }
939 942
940 /* Save the IN_BACKGROUND env flag so it's ONLY passed to the service 943 /* Save the IN_BACKGROUND env flag so it's ONLY passed to the service
963 966
964 if (strcmp (argv[i], "--debug") == 0) 967 if (strcmp (argv[i], "--debug") == 0)
965 setenv ("RC_DEBUG", "yes", 1); 968 setenv ("RC_DEBUG", "yes", 1);
966 else if (strcmp (argv[i], "--help") == 0) 969 else if (strcmp (argv[i], "--help") == 0)
967 { 970 {
968 execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, NULL); 971 execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL);
969 eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s", 972 eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s",
970 applet, strerror (errno)); 973 applet, strerror (errno));
971 } 974 }
972 else if (strcmp (argv[i],"--ifstarted") == 0) 975 else if (strcmp (argv[i],"--ifstarted") == 0)
973 ifstarted = true; 976 ifstarted = true;
1069 rc_mark_service (applet, rc_service_stopped); 1072 rc_mark_service (applet, rc_service_stopped);
1070 uncoldplug (applet); 1073 uncoldplug (applet);
1071 } 1074 }
1072 else if (strcmp (argv[i], "help") == 0) 1075 else if (strcmp (argv[i], "help") == 0)
1073 { 1076 {
1074 execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, "help", NULL); 1077 execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, "help", (char *) NULL);
1075 eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s", 1078 eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s",
1076 applet, strerror (errno)); 1079 applet, strerror (errno));
1077 } 1080 }
1078 else 1081 else
1079 svc_exec (service, argv[i], NULL); 1082 svc_exec (service, argv[i], NULL);
1086 restart_services = NULL; 1089 restart_services = NULL;
1087 } 1090 }
1088 1091
1089 if (! doneone) 1092 if (! doneone)
1090 { 1093 {
1091 execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, NULL); 1094 execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL);
1092 eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s", 1095 eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s",
1093 applet, strerror (errno)); 1096 applet, strerror (errno));
1094 } 1097 }
1095 1098
1096 return (retval); 1099 return (retval);

Legend:
Removed from v.2547  
changed lines
  Added in v.2549

  ViewVC Help
Powered by ViewVC 1.1.20