1e71ca95cSGerald Jelinek /*
2e71ca95cSGerald Jelinek  * CDDL HEADER START
3e71ca95cSGerald Jelinek  *
4e71ca95cSGerald Jelinek  * The contents of this file are subject to the terms of the
5e71ca95cSGerald Jelinek  * Common Development and Distribution License (the "License").
6e71ca95cSGerald Jelinek  * You may not use this file except in compliance with the License.
7e71ca95cSGerald Jelinek  *
8e71ca95cSGerald Jelinek  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9e71ca95cSGerald Jelinek  * or http://www.opensolaris.org/os/licensing.
10e71ca95cSGerald Jelinek  * See the License for the specific language governing permissions
11e71ca95cSGerald Jelinek  * and limitations under the License.
12e71ca95cSGerald Jelinek  *
13e71ca95cSGerald Jelinek  * When distributing Covered Code, include this CDDL HEADER in each
14e71ca95cSGerald Jelinek  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15e71ca95cSGerald Jelinek  * If applicable, add the following below this CDDL HEADER, with the
16e71ca95cSGerald Jelinek  * fields enclosed by brackets "[]" replaced with your own identifying
17e71ca95cSGerald Jelinek  * information: Portions Copyright [yyyy] [name of copyright owner]
18e71ca95cSGerald Jelinek  *
19e71ca95cSGerald Jelinek  * CDDL HEADER END
20e71ca95cSGerald Jelinek  */
21e71ca95cSGerald Jelinek /*
22*98f4f4f6Sjv  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
23e71ca95cSGerald Jelinek  */
24e71ca95cSGerald Jelinek 
25e71ca95cSGerald Jelinek /*
26e71ca95cSGerald Jelinek  * s10_support is a small cli utility used to perform some brand-specific
27e71ca95cSGerald Jelinek  * tasks when verifying a zone.  This utility is not intended to be called
28e71ca95cSGerald Jelinek  * by users - it is intended to be invoked by the zones utilities.
29e71ca95cSGerald Jelinek  */
30e71ca95cSGerald Jelinek 
31e71ca95cSGerald Jelinek #include <ctype.h>
32e71ca95cSGerald Jelinek #include <errno.h>
33e71ca95cSGerald Jelinek #include <fcntl.h>
34e71ca95cSGerald Jelinek #include <libgen.h>
35e71ca95cSGerald Jelinek #include <limits.h>
36e71ca95cSGerald Jelinek #include <s10_brand.h>
37e71ca95cSGerald Jelinek #include <stdarg.h>
38e71ca95cSGerald Jelinek #include <stdio.h>
39e71ca95cSGerald Jelinek #include <stdlib.h>
40e71ca95cSGerald Jelinek #include <string.h>
41e71ca95cSGerald Jelinek #include <strings.h>
42e71ca95cSGerald Jelinek #include <stropts.h>
43e71ca95cSGerald Jelinek #include <sys/stat.h>
44e71ca95cSGerald Jelinek #include <sys/types.h>
45e71ca95cSGerald Jelinek #include <sys/utsname.h>
46e71ca95cSGerald Jelinek #include <sys/varargs.h>
47e71ca95cSGerald Jelinek #include <unistd.h>
48e71ca95cSGerald Jelinek #include <libintl.h>
49e71ca95cSGerald Jelinek #include <locale.h>
50e71ca95cSGerald Jelinek #include <dirent.h>
51e71ca95cSGerald Jelinek #include <sys/systeminfo.h>
52e71ca95cSGerald Jelinek 
53e71ca95cSGerald Jelinek #include <libzonecfg.h>
54e71ca95cSGerald Jelinek 
55e71ca95cSGerald Jelinek static void s10_err(char *msg, ...) __NORETURN;
56e71ca95cSGerald Jelinek static void usage(void) __NORETURN;
57e71ca95cSGerald Jelinek 
58e71ca95cSGerald Jelinek /*
59e71ca95cSGerald Jelinek  * XXX This is a temporary flag for the initial release to enable the
60e71ca95cSGerald Jelinek  * use of features which are not yet tested or fully implemented.
61e71ca95cSGerald Jelinek  */
62e71ca95cSGerald Jelinek static boolean_t override = B_FALSE;
63e71ca95cSGerald Jelinek 
64e71ca95cSGerald Jelinek static char *bname = NULL;
65e71ca95cSGerald Jelinek 
66*98f4f4f6Sjv /*
67*98f4f4f6Sjv  * DELETE_LIST_PATH represents the path to a solaris10-branded zone's "delete
68*98f4f4f6Sjv  * list", which is generated by patchrm when it needs to remove files after
69*98f4f4f6Sjv  * the zone reboots.  See set_zone_emul_bitmap() below for additional details.
70*98f4f4f6Sjv  */
71*98f4f4f6Sjv #define	DELETE_LIST_PATH	"/var/sadm/patch/.delete_list"
73e71ca95cSGerald Jelinek #define	PKGINFO_RD_LEN	128
74e71ca95cSGerald Jelinek #define	PATCHLIST	"PATCHLIST="
75e71ca95cSGerald Jelinek 
76e71ca95cSGerald Jelinek #if !defined(TEXT_DOMAIN)		/* should be defined by cc -D */
77e71ca95cSGerald Jelinek #define	TEXT_DOMAIN	"SYS_TEST"	/* Use this only if it wasn't */
78e71ca95cSGerald Jelinek #endif
79e71ca95cSGerald Jelinek 
80e71ca95cSGerald Jelinek /*PRINTFLIKE1*/
81e71ca95cSGerald Jelinek static void
s10_err(char * msg,...)82e71ca95cSGerald Jelinek s10_err(char *msg, ...)
83e71ca95cSGerald Jelinek {
84e71ca95cSGerald Jelinek 	char	buf[1024];
85e71ca95cSGerald Jelinek 	va_list	ap;
86e71ca95cSGerald Jelinek 
87e71ca95cSGerald Jelinek 	va_start(ap, msg);
88e71ca95cSGerald Jelinek 	(void) vsnprintf(buf, sizeof (buf), msg, ap);
89e71ca95cSGerald Jelinek 	va_end(ap);
90e71ca95cSGerald Jelinek 
91e71ca95cSGerald Jelinek 	/* This needs go to stdout so the msgs show up through zoneadm. */
92e71ca95cSGerald Jelinek 	(void) printf("Error: %s\n", buf);
93e71ca95cSGerald Jelinek 
94e71ca95cSGerald Jelinek 	exit(1);
95e71ca95cSGerald Jelinek 	/*NOTREACHED*/
96e71ca95cSGerald Jelinek }
97e71ca95cSGerald Jelinek 
98e71ca95cSGerald Jelinek static int
s10_verify(char * xmlfile)99