diff --git a/README b/README index dbd01666..51244eff 100644 --- a/README +++ b/README @@ -73,5 +73,5 @@ problems related to udev and pam. 4 - Set the pointer device in the X server configuration to /dev/input/mice -5 - Have a user named "user", or change DEFUSER in the source file +5 - Have a user named "user", or change the default in Makefile diff --git a/finit-alt.c b/finit-alt.c index fca6bc48..f81dfd66 100644 --- a/finit-alt.c +++ b/finit-alt.c @@ -58,7 +58,7 @@ THE SOFTWARE. #define RANDOMSEED "/var/lib/random-seed" #define SYSROOT "/sysroot" #define GETTY "/sbin/mingetty tty3" -#define RUNPARTS "/usr/bin/run-parts --arg=-i" +#define RUNPARTS "/usr/bin/run-parts" #define REMOUNT_ROOTFS_RW #define MAKE_DEVICES #else /* original Eeepc distribution */ @@ -230,7 +230,7 @@ int main() touch("/etc/resolvconf/run/enable-updates"); chdir("/etc/resolvconf/run/interface"); - system(RUNPARTS " /etc/resolvconf/update.d"); + system(RUNPARTS " --arg=i /etc/resolvconf/update.d"); chdir("/"); #ifdef TOUCH_ETC_NETWORK_RUN_IFSTATE diff --git a/helpers.c b/helpers.c index e7df1809..e5a67d53 100644 --- a/helpers.c +++ b/helpers.c @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -9,6 +10,8 @@ #include #include #include +#include +#include #include "helpers.h" @@ -90,3 +93,72 @@ void copyfile(char *src, char *dst, int size) } } +#if 0 + +/* Running the system /bin/run-parts is good enough, enable this if you + can't use it. Some distributions have it under /usr/bin, in this case + you can assume that the distribution is broken or run-parts is not used + in the boot process. + */ + +#define NUM_SCRIPTS 128 /* ought to be enough for anyone */ +#define NUM_ARGS 16 + +static int cmp(const void *s1, const void *s2) +{ + return strcmp(*(char **)s1, *(char **)s2); +} + +int run_parts(char *dir, ...) +{ + DIR *d; + struct dirent *e; + struct stat st; + char *ent[NUM_SCRIPTS]; + int i, num = 0, argnum = 1; + char *args[NUM_ARGS]; + va_list ap; + + if ((d = opendir(dir)) == NULL) + return -1; + + if (chdir(dir)) + return -1; + + va_start(ap, dir); + while (argnum < NUM_ARGS && (args[argnum++] = va_arg(ap, char *))); + va_end(ap); + + while (1) { + e = readdir(d); + if (e) { + if (e->d_type == DT_REG) { + if (stat(e->d_name, &st)) + continue; + + if (st.st_mode & S_IXUSR) { + ent[num++] = strdup(e->d_name); + if (num >= NUM_SCRIPTS) + break; + } + + } + } else + break; + } + + if (num == 0) + return 0; + + qsort(ent, num, sizeof(char *), cmp); + + for (i = 0; i < num; i++) { + args[0] = ent[i]; + execv(ent[i], args); + free(ent[i]); + } + + return 0; +} + +#endif diff --git a/helpers.h b/helpers.h index cee06ae0..80bf6ac1 100644 --- a/helpers.h +++ b/helpers.h @@ -4,5 +4,6 @@ int makepath (char *); void ifconfig (char *, char *, char *, int); void copyfile (char *, char *, int); +int run_parts (char *, ...); #endif