Follow-up to issue #81: remove SysV shared memory IPC altogether

This change removes a long standing kernel requirement and architectural
mishap in the design of Finit v1.  It is no longer necessary to include
CONFIG_SYSVIPC in the kernel to use Finit and its command line tool
initctl.  It is also no longer possible to connect to the internals of
PID 1 using shmat(), the initctl tool has already been updated to use
the domain socket API.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2017-12-18 11:20:21 +01:00
1 parent c0515d112e
commit d7401b2a96
4 files changed
+7 -50

No files matched your search

+7 -24
View File
@@ -35,37 +35,20 @@
/* Each svc_t needs a unique job# */
static int jobcounter = 1;
static svc_t *workaround = NULL;
static svc_t *svc_list = NULL;
static svc_t *__connect_shm(void)
{
svc_t *list;
if (svc_list)
return svc_list;
list = finit_svc_connect();
if (!list) {
if (workaround)
return workaround;
/* Linux not built with CONFIG_SYSVIPC, or libc does not support shmat()/shmget() */
if (ENOSYS == errno)
warn("Kernel does support SYSV shmat() IPC, error %d", errno);
/* Try to prevent PID 1 from aborting, issue #81 */
if (getpid() == 1) {
warnx("Implementing PID 1 workaround, initctl tool will not work ...");
if (!workaround)
workaround = calloc(MAX_NUM_SVC, sizeof(svc_t));
list = workaround;
}
}
if (!list) {
warn("Failed connecting to shared memory, error %d", errno);
svc_list = calloc(MAX_NUM_SVC, sizeof(svc_t));
if (!svc_list) {
warn("Failed allocating static list of services, error %d", errno);
abort();
}
return list;
return svc_list;
}
/**