From c6774d1c74baaf62827e82967ff62bb843854477 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 15 Jan 2008 19:47:48 +0000 Subject: If adding to the boot runlevel, ensure that the realpath of the resolved service points to /etc/init.d/$service --- src/librc/librc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/librc/librc.c b/src/librc/librc.c index 0e35c8b8..38961b75 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -765,14 +765,18 @@ bool rc_service_add (const char *runlevel, const char *service) /* We need to ensure that only things in /etc/init.d are added * to the boot runlevel */ if (strcmp (runlevel, RC_LEVEL_BOOT) == 0) { - char *tmp = xstrdup (init); + char tmp[MAXPATHLEN]; + + if (! realpath (init, tmp)) + return (false); retval = (strcmp (dirname (tmp), RC_INITDIR) == 0); - free (tmp); if (! retval) { free (init); errno = EPERM; return (false); } + free (init); + init = xstrdup (tmp); } file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service), -- cgit v1.2.3