]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/notify/notify.c
Merge pull request #12411 from keszybz/pr/12394
[thirdparty/systemd.git] / src / notify / notify.c
index 07ad97a490d31678e7251f8a47dcbb5e084daabf..750529bbbd39985ebf6a7d79d7e76337c538bba0 100644 (file)
@@ -96,10 +96,9 @@ static int parse_argv(int argc, char *argv[]) {
                 case ARG_PID:
 
                         if (optarg) {
-                                if (parse_pid(optarg, &arg_pid) < 0) {
-                                        log_error("Failed to parse PID %s.", optarg);
-                                        return -EINVAL;
-                                }
+                                if (parse_pid(optarg, &arg_pid) < 0)
+                                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                               "Failed to parse PID %s.", optarg);
                         } else
                                 arg_pid = getppid();
 
@@ -152,6 +151,7 @@ static int run(int argc, char* argv[]) {
         unsigned i = 0;
         int r;
 
+        log_show_color(true);
         log_parse_environment();
         log_open();
 
@@ -193,7 +193,7 @@ static int run(int argc, char* argv[]) {
         if (!n)
                 return log_oom();
 
-        /* If this is requested change to the requested UID/GID. Note thta we only change the real UID here, and leave
+        /* If this is requested change to the requested UID/GID. Note that we only change the real UID here, and leave
            the effective UID in effect (which is 0 for this to work). That's because we want the privileges to fake the
            ucred data, and sd_pid_notify() uses the real UID for filling in ucred. */
 
@@ -208,10 +208,9 @@ static int run(int argc, char* argv[]) {
         r = sd_pid_notify(arg_pid ? arg_pid : getppid(), false, n);
         if (r < 0)
                 return log_error_errno(r, "Failed to notify init system: %m");
-        if (r == 0) {
-                log_error("No status data could be sent: $NOTIFY_SOCKET was not set");
-                return -EOPNOTSUPP;
-        }
+        if (r == 0)
+                return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
+                                       "No status data could be sent: $NOTIFY_SOCKET was not set");
         return 0;
 }