valeriyvdovin / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0341-systemctl-return-diffrent-error-code-if-service-exis.patch

923a60
From 2eb2ddac8eaa258dd1ac0b2d4c1aefef9b66a989 Mon Sep 17 00:00:00 2001
923a60
From: Susant Sahani <ssahani@users.noreply.github.com>
923a60
Date: Mon, 30 May 2016 20:23:15 +0530
923a60
Subject: [PATCH] systemctl: return diffrent error code if service exist or not
923a60
 (#3385)
923a60
MIME-Version: 1.0
923a60
Content-Type: text/plain; charset=UTF-8
923a60
Content-Transfer-Encoding: 8bit
923a60
923a60
Before:
923a60
[sus@maximus bz-1256858]$ systemctl status rsyslog.service;echo $?
923a60
● rsyslog.service - System Logging Service
923a60
   Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor
923a60
preset: enabled)
923a60
  Drop-In: /etc/systemd/system/rsyslog.service.d
923a60
           └─50-CPUShares.conf
923a60
   Active: inactive (dead) since Mon 2016-05-30 11:54:25 IST; 2h 26min ago
923a60
     Docs: man:rsyslogd(8)
923a60
           http://www.rsyslog.com/doc/
923a60
  Process: 1159 ExecStart=/usr/sbin/rsyslogd -n $SYSLOGD_OPTIONS (code=exited,
923a60
status=0/SUCCESS)
923a60
 Main PID: 1159 (code=exited, status=0/SUCCESS)
923a60
923a60
May 30 11:07:50 maximus systemd[1]: Starting System Logging Service...
923a60
May 30 11:07:50 maximus systemd[1]: Started System Logging Service.
923a60
May 30 11:54:25 maximus systemd[1]: Stopping System Logging Service...
923a60
May 30 11:54:25 maximus systemd[1]: Stopped System Logging Service.
923a60
3
923a60
[sus@maximus bz-1256858]$ systemctl status hello.service;echo $?
923a60
● hello.service
923a60
   Loaded: not-found (Reason: No such file or directory)
923a60
   Active: inactive (dead)
923a60
3
923a60
923a60
After:
923a60
$ ./systemctl status hello.service;echo $?
923a60
Failed to dump process list, ignoring: Access denied
923a60
● hello.service
923a60
   Loaded: not-found (Reason: No such file or directory)
923a60
   Active: inactive (dead)
923a60
4
923a60
[sus@maximus bz-1256858]$  ./systemctl status rsyslog.service;echo $?
923a60
Failed to dump process list, ignoring: Access denied
923a60
● rsyslog.service - System Logging Service
923a60
   Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor
923a60
preset: enabled)
923a60
  Drop-In: /etc/systemd/system/rsyslog.service.d
923a60
           └─50-CPUShares.conf
923a60
   Active: inactive (dead) since Mon 2016-05-30 11:54:25 IST; 2h 24min ago
923a60
     Docs: man:rsyslogd(8)
923a60
           http://www.rsyslog.com/doc/
923a60
  Process: 1159 ExecStart=/usr/sbin/rsyslogd -n $SYSLOGD_OPTIONS (code=exited,
923a60
status=0/SUCCESS)
923a60
 Main PID: 1159 (code=exited, status=0/SUCCESS)
923a60
923a60
May 30 11:07:50 maximus systemd[1]: Starting System Logging Service...
923a60
May 30 11:07:50 maximus systemd[1]: Started System Logging Service.
923a60
May 30 11:54:25 maximus systemd[1]: Stopping System Logging Service...
923a60
May 30 11:54:25 maximus systemd[1]: Stopped System Logging Service.
923a60
3
923a60
923a60
Fixes: 1092
923a60
923a60
(cherry picked from commit ca473d572f0d2d8f547ff787ae67afd489a3f15e)
923a60
Resolves: #1047466
923a60
---
923a60
 src/systemctl/systemctl.c | 2 ++
923a60
 1 file changed, 2 insertions(+)
923a60
923a60
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
923a60
index 95ddf3be76..6079d60dbf 100644
923a60
--- a/src/systemctl/systemctl.c
923a60
+++ b/src/systemctl/systemctl.c
923a60
@@ -4295,6 +4295,8 @@ static int show_one(
923a60
                  */
923a60
                 if (info.pid_file && access(info.pid_file, F_OK) == 0)
923a60
                         r = 1;
923a60
+                else if (streq_ptr(info.load_state, "not-found") && streq_ptr(info.active_state, "inactive"))
923a60
+                        r = 4;
923a60
                 else
923a60
                         r = 3;
923a60
         }