]> git.saurik.com Git - apple/security.git/blobdiff - OSX/sec/SecurityTool/SecurityTool.c
Security-58286.1.32.tar.gz
[apple/security.git] / OSX / sec / SecurityTool / SecurityTool.c
index 9e0d0346c80c58c7da751d830f2db9a091d53a64..c5cb97502d966bcd283f730e2d62bac09ddd8e36 100644 (file)
@@ -1,15 +1,15 @@
 /*
- * Copyright (c) 2003-2010,2013 Apple Inc. All Rights Reserved.
+ * Copyright (c) 2003-2010,2013-2017 Apple Inc. All Rights Reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
- * 
+ *
  * This file contains Original Code and/or Modifications of Original Code
  * as defined in and that are subject to the Apple Public Source License
  * Version 2.0 (the 'License'). You may not use this file except in
  * compliance with the License. Please obtain a copy of the License at
  * http://www.opensource.apple.com/apsl/ and read it before using this
  * file.
- * 
+ *
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  * Please see the License for the specific language governing rights and
  * limitations under the License.
- * 
+ *
  * @APPLE_LICENSE_HEADER_END@
  *
  * security.c
  */
 
 #include "SecurityTool.h"
+#include "SecInternalReleasePriv.h"
 
 #include <SecurityTool/readline.h>
 
 #include "leaks.h"
 
 #include <ctype.h>
+#include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 /* The default prompt. */
 const char *prompt_string = "security> ";
 
-/* The name of this program. */
-const char *prog_name;
-
-
 /* Forward declarations of static functions. */
 
 
@@ -228,12 +226,12 @@ usage(void)
                "    -p    Set the prompt to \"prompt\" (implies -i).\n"
                "    -q    Be less verbose.\n"
                "    -v    Be more verbose about what's going on.\n"
-               "%s commands are:\n", prog_name, prog_name);
+               "%s commands are:\n", getprogname(), getprogname());
        help(0, NULL);
        return 2;
 }
 
-/* Execute a single command. */ 
+/* Execute a single command. */
 static int
 execute_command(int argc, char * const *argv)
 {
@@ -279,7 +277,7 @@ execute_command(int argc, char * const *argv)
        }
        else
        {
-               fprintf(stderr, "unknown command \"%s\"", argv[0]);
+               warnx("unknown command: %s", argv[0]);
                return 1;
        }
 }
@@ -300,9 +298,9 @@ main(int argc, char * const *argv)
        int do_leaks = 0;
        int ch;
 
-       /* Remember my name. */
-       prog_name = strrchr(argv[0], '/');
-       prog_name = prog_name ? prog_name + 1 : argv[0];
+       if (!SecIsInternalRelease()) {
+               errx(1, "command unavailable");
+       }
 
        /* Do getopt stuff for global options. */
        optind = 1;