Date: Wed, 8 Mar 2006 22:04:52 GMT From: Todd Miller <millert@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 92995 for review Message-ID: <200603082204.k28M4qr5047622@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=92995 Change 92995 by millert@millert_g5tower on 2006/03/08 22:04:18 Add usage(), use err(3). Affected files ... .. //depot/projects/trustedbsd/sedarwin7/src/darwin/mac_cmds/mexec/mexec.c#3 edit Differences ... ==== //depot/projects/trustedbsd/sedarwin7/src/darwin/mac_cmds/mexec/mexec.c#3 (text+ko) ==== @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2006 SPARTA, Inc. * Copyright (c) 2004 Networks Associates Technology, Inc. * All rights reserved. * @@ -26,24 +27,35 @@ #include <sys/types.h> #include <sys/mac.h> +#include <err.h> +#include <stdio.h> +#include <stdlib.h> #include <unistd.h> +void +usage(void) +{ + extern char *__progname; + + fprintf(stderr, "usage: %s label command_path [command args]\n", + __progname); + exit(1); +} + int main(int argc, char *argv[]) { mac_t exl; - /* XXXRW: Shouldn't there be an (argc>=3) usage check here? */ - if (mac_prepare(&exl, "sebsd")) { - perror("mexec"); - return (1); - } - if (mac_from_text(&exl, argv[1])) { - perror(argv[1]); - return (1); - } - argv+=2; + if (argc < 3) + usage(); + + if (mac_prepare(&exl, "sebsd")) + err(1, "sebsd"); + if (mac_from_text(&exl, argv[1])) + err(1, argv[1]); + argv += 2; if (mac_execve(argv[0], argv, NULL, exl)) - perror("mexec"); - return (1); + perror(argv[0]); + exit(1); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603082204.k28M4qr5047622>