4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
32 * Description: Get the zone pathname associated with a label.
34 * Usage: getzonepath sensitivity_label
43 #include <tsol/label.h>
48 label_error(const char *label
, const int err
)
50 if (errno
== EINVAL
) {
53 (void) fprintf(stderr
,
54 gettext("%s: bad string %s\n"), prog
, label
);
57 (void) fprintf(stderr
,
58 gettext("%s: bad previous label\n"), prog
);
61 (void) fprintf(stderr
,
62 gettext("%s: parsing error found in "
63 "\"%s\" at position %d\n"), prog
, label
, err
);
73 main(int argc
, char **argv
)
76 m_label_t
*label
= NULL
;
79 (void) setlocale(LC_ALL
, "");
80 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
81 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it were'nt */
83 (void) textdomain(TEXT_DOMAIN
);
85 if ((prog
= strrchr(argv
[0], '/')) == NULL
)
91 (void) fprintf(stderr
, gettext(
92 "Usage: %s label\n"), prog
);
96 if (str_to_label(argv
[1], &label
, MAC_LABEL
, L_NO_CORRECTION
,
98 label_error(argv
[1], err
);
101 if ((zone_root
= getzonerootbylabel(label
)) == NULL
) {
102 (void) fprintf(stderr
,
103 gettext("%s: cannot get path for label: %s.\n"), prog
,
108 (void) printf("%s\n", zone_root
);