0002-procd-add-support-for-alternative-rc.d-directories.patch 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Wed, 6 Aug 2014 19:12:00 +0200
  3. Subject: procd: add support for alternative rc.d directories
  4. diff --git a/package/system/procd/patches/0001-Add-support-for-alternative-rc.d-directories.patch b/package/system/procd/patches/0001-Add-support-for-alternative-rc.d-directories.patch
  5. new file mode 100644
  6. index 0000000..bc24342
  7. --- /dev/null
  8. +++ b/package/system/procd/patches/0001-Add-support-for-alternative-rc.d-directories.patch
  9. @@ -0,0 +1,97 @@
  10. +From 03a2bc70e4260ec9f669391c47b9a7a9ecd0b75d Mon Sep 17 00:00:00 2001
  11. +Message-Id: <03a2bc70e4260ec9f669391c47b9a7a9ecd0b75d.1407329621.git.mschiffer@universe-factory.net>
  12. +From: Matthias Schiffer <mschiffer@universe-factory.net>
  13. +Date: Wed, 6 Aug 2014 14:51:49 +0200
  14. +Subject: [PATCH] Add support for alternative rc.d directories
  15. +
  16. +---
  17. + initd/preinit.c | 38 ++++++++++++++++++++++++++++++++++++++
  18. + rcS.c | 2 +-
  19. + 2 files changed, 39 insertions(+), 1 deletion(-)
  20. +
  21. +diff --git a/initd/preinit.c b/initd/preinit.c
  22. +index fb94527..8b832a7 100644
  23. +--- a/initd/preinit.c
  24. ++++ b/initd/preinit.c
  25. +@@ -12,6 +12,8 @@
  26. + * GNU General Public License for more details.
  27. + */
  28. +
  29. ++#define _GNU_SOURCE
  30. ++
  31. + #include <sys/stat.h>
  32. + #include <sys/types.h>
  33. + #include <sys/mount.h>
  34. +@@ -46,6 +48,35 @@ check_dbglvl(void)
  35. + debug = lvl;
  36. + }
  37. +
  38. ++static char*
  39. ++get_rc_d(void)
  40. ++{
  41. ++ size_t n = 0;
  42. ++ ssize_t len;
  43. ++ char *ret = NULL;
  44. ++
  45. ++ FILE *fp = fopen("/tmp/rc_d_path", "r");
  46. ++
  47. ++ if (!fp)
  48. ++ return NULL;
  49. ++
  50. ++ len = getline(&ret, &n, fp);
  51. ++
  52. ++ fclose(fp);
  53. ++
  54. ++ unlink("/tmp/rc_d_path");
  55. ++
  56. ++ if (len <= 0) {
  57. ++ free(ret);
  58. ++ return NULL;
  59. ++ }
  60. ++
  61. ++ if (ret[len-1] == '\n')
  62. ++ ret[len-1] = 0;
  63. ++
  64. ++ return ret;
  65. ++}
  66. ++
  67. + static void
  68. + spawn_procd(struct uloop_process *proc, int ret)
  69. + {
  70. +@@ -53,6 +84,7 @@ spawn_procd(struct uloop_process *proc, int ret)
  71. + char *argv[] = { "/sbin/procd", NULL};
  72. + struct stat s;
  73. + char dbg[2];
  74. ++ char *rc_d_path;
  75. +
  76. + if (plugd_proc.pid > 0)
  77. + kill(plugd_proc.pid, SIGKILL);
  78. +@@ -72,6 +104,12 @@ spawn_procd(struct uloop_process *proc, int ret)
  79. + setenv("DBGLVL", dbg, 1);
  80. + }
  81. +
  82. ++ rc_d_path = get_rc_d();
  83. ++ if (rc_d_path) {
  84. ++ setenv("RC_D_PATH", rc_d_path, 1);
  85. ++ free(rc_d_path);
  86. ++ }
  87. ++
  88. + execvp(argv[0], argv);
  89. + }
  90. +
  91. +diff --git a/rcS.c b/rcS.c
  92. +index 0e1b0ba..1b00831 100644
  93. +--- a/rcS.c
  94. ++++ b/rcS.c
  95. +@@ -150,7 +150,7 @@ int rcS(char *pattern, char *param, void (*q_empty)(struct runqueue *))
  96. + q.empty_cb = q_empty;
  97. + q.max_running_tasks = 1;
  98. +
  99. +- return _rc(&q, "/etc/rc.d", pattern, "*", param);
  100. ++ return _rc(&q, getenv("RC_D_PATH") ?: "/etc/rc.d", pattern, "*", param);
  101. + }
  102. +
  103. + int rc(const char *file, char *param)
  104. +--
  105. +2.0.4
  106. +