From: Igor Vlasenko <vlasenko@imath.kiev.ua> To: ALT Devel discussion list <devel@lists.altlinux.org> Cc: "Dmitry V. Levin" <ldv@altlinux.org> Subject: Re: [devel] systemd policy - different names for systemd and sysV. Date: Fri, 11 May 2012 22:19:06 +0300 Message-ID: <20120511191906.GA24819@dad.imath.kiev.ua> (raw) In-Reply-To: <20120511183128.GA3702@altlinux.org> [-- Attachment #1: Type: text/plain, Size: 2020 bytes --] On Fri, May 11, 2012 at 10:31:28PM +0400, Dmitry V. Levin wrote: > > + /* wheather the end of realName ends with .service */ > > + if (strncmp (realName+strlen(realName)-sizeof(".service"), > > + ".service", sizeof(".service")) != 0) { > > Если вдруг strlen(realName) окажется меньше sizeof(".service"), то > может получиться не очень хорошо. Спасибо, поправил, patch3 в аттачменте. > Патч, в принципе, логичный, и (с точностью до кода проверки суффикса) > применимый. Только не логичнее ли применить это изменение прямо в > systemctl? Есть ли какие-нибудь причины патчить именно chkconfig, > а не systemctl? В systemctl этот патч может вызвать нежелательные эффекты, например, сломать user overrides в /etc/systemd. Поэтому врядли этот патч попадет в апстрим. См. аналогичной функциональности патч от Andrey Borzenkov'а [ http://lists.freedesktop.org/archives/systemd-devel/2011-March/001725.html ] и ответ на него Lennart'а Poettering'га [ http://lists.freedesktop.org/archives/systemd-devel/2011-March/001790.html ] А поскольку код systemd бурно развивается, без поддержки апстрима поддерживать в нем патчи достаточно накладно. В то же время chkconfig достаточно стабилен, и логика иметь у нас переносимый между init-ами скрипт туда вписывается. -- Dr. Igor Vlasenko -------------------- Topology Department Institute of Math Kiev, Ukraine -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. [-- Attachment #2: chkconfig-3.patch --] [-- Type: text/plain, Size: 1953 bytes --] diff --git a/chkconfig.c b/chkconfig.c index 63ddd73..f293426 100644 --- a/chkconfig.c +++ b/chkconfig.c @@ -622,15 +622,44 @@ int setService(char * name, int type, int where, int state) { return 0; } +#ifndef SYSTEMD_UNITDIR +# define SYSTEMD_UNITDIR "/lib/systemd/system" +#endif + +static char* systemdServiceName (const char* name) { + char *p; + char *serviceFile; + struct stat statbuf; + xasprintf(&serviceFile, SYSTEMD_UNITDIR "%s.service", name); + lstat(serviceFile,&statbuf); + if (!S_ISLNK(statbuf.st_mode)) { + xasprintf(&p, "%s.service", name); + } else { + char *realFile = realpath(serviceFile,NULL); + char *realName = basename(realFile); + off_t suffixOffset = strlen(realName)-sizeof(".service"); + /* wheather the end of realName ends with .service */ + if (suffixOffset <= 0 || strncmp (realName + suffixOffset, + ".service", sizeof(".service")) != 0) { + fprintf(stderr, _("Symlink %s does not point to a *.service file. Falling back to %s as systemd service name.\n"), realFile, name); + xasprintf(&p, "%s.service", name); + } else { + p = strdup (realName); + } + free(realFile); + } + free(serviceFile); + return p; +} + + void forwardSystemd(const char *name, int type, const char *verb) { if (type == TYPE_XINETD) return; if (systemdActive() && isOverriddenBySystemd(name)) { - char *p; - - xasprintf(&p, "%s.service", name); + char *p = systemdServiceName(name); fprintf(stderr, _("Note: Forwarding request to 'systemctl %s %s'.\n"), verb, p); @@ -648,8 +677,10 @@ static int systemd_loaded_type(const char *name) { char *cmd; FILE *p; int rc = 0; + char *systemdName = systemdServiceName(name); - xasprintf(&cmd, "systemctl status %s.service", name); + xasprintf(&cmd, "systemctl status %s", systemdName); + free(systemdName); p = popen(cmd, "r"); if (p) { char buf[1024];
next prev parent reply other threads:[~2012-05-11 19:19 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-05-11 11:16 Igor Vlasenko 2012-05-11 18:31 ` Dmitry V. Levin 2012-05-11 19:19 ` Igor Vlasenko [this message] 2012-05-11 19:36 ` Igor Vlasenko 2012-05-18 9:55 ` Alexey Shabalin 2012-05-18 10:19 ` Dmitry V. Levin 2012-05-18 10:51 ` Alexey Shabalin 2012-05-18 15:07 ` Dmitry V. Levin 2012-05-18 16:05 ` Alexey Shabalin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20120511191906.GA24819@dad.imath.kiev.ua \ --to=vlasenko@imath.kiev.ua \ --cc=devel@lists.altlinux.org \ --cc=ldv@altlinux.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux Team development discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \ devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru public-inbox-index devel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git