>Number:         153527
>Category:       bin
>Synopsis:       wake(8) should use sysexits.h
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 29 19:30:10 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     douglas steinwand
>Release:        FreeBSD 8.1
>Organization:
>Environment:
FreeBSD paris.fx.org 8.1-RELEASE-p1 FreeBSD 8.1-RELEASE-p1 #23: Sat Oct  9 
09:33:09 PDT 2010     [email protected]:/usr/obj/usr/src/sys/PARIS8  amd64

>Description:
The /usr/sbin/wake utility exits success (0) if an error occurs, for example if 
run by an unprivileged user or an unknown host is specified:

  $ wake foo bar; echo "exit=$?"
  wake: no bpf: Permission denied
  wake: error sending Wake on LAN frame over foo to bar

  exit=0

This causes problems when the utility is called from a shell script or other 
environment which expects a meaningful exit value. 
>How-To-Repeat:
Run wake(8) utility with an error condition.
>Fix:
The attached patch applies to FreeBSD 8.1 (src/usr.sbin/wake/wake.c,v 
1.3.2.1.4.1)

Patch attached with submission follows:

--- usr.sbin/wake/wake.c.orig   2010-10-09 09:31:39.904356000 -0700
+++ usr.sbin/wake/wake.c        2010-12-29 10:59:54.646423552 -0800
@@ -41,6 +41,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <sysexits.h>
 
 #define        _PATH_BPF       "/dev/bpf"
 
@@ -63,7 +64,7 @@
 {
 
        (void)fprintf(stderr, "usage: wake interface lladdr...\n");
-       exit(1);
+       exit(EX_USAGE);
 }
 
 static int
@@ -166,13 +167,16 @@
 main(int argc, char *argv[])
 {
        int n;
+       int rv = EX_OK;
 
        if (argc < 3)
                usage();
 
        for (n = 2; n < argc; n++)
-               if (wake(argv[1], argv[n]))
+               if (wake(argv[1], argv[n])) {
                        warnx("error sending Wake on LAN frame over %s to %s",
                            argv[1], argv[n]);
-       return (0);
+                       rv = EX_IOERR;
+               }
+       return (rv);
 }


>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to