/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* s10_support is a small cli utility used to perform some brand-specific
* tasks when verifying a zone. This utility is not intended to be called
* by users - it is intended to be invoked by the zones utilities.
*/
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <limits.h>
#include <s10_brand.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stropts.h>
#include <unistd.h>
#include <libintl.h>
#include <locale.h>
#include <dirent.h>
#include <sys/systeminfo.h>
#include <libzonecfg.h>
static void usage(void) __NORETURN;
/*
* XXX This is a temporary flag for the initial release to enable the
* use of features which are not yet tested or fully implemented.
*/
/*
* DELETE_LIST_PATH represents the path to a solaris10-branded zone's "delete
* list", which is generated by patchrm when it needs to remove files after
* the zone reboots. See set_zone_emul_bitmap() below for additional details.
*/
#if !defined(TEXT_DOMAIN) /* should be defined by cc -D */
#endif
/*PRINTFLIKE1*/
static void
{
/* This needs go to stdout so the msgs show up through zoneadm. */
exit(1);
/*NOTREACHED*/
}
static int
{
}
/*
* Check to see whether the zone has any unsupported devices
* configured.
*
* The audio framework has changed in Solaris Next as compared to
* S10. Data indicates the less than 1/10 of 1 percent of zones
* revisit this if there is enough demand.
*/
}
!override) {
}
}
(void) zonecfg_enddevent(handle);
return (0);
}
/*
* Read an entry from a pkginfo file. Some of these lines can
* either be arbitrarily long or be continued by a backslash at the end of
* the line. This function coalesces lines that are longer than the read
* buffer, and lines that are continued, into one buffer which is returned.
* The caller must free this memory. NULL is returned when we hit EOF or
* if we run out of memory (errno is set to ENOMEM).
*/
static char *
{
char *start;
char *inp;
char *p;
int char_cnt = 0;
errno = 0;
return (NULL);
}
int len;
break;
}
else
break;
}
start = p;
}
}
return (start);
}
/*
* Read the SUNWcakr pkginfo file and get the PATCHLIST for the pkg.
*/
static int
{
char *buf;
int err = 0;
>= sizeof (pkginfo))
return (errno);
int len;
/* remove trailing newline */
if ((*patchlist =
break;
}
}
return (err);
}
/*
* Verify that we have the minimum KU needed.
* Note that KU patches are accumulative so future KUs will still deliver
* 141444 or 141445.
*/
static boolean_t
{
char *p;
char *lastp;
char *pstr;
char *vers_table[] = {
"141444-09",
"141445-09"};
/*
* If the zone was installed to bypass sanity checking for internal
* testing purposes, just return success.
*/
zonepath) >= sizeof (sanity_skip))
return (B_TRUE);
return (B_FALSE);
/*
* Check if we're running on the i86xpv platform. If so, the zone
* needs a different ku patch to work properly.
*/
if (is_xpv) {
return (B_TRUE);
} else {
if (strcmp(p, vers_table[0]) == 0 ||
return (B_TRUE);
}
}
if (is_xpv)
"when running in a paravirtualized domain"));
return (B_FALSE);
}
/*
* Convert the specified file basename into an unsigned integer. If the
* basename contains characters that cannot be converted into digits or the
* basename isn't NULL or newline-terminated, then this function returns
* the unsigned equivalent of -1.
*/
static unsigned int
{
char *filename_endptr;
unsigned int bit_index;
errno = 0;
return ((unsigned int)-1);
return (bit_index);
}
/*
* representing the results. Associate the bitmap with the zone so that
* the brand's emulation library will be able to retrieve the bitmap and
* determine how the zone's process' behaviors should be emulated.
*
* This function does not return if an error occurs.
*/
static void
{
unsigned int bit_index;
/*
* If the Solaris 10 directory containing emulation feature files
* doesn't exist in the zone, then assume that it only needs the
* most basic emulation and, therefore, doesn't need a bitmap.
*/
return;
/*
* Iterate over the contents of the directory and determine which
* features the brand should emulate for this zone.
*/
continue;
/*
* Convert the file's name to an unsigned integer. Ignore
* files whose names aren't unsigned integers.
*/
if (bit_index == (unsigned int)-1)
continue;
/*
* Determine if the brand can emulate the feature specified
* by bit_index.
*/
if (bit_index >= S10_NUM_EMUL_FEATURES) {
/*
* The zone requires emulation that the brand can't
* provide. Notify the user by displaying an error
* message.
*/
"incompatible with the\ncurrent version of the "
"solaris10 brand.\nPlease update your Solaris "
"system to the latest release."));
} else {
/*
* Set the feature's flag in the bitmap.
*/
}
}
(void) closedir(req_emulation_dirp);
/*
* The zone's administrator might have removed a patch that delivered
* an emulation feature file the last time the zone ran. If so, then
* the zone's patch utilities won't delete the file until the zone's
* svc:/system/patch-finish:delete SMF service runs. This is
* problematic because the zone will be using system libraries whose
* ioctl structures and syscall invocations will differ from those
* expected by the emulation library. For example, if an administrator
* removes a patch that affects the formats of MNTFS ioctls, then the
* administrator's zone will use a version of libc.so.1 that issues
* MNTFS ioctls that use older structure versions than the zone's
* emulation library will expect.
*
* Fortunately, the patchrm utility creates a hidden file,
* svc:/system/patch-finish:delete will delete. We'll determine whether
* this file exists in the zone and disable the emulation bits
* associated with the emulation feature files that will be deleted.
*
* NOTE: The patch tools lofs mount backup copies of critical system
* administrators add or remove DAP patches. Consequently, there isn't
* a window of vulnerability between patch addition or removal and
* zone reboot. The aforementioned problem only occurs after a zone
* reboots.
*/
sizeof (path))
" is too long"), zoneroot);
sizeof (S10_REQ_EMULATION_DIR);
/*
* Make sure that the file is in the directory
* containing emulation feature files. If it is,
* then basenamep should refer to the basename of
* the file.
*/
sizeof (S10_REQ_EMULATION_DIR) - 1) != 0)
continue;
continue;
/*
* Convert the file's basename into a bit index in
* the emulation bitmap. If the file's basename isn't
* integral, then skip the file. Otherwise, clear the
* corresponding bit in the bitmap.
*/
if (bit_index == (unsigned int)-1)
continue;
if (bit_index < S10_NUM_EMUL_FEATURES)
}
(void) fclose(delete_listp);
/*
* The delete list exists but couldn't be opened. Warn the
* administrator.
*/
}
/*
* We're done scanning files. Set the zone's emulation bitmap.
*/
}
static int
{
if (!have_valid_ku(zonename))
"not supported"));
return (0);
}
static void
usage()
{
"usage:\t%s verify <xml file>\n"
"\t%s boot\n"),
exit(1);
}
int
{
(void) textdomain(TEXT_DOMAIN);
if (argc != 3)
usage();
/*
* XXX This is a temporary env variable for the initial release to
* enable the use of features which are not yet tested or fully
* implemented.
*/
usage();
/*NOTREACHED*/
}