/[gentoo-src]/rc-scripts/src/runscript.c
Gentoo

Contents of /rc-scripts/src/runscript.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download) (as text)
Thu Dec 23 19:15:06 2004 UTC (15 years, 3 months ago) by vapier
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +15 -15 lines
File MIME type: text/x-csrc
merge freebsd fixes

1 /*
2 * runscript.c
3 * Handle launching of Gentoo init scripts.
4 *
5 * Copyright 1999-2004 Gentoo Foundation
6 * Distributed under the terms of the GNU General Public License v2
7 * $Header: /var/cvsroot/gentoo-src/rc-scripts/src/runscript.c,v 1.7 2004/10/06 01:17:27 vapier Exp $
8 */
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <sys/types.h>
14 #include <sys/wait.h>
15 #include <dlfcn.h>
16
17 static void (*selinux_run_init_old) (void);
18 static void (*selinux_run_init_new) (int argc, char **argv);
19
20 int main(int argc, char *argv[]) {
21 char *myargs[32];
22 void *lib_handle;
23 int new = 1;
24 myargs[0] = "runscript";
25
26 while (argv[new] != 0) {
27 myargs[new] = argv[new];
28 new++;
29 }
30 myargs[new] = NULL;
31 if (argc < 3) {
32 execv("/lib/rcscripts/sh/rc-help.sh", myargs);
33 exit(1);
34 }
35
36 lib_handle = dlopen("/lib/rcscripts/runscript_selinux.so", RTLD_NOW | RTLD_GLOBAL);
37 if (lib_handle != NULL) {
38 selinux_run_init_old = dlsym(lib_handle, "selinux_runscript");
39 selinux_run_init_new = dlsym(lib_handle, "selinux_runscript2");
40
41 /* use new run_init if it exists, else fall back to old */
42 if (selinux_run_init_new != NULL)
43 selinux_run_init_new(argc, argv);
44 else if (selinux_run_init_old != NULL)
45 selinux_run_init_old();
46 else {
47 /* this shouldnt happen... probably corrupt lib */
48 fprintf(stderr,"Run_init is missing from runscript_selinux.so!\n");
49 exit(127);
50 }
51 }
52
53 if (execv("/sbin/runscript.sh", myargs) < 0)
54 exit(1);
55
56 return 0;
57 }

  ViewVC Help
Powered by ViewVC 1.1.20