Project

General

Profile

Actions

Bug #4894

closed

svcadm returns unexpected exit codes for restart/refresh when EPERM

Added by Dave Eddy about 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
cmd - userland programs
Start date:
2014-05-27
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:
External Bug:

Description

When running svcadm from a limited user that does not have permissions, the enable and disable actions return a failure exit code, but the restart and refresh action return 0.

$ svcadm enable postfix; echo $?
svcadm: svc:/pkgsrc/postfix:default: Permission denied.
1
$ svcadm disable postfix; echo $?
svcadm: svc:/pkgsrc/postfix:default: Permission denied.
1
$ svcadm restart postfix; echo $?
svcadm: svc:/pkgsrc/postfix:default: Permission denied.
0
$ svcadm refresh postfix; echo $?
svcadm: svc:/pkgsrc/postfix:default: Permission denied.
0

Using this patch, the exit codes are set properly.

~/dev/illumos-gate/usr/src/cmd/svc/svcadm (git:master) $ git diff
diff --git a/usr/src/cmd/svc/svcadm/svcadm.c b/usr/src/cmd/svc/svcadm/svcadm.c
index f3d34ac..28b61c9 100644
--- a/usr/src/cmd/svc/svcadm/svcadm.c
+++ b/usr/src/cmd/svc/svcadm/svcadm.c
@@ -1338,8 +1338,10 @@ set_inst_action(const char *fmri, const scf_instance_t *inst,
            (ent = scf_entry_create(h)) == NULL)
                scfdie();

-       if (restarter_setup(fmri, inst))
+       if (restarter_setup(fmri, inst)) {
+               exit_status = 1;
                goto out;
+       }

        if (scf_instance_get_pg(inst, scf_pg_restarter_actions, pg) == -1) {
                if (scf_error() != SCF_ERROR_NOT_FOUND)

And the tests

$ ./svcadm enable postfix; echo $?
svcadm: svc:/pkgsrc/postfix:default: Permission denied.
1
$ ./svcadm disable postfix; echo $?
svcadm: svc:/pkgsrc/postfix:default: Permission denied.
1
$ ./svcadm restart postfix; echo $?
svcadm: svc:/pkgsrc/postfix:default: Permission denied.
1
$ ./svcadm refresh postfix; echo $?
svcadm: svc:/pkgsrc/postfix:default: Permission denied.
1

Originally from this gist: https://gist.github.com/bahamas10/03c6d77ca1746a3b3386

Actions #1

Updated by Electric Monk almost 9 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit a97d4a16317db7306cf947e1fccba57d895df625

commit  a97d4a16317db7306cf947e1fccba57d895df625
Author: Dave Eddy <dave@daveeddy.com>
Date:   2014-07-02T21:41:52.000Z

    4894 svcadm returns unexpected exit codes for restart/refresh when EPERM
    Reviewed by: Dan McDonald <danmcd@omniti.com>
    Approved by: Robert Mustacchi <rm@joyent.com>

Actions

Also available in: Atom PDF