# HG changeset patch # User Garrett D'Amore # Date 1289880207 28800 # Node ID 35f707bf8b405d607fbd7fc6566498960a811807 # Parent f82e1d54cdbdc706ea30f5af9ab9fa63763de6ca 420 remove patch (sparse package) support from svr4 pkg 421 libpkg and libadm need to be lint clean Reviewed by: gwr@nexenta.com Reviewed by: peter.tribble@gmail.com Approved by: gwr@nexenta.com diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/Makefile.lint --- a/usr/src/Makefile.lint Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/Makefile.lint Mon Nov 15 20:03:27 2010 -0800 @@ -340,6 +340,7 @@ lib/brand/solaris10 \ lib/crypt_modules \ lib/extendedFILE \ + lib/libadm \ lib/libadutils \ lib/libadt_jni \ lib/libaio \ @@ -407,6 +408,7 @@ lib/libpctx \ lib/libpicl \ lib/libpicltree \ + lib/libpkg \ lib/libpool \ lib/libproc \ lib/libpthread \ @@ -475,12 +477,6 @@ ucbcmd/users \ ucbcmd/whoami -$(CLOSED_BUILD)COMMON_SUBDIRS += \ - $(CLOSED)/cmd/cmd-inet/usr.lib/in.iked \ - $(CLOSED)/cmd/pax \ - $(CLOSED)/cmd/sed_xpg4 \ - $(CLOSED)/lib/libc_i18n - i386_SUBDIRS= \ cmd/acpihpd \ cmd/biosdev \ @@ -511,8 +507,6 @@ lib/storage \ stand -$(CLOSED_BUILD)COMMON_SUBDIRS += $(CLOSED)/cmd/mtst - LINTSUBDIRS= $(COMMON_SUBDIRS) $($(MACH)_SUBDIRS) .PARALLEL: $(LINTSUBDIRS) diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/cmd/svr4pkg/hdrs/libinst.h --- a/usr/src/cmd/svr4pkg/hdrs/libinst.h Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/cmd/svr4pkg/hdrs/libinst.h Mon Nov 15 20:03:27 2010 -0800 @@ -239,8 +239,6 @@ /* dockdeps.c */ extern void setUpdate __P((void)); extern int isUpdate __P((void)); -extern void setPatchUpdate __P((void)); -extern int isPatchUpdate __P((void)); /* mntinfo.c */ extern int get_mntinfo __P((int map_client, char *vfstab_file)); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/cmd/svr4pkg/hdrs/messages.h --- a/usr/src/cmd/svr4pkg/hdrs/messages.h Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/cmd/svr4pkg/hdrs/messages.h Mon Nov 15 20:03:27 2010 -0800 @@ -537,7 +537,6 @@ #define ERR_OPRESVR4 gettext("unable to unlink options file <%s>") #define ERR_OUTPUT_WRITING gettext("error while writing file <%s>: (%d) %s") #define ERR_PACKAGEBINREN gettext("unable to rename <%s>\n\tto <%s>") -#define ERR_PATCHPKG gettext("unable to update patch_table with patches that have been pre installed") #define ERR_PATH gettext("the path <%s> is invalid!") #define ERR_PKGABRV gettext("illegal package abbreviation <%s> in dependency file") #define ERR_PKGADDCHK_CNFFAILED gettext("Conflicting file dependency checking failed.") @@ -670,7 +669,6 @@ #define ERR_WTMPFILE gettext("unable to write temporary file <%s>") #define ERR_ZONETEMPDIR gettext("unable to make temporary directory for non-global zone operations in directory <%s>: %s") #define ERR_Z_USED_IN_NONGLOBAL_ZONE gettext("the zonelist option may not be used in a non-global zone") -#define ERR_PKGINFO_COPY gettext("unable to copy %s to %s") #define ERR_CANNOT_ENABLE_LOCAL_FS gettext("Failed to enable the filesystem/local service.\n") #define ERR_CANNOT_RESTORE_LOCAL_FS gettext("Failed to bring the filesystem/local service back to its original state.\n") @@ -838,7 +836,6 @@ #define WRN_INSTVOL_NOTDIR gettext("WARNING: %s may not overwrite a populated directory.") #define WRN_INSTVOL_NOVERIFY gettext("WARNING: %s ") #define WRN_NOMAIL gettext("WARNING: unable to send e-mail notification") -#define WRN_PKGREMOVE_PATCHES gettext("\\nWARNING: The following patch(es) are installed to <%s>. If <%s> is removed, the patches applied to it will be removed as well leaving the patch partially installed. It is recommended that the patch(es) be removed before removing <%s>.\\n\\t%s") #define WRN_RELATIVE gettext("attempting to rename a relative file <%s>") #define WRN_RSCRIPTALT_BAD gettext("WARNING: the admin parameter <%s> is set to <%s> which is not recognized; the parameter may only be set to <%s> or <%s>") #define WRN_RSCRIPTALT_USING gettext("WARNING: the admin parameter <%s> is assumed to be set to <%s>") diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/cmd/svr4pkg/libinst/dockdeps.c --- a/usr/src/cmd/svr4pkg/libinst/dockdeps.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/cmd/svr4pkg/libinst/dockdeps.c Mon Nov 15 20:03:27 2010 -0800 @@ -67,7 +67,6 @@ static int pkgexist; static int pkgokay; static int is_update; -static int is_patch_update; /* * IMPORTANT NOTE: THE SIZE OF 'abbrev' IS HARD CODED INTO THE CHARACTER @@ -188,18 +187,6 @@ } void -setPatchUpdate(void) -{ - is_patch_update = 1; -} - -int -isPatchUpdate(void) -{ - return ((is_patch_update) ? 1 : 0); -} - -void setUpdate(void) { is_update = 1; diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/cmd/svr4pkg/pkgadd/main.c --- a/usr/src/cmd/svr4pkg/pkgadd/main.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/cmd/svr4pkg/pkgadd/main.c Mon Nov 15 20:03:27 2010 -0800 @@ -165,10 +165,6 @@ static boolean_t globalZoneOnly = B_FALSE; -/* Set by -O patchPkgRemoval */ - -static boolean_t patchPkgRemoval = B_FALSE; - /* * Assume the package is ABI and POSIX compliant as regards user * interactiion during procedure scripts. @@ -624,27 +620,6 @@ continue; } - /* - * Private interface: package is being - * installed as a patch package. - */ - - if (strcmp(p, "patchPkgInstall") == 0) { - setPatchUpdate(); - continue; - } - - /* - * If this is a patch removal - * then call setPatchUpdate() and set - * patchPkgRemoval flag. - */ - if (strcmp(p, "patchPkgRemoval") == 0) { - setPatchUpdate(); - patchPkgRemoval = B_TRUE; - continue; - } - if (strncmp(p, "zonelist=", 9) == 0) { /* * If colons used as separators, @@ -1661,16 +1636,6 @@ arg[nargs++] = "-O"; arg[nargs++] = "addzonename"; - if (isPatchUpdate()) { - if (patchPkgRemoval == B_TRUE) { - arg[nargs++] = "-O"; - arg[nargs++] = "patchPkgRemoval"; - } else { - arg[nargs++] = "-O"; - arg[nargs++] = "patchPkgInstall"; - } - } - /* * add parent zone info/type */ @@ -2009,16 +1974,6 @@ arg[nargs++] = "-O"; arg[nargs++] = "addzonename"; - if (isPatchUpdate()) { - if (patchPkgRemoval == B_TRUE) { - arg[nargs++] = "-O"; - arg[nargs++] = "patchPkgRemoval"; - } else { - arg[nargs++] = "-O"; - arg[nargs++] = "patchPkgInstall"; - } - } - /* * add parent zone info/type */ @@ -2187,18 +2142,6 @@ arg[nargs++] = "debug"; } - /* Installation is from a patch package. */ - - if (isPatchUpdate()) { - if (patchPkgRemoval == B_TRUE) { - arg[nargs++] = "-O"; - arg[nargs++] = "patchPkgRemoval"; - } else { - arg[nargs++] = "-O"; - arg[nargs++] = "patchPkgInstall"; - } - } - arg[nargs++] = "-O"; arg[nargs++] = pkgmodeargument(pkgservergetmode()); @@ -2386,7 +2329,7 @@ arg[nargs++] = a_idsName; arg[nargs++] = "-p"; ds_close(1); - ds_putinfo(buffer); + ds_putinfo(buffer, sizeof (buffer)); arg[nargs++] = buffer; } else if (pkgdev.mount != NULL) { arg[nargs++] = "-d"; diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/cmd/svr4pkg/pkgadm/pkgadm.h --- a/usr/src/cmd/svr4pkg/pkgadm/pkgadm.h Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/cmd/svr4pkg/pkgadm/pkgadm.h Mon Nov 15 20:03:27 2010 -0800 @@ -28,11 +28,6 @@ #define _PKGADM_H -/* - * Module: patchutil.h - * Description: This module contains the interfaces for patchadd - */ - #ifdef __cplusplus extern "C" { #endif diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/cmd/svr4pkg/pkgadm/pkgadm_msgs.h --- a/usr/src/cmd/svr4pkg/pkgadm/pkgadm_msgs.h Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/cmd/svr4pkg/pkgadm/pkgadm_msgs.h Mon Nov 15 20:03:27 2010 -0800 @@ -247,9 +247,6 @@ #define MSG_NOT_READABLE gettext(\ "Operation failed: unable to read file %s") -#define MSG_PATCH_UPGD gettext(\ - "Operation failed: unable to process patch information\n") - #define MSG_BUILD_INDEXES gettext(\ "Operation failed: unable to build indexes\n") diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/cmd/svr4pkg/pkgcond/main.c --- a/usr/src/cmd/svr4pkg/pkgcond/main.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/cmd/svr4pkg/pkgcond/main.c Mon Nov 15 20:03:27 2010 -0800 @@ -148,8 +148,6 @@ long gd_fileSystemConfigLen; /* current zone name */ char *gd_zoneName; - /* version of target: PATCH_CLIENT_VERSION */ - char *gd_patchClientVersion; /* SUNW_PKGCOND_GLOBAL_DATA:parentZone:zoneName */ char *gd_parentZoneName; /* SUNW_PKGCOND_GLOBAL_DATA:parentZone:zoneType */ @@ -3874,30 +3872,16 @@ } /* - * get package install root. If it doesn't exist check for - * patch install root (ROOTDIR) + * get package install root. */ a = getenv(ENV_VAR_PKGROOT); if ((a != NULL) && (*a != '\0')) { (*r_gdt)->gd_installRoot = a; } else { - a = getenv(ENV_VAR_PATCHROOT); - if ((a != NULL) && (*a != '\0')) { - (*r_gdt)->gd_installRoot = a; - } else { - (*r_gdt)->gd_installRoot = "/"; - } + (*r_gdt)->gd_installRoot = "/"; } - /* - * get patch client version: always set if $ROOTDIR != / and - * the $ROOTDIR/var/sadm/softinfo/INST_RELEASE file exists. - */ - - a = getenv(ENV_VAR_PATCH_CLIENTVER); - (*r_gdt)->gd_patchClientVersion = (a ? a : ""); - /* get the global data environment variable */ a = getenv(a_envVar); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/cmd/svr4pkg/pkgcond/pkgcond.h --- a/usr/src/cmd/svr4pkg/pkgcond/pkgcond.h Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/cmd/svr4pkg/pkgcond/pkgcond.h Mon Nov 15 20:03:27 2010 -0800 @@ -38,12 +38,10 @@ /* environment variable */ #define ENV_VAR_DEBUG "PKGCOND_DEBUG" #define ENV_VAR_PKGROOT "PKG_INSTALL_ROOT" -#define ENV_VAR_PATCHROOT "ROOTDIR" #define ENV_VAR_SET "SET_FROM_ENVIRONMENT" #define ENV_VAR_VERBOSE "PKGCOND_VERBOSE" #define ENV_VAR_PKGZONENAME "SUNW_PKG_INSTALL_ZONENAME" #define ENV_VAR_INITIAL_INSTALL "PKG_INIT_INSTALL" -#define ENV_VAR_PATCH_CLIENTVER "PATCH_CLIENT_VERSION" /* return codes used with pkgcond itself */ #define R_SUCCESS 0x0 /* condition match / success */ diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/cmd/svr4pkg/pkginstall/main.c --- a/usr/src/cmd/svr4pkg/pkginstall/main.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/cmd/svr4pkg/pkginstall/main.c Mon Nov 15 20:03:27 2010 -0800 @@ -181,14 +181,6 @@ static boolean_t globalZoneOnly = B_FALSE; -/* Set by -O patchPkgInstall */ - -static boolean_t patchPkgInstall = B_FALSE; - -/* Set by -O patchPkgRemoval */ - -static boolean_t patchPkgRemoval = B_FALSE; - /* Set by -O preinstallcheck */ static boolean_t preinstallCheck = B_FALSE; @@ -632,29 +624,6 @@ continue; } - /* - * If this is a patch installation - * then call setPatchUpdate(). - */ - - if (strcmp(p, "patchPkgInstall") == 0) { - setPatchUpdate(); - patchPkgInstall = B_TRUE; - continue; - } - - /* - * If this is a patch removal - * then call setPatchUpdate() and set - * patchPkgRemoval flag. - */ - - if (strcmp(p, "patchPkgRemoval") == 0) { - setPatchUpdate(); - patchPkgRemoval = B_TRUE; - continue; - } - /* process parent-zone-name option */ if (strncmp(p, PARENTZONENAME, @@ -1438,14 +1407,13 @@ } /* - * Need to force UPDATE to be NULL in case a patch has been applied - * before creating a zone. Some pkgs (SUNWcsr) already spooled - * to the zone, check the value of UPDATE in their postinstall script. - * After a pkg has been patched UPDATE exists statically in the - * pkginfo file and this value must be reset when installing a zone. + * Some pkgs (SUNWcsr) already spooled to the zone, check the + * value of UPDATE in their postinstall script. After a pkg + * has been patched UPDATE exists statically in the pkginfo + * file and this value must be reset when installing a zone. */ - if (saveSpoolInstall != 0 && !isPatchUpdate() && !isUpdate()) { + if (saveSpoolInstall != 0 && !isUpdate()) { putparam("UPDATE", ""); } @@ -2147,7 +2115,7 @@ */ rm_icas(pkgbin); - if ((globalZoneOnly) && (!patchPkgInstall) && (!patchPkgRemoval)) { + if (globalZoneOnly) { boolean_t b; b = pkgAddPackageToGzonlyList(pkginst, get_inst_root()); if (b == B_FALSE) { @@ -2535,13 +2503,12 @@ newValue = getenv(param); /* - * If zone attributes of patch packages haven't been verified - * by pdo, if there is no new value, and a zone attribute + * If there is no new value, and a zone attribute * is being changed, it is the same as setting the zone package * attribute to 'false' - make sure current setting is 'false'. */ - if ((patchPkgInstall == B_FALSE) && (newValue == NULL) && + if ((newValue == NULL) && (setZoneAttribute == B_TRUE) && (strcasecmp(oldValue, "false") != 0)) { @@ -2570,13 +2537,11 @@ } /* - * If zone attributes of patch packages haven't been verified - * by pdo, check if old and new values differ. + * Check if old and new values differ. * Error if zone parameter */ - if ((patchPkgInstall == B_FALSE) && - (setZoneAttribute == B_TRUE)) { + if (setZoneAttribute == B_TRUE) { /* illegal change to zone attribute */ progerr(ERR_MERGINFOS_CHANGE_ZONEATTR, pkgName, @@ -2606,67 +2571,56 @@ } /* - * Skip this if() section, if zone attributes of patch packages - * have been verified by pdo. + * verify that no zone attribute has been + * set to an invalid value + */ + + /* SUNW_PKG_ALLZONES */ + + newValue = getenv(PKG_ALLZONES_VARIABLE); + + /* + * complain if setting SUNW_PKG_ALLZONES to other than "false" */ - if (patchPkgInstall == B_FALSE) { - - /* - * verify that no zone attribute has been - * set to an invalid value - */ - - /* SUNW_PKG_ALLZONES */ - - newValue = getenv(PKG_ALLZONES_VARIABLE); - - /* - * complain if setting SUNW_PKG_ALLZONES to other than "false" - */ - - - if ((newValue != NULL) && (*SUNW_PKG_ALLZONES == '\0') && - (strcasecmp(newValue, "false") != 0)) { - /* change ALLZONES from "true" to "false" (unset) */ - progerr(ERR_MERGINFOS_SET_ZONEATTR, pkgName, - pkgVersion, PKG_ALLZONES_VARIABLE, newValue); - return (1); - } - - /* SUNW_PKG_THISZONE */ - - newValue = getenv(PKG_THISZONE_VARIABLE); - - /* - * complain if setting SUNW_PKG_THISZONE to other than "false" - */ - - if ((newValue != NULL) && (*SUNW_PKG_THISZONE == '\0') && - (strcasecmp(newValue, "false") != 0)) { - /* change THISZONE from "true" to "false" (unset) */ - progerr(ERR_MERGINFOS_SET_ZONEATTR, pkgName, - pkgVersion, PKG_THISZONE_VARIABLE, newValue); - return (1); - } - - /* SUNW_PKG_HOLLOW */ - - newValue = getenv(PKG_HOLLOW_VARIABLE); - - /* complain if setting SUNW_PKG_HOLLOW to other than "false" */ - - if ((newValue != NULL) && (*SUNW_PKG_HOLLOW == '\0') && - (strcasecmp(newValue, "false") != 0)) { - /* change HOLLOW from "true" to 'false" (unset) */ - progerr(ERR_MERGINFOS_SET_ZONEATTR, pkgName, - pkgVersion, PKG_HOLLOW_VARIABLE, newValue); - return (1); - } - + + if ((newValue != NULL) && (*SUNW_PKG_ALLZONES == '\0') && + (strcasecmp(newValue, "false") != 0)) { + /* change ALLZONES from "true" to "false" (unset) */ + progerr(ERR_MERGINFOS_SET_ZONEATTR, pkgName, + pkgVersion, PKG_ALLZONES_VARIABLE, newValue); + return (1); } - /* return */ + /* SUNW_PKG_THISZONE */ + + newValue = getenv(PKG_THISZONE_VARIABLE); + + /* + * complain if setting SUNW_PKG_THISZONE to other than "false" + */ + + if ((newValue != NULL) && (*SUNW_PKG_THISZONE == '\0') && + (strcasecmp(newValue, "false") != 0)) { + /* change THISZONE from "true" to "false" (unset) */ + progerr(ERR_MERGINFOS_SET_ZONEATTR, pkgName, + pkgVersion, PKG_THISZONE_VARIABLE, newValue); + return (1); + } + + /* SUNW_PKG_HOLLOW */ + + newValue = getenv(PKG_HOLLOW_VARIABLE); + + /* complain if setting SUNW_PKG_HOLLOW to other than "false" */ + + if ((newValue != NULL) && (*SUNW_PKG_HOLLOW == '\0') && + (strcasecmp(newValue, "false") != 0)) { + /* change HOLLOW from "true" to 'false" (unset) */ + progerr(ERR_MERGINFOS_SET_ZONEATTR, pkgName, + pkgVersion, PKG_HOLLOW_VARIABLE, newValue); + return (1); + } echoDebug(DBG_MERGINFOS_EXIT, pkginfo_path, 0); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/cmd/svr4pkg/pkginstall/merginfo.c --- a/usr/src/cmd/svr4pkg/pkginstall/merginfo.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/cmd/svr4pkg/pkginstall/merginfo.c Mon Nov 15 20:03:27 2010 -0800 @@ -421,9 +421,8 @@ } if ((strncmp(ep, "UPDATE=", 7) == 0) && - install_from_pspool != 0 && - !isPatchUpdate() && - !isUpdate()) { + install_from_pspool != 0 && + !isUpdate()) { continue; } @@ -488,8 +487,7 @@ quit(1); } - if (((pdirfp = opendir(path)) != NULL) && - !isPatchUpdate()) { + if ((pdirfp = opendir(path)) != NULL) { struct dirent *dp; @@ -559,30 +557,23 @@ quit(99); } - /* - * Only want to copy the FCS pkgmap if this is not a - * patch installation. - */ - - if (!isPatchUpdate()) { - i = snprintf(path, sizeof (path), "%s/pkgmap", instdir); - if (i > sizeof (path)) { - progerr(ERR_CREATE_PATH_2, instdir, "pkgmap"); - quit(1); - } + i = snprintf(path, sizeof (path), "%s/pkgmap", instdir); + if (i > sizeof (path)) { + progerr(ERR_CREATE_PATH_2, instdir, "pkgmap"); + quit(1); + } - i = snprintf(temp, sizeof (temp), "%s/pkgmap", - saveSpoolInstallDir); - if (i > sizeof (path)) { - progerr(ERR_CREATE_PATH_2, saveSpoolInstallDir, - "pkgmap"); - quit(1); - } + i = snprintf(temp, sizeof (temp), "%s/pkgmap", + saveSpoolInstallDir); + if (i > sizeof (path)) { + progerr(ERR_CREATE_PATH_2, saveSpoolInstallDir, + "pkgmap"); + quit(1); + } - if (cppath(MODE_SRC, path, temp, 0644)) { - progerr(ERR_CANNOT_COPY, path, temp); - quit(99); - } + if (cppath(MODE_SRC, path, temp, 0644)) { + progerr(ERR_CANNOT_COPY, path, temp); + quit(99); } } @@ -602,11 +593,9 @@ quit(1); } - if ((stat(path, &status) == 0) && - (status.st_mode & S_IFDIR) && - !isPatchUpdate()) { + if ((stat(path, &status) == 0) && (status.st_mode & S_IFDIR)) { i = snprintf(cmd, sizeof (cmd), "cp -pr %s/* %s", - path, pkgsav); + path, pkgsav); if (i > sizeof (cmd)) { progerr(ERR_SNPRINTF, "cp -pr %s/* %s"); quit(1); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/cmd/svr4pkg/pkginstall/quit.c --- a/usr/src/cmd/svr4pkg/pkginstall/quit.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/cmd/svr4pkg/pkginstall/quit.c Mon Nov 15 20:03:27 2010 -0800 @@ -67,7 +67,6 @@ extern char *msgtext; extern char *pkginst; extern char *pkgname; -extern char saveSpoolInstallDir[]; /* pkginstall/main.c */ /* * exported functions @@ -238,9 +237,6 @@ void quit(int retcode) { - char orig_pkginfo_path[PATH_MAX]; - char pkginfo_path[PATH_MAX]; - /* disable interrupts */ (void) signal(SIGINT, SIG_IGN); @@ -359,34 +355,6 @@ (void) rrmdir(pkgloc_sav); } } - - if (isPatchUpdate()) { - if (pkgloc[0] && !access(pkgloc, F_OK) && - !access(saveSpoolInstallDir, F_OK)) { - /* - * Copy the pkginfo file to the pspool - * directory. This propagates patch - * info to the patched pkg in the local - * zone. - */ - (void) snprintf(orig_pkginfo_path, - sizeof (orig_pkginfo_path), - "%s/%s/%s", get_PKGLOC(), - pkginst, PKGINFO); - - (void) snprintf(pkginfo_path, - sizeof (pkginfo_path), "%s/%s", - saveSpoolInstallDir, PKGINFO); - - if (cppath(MODE_SET|DIR_DISPLAY, - orig_pkginfo_path, pkginfo_path, - 0644)) { - progerr(ERR_PKGINFO_COPY, - orig_pkginfo_path, - pkginfo_path); - } - } - } } /* diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/cmd/svr4pkg/pkgremove/check.c --- a/usr/src/cmd/svr4pkg/pkgremove/check.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/cmd/svr4pkg/pkgremove/check.c Mon Nov 15 20:03:27 2010 -0800 @@ -149,27 +149,6 @@ } int -rckpatchpkg(char *p, char *pt) -{ - int n; - char ans[MAX_INPUT]; - - ptext(stderr, WRN_PKGREMOVE_PATCHES, p, p, p, pt); - - n = ckyorn(ans, NULL, NULL, NULL, ASK_PKGREMOVE_CONTINUE); - - if (n != 0) { - return (n); - } - - if (strchr("yY", *ans) == NULL) { - return (3); - } - - return (0); -} - -int rckdepend(void) { int n; diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/head/libzonecfg.h --- a/usr/src/head/libzonecfg.h Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/head/libzonecfg.h Mon Nov 15 20:03:27 2010 -0800 @@ -239,10 +239,6 @@ char zone_pkg_version[ZONE_PKG_VERSMAX]; }; -struct zone_patchtab { - char zone_patch_id[MAXNAMELEN]; -}; - struct zone_devpermtab { char zone_devperm_name[MAXPATHLEN]; uid_t zone_devperm_uid; @@ -266,7 +262,6 @@ uu_avl_node_t zpe_entry; char *zpe_name; char *zpe_vers; - uu_avl_t *zpe_patches_avl; } zone_pkg_entry_t; typedef enum zone_iptype { @@ -462,8 +457,6 @@ uid_t, gid_t, mode_t, const char *); extern void zonecfg_set_swinv(zone_dochandle_t); extern int zonecfg_add_pkg(zone_dochandle_t, char *, char *); -extern int zonecfg_add_patch(zone_dochandle_t, char *, void **); -extern int zonecfg_add_patch_obs(char *, void *); /* * External zone verification support. diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libadm/common/ckdate.c --- a/usr/src/lib/libadm/common/ckdate.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libadm/common/ckdate.c Mon Nov 15 20:03:27 2010 -0800 @@ -71,11 +71,11 @@ #define TAB ' ' static void -setmsg(char *msg, char *fmt) +setmsg(char *msg, char *fmt, size_t sz) { if ((fmt == NULL) || strcmp(fmt, "%D") == 0) fmt = "%m/%d/%y"; - (void) sprintf(msg, "%s. Format is <%s>.", MESG, fmt); + (void) snprintf(msg, sz, "%s. Format is <%s>.", MESG, fmt); } static char * @@ -234,7 +234,7 @@ if ((fmt != NULL) && (fmtcheck(fmt) == 1)) return (4); - setmsg(defmesg, fmt); + setmsg(defmesg, fmt, MSGSIZ); puterror(stdout, defmesg, error); return (0); } @@ -246,7 +246,7 @@ if ((fmt != NULL) && (fmtcheck(fmt) == 1)) return (4); - setmsg(defmesg, fmt); + setmsg(defmesg, fmt, MSGSIZ); puthelp(stdout, defmesg, help); return (0); } @@ -416,7 +416,7 @@ if ((fmt != NULL) && (fmtcheck(fmt) == 1)) return (4); - setmsg(defmesg, fmt); + setmsg(defmesg, fmt, MSGSIZ); (void) sprintf(ept, "[?,q]"); if (!prompt) diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libadm/common/ckitem.c --- a/usr/src/lib/libadm/common/ckitem.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libadm/common/ckitem.c Mon Nov 15 20:03:27 2010 -0800 @@ -27,8 +27,10 @@ * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2010 Nexenta Systems, Inc. All rights reserved. + */ -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4 */ /*LINTLIBRARY*/ #include @@ -463,6 +465,7 @@ for (i = 1; chp; ++i) { if (!(menup->attr & CKUNNUM)) (void) fprintf(stderr, "%3d ", i); + /* LINTED E_SEC_PRINTF_VAR_FMT */ (void) fprintf(stderr, format, chp->token); if (chp->text) { /* there is text associated with the token */ @@ -473,6 +476,7 @@ if (!(menup->attr & CKUNNUM)) (void) fprintf(stderr, "%5s", ""); + /* LINTED E_SEC_PRINTF_VAR_FMT */ (void) fprintf(stderr, format, ""); while (isspace((unsigned char)*pt)) ++pt; @@ -505,17 +509,16 @@ getstr(char *strval, char *defstr, char *error, char *help, char *prompt) { char input[MAX_INPUT]; - char *ept, end[MAX_INPUT]; + char end[MAX_INPUT]; - *(ept = end) = '\0'; + *end = '\0'; if (defstr) { - (void) sprintf(ept, "(default: %s) ", defstr); - ept += strlen(ept); + (void) snprintf(end, MAX_INPUT, "(default: %s) ", defstr); } if (ckquit) { - (void) strcat(ept, "[?,??,q]"); + (void) strlcat(end, "[?,??,q]", MAX_INPUT); } else { - (void) strcat(ept, "[?,??]"); + (void) strlcat(end, "[?,??]", MAX_INPUT); } start: diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libadm/common/ckpath.c --- a/usr/src/lib/libadm/common/ckpath.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libadm/common/ckpath.c Mon Nov 15 20:03:27 2010 -0800 @@ -27,8 +27,10 @@ * Copyright (c) 1996-1998, 2001 by Sun Microsystems, Inc. * All rights reserved. */ +/* + * Copyright 2010 Nexenta Systems, Inc. All rights reserved. + */ -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */ /*LINTLIBRARY*/ #include @@ -244,7 +246,8 @@ if (input) { if (ckpath_val(input, pflags)) { - (void) sprintf(buffer, "Pathname %s.", errstr); + (void) snprintf(buffer, sizeof (buffer), + "Pathname %s.", errstr); puterror(stdout, buffer, error); return; } @@ -311,7 +314,8 @@ } if (ckpath_val(input, pflags)) { - (void) sprintf(buffer, "Pathname %s.", errstr); + (void) snprintf(buffer, sizeof (buffer), + "Pathname %s.", errstr); puterror(stderr, buffer, error); goto start; } diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libadm/common/ckstr.c --- a/usr/src/lib/libadm/common/ckstr.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libadm/common/ckstr.c Mon Nov 15 20:03:27 2010 -0800 @@ -28,8 +28,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include #include #include @@ -50,14 +48,14 @@ #define ERRMSG2 \ "Pattern matching has failed." #define ERRMSG3 \ - "Please enter a string which contains no imbedded, \ + "Please enter a string which contains no embedded, \ leading or trailing spaces or tabs." #define HLPMSG0 "Please enter a string" #define HLPMSG1 "Please enter a string containing no more than %d characters" #define HLPMSG2 "matches one of the following patterns:" #define HLPMSG3 "matches the following pattern:" -#define HLPMSG4 "contains no imbedded, leading or trailing spaces or tabs." +#define HLPMSG4 "contains no embedded, leading or trailing spaces or tabs." static char *errstr; @@ -119,7 +117,8 @@ if (input) { if (ckstr_val(regexp, length, input)) { - (void) sprintf(temp, errstr, length); + /* LINTED E_SEC_PRINTF_VAR_FMT */ + (void) snprintf(temp, sizeof (temp), errstr, length); puterror(stdout, temp, error); return; } @@ -178,7 +177,8 @@ return (3); } if (ckstr_val(regexp, length, input)) { - (void) sprintf(errbuf, errstr, length); + /* LINTED E_SEC_PRINTF_VAR_FMT */ + (void) snprintf(errbuf, sizeof (errbuf), errstr, length); puterror(stderr, errbuf, error); goto start; } diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libadm/common/cktime.c --- a/usr/src/lib/libadm/common/cktime.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libadm/common/cktime.c Mon Nov 15 20:03:27 2010 -0800 @@ -27,8 +27,10 @@ * Copyright (c) 1997,1998 by Sun Microsystems, Inc. * All rights reserved. */ +/* + * Copyright 2010 Nexenta Systems, Inc. All rights reserved. + */ -#pragma ident "%Z%%M% %I% %E% SMI" /*LINTLIBRARY*/ #include @@ -58,11 +60,11 @@ #define TAB ' ' static void -setmsg(char *msg, char *fmt) +setmsg(char *msg, char *fmt, size_t sz) { if (fmt == NULL) fmt = DEFAULT; - (void) sprintf(msg, "%s <%s>.", ERRMSG, fmt); + (void) snprintf(msg, sz, "%s <%s>.", ERRMSG, fmt); } static char * @@ -281,7 +283,7 @@ if ((fmt != NULL) && (fmtcheck(fmt) == 1)) return (4); - setmsg(defmesg, fmt); + setmsg(defmesg, fmt, sizeof (defmesg)); puterror(stdout, defmesg, error); return (0); } @@ -293,7 +295,7 @@ if ((fmt != NULL) && (fmtcheck(fmt) == 1)) return (4); - setmsg(defmesg, fmt); + setmsg(defmesg, fmt, sizeof (defmesg)); puthelp(stdout, defmesg, help); return (0); } @@ -355,7 +357,7 @@ if (fmt == NULL) fmt = DEFAULT; - setmsg(defmesg, fmt); + setmsg(defmesg, fmt, sizeof (defmesg)); if (!prompt) prompt = "Enter a time of day"; diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libadm/common/getvol.c --- a/usr/src/lib/libadm/common/getvol.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libadm/common/getvol.c Mon Nov 15 20:03:27 2010 -0800 @@ -28,7 +28,6 @@ * All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" /*LINTLIBRARY*/ #include @@ -196,7 +195,7 @@ } else volname[0] = '\0'; - (void) sprintf(buffer, "/etc/labelit %s", cdevice); + (void) snprintf(buffer, sizeof (buffer), "/etc/labelit %s", cdevice); pp = popen(buffer, "r"); pt = buffer; while ((c = getc(pp)) != EOF) @@ -229,6 +228,7 @@ if (strcmp(fsname, pfsname) || strcmp(volname, pvolname)) { /* mismatched label */ if (flag) { + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ (void) sprintf(label, "%s,%s", pfsname, pvolname); } else { labelerr(pfsname, pvolname); @@ -260,17 +260,20 @@ (void) strcpy(volname, origvolname); if (IFTAPE(cdevice)) { - (void) sprintf(buffer, "/etc/labelit %s \"%s\" \"%s\" -n 1>&2", + (void) snprintf(buffer, sizeof (buffer), + "/etc/labelit %s \"%s\" \"%s\" -n 1>&2", cdevice, fsname, volname); } else { - (void) sprintf(buffer, "/etc/labelit %s \"%s\" \"%s\" 1>&2", - cdevice, fsname, volname); + (void) snprintf(buffer, sizeof (buffer), + "/etc/labelit %s \"%s\" \"%s\" 1>&2", + cdevice, fsname, volname); } if (system(buffer)) { (void) fprintf(stderr, "\nWrite of label to %s failed.", pname); return (1); } if (label) + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ (void) sprintf(label, "%s,%s", fsname, volname); return (0); } @@ -300,7 +303,7 @@ dev_type = devattr(device, "type"); if (prompt) { - (void) strcpy(prmpt, prompt); + (void) strlcpy(prmpt, prompt, sizeof (prmpt)); for (pt = prmpt; *prompt; ) { if ((*prompt == '\\') && (prompt[1] == '%')) prompt++; @@ -326,17 +329,21 @@ } *pt = '\0'; } else { + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ (void) sprintf(prmpt, "Insert a %s into %s.", voltxt, pname); if (label && (options & DM_ELABEL)) { (void) strcat(prmpt, " The following external label "); + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ (void) sprintf(prmpt+strlen(prmpt), " should appear on the %s:\\n\\t%s", voltxt, label); } if (label && !(options & DM_ELABEL)) { + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ (void) sprintf(prmpt+strlen(prmpt), - " The %s should be internally labeled as follows:", - voltxt); + " The %s should be internally labeled as follows:", + voltxt); + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ (void) sprintf(prmpt+strlen(prmpt), "\\n\\t%s\\n", label); } @@ -350,23 +357,28 @@ if (options & DM_FORMFS) { if (fmtcmd && *fmtcmd && mkfscmd && *mkfscmd) { + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ pt += sprintf(pt, FORMFS_MSG, voltxt); keyword[n++] = "f"; } else if (fmtcmd && *fmtcmd) { + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ pt += sprintf(pt, FORMAT_MSG, voltxt); keyword[n++] = "f"; } if (mkfscmd && *mkfscmd) { + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ pt += sprintf(pt, MAKEFS_MSG, voltxt); keyword[n++] = "m"; } } else if (options & DM_FORMAT) { if (fmtcmd && *fmtcmd) { + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ pt += sprintf(pt, FORMAT_MSG, voltxt); keyword[n++] = "f"; } } if (options & DM_WLABEL) { + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ pt += sprintf(pt, WLABEL_MSG, voltxt); keyword[n++] = "w"; } @@ -376,9 +388,11 @@ } if (removecmd && *removecmd && dev_type && *dev_type) { if (strcmp(dev_type, "diskette") == 0) { + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ pt += sprintf(pt, EJECT_MSG, voltxt); keyword[n++] = "e"; } else { + /* LINTED E_SEC_SPRINTF_UNBOUNDED_COPY */ pt += sprintf(pt, UNLOAD_MSG, voltxt); keyword[n++] = "u"; } @@ -425,7 +439,7 @@ if (fmtcmd && *fmtcmd) { (void) fprintf(stderr, "\t[%s]\n", fmtcmd); - (void) sprintf(buffer, "(%s) 1>&2", fmtcmd); + (void) snprintf(buffer, sizeof (buffer), "(%s) 1>&2", fmtcmd); if (system(buffer)) { (void) fprintf(stderr, ERR_FMT, voltxt); return; @@ -433,7 +447,7 @@ } if (mkfscmd && *mkfscmd) { (void) fprintf(stderr, "\t[%s]\n", mkfscmd); - (void) sprintf(buffer, "(%s) 1>&2", mkfscmd); + (void) snprintf(buffer, sizeof (buffer), "(%s) 1>&2", mkfscmd); if (system(buffer)) { (void) fprintf(stderr, ERR_MKFS, voltxt); return; @@ -452,7 +466,8 @@ if (removecmd && *removecmd) { if (echo) (void) fprintf(stderr, "\t[%s]\n", removecmd); - (void) sprintf(buffer, "(%s) 1>&2", removecmd); + (void) snprintf(buffer, sizeof (buffer), + "(%s) 1>&2", removecmd); if (system(buffer)) { if (echo) (void) fprintf(stderr, ERR_REMOVE, diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libadm/common/pkginfo.c --- a/usr/src/lib/libadm/common/pkginfo.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libadm/common/pkginfo.c Mon Nov 15 20:03:27 2010 -0800 @@ -251,11 +251,13 @@ PI_INSTALLED); if (info->status == PI_INSTALLED) { - (void) sprintf(temp, "%s/%s/!I-Lock!", pkgdir, pkginst); + (void) snprintf(temp, sizeof (temp), + "%s/%s/!I-Lock!", pkgdir, pkginst); if (access(temp, 0) == 0) info->status = PI_PARTIAL; else { - (void) sprintf(temp, "%s/%s/!R-Lock!", pkgdir, pkginst); + (void) snprintf(temp, sizeof (temp), + "%s/%s/!R-Lock!", pkgdir, pkginst); if (access(temp, 0) == 0) info->status = PI_PARTIAL; } @@ -287,7 +289,7 @@ static char pkginst[PKGSIZ+1]; static DIR *pdirfp; struct dirent64 *dp; - char *pt, *ckarch, *ckvers; + char *ckarch, *ckvers; va_list ap; va_start(ap, pkg); @@ -376,7 +378,8 @@ FILE *fp; char temp[256]; - (void) sprintf(temp, "%s/%s/install/compver", get_PKGLOC(), pkginst); + (void) snprintf(temp, sizeof (temp), + "%s/%s/install/compver", get_PKGLOC(), pkginst); if ((fp = fopen(temp, "r")) == NULL) return (-1); @@ -424,7 +427,7 @@ char *pt, *copy, *value, *myarch, *myvers; int errflg; - (void) sprintf(file, "%s/%s/pkginfo", pkgdir, inst); + (void) snprintf(file, sizeof (file), "%s/%s/pkginfo", pkgdir, inst); if ((fp = fopen(file, "r")) == NULL) return (1); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libadm/common/pkgparam.c --- a/usr/src/lib/libadm/common/pkgparam.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libadm/common/pkgparam.c Mon Nov 15 20:03:27 2010 -0800 @@ -26,6 +26,10 @@ * Use is subject to license terms. */ +/* + * Copyright 2010 Nexenta Systems, Inc. All rights reserved. + */ + /*LINTLIBRARY*/ /* 5-20-92 newroot support added */ @@ -390,12 +394,14 @@ set_PKGpaths(char *path) { if (path && *path) { - (void) sprintf(Adm_pkgloc, "%s%s", path, PKGLOC); - (void) sprintf(Adm_pkgadm, "%s%s", path, PKGADM); + (void) snprintf(Adm_pkgloc, sizeof (Adm_pkgloc), + "%s%s", path, PKGLOC); + (void) snprintf(Adm_pkgadm, sizeof (Adm_pkgadm), + "%s%s", path, PKGADM); set_install_root(path); } else { - (void) sprintf(Adm_pkgloc, "%s", PKGLOC); - (void) sprintf(Adm_pkgadm, "%s", PKGADM); + (void) snprintf(Adm_pkgloc, sizeof (Adm_pkgloc), "%s", PKGLOC); + (void) snprintf(Adm_pkgadm, sizeof (Adm_pkgadm), "%s", PKGADM); } canonize_name(Adm_pkgloc); canonize_name(Adm_pkgadm); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libadm/common/putdev.c --- a/usr/src/lib/libadm/common/putdev.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libadm/common/putdev.c Mon Nov 15 20:03:27 2010 -0800 @@ -26,8 +26,10 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ +/* + * Copyright 2010 Nexenta Systems, Inc. All rights reserved. + */ -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ /* LINTLIBRARY */ /* @@ -78,12 +80,9 @@ * * TDTABNM Name of the temporary device table (in the * directory of the existing table) - * TDTABNMLN Number of characters added to the directory - * name -- the length of the device table temp name */ #define TDTABNM "%sdevtab.%6.6d" -#define TDTABNMLN 13 /* @@ -190,21 +189,20 @@ *(p+1) = '\0'; dirname = oldname; } else dirname = "./"; - if (buf = malloc(TDTABNMLN + strlen(dirname) + 1)) { + if (asprintf(&buf, TDTABNM, dirname, getpid()) >= 0) { - /* - * Build the name of the temp device table and open the - * file. We must reset the owner, group and perms to those - * of the original devtab file. - */ - (void) sprintf(buf, TDTABNM, dirname, getpid()); - if (fp = fopen(buf, "w")) { - *pname = buf; - (void) fchmod(fileno(fp), sbuf.st_mode & 0777); - (void) fchown(fileno(fp), sbuf.st_uid, sbuf.st_gid); - } else { - free(buf); - } + /* + * Build the name of the temp device table and + * open the file. We must reset the owner, group + * and perms to those of the original devtab file. + */ + if (fp = fopen(buf, "w")) { + *pname = buf; + (void) fchmod(fileno(fp), sbuf.st_mode & 0777); + (void) fchown(fileno(fp), sbuf.st_uid, sbuf.st_gid); + } else { + free(buf); + } } /* diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libadm/common/putdgrp.c --- a/usr/src/lib/libadm/common/putdgrp.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libadm/common/putdgrp.c Mon Nov 15 20:03:27 2010 -0800 @@ -26,8 +26,10 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ +/* + * Copyright 2010 Nexenta Systems, Inc. All rights reserved. + */ -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ /* LINTLIBRARY */ /* @@ -74,12 +76,9 @@ * L O C A L D E F I N I T I O N S * TDGTABNM Name of the temporary device-group table (in the * directory of the existing table) - * TDGTABNMLN Number of characters added to the directory - * name -- the length of the device-group table temp name */ #define TDGTABNM "%sdgroup.%6.6d" -#define TDGTABNMLN 13 /* @@ -137,49 +136,51 @@ /* Get the name of the device-group table */ if (oldname = _dgrptabpath()) { - /* - * It is possible for us to have sufficient permissions to create - * the new file without having sufficient permissions to write the - * original dgrptab file. For consistency with the operations which - * modify the original file by writing it directly we require write - * permissions for the original file in order to make a new one. - */ - if ((fd = open(oldname, O_WRONLY)) == -1) - return (NULL); + /* + * It is possible for us to have sufficient + * permissions to create the new file without having + * sufficient permissions to write the original + * dgrptab file. For consistency with the operations + * which modify the original file by writing it + * directly we require write permissions for the + * original file in order to make a new one. + */ + if ((fd = open(oldname, O_WRONLY)) == -1) + return (NULL); - if (fstat64(fd, &sbuf) == -1) { + if (fstat64(fd, &sbuf) == -1) { + (void) close(fd); + return (NULL); + } (void) close(fd); - return (NULL); - } - (void) close(fd); - /* Get the directory that the device-group table lives in */ - if (p = strrchr(oldname, '/')) { - *(p+1) = '\0'; - dirname = oldname; - } else - dirname = "./"; - - /* Get space for the temp dgrptab pathname */ - if (buf = malloc(TDGTABNMLN+strlen(dirname)+1)) { + /* Get the directory that the device-group table lives in */ + if (p = strrchr(oldname, '/')) { + *(p+1) = '\0'; + dirname = oldname; + } else + dirname = "./"; - /* - * Build the name of the temp dgrptab and open the - * file. We must reset the owner, group and perms to those - * of the original dgrptab file. - */ - (void) sprintf(buf, TDGTABNM, dirname, getpid()); - if (fp = fopen(buf, "w")) { - *pname = buf; - (void) fchmod(fileno(fp), sbuf.st_mode & 0777); - (void) fchown(fileno(fp), sbuf.st_uid, sbuf.st_gid); - } else { - free(buf); + /* Get space for the temp dgrptab pathname */ + if (asprintf(&buf, TDGTABNM, dirname, getpid()) >= 0) { + /* + * Build the name of the temp dgrptab and open + * the file. We must reset the owner, group + * and perms to those of the original dgrptab + * file. + */ + if (fp = fopen(buf, "w")) { + *pname = buf; + (void) fchmod(fileno(fp), sbuf.st_mode & 0777); + (void) fchown(fileno(fp), sbuf.st_uid, + sbuf.st_gid); + } else { + free(buf); + } } - } - /* Free the space containing the dgrptab's name */ - free(oldname); + /* Free the space containing the dgrptab's name */ + free(oldname); } /* Finished. Return what we've got */ @@ -243,21 +244,26 @@ /* Get the dgrptab's pathname */ if (dgrpname = _dgrptabpath()) { - /* Unlink the existing file */ - if (unlink(dgrpname) == 0) { + /* Unlink the existing file */ + if (unlink(dgrpname) == 0) { - /* Make the temp file the real device-group table */ - noerr = (link(tempname, dgrpname) == 0) ? TRUE : FALSE; + /* Make the temp file the real device-group table */ + noerr = (link(tempname, dgrpname) == 0) ? TRUE : FALSE; + + /* Remove the temp file */ + if (noerr) + noerr = rmnewdgrptab(tempname); - /* Remove the temp file */ - if (noerr) noerr = rmnewdgrptab(tempname); - - } else noerr = FALSE; /* unlink() failed */ + } else { + noerr = FALSE; /* unlink() failed */ + } - /* Free the dgrptab's name */ - free(dgrpname); + /* Free the dgrptab's name */ + free(dgrpname); - } else noerr = FALSE; /* dgrptabpath() failed */ + } else { + noerr = FALSE; /* dgrptabpath() failed */ + } /* Finished. Return success indicator */ return (noerr); @@ -297,48 +303,54 @@ noerr = TRUE; if (_opendgrptab(o_mode)) { - /* - * Lock the device-group table (for writing). If it's not - * available, wait until it is, then close and open the - * table (modify and delete change the table!) and try - * to lock it again - */ - - /* Build the locking structure */ - lockinfo.l_type = lktype; - lockinfo.l_whence = 0; - lockinfo.l_start = 0L; - lockinfo.l_len = 0L; - olderrno = errno; - - /* Keep on going until we lock the file or an error happens */ - while ((fcntl(fileno(oam_dgroup), F_SETLK, &lockinfo) == -1) && - !noerr) { - /* - * fcntl() failed. - * If errno=EACCES, it's because the file's locked by someone - * else. Wait for the file to be unlocked, then close and - * reopen the file and try the lock again. + * Lock the device-group table (for writing). If it's not + * available, wait until it is, then close and open the + * table (modify and delete change the table!) and try + * to lock it again */ - if (errno == EACCES) { - if (fcntl(fileno(oam_dgroup), F_SETLKW, &lockinfo) == -1) - noerr = FALSE; - else { - _enddgrptab(); - if (!_opendgrptab(o_mode)) noerr = FALSE; - else errno = olderrno; - } + /* Build the locking structure */ + lockinfo.l_type = lktype; + lockinfo.l_whence = 0; + lockinfo.l_start = 0L; + lockinfo.l_len = 0L; + olderrno = errno; + + /* Keep on going until we lock the file or an error happens */ + while ((fcntl(fileno(oam_dgroup), F_SETLK, &lockinfo) == -1) && + !noerr) { + + /* + * fcntl() failed. If errno=EACCES, it's + * because the file's locked by someone else. + * Wait for the file to be unlocked, then + * close and reopen the file and try the lock + * again. + */ - } else noerr = FALSE; /* fcntl() failed hard */ - - } /* End while (fcntl() && !noerr) */ + if (errno == EACCES) { + if (fcntl(fileno(oam_dgroup), F_SETLKW, + &lockinfo) == -1) + noerr = FALSE; + else { + _enddgrptab(); + if (!_opendgrptab(o_mode)) + noerr = FALSE; + else + errno = olderrno; + } - /* Don't keep file open if an error happened */ - if (!noerr) _enddgrptab(); + } else + noerr = FALSE; /* fcntl() failed hard */ + + } /* End while (fcntl() && !noerr) */ - } else noerr = FALSE; /* _opendgrptab() failed */ + /* Don't keep file open if an error happened */ + if (!noerr) _enddgrptab(); + + } else + noerr = FALSE; /* _opendgrptab() failed */ /* Done */ return (noerr); @@ -499,7 +511,8 @@ /* Comment or data record? */ - if (rec->comment) count = fputs(rec->dataspace, stream); + if (rec->comment) + count = fputs(rec->dataspace, stream); else { /* diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libinstzones/common/instzones_lib.h --- a/usr/src/lib/libinstzones/common/instzones_lib.h Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libinstzones/common/instzones_lib.h Mon Nov 15 20:03:27 2010 -0800 @@ -98,9 +98,6 @@ /* this locks all packages, in all zones */ #define LOBJ_PKGADMIN "zone.*/package.*" -/* this locks all patches, in all zones */ -#define LOBJ_PATCHADMIN "zone.*/patch.*" - #define LOCK_OBJECT_MAXLEN 512 #define LOCK_KEY_MAXLEN 37 diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libinstzones/common/zones.c --- a/usr/src/lib/libinstzones/common/zones.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libinstzones/common/zones.c Mon Nov 15 20:03:27 2010 -0800 @@ -693,20 +693,6 @@ } } - /* lock patch administration always */ - - if (a_lflags & ZLOCKS_PATCH_ADMIN) { - b = _z_lock_zone_object(&_z_global_data._z_ObjectLocks, - zoneName, LOBJ_PATCHADMIN, pid, - MSG_ZONES_LCK_THIS_PATCHADM, - ERR_ZONES_LCK_THIS_PATCHADM); - if (!b) { - (void) z_unlock_this_zone(a_lflags); - (void) free(zoneName); - return (B_FALSE); - } - } - (void) free(zoneName); return (B_TRUE); @@ -908,9 +894,6 @@ /* * lofs resolve the non-global zone's root path first in case * its in a path that's been lofs mounted read-only. - * (e.g. This happens when we're tyring to patch a zone in an ABE - * that lives on a filesystem that the ABE shares with the currently - * running BE.) */ z_resolve_lofs(lzRootPath, sizeof (lzRootPath)); @@ -1390,16 +1373,6 @@ zoneName = z_get_zonename(); - /* unlock patch administration */ - - if (a_lflags & ZLOCKS_PATCH_ADMIN) { - b = _z_unlock_zone_object(&_z_global_data._z_ObjectLocks, - zoneName, LOBJ_PATCHADMIN, ERR_ZONES_ULK_THIS_PATCH); - if (!b) { - errors = B_TRUE; - } - } - /* unlock package administration */ if (a_lflags & ZLOCKS_PKG_ADMIN) { @@ -1670,7 +1643,7 @@ /* * Both "native" and "cluster" are native brands * that use the standard facilities in the areas - * of packaging/installation/patching/update. + * of packaging/installation/update. */ if (streq(brandname, NATIVE_BRAND_NAME) || streq(brandname, CLUSTER_BRAND_NAME)) { diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libinstzones/common/zones_locks.c --- a/usr/src/lib/libinstzones/common/zones_locks.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libinstzones/common/zones_locks.c Mon Nov 15 20:03:27 2010 -0800 @@ -540,31 +540,6 @@ } /* - * acquire patch lock - */ - - if (a_lflags & ZLOCKS_PATCH_ADMIN) { - - /* - * zone and package administration is locked; lock patch - * administration; if the lock cannot be released, stop, - * release the other locks and return an error - */ - - _z_echoDebug(DBG_ZONES_LCK_ZONE_PATCHADM, a_zlst->_zlName, - LOBJ_PATCHADMIN); - - b = _z_lock_zone_object(&a_zlst->_zlLockObjects, - scratchName, LOBJ_PATCHADMIN, (pid_t)0, - MSG_ZONES_LCK_ZONE_PATCHADM, - ERR_ZONES_LCK_ZONE_PATCHADM); - if (b == B_FALSE) { - (void) _z_unlock_zone(a_zlst, a_lflags); - return (b); - } - } - - /* * all locks have been obtained - return success! */ @@ -832,23 +807,6 @@ scratchName = a_zlst->_zlScratchName == NULL ? a_zlst->_zlName : a_zlst->_zlScratchName; - if (a_lflags & ZLOCKS_PATCH_ADMIN) { - /* - * if locked, unlock patch administration lock - * if the lock cannot be released, continue anyway - */ - - _z_echoDebug(DBG_ZONES_ULK_ZONE_PATCHADM, a_zlst->_zlName, - LOBJ_PATCHADMIN); - - b = _z_unlock_zone_object(&a_zlst->_zlLockObjects, - scratchName, LOBJ_PATCHADMIN, - WRN_ZONES_ULK_ZONE_PATCHADM); - if (b == B_FALSE) { - errors = B_TRUE; - } - } - if (a_lflags & ZLOCKS_PKG_ADMIN) { /* * if locked, unlock package administration lock diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libinstzones/common/zones_strings.h --- a/usr/src/lib/libinstzones/common/zones_strings.h Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libinstzones/common/zones_strings.h Mon Nov 15 20:03:27 2010 -0800 @@ -93,7 +93,6 @@ #define DBG_ZONES_LCK_ZONES_EXIST ILIBSTR("locking all non-global zones defined") #define DBG_ZONES_LCK_ZONES_NOZONES ILIBSTR("no zones locked: no non-global zones exist") #define DBG_ZONES_LCK_ZONES_UNIMP ILIBSTR("no zones locked: zones are not implemented") -#define DBG_ZONES_LCK_ZONE_PATCHADM ILIBSTR("locking patch administration: zone <%s> object <%s>") #define DBG_ZONES_LCK_ZONE_PKGADM ILIBSTR("locking package administration: zone <%s> object <%s>") #define DBG_ZONES_LCK_ZONE_ZONEADM ILIBSTR("locking zone administration: zone <%s> object <%s>") #define DBG_ZONES_MOUNT_IN_LZ_ENTRY ILIBSTR("mount in non-global zone: zone <%s> global-zone path <%s>") @@ -112,7 +111,6 @@ #define DBG_ZONES_ULK_ZONES_EXIST ILIBSTR("unlocking all non-global zones defined") #define DBG_ZONES_ULK_ZONES_NOZONES ILIBSTR("no zones unlocked: no non-global zones exist") #define DBG_ZONES_ULK_ZONES_UNIMP ILIBSTR("no zones unlocked: zones are not implemented") -#define DBG_ZONES_ULK_ZONE_PATCHADM ILIBSTR("unlocking patch administration: zone <%s> object <%s>") #define DBG_ZONES_ULK_ZONE_PKGADM ILIBSTR("unlocking package administration: zone <%s> object <%s>") #define DBG_ZONES_ULK_ZONE_ZONEADM ILIBSTR("unlocking zone administration: zone <%s> object <%s>") #define DBG_ZONES_UNMOUNT_FROM_LZ_ENTRY ILIBSTR("unmount non-global zone: mount point <%s>") @@ -171,16 +169,13 @@ #define ERR_ZONEREADY_DIDNT_READY ILIBSTR("unable to ready zone <%s>: zone failed to transition to ready state") #define ERR_ZONEREADY_EXEC ILIBSTR("unable to ready zone: could not execute zone administration command <%s>: %s") #define ERR_ZONEROOT_NOTDIR ILIBSTR("unable to use temporary mount point <%s> in zone <%s>: %s") -#define ERR_ZONES_LCK_THIS_PATCHADM ILIBSTR("Unable to acquire patch administration lock for this system; try again later") #define ERR_ZONES_LCK_THIS_PKGADM ILIBSTR("Unable to acquire package administration lock for this system; try again later") #define ERR_ZONES_LCK_THIS_ZONEADM ILIBSTR("Unable to acquire zone administration lock for this system; please try again later") #define ERR_ZONES_LCK_ZONES_FAILED ILIBSTR("Unable to acquire lock on non-global zone <%s>: releasing all locks") -#define ERR_ZONES_LCK_ZONE_PATCHADM ILIBSTR("Unable to acquire patch administration lock for zone <%s>; please try again later") #define ERR_ZONES_LCK_ZONE_PKGADM ILIBSTR("Unable to acquire package administration lock for zone <%s>; please try again later") #define ERR_ZONES_LCK_ZONE_ZONEADM ILIBSTR("Unable to acquire zone administration lock for zone <%s>; please try again later") #define ERR_ZONES_NOT_IMPLEMENTED ILIBSTR("error: zones not implemented") #define ERR_ZONES_ULK_THIS_PACKAGE ILIBSTR("Unable to release package administration lock for this system; try again later") -#define ERR_ZONES_ULK_THIS_PATCH ILIBSTR("Unable to release patch administration lock for this system; try again later") #define ERR_ZONES_ULK_THIS_ZONES ILIBSTR("Unable to release zone administration lock for this system; please try again later") #define ERR_ZONE_LIST_EMPTY ILIBSTR("empty zone list specified") #define ERR_ZONE_NAME_ILLEGAL ILIBSTR("illegal zone name %.*s") @@ -197,10 +192,8 @@ */ #define MSG_PROG_ERR ILIBSTR("ERROR: %s") -#define MSG_ZONES_LCK_THIS_PATCHADM ILIBSTR("## Waiting for up to <%ld> seconds for patch administration commands to become available (another user is administering patches)") #define MSG_ZONES_LCK_THIS_PKGADM ILIBSTR("## Waiting for up to <%ld> seconds for package administration commands to become available (another user is administering packages)") #define MSG_ZONES_LCK_THIS_ZONEADM ILIBSTR("## Waiting for up to <%ld> seconds for zone administration commands to become available (another user is administering zones)") -#define MSG_ZONES_LCK_ZONE_PATCHADM ILIBSTR("## Waiting for up to <%ld> seconds for patch administration commands to become available (another user is administering patches on zone <%s>)") #define MSG_ZONES_LCK_ZONE_PKGADM ILIBSTR("## Waiting for up to <%ld> seconds for package administration commands to become available (another user is administering packages on zone <%s>)") #define MSG_ZONES_LCK_ZONE_ZONEADM ILIBSTR("## Waiting for up to <%ld> seconds for zone administration commands to become available (another user is administering zones on zone <%s>)") @@ -209,7 +202,6 @@ * during the normal usage of the products */ -#define WRN_ZONES_ULK_ZONE_PATCHADM ILIBSTR("WARNING: Unable to release patch administration lock for zone <%s>") #define WRN_ZONES_ULK_ZONE_PKGADM ILIBSTR("WARNING: Unable to release package administration lock for zone <%s>") #define WRN_ZONES_ULK_ZONE_ZONEADM ILIBSTR("WARNING: Unable to release zone administration lock for zone <%s>") diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libinstzones/hdrs/instzones_api.h --- a/usr/src/lib/libinstzones/hdrs/instzones_api.h Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libinstzones/hdrs/instzones_api.h Mon Nov 15 20:03:27 2010 -0800 @@ -80,7 +80,6 @@ #define ZLOCKS_ZONE_ADMIN ((ZLOCKS_T)0x00000001) /* zone admin */ #define ZLOCKS_PKG_ADMIN ((ZLOCKS_T)0x00000002) /* package admin */ -#define ZLOCKS_PATCH_ADMIN ((ZLOCKS_T)0x00000004) /* patch admin */ #define ZLOCKS_ALL ((ZLOCKS_T)0xFFFFFFFF) /* all locks */ #define ZLOCKS_NONE ((ZLOCKS_T)0x00000000) /* no locks */ diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/Makefile.com --- a/usr/src/lib/libpkg/Makefile.com Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/Makefile.com Mon Nov 15 20:03:27 2010 -0800 @@ -34,7 +34,7 @@ gpkgmap.o isdir.o logerr.o \ mappath.o ncgrpw.o nhash.o \ pkgexecl.o pkgexecv.o pkgmount.o \ - pkgtrans.o pkgxpand.o ppkgmap.o \ + pkgtrans.o ppkgmap.o \ progerr.o putcfile.o rrmdir.o \ runcmd.o srchcfile.o tputcfent.o \ verify.o security.o pkgweb.o \ diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/ckparam.c --- a/usr/src/lib/libpkg/common/ckparam.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/ckparam.c Mon Nov 15 20:03:27 2010 -0800 @@ -162,7 +162,7 @@ too_long(char *param, char *pt, int len) { if (strlen(pt) > (size_t)len) { - progerr(pkg_gt(ERR_LEN), pt); + progerr(pkg_gt(ERR_LEN), param); return (1); } return (0); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/dstream.c --- a/usr/src/lib/libpkg/common/dstream.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/dstream.c Mon Nov 15 20:03:27 2010 -0800 @@ -42,18 +42,10 @@ #include #include #include -#ifdef u3b2 -#include -#endif /* u3b2 */ #include #include "pkglib.h" #include "pkglibmsgs.h" #include "pkglocale.h" -#ifdef u3b2 -static -struct stat orig_st_buf; /* Stat structure of original file (3B2/CTC) */ -static char ds_ctcflg; -#endif /* u3b2 */ /* libadm.a */ extern char *devattr(char *device, char *attribute); @@ -203,7 +195,7 @@ (void) ds_close(0); return (0); } - memcpy(ds_header, buf, BLK_SIZE); + (void) memcpy(ds_header, buf, BLK_SIZE); ds_headsize = BLK_SIZE; if (ds_ginit(device) < 0) { @@ -232,7 +224,7 @@ char volnos[128], tmpvol[128]; if (toc->volnos[0]) { int index, sum; - sscanf(toc->volnos, "%d %[ 0-9]", &curpartcnt, volnos); + (void) sscanf(toc->volnos, "%d %[ 0-9]", &curpartcnt, volnos); volcnt = 0; sum = curpartcnt; while (sum < toc->nparts && sscanf(volnos, "%d %[ 0-9]", @@ -254,7 +246,8 @@ ds_pkginit(void) { if (ds_toc->volnos[0]) - sscanf(ds_toc->volnos, "%d %[ 0-9]", &ds_curpartcnt, ds_volnos); + (void) sscanf(ds_toc->volnos, "%d %[ 0-9]", &ds_curpartcnt, + ds_volnos); else ds_curpartcnt = -1; } @@ -263,9 +256,9 @@ * functions to pass current package info to exec'ed program */ void -ds_putinfo(char *buf) +ds_putinfo(char *buf, size_t sz) { - (void) sprintf(buf, "%d %d %d %d %d %d %d %d %d %d %s", + (void) snprintf(buf, sz, "%d %d %d %d %d %d %d %d %d %d %s", ds_fd, ds_realfd, ds_volcnt, ds_volno, ds_totread, ds_volpart, ds_skippart, ds_bufsize, ds_toc->nparts, ds_toc->maxsiz, ds_toc->volnos); @@ -435,7 +428,7 @@ (void) ds_close(0); return (1); } - memcpy(ds_header_raw, ds_header, header_size); + (void) memcpy(ds_header_raw, ds_header, header_size); /* read datastream table of contents */ ds_head = tail = (struct dstoc *)0; @@ -454,6 +447,7 @@ (void) free(ds_header); return (-1); } + /* LINTED E_SEC_SCANF_UNBOUNDED_COPY */ if (sscanf(line, "%s %d %d %[ 0-9]", toc_pt->pkg, &toc_pt->nparts, &toc_pt->maxsiz, toc_pt->volnos) < 3) { progerr(pkg_gt(ERR_UNPACK)); @@ -476,8 +470,8 @@ (void) free(ds_header); return (-1); } - sighold(SIGINT); - sigrelse(SIGINT); + (void) sighold(SIGINT); + (void) sigrelse(SIGINT); if (!ds_head) { progerr(pkg_gt(ERR_UNPACK)); logerr(pkg_gt(MSG_EMPTY)); @@ -485,25 +479,22 @@ return (-1); } /* this could break, thanks to cpio command limit */ -#ifndef SUNOS41 - (void) sprintf(cmd, "%s -icdumD -C %d", CPIOPROC, (int)BLK_SIZE); -#else - (void) sprintf(cmd, "%s -icdum -C %d", CPIOPROC, (int)BLK_SIZE); -#endif + (void) snprintf(cmd, sizeof (cmd), "%s -icdumD -C %d", + CPIOPROC, (int)BLK_SIZE); n = 0; for (i = 0; pkg[i]; i++) { if (strcmp(pkg[i], "all") == 0) continue; if (n == 0) { - strcat(cmd, " "); + (void) strlcat(cmd, " ", CMDSIZ); n = 1; } - strlcat(cmd, pkg[i], CMDSIZ); - strlcat(cmd, "'/*' ", CMDSIZ); + (void) strlcat(cmd, pkg[i], CMDSIZ); + (void) strlcat(cmd, "'/*' ", CMDSIZ); /* extract signature too, if present. */ - strlcat(cmd, SIGNATURE_FILENAME, CMDSIZ); - strlcat(cmd, " ", CMDSIZ); + (void) strlcat(cmd, SIGNATURE_FILENAME, CMDSIZ); + (void) strlcat(cmd, " ", CMDSIZ); } /* @@ -608,13 +599,9 @@ logerr(pkg_gt(MSG_STATFS), errno); return (-1); } -#ifdef SUNOS41 - free_blocks = svfsb.f_bfree * howmany(svfsb.f_bsize, DEV_BSIZE); -#else /* !SUNOS41 */ free_blocks = (((long)svfsb.f_frsize > 0) ? - howmany(svfsb.f_frsize, DEV_BSIZE) : - howmany(svfsb.f_bsize, DEV_BSIZE)) * svfsb.f_bfree; -#endif /* SUNOS41 */ + howmany(svfsb.f_frsize, DEV_BSIZE) : + howmany(svfsb.f_bsize, DEV_BSIZE)) * svfsb.f_bfree; if ((ds_maxsiz + 50) > free_blocks) { progerr(pkg_gt(ERR_UNPACK)); logerr(pkg_gt(MSG_NOSPACE), ds_maxsiz+50, free_blocks); @@ -659,12 +646,8 @@ while (nskip--) { /* skip this one */ -#ifndef SUNOS41 - (void) sprintf(cmd, "%s -ictD -C %d > /dev/null", -#else - (void) sprintf(cmd, "%s -ict -C %d > /dev/null", -#endif - CPIOPROC, (int)BLK_SIZE); + (void) snprintf(cmd, sizeof (cmd), + "%s -ictD -C %d > /dev/null", CPIOPROC, (int)BLK_SIZE); if (n = esystem(cmd, ds_fd, -1)) { rpterr(); progerr(pkg_gt(ERR_UNPACK)); @@ -706,11 +689,7 @@ (void) strcpy(ds_volnos, tmpvol); ds_curpartcnt += index; } -#ifndef SUNOS41 - (void) sprintf(cmd, "%s -icdumD -C %d", -#else - (void) sprintf(cmd, "%s -icdum -C %d", -#endif + (void) snprintf(cmd, sizeof (cmd), "%s -icdumD -C %d", CPIOPROC, (int)BLK_SIZE); if (n = esystem(cmd, ds_fd, -1)) { rpterr(); @@ -794,7 +773,7 @@ char zeros[BLK_SIZE]; - memset(zeros, 0, BLK_SIZE); + (void) memset(zeros, 0, BLK_SIZE); if (BIO_write(bio, ds_header_raw, ds_headsize) != ds_headsize) { pkgerr_add(err, PKGERR_WRITE, ERR_WRITE, "bio", @@ -807,32 +786,12 @@ /* * ds_ginit: Determine the device being accessed, set the buffer size, - * and perform any device specific initialization. For the 3B2, - * a device with major number of 17 (0x11) is an internal hard disk, - * unless the minor number is 128 (0x80) in which case it is an internal - * floppy disk. Otherwise, get the system configuration - * table and check it by comparing slot numbers to major numbers. - * For the special case of the 3B2 CTC several unusual things must be done. - * To enable - * streaming mode on the CTC, the file descriptor must be closed, re-opened - * (with O_RDWR and O_CTSPECIAL flags set), the STREAMON ioctl(2) command - * issued, and the file descriptor re-re-opened either read-only or write_only. + * and perform any device specific initialization. */ int ds_ginit(char *device) { -#ifdef u3b2 - major_t maj; - minor_t min; - int nflag, i, count, size; - struct s3bconf *buffer; - struct s3bc *table; - struct stat st_buf; - int devtype; - char buf[BLK_SIZE]; - int fd2, fd; -#endif /* u3b2 */ int oflag; char *pbufsize, cmd[CMDSIZ]; int fd2, fd; @@ -843,104 +802,7 @@ } else ds_bufsize = BLK_SIZE; oflag = fcntl(ds_fd, F_GETFL, 0); -#ifdef u3b2 - devtype = G_NO_DEV; - if (fstat(ds_fd, &st_buf) == -1) - return (-1); - if (!S_ISCHR(st_buf.st_mode) && !S_ISBLK(st_buf.st_mode)) - goto lab; - /* - * We'll have to add a remote attribute to stat but this should - * work for now. - */ - else if (st_buf.st_dev & 0x8000) /* if remote rdev */ - goto lab; - - maj = major(st_buf.st_rdev); - min = minor(st_buf.st_rdev); - if (maj == 0x11) { /* internal hard or floppy disk */ - if (min & 0x80) - devtype = G_3B2_FD; /* internal floppy disk */ - else - devtype = G_3B2_HD; /* internal hard disk */ - } else { - if (sys3b(S3BCONF, (struct s3bconf *)&count, sizeof (count)) == - -1) - return (-1); - size = sizeof (int) + (count * sizeof (struct s3bconf)); - buffer = (struct s3bconf *)malloc((unsigned)size); - if (sys3b(S3BCONF, buffer, size) == -1) - return (-1); - table = (struct s3bc *)((char *)buffer + sizeof (int)); - for (i = 0; i < count; i++) { - if (maj == (int)table->board) { - if (strncmp(table->name, "CTC", 3) == 0) { - devtype = G_3B2_CTC; - break; - } else if (strncmp(table->name, "TAPE", 4) - == 0) { - devtype = G_TAPE; - break; - } - /* other possible devices can go here */ - } - table++; - } - } - switch (devtype) { - case G_3B2_CTC: /* do special CTC initialization */ - ds_bufsize = pbufsize ? ds_bufsize : 15872; - if (fstat(ds_fd, &orig_st_buf) < 0) { - ds_bufsize = -1; - break; - } - nflag = (O_RDWR | O_CTSPECIAL); - (void) close(ds_fd); - if ((ds_fd = open(device, nflag, 0666)) != -1) { - if (ioctl(ds_fd, STREAMON) != -1) { - (void) close(ds_fd); - nflag = (oflag == O_WRONLY) ? - O_WRONLY : O_RDONLY; - if ((ds_fd = - open(device, nflag, 0666)) == -1) { - rpterr(); - progerr( - pkg_gt(ERR_TRANSFER)); - logerr(pkg_gt(MSG_OPEN), - device, errno); - return (-1); - } - ds_bufsize = 15872; - } - } else - ds_bufsize = -1; - if (oflag == O_RDONLY && ds_header && ds_totread == 0) - /* Have already read in first block of header */ - read(ds_fd, buf, BLK_SIZE); - ds_ctcflg = 1; - - break; - case G_NO_DEV: - case G_3B2_HD: - case G_3B2_FD: - case G_TAPE: - case G_SCSI_HD: /* not developed yet */ - case G_SCSI_FD: - case G_SCSI_9T: - case G_SCSI_Q24: - case G_SCSI_Q120: - case G_386_HD: - case G_386_FD: - case G_386_Q24: - ds_bufsize = pbufsize ? ds_bufsize : BLK_SIZE; - break; - default: - ds_bufsize = -1; - errno = ENODEV; - } /* devtype */ -lab: -#endif /* u3b2 */ if (ds_bufsize > BLK_SIZE) { if (oflag & O_WRONLY) fd = 1; @@ -948,20 +810,20 @@ fd = 0; fd2 = fcntl(fd, F_DUPFD, fd); (void) close(fd); - fcntl(ds_fd, F_DUPFD, fd); + (void) fcntl(ds_fd, F_DUPFD, fd); if (fd) - sprintf(cmd, "%s obs=%d 2>/dev/null", DDPROC, - ds_bufsize); + (void) snprintf(cmd, sizeof (cmd), + "%s obs=%d 2>/dev/null", DDPROC, ds_bufsize); else - sprintf(cmd, "%s ibs=%d 2>/dev/null", DDPROC, - ds_bufsize); + (void) snprintf(cmd, sizeof (cmd), + "%s ibs=%d 2>/dev/null", DDPROC, ds_bufsize); if ((ds_pp = popen(cmd, fd ? "w" : "r")) == NULL) { progerr(pkg_gt(ERR_TRANSFER)); logerr(pkg_gt(MSG_POPEN), cmd, errno); return (-1); } (void) close(fd); - fcntl(fd2, F_DUPFD, fd); + (void) fcntl(fd2, F_DUPFD, fd); (void) close(fd2); ds_realfd = ds_fd; ds_fd = fileno(ds_pp); @@ -972,42 +834,8 @@ int ds_close(int pkgendflg) { -#ifdef u3b2 - int cnt, mode; - char *ptr; - struct stat statbuf; -#endif /* u3b2 */ int n, ret = 0; -#ifdef u3b2 - if (ds_pp && ds_ctcflg) { - ds_ctcflg = 0; - if ((mode = fcntl(ds_realfd, F_GETFL, 0)) < 0) { - ret = -1; - } else if (mode & O_WRONLY) { - /* - * pipe to dd write process, - * make sure one more buffer - * gets written out - */ - if ((ptr = calloc(BLK_SIZE, 1)) == NULL) { - ret = -1; - /* pad to bufsize */ - } else { - cnt = ds_bufsize; - while (cnt > 0) { - if ((n = write(ds_fd, ptr, - BLK_SIZE)) < 0) { - ret = -1; - break; - } - cnt -= n; - } - (void) free(ptr); - } - } - } -#endif if (pkgendflg) { if (ds_header) (void) free(ds_header); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/gpkglist.c --- a/usr/src/lib/libpkg/common/gpkglist.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/gpkglist.c Mon Nov 15 20:03:27 2010 -0800 @@ -146,8 +146,9 @@ if (!info.pkginst || !info.name || !info.arch || !info.version) continue; - (void) sprintf(temp, "%s %s\n(%s) %s", info.pkginst, - info.name, info.arch, info.version); + (void) snprintf(temp, sizeof (temp), + "%s %s\n(%s) %s", info.pkginst, + info.name, info.arch, info.version); if (setitem(menup, temp)) { errno = EFAULT; return (NULL); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/gpkgmap.c --- a/usr/src/lib/libpkg/common/gpkgmap.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/gpkgmap.c Mon Nov 15 20:03:27 2010 -0800 @@ -147,13 +147,8 @@ ept->ainfo.mode = d_mode; (void) strcpy(ept->ainfo.owner, d_owner); (void) strcpy(ept->ainfo.group, d_group); -#ifdef SUNOS41 - ept->ainfo.xmajor = BADMAJOR; - ept->ainfo.xminor = BADMINOR; -#else ept->ainfo.major = BADMAJOR; ept->ainfo.minor = BADMINOR; -#endif ept->cinfo.cksum = ept->cinfo.modtime = ept->cinfo.size = (-1L); ept->npkgs = 0; @@ -310,18 +305,10 @@ } if (strchr("cb", ept->ftype)) { -#ifdef SUNOS41 - ept->ainfo.xmajor = BADMAJOR; - ept->ainfo.xminor = BADMINOR; - if (getnum(fp, 10, (long *)&ept->ainfo.xmajor, BADMAJOR) || - getnum(fp, 10, (long *)&ept->ainfo.xminor, BADMINOR)) -#else ept->ainfo.major = BADMAJOR; ept->ainfo.minor = BADMINOR; if (getnum(fp, 10, (long *)&ept->ainfo.major, BADMAJOR) || - getnum(fp, 10, (long *)&ept->ainfo.minor, BADMINOR)) -#endif - { + getnum(fp, 10, (long *)&ept->ainfo.minor, BADMINOR)) { setErrstr(pkg_gt(ERR_CANNOT_READ_MM_DEVNUMS)); goto error; } diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/keystore.c --- a/usr/src/lib/libpkg/common/keystore.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/keystore.c Mon Nov 15 20:03:27 2010 -0800 @@ -994,7 +994,7 @@ { char currtimestr[ATTR_MAX]; time_t currtime; - char *r, *before_str, *after_str; + char *r; /* get current time */ if ((currtime = time(NULL)) == (time_t)-1) { pkgerr_add(err, PKGERR_TIME, gettext(ERR_CURR_TIME)); @@ -1942,7 +1942,7 @@ * use the one used when the keystore * was read */ - strlcpy(passbuf, keystore->passphrase, + (void) strlcpy(passbuf, keystore->passphrase, KEYSTORE_PASS_MAX); } @@ -1984,7 +1984,7 @@ } } else { /* use the one used when the keystore was read */ - strlcpy(passbuf, keystore->passphrase, + (void) strlcpy(passbuf, keystore->passphrase, KEYSTORE_PASS_MAX); } diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/logerr.c --- a/usr/src/lib/libpkg/common/logerr.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/logerr.c Mon Nov 15 20:03:27 2010 -0800 @@ -34,7 +34,7 @@ #include #include "pkglocale.h" -/*VARARGS*/ +/*PRINTFLIKE1*/ void logerr(char *fmt, ...) { @@ -59,7 +59,7 @@ * this routine be in the same internationalization domain * as this library. */ - (void) vsprintf(buffer, fmt, ap); + (void) vsnprintf(buffer, sizeof (buffer), fmt, ap); va_end(ap); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/mapfile-vers --- a/usr/src/lib/libpkg/common/mapfile-vers Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/mapfile-vers Mon Nov 15 20:03:27 2010 -0800 @@ -132,14 +132,12 @@ open_keystore; path_valid; pkg_passphrase_cb; - pkgalias; pkgclosefilter; pkgcloseserver; pkgcmd; pkgerr; pkgerr_add; pkgerr_clear; - pkgerr_dump; pkgerr_free; pkgerr_get; pkgerr_new; diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/ncgrpw.c --- a/usr/src/lib/libpkg/common/ncgrpw.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/ncgrpw.c Mon Nov 15 20:03:27 2010 -0800 @@ -595,15 +595,16 @@ struct group *gr; char *instroot, *buf; FILE *gr_ptr; + size_t bufsz; if ((instroot = get_install_root()) != NULL) { - if ((buf = (char *)malloc(strlen(instroot) + - strlen(GROUP) + 1)) == NULL) { + bufsz = strlen(instroot) + strlen(GROUP) + 1; + if ((buf = (char *)malloc(bufsz)) == NULL) { (void) fprintf(stderr, - pkg_gt(ERR_MALLOC), "clgrnam()", - strlen(instroot) + strlen(GROUP), "buf"); + pkg_gt(ERR_MALLOC), "clgrnam()", + strlen(instroot) + strlen(GROUP), "buf"); } - (void) sprintf(buf, "%s%s", instroot, GROUP); + (void) snprintf(buf, bufsz, "%s%s", instroot, GROUP); if ((gr_ptr = fopen(buf, "r")) == NULL) { free(buf); return (NULL); @@ -636,13 +637,12 @@ FILE *pw_ptr; if ((instroot = get_install_root()) != NULL) { - if ((buf = (char *)malloc(strlen(instroot) + - strlen(PASSWD) + 1)) == NULL) { + if (asprintf(&buf, "%s%s", instroot, PASSWD) < 0) { (void) fprintf(stderr, - pkg_gt(ERR_MALLOC), "clpwnam()", - strlen(instroot) + strlen(PASSWD), "buf"); + pkg_gt(ERR_MALLOC), "clpwnam()", + strlen(instroot) + strlen(PASSWD), "buf"); + return (NULL); } - (void) sprintf(buf, "%s%s", instroot, PASSWD); if ((pw_ptr = fopen(buf, "r")) == NULL) { free(buf); return (NULL); @@ -675,13 +675,13 @@ FILE *gr_ptr; if ((instroot = get_install_root()) != NULL) { - if ((buf = (char *)malloc(strlen(instroot) + - strlen(GROUP) + 1)) == NULL) { + if (asprintf(&buf, "%s%s", instroot, GROUP) < 0) { (void) fprintf(stderr, - pkg_gt(ERR_MALLOC), "clgrgid()", - strlen(instroot) + strlen(GROUP), "buf"); + pkg_gt(ERR_MALLOC), "clgrgid()", + strlen(instroot) + strlen(GROUP), "buf"); + return (NULL); } - (void) sprintf(buf, "%s%s", instroot, GROUP); + if ((gr_ptr = fopen(buf, "r")) == NULL) { free(buf); return (NULL); @@ -714,13 +714,11 @@ FILE *pw_ptr; if ((instroot = get_install_root()) != NULL) { - if ((buf = (char *)malloc(strlen(instroot) + - strlen(PASSWD) + 1)) == NULL) { - (void) fprintf(stderr, - pkg_gt(ERR_MALLOC), "clpwuid()", - strlen(instroot) + strlen(PASSWD), "buf"); + if (asprintf(&buf, "%s%s", instroot, PASSWD) < 0) { + (void) fprintf(stderr, pkg_gt(ERR_MALLOC), "clpwuid()", + strlen(instroot) + strlen(PASSWD), "buf"); + return (NULL); } - (void) sprintf(buf, "%s%s", instroot, PASSWD); if ((pw_ptr = fopen(buf, "r")) == NULL) { free(buf); return (NULL); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/pkgerr.c --- a/usr/src/lib/libpkg/common/pkgerr.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/pkgerr.c Mon Nov 15 20:03:27 2010 -0800 @@ -64,6 +64,7 @@ return (newerr); } +/*PRINTFLIKE3*/ void pkgerr_add(PKG_ERR *err, PKG_ERR_CODE code, char *fmt, ...) { @@ -101,17 +102,6 @@ } int -pkgerr_dump(PKG_ERR *err, FILE *fp) -{ - int i; - - for (i = 0; i < err->nerrs; i++) { - (void) fprintf(fp, err->msgs[i]); - } - return (0); -} - -int pkgerr_num(PKG_ERR *err) { return (err->nerrs); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/pkgexecv.c --- a/usr/src/lib/libpkg/common/pkgexecv.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/pkgexecv.c Mon Nov 15 20:03:27 2010 -0800 @@ -40,6 +40,7 @@ #include #include #include +#include #include "pkglib.h" #include "pkglibmsgs.h" #include "pkglocale.h" @@ -70,6 +71,7 @@ static void sig_trap(int a_signo) { + _NOTE(ARGUNUSED(a_signo)); sig_received++; } @@ -252,7 +254,7 @@ for (;;) { status = 0; - waitstat = waitpid(pid, (int *)&status, 0); + waitstat = waitpid(pid, &status, 0); if (waitstat < 0) { /* waitpid returned error */ if (errno == EAGAIN) { @@ -293,8 +295,8 @@ /* error if child process does not match */ if (waitstat != pid) { - progerr(pkg_gt(ERR_WAIT_FAILED), pid, waitstat, status, - errno, strerror(errno)); + progerr(pkg_gt(ERR_WAIT_FAILED), pid, status, + errno, strerror(errno)); return (-1); } diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/pkglib.h --- a/usr/src/lib/libpkg/common/pkglib.h Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/pkglib.h Mon Nov 15 20:03:27 2010 -0800 @@ -403,8 +403,6 @@ #define streq(a, b) (strcmp((a), (b)) == 0) #define strneq(a, b, c) (strncmp((a), (b), (c)) == 0) -#ifdef __STDC__ - extern FILE *epopen(char *cmd, char *mode); extern char **gpkglist(char *dir, char **pkg, char **catg); extern int is_not_valid_length(char **category); @@ -496,7 +494,7 @@ extern void checksum_on(void); extern void cvtpath(char *path, char *copy); extern void ds_order(char *list[]); -extern void ds_putinfo(char *buf); +extern void ds_putinfo(char *buf, size_t); extern void ds_skiptoend(char *device); extern void ecleanup(void); /*PRINTFLIKE1*/ @@ -587,104 +585,6 @@ extern start_mode_t pkgparsemode(const char *); extern char *pkgmodeargument(start_mode_t); - -#else /* __STDC__ */ - -extern FILE *epopen(); -extern void pkglist_cont(); -extern char **gpkglist(); -extern char **pkgalias(); -extern char *get_prog_name(); -extern char *set_prog_name(); -extern int averify(); -extern int ckparam(); -extern int ckvolseq(); -extern int cverify(); -extern unsigned long compute_checksum(); -extern int fverify(); -extern char *getErrbufAddr(); -extern int getErrbufSize(); -extern char *getErrstr(); -extern void setErrstr(); -extern int devtype(); -extern int ds_close(); -extern int ds_findpkg(); -extern int ds_getinfo(); -extern int ds_getpkg(); -extern int ds_ginit(); -extern boolean_t ds_fd_open(); -extern int ds_init(); -extern int ds_next(); -extern int ds_readbuf(); -extern int epclose(); -extern int esystem(); -extern int e_ExecCmdArray(); -extern int e_ExecCmdList(); -extern int gpkgmap(); -extern int isFdRemote(); -extern int isFstypeRemote(); -extern int isPathRemote(); -extern int iscpio(); -extern int isdir(); -extern int isfile(); -extern int pkgexecl(); -extern int pkgexecv(); -extern int pkghead(); -extern int pkgmount(); -extern int pkgtrans(); -extern int pkgumount(); -extern int ppkgmap(); -extern int putcfile(); -extern int putcvfpfile(); -extern int rrmdir(); -extern int srchcfile(); -extern struct group *cgrgid(); -extern struct group *cgrnam(); -extern struct passwd *cpwnam(); -extern struct passwd *cpwuid(); -extern void basepath(); -extern void canonize(); -extern void canonize_slashes(); -extern void checksum_off(); -extern void checksum_on(); -extern void cvtpath(); -extern void ds_order(); -extern void ds_putinfo(); -extern void ds_skiptoend(); -extern void ecleanup(); -extern void logerr(); -extern int mappath(); -extern int mapvar(); -extern void progerr(); -extern void rpterr(); -extern void tputcfent(); -extern void set_nonABI_symlinks(); -extern int nonABI_symlinks(); -extern void disable_attribute_check(); -extern int get_disable_attribute_check(); -/* vfpops.c */ -extern int vfpCheckpointFile(); -extern int vfpCheckpointOpen(); -extern int vfpClearModified(); -extern int vfpClose(); -extern int vfpGetModified(); -extern int vfpOpen(); -extern void vfpRewind(); -extern int vfpSetFlags(); -extern int vfpSetModified(); -extern int vfpSetSize(); -extern void vfpTruncate(); -extern int vfpWriteToFile(); - -/* handlelocalfs.c */ -boolean_t enable_local_fs(); -boolean_t restore_local_fs(); - -/* gpkgmap.c */ -int getmapmode(void); - -#endif /* __STDC__ */ - #ifdef __cplusplus } #endif diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/pkglibmsgs.h --- a/usr/src/lib/libpkg/common/pkglibmsgs.h Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/pkglibmsgs.h Mon Nov 15 20:03:27 2010 -0800 @@ -209,7 +209,7 @@ #define MSG_KEYSTORE_UNKNOWN "Unknown" /* parameter errors */ -#define ERR_LEN "length of parameter value <%s> exceeds limit" +#define ERR_LEN "length of parameter <%s> value exceeds limit" #define ERR_ASCII "parameter <%s> must be ascii" #define ERR_ALNUM "parameter <%s> must be alphanumeric" #define ERR_CHAR "parameter <%s> has incorrect first character" @@ -235,7 +235,8 @@ #define MSG_PKGNAME "- invalid package name in datastream table-of-contents" #define MSG_NOPKG "- package <%s> not in datastream" #define MSG_STATFS "- unable to stat filesystem, errno=%d" -#define MSG_NOSPACE "- not enough space, %d blocks required, %d available" +#define MSG_NOSPACE "- not enough space, %ld blocks required, "\ + "%lld available" /* pkglist errors */ #define ERR_MEMORY "memory allocation failure, errno=%d" @@ -271,7 +272,7 @@ #define LABEL3 "Insert %%v into %%p." /* package verify errors */ -#define MSG_WLDDEVNO "NOTE: <%s> created as device (%d, %d)." +#define MSG_WLDDEVNO "NOTE: <%s> created as device (%ld, %ld)." #define WRN_QV_SIZE "WARNING: quick verify of <%s>; wrong size." #define WRN_QV_MTIME "WARNING: quick verify of <%s>; wrong mod time." @@ -288,8 +289,9 @@ #define ERR_CKSUM "file cksum <%ld> expected <%ld> actual" #define ERR_NO_CKSUM "unable to checksum, may need to re-run command as " \ "user \"root\"" -#define ERR_MAJMIN "major/minor device <%d, %d> expected <%d, %d> actual" -#define ERR_PERM "permissions <%04o> expected <%04o> actual" +#define ERR_MAJMIN "major/minor device <%ld, %ld> " \ + "expected <%ld, %ld> actual" +#define ERR_PERM "permissions <%04lo> expected <%04lo> actual" #define ERR_GROUP "group name <%s> expected <%s> actual" #define ERR_OWNER "owner name <%s> expected <%s> actual" #define ERR_MODFAIL "unable to fix modification time" @@ -325,8 +327,8 @@ #define ERR_TOO_MANY_ARGS "too many arguments passed to pkgexecl " \ "for command <%s>" -#define ERR_WAIT_FAILED "wait for process %ld failed, pid <%ld> status " \ - "<0x%08lx> errno <%d> (%s)" +#define ERR_WAIT_FAILED "wait for process %ld failed, status " \ + "<0x%08x> errno <%d> (%s)" #define ERR_FORK_FAILED "fork() failed errno=%d (%s)" #define ERR_FREOPEN "freopen(%s, \"%s\", %s) failed, errno=%d (%s)" #define ERR_FDOPEN "fdopen(%d, \"%s\") failed, errno=%d (%s)" diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/pkgmount.c --- a/usr/src/lib/libpkg/common/pkgmount.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/pkgmount.c Mon Nov 15 20:03:27 2010 -0800 @@ -43,7 +43,6 @@ #include "pkglibmsgs.h" #include "pkglocale.h" -extern void quit(int retcode); /* Expected to be declared by caller! */ /* libadm.a */ extern int getvol(char *device, char *label, int options, char *prompt); @@ -63,16 +62,16 @@ if (part && nparts) { if (pkg) { - (void) sprintf(prompt, pkg_gt(LABEL0), part, - nparts, pkg); + (void) snprintf(prompt, sizeof (prompt), + pkg_gt(LABEL0), part, nparts, pkg); } else { - (void) sprintf(prompt, pkg_gt(LABEL1), part, - nparts); + (void) snprintf(prompt, sizeof (prompt), + pkg_gt(LABEL1), part, nparts); } } else if (pkg) - (void) sprintf(prompt, pkg_gt(LABEL2), pkg); + (void) snprintf(prompt, sizeof (prompt), pkg_gt(LABEL2), pkg); else - (void) sprintf(prompt, pkg_gt(LABEL3)); + (void) snprintf(prompt, sizeof (prompt), pkg_gt(LABEL3)); n = 0; for (;;) { @@ -96,7 +95,8 @@ } if (devp->fstyp == NULL) { - (void) sprintf(cmd, "%s %s", FSTYP, devp->bdevice); + (void) snprintf(cmd, sizeof (cmd), + "%s %s", FSTYP, devp->bdevice); if ((pp = epopen(cmd, "r")) == NULL) { rpterr(); logerr(pkg_gt(ERR_FSTYP), devp->bdevice); @@ -158,7 +158,7 @@ if (n != 0) { progerr(pkg_gt("retrying umount of %s"), devp->bdevice); - sleep(5); + (void) sleep(5); } } if (n == 0) diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/pkgserv.c --- a/usr/src/lib/libpkg/common/pkgserv.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/pkgserv.c Mon Nov 15 20:03:27 2010 -0800 @@ -358,7 +358,7 @@ assert(args <= sizeof (cmd)/sizeof (char *)); if (posix_spawn(&pid, PKGSERV_PATH, NULL, NULL, cmd, environ) == 0) { - server->onetime |= mode == RUN_ONCE; + server->onetime |= (mode == RUN_ONCE); while (wait4(pid, &stat, 0, NULL) != -1) { if (WIFEXITED(stat)) { int s = WEXITSTATUS(stat); @@ -434,6 +434,7 @@ } progerr(gettext("Bad pkgserv mode: %d"), (int)mode); exit(99); + /*NOTREACHED*/ } void diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/pkgtrans.c --- a/usr/src/lib/libpkg/common/pkgtrans.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/pkgtrans.c Mon Nov 15 20:03:27 2010 -0800 @@ -51,6 +51,7 @@ #include #include #include +#include #include "pkginfo.h" #include "pkgstrct.h" #include "pkgtrans.h" @@ -114,7 +115,7 @@ static int pkgxfer(char *srcinst, int options); static int wdsheader(struct dm_buf *, char *src, char *device, char **pkg, PKCS7 *); -static struct dm_buf *genheader(char *, char *, char **); +static struct dm_buf *genheader(char *, char **); static int dump_hdr_and_pkgs(BIO *, struct dm_buf *, char **); @@ -286,7 +287,7 @@ /* initialize PKCS7 object to be filled in later */ sec_pkcs7 = PKCS7_new(); - PKCS7_set_type(sec_pkcs7, NID_pkcs7_signed); + (void) PKCS7_set_type(sec_pkcs7, NID_pkcs7_signed); sec_signerinfo = PKCS7_add_signature(sec_pkcs7, pubcert, privkey, EVP_sha1()); @@ -298,7 +299,7 @@ } /* add signer cert into signature */ - PKCS7_add_certificate(sec_pkcs7, pubcert); + (void) PKCS7_add_certificate(sec_pkcs7, pubcert); /* attempt to resolve cert chain starting at the signer cert */ if (get_cert_chain(err, pubcert, clcerts, cacerts, @@ -314,7 +315,7 @@ * since it's baked in already, so skip it */ for (i = 1; i < sk_X509_num(sec_chain); i++) { - PKCS7_add_certificate(sec_pkcs7, + (void) PKCS7_add_certificate(sec_pkcs7, sk_X509_value(sec_chain, i)); } @@ -526,14 +527,14 @@ logerr(pkg_gt(MSG_GETVOL)); return (1); } - if ((hdr = genheader(src, ods_name, pkg)) == NULL) { + if ((hdr = genheader(src, pkg)) == NULL) { cleanup(); return (1); } if (making_sig) { /* start up signature data stream */ - PKCS7_content_new(sec_pkcs7, NID_pkcs7_data); - PKCS7_set_detached(sec_pkcs7, 1); + (void) PKCS7_content_new(sec_pkcs7, NID_pkcs7_data); + (void) PKCS7_set_detached(sec_pkcs7, 1); p7_bio = PKCS7_dataInit(sec_pkcs7, NULL); /* @@ -568,7 +569,7 @@ return (1); } - BIO_free(p7_bio); + (void) BIO_free(p7_bio); } /* write out header to stream, which includes signature */ @@ -767,13 +768,14 @@ } static struct dm_buf * -genheader(char *src, char *device, char **pkg) +genheader(char *src, char **pkg) { FILE *fp; char path[MAXPATHLEN], tmp_entry[ENTRY_MAX]; int i, n, nparts, maxpsize; - int partcnt, totsize; + int partcnt; + long totsize; struct stat statbuf; if ((hdrbuf.text_buffer = (char *)malloc(BLK_SIZE)) == NULL) { @@ -841,7 +843,8 @@ if (dstdev.capacity && maxpsize > dstdev.capacity) { progerr(pkg_gt(ERR_TRANSFER)); - logerr(pkg_gt(MSG_NOSPACE)); + logerr(pkg_gt(MSG_NOSPACE), (long)maxpsize, + dstdev.capacity); (void) fclose(fp); ecleanup(); return (NULL); @@ -867,15 +870,6 @@ totsize += nparts * maxpsize; if (dstdev.capacity && dstdev.capacity < totsize) { int lastpartcnt = 0; -#if 0 - if (i != 0) { - progerr(pkg_gt(ERR_TRANSFER)); - logerr(pkg_gt(MSG_NOSPACE)); - (void) fclose(fp); - ecleanup(); - return (NULL); - } -#endif /* 0 */ if (totsize) totsize -= nparts * maxpsize; @@ -969,7 +963,7 @@ */ for (block_cnt = 0; block_cnt < hdr->allocation; block_cnt += BLK_SIZE) { - write(ds_fd, (hdr->text_buffer + block_cnt), BLK_SIZE); + (void) write(ds_fd, (hdr->text_buffer + block_cnt), BLK_SIZE); } /* @@ -978,9 +972,9 @@ * for all packages */ (void) tmpnam(tmp_file); /* temporary file name */ - if ((list_fd = open(tmp_file, O_RDWR | O_CREAT)) == -1) { + if ((list_fd = open(tmp_file, O_RDWR | O_CREAT, 0644)) == -1) { progerr(pkg_gt(ERR_TRANSFER)); - logerr(pkg_gt(MSG_NOTMPFIL)); + logerr(pkg_gt(MSG_NOTMPFIL), tmp_file); return (1); } @@ -1004,7 +998,7 @@ if (write(list_fd, tmp_entry, entry_size) != entry_size) { progerr(pkg_gt(ERR_TRANSFER)); - logerr(pkg_gt(MSG_NOTMPFIL)); + logerr(pkg_gt(MSG_NOTMPFIL), tmp_file); (void) close(list_fd); ecleanup(); return (1); @@ -1045,20 +1039,22 @@ cleanup(); return (1); } - PEM_write_PKCS7(fp, sig); + (void) PEM_write_PKCS7(fp, sig); (void) fclose(fp); for (i = 0; pkg[i]; i++) { - sprintf(path, "%s/%s", tmpsymdir, pkg[i]); + (void) snprintf(path, sizeof (path), + "%s/%s", tmpsymdir, pkg[i]); if (mkdir(path, 0755)) { progerr(pkg_gt(ERR_TRANSFER)); logerr(pkg_gt(MSG_MKDIR), path); cleanup(); return (1); } - sprintf(path, "%s/%s/%s", tmpsymdir, - pkg[i], PKGINFO); - sprintf(srcpath, "%s/%s/%s", src, pkg[i], PKGINFO); + (void) snprintf(path, sizeof (path), + "%s/%s/%s", tmpsymdir, pkg[i], PKGINFO); + (void) snprintf(srcpath, sizeof (srcpath), + "%s/%s/%s", src, pkg[i], PKGINFO); if (symlink(srcpath, path) != 0) { progerr(pkg_gt(ERR_TRANSFER)); logerr(pkg_gt(MSG_SYMLINK), path, srcpath); @@ -1066,9 +1062,10 @@ return (1); } - sprintf(path, "%s/%s/%s", tmpsymdir, - pkg[i], PKGMAP); - sprintf(srcpath, "%s/%s/%s", src, pkg[i], PKGMAP); + (void) snprintf(path, sizeof (path), + "%s/%s/%s", tmpsymdir, pkg[i], PKGMAP); + (void) snprintf(srcpath, sizeof (srcpath), + "%s/%s/%s", src, pkg[i], PKGMAP); if (symlink(srcpath, path) != 0) { progerr(pkg_gt(ERR_TRANSFER)); logerr(pkg_gt(MSG_SYMLINK), path, srcpath); @@ -1081,14 +1078,14 @@ * temporary string allowing for the first line * as a special case. */ - entry_size = sprintf(tmp_entry, + entry_size = snprintf(tmp_entry, sizeof (tmp_entry), (i == 0) ? "%s/%s\n%s/%s" : "\n%s/%s\n%s/%s", pkg[i], PKGINFO, pkg[i], PKGMAP); if (write(list_fd, tmp_entry, entry_size) != entry_size) { progerr(pkg_gt(ERR_TRANSFER)); - logerr(pkg_gt(MSG_NOTMPFIL)); + logerr(pkg_gt(MSG_NOTMPFIL), tmp_file); (void) close(list_fd); ecleanup(); cleanup(); @@ -1097,7 +1094,8 @@ } /* add signature to list of files */ - entry_size = sprintf(tmp_entry, "\n%s", SIGNATURE_FILENAME); + entry_size = snprintf(tmp_entry, sizeof (tmp_entry), "\n%s", + SIGNATURE_FILENAME); if (write(list_fd, tmp_entry, entry_size) != entry_size) { progerr(pkg_gt(ERR_TRANSFER)); logerr(pkg_gt(MSG_NOTMPFIL), tmp_file); @@ -1111,26 +1109,16 @@ (void) lseek(list_fd, 0, SEEK_SET); if (!making_sig) { -#ifndef SUNOS41 - (void) sprintf(tmp_entry, "%s -ocD -C %d", - CPIOPROC, (int)BLK_SIZE); -#else - (void) sprintf(tmp_entry, "%s -oc -C %d", - CPIOPROC, (int)BLK_SIZE); -#endif + (void) snprintf(tmp_entry, sizeof (tmp_entry), + "%s -ocD -C %d", CPIOPROC, (int)BLK_SIZE); } else { /* * when making a signature, we must make sure to follow * symlinks during the cpio so that we don't archive * the links themselves */ -#ifndef SUNOS41 - (void) sprintf(tmp_entry, "%s -ocDL -C %d", - CPIOPROC, (int)BLK_SIZE); -#else - (void) sprintf(tmp_entry, "%s -ocL -C %d", - CPIOPROC, (int)BLK_SIZE); -#endif + (void) snprintf(tmp_entry, sizeof (tmp_entry), + "%s -ocDL -C %d", CPIOPROC, (int)BLK_SIZE); } if (making_sig) { @@ -1180,7 +1168,7 @@ { char path[PATH_MAX]; - (void) sprintf(path, "%s/%s", dir, inst); + (void) snprintf(path, sizeof (path), "%s/%s", dir, inst); if (access(path, 0) == 0) { if (options & PT_OVERWRITE) return (rrmdir(path)); @@ -1223,11 +1211,12 @@ if (!(options & PT_SILENT)) (void) fprintf(stderr, pkg_gt(MSG_TRANSFER), srcinst); - (void) strcpy(dstinst, srcinst); + (void) strlcpy(dstinst, srcinst, sizeof (dstinst)); if (!(options & PT_ODTSTREAM)) { /* destination is a (possibly mounted) directory */ - (void) sprintf(dstdir, "%s/%s", dst, dstinst); + (void) snprintf(dstdir, sizeof (dstdir), + "%s/%s", dst, dstinst); /* * need to check destination directory to assure @@ -1244,10 +1233,10 @@ } pkgdir = dst; - (void) strcpy(temp, srcinst); + (void) strlcpy(temp, srcinst, sizeof (temp)); if (pt = strchr(temp, '.')) *pt = '\0'; - (void) strcat(temp, ".*"); + (void) strlcat(temp, ".*", sizeof (temp)); if (pt = fpkginst(temp, info.arch, info.version)) { /* @@ -1255,8 +1244,9 @@ * its pkgid might be different */ if (options & PT_OVERWRITE) { - (void) strcpy(dstinst, pt); - (void) sprintf(dstdir, "%s/%s", dst, dstinst); + (void) strlcpy(dstinst, pt, sizeof (dstinst)); + (void) snprintf(dstdir, sizeof (dstdir), + "%s/%s", dst, dstinst); } else { progerr(pkg_gt(ERR_TRANSFER)); logerr(pkg_gt(MSG_DUPVERS), srcinst); @@ -1273,8 +1263,10 @@ if (pt = strchr(temp, '.')) *pt = '\0'; for (i = 2; (access(dstdir, 0) == 0); i++) { - (void) sprintf(dstinst, "%s.%d", temp, i); - (void) sprintf(dstdir, "%s/%s", dst, dstinst); + (void) snprintf(dstinst, sizeof (dstinst), + "%s.%d", temp, i); + (void) snprintf(dstdir, sizeof (dstdir), + "%s/%s", dst, dstinst); } } else if (options & PT_OVERWRITE) { /* @@ -1300,7 +1292,8 @@ return (1); } - (void) sprintf(srcdir, "%s/%s", src, srcinst); + (void) snprintf(srcdir, sizeof (srcdir), + "%s/%s", src, srcinst); if (stat(srcdir, &srcstat) != -1) { if (chmod(dstdir, (srcstat.st_mode & S_IAMB)) == -1) { progerr(pkg_gt(ERR_TRANSFER)); @@ -1317,7 +1310,7 @@ if (!(options & PT_SILENT) && strcmp(dstinst, srcinst)) (void) fprintf(stderr, pkg_gt(MSG_RENAME), dstinst); - (void) sprintf(srcdir, "%s/%s", src, srcinst); + (void) snprintf(srcdir, sizeof (srcdir), "%s/%s", src, srcinst); if (chdir(srcdir)) { progerr(pkg_gt(ERR_TRANSFER)); logerr(pkg_gt(MSG_CHDIR), srcdir); @@ -1328,7 +1321,8 @@ /* * transfer pkginfo & pkgmap first */ - (void) sprintf(cmd, "%s -pudm %s", CPIOPROC, dstdir); + (void) snprintf(cmd, sizeof (cmd), + "%s -pudm %s", CPIOPROC, dstdir); if ((pp = epopen(cmd, "w")) == NULL) { rpterr(); progerr(pkg_gt(ERR_TRANSFER)); @@ -1337,11 +1331,11 @@ } (void) fprintf(pp, "%s\n%s\n", PKGINFO, PKGMAP); - sighold(SIGINT); - sighold(SIGHUP); + (void) sighold(SIGINT); + (void) sighold(SIGHUP); r = epclose(pp); - sigrelse(SIGINT); - sigrelse(SIGHUP); + (void) sigrelse(SIGINT); + (void) sigrelse(SIGHUP); if (r != 0) { rpterr(); @@ -1415,11 +1409,11 @@ } (void) fprintf(pp, "pkginfo"); - sighold(SIGINT); - sighold(SIGHUP); + (void) sighold(SIGINT); + (void) sighold(SIGHUP); r = epclose(pp); - sigrelse(SIGINT); - sigrelse(SIGHUP); + (void) sigrelse(SIGINT); + (void) sigrelse(SIGHUP); if (r != 0) { rpterr(); @@ -1467,10 +1461,12 @@ char line[128]; (void) mgets(line, 128); curpartcnt = -1; - if (sscanf(line, "%s %d %d %[ 0-9]", &pkgname, &nparts, + /* LINTED E_SEC_SCANF_UNBOUNDED_COPY */ + if (sscanf(line, "%s %d %d %[ 0-9]", pkgname, &nparts, &maxpartsize, volnos) == 4) { - sscanf(volnos, "%d %[ 0-9]", &curpartcnt, tmpvol); - strcpy(volnos, tmpvol); + (void) sscanf(volnos, + "%d %[ 0-9]", &curpartcnt, tmpvol); + (void) strlcpy(volnos, tmpvol, sizeof (volnos)); } } @@ -1500,7 +1496,7 @@ } (void) sscanf(volnos, "%d %[ 0-9]", &index, tmpvol); - (void) strcpy(volnos, tmpvol); + (void) strlcpy(volnos, tmpvol, sizeof (volnos)); curpartcnt += index; } @@ -1508,59 +1504,61 @@ nparts = 0; if (part == 1) { - (void) sprintf(cmd, "find %s %s", PKGINFO, PKGMAP); + (void) snprintf(cmd, sizeof (cmd), + "find %s %s", PKGINFO, PKGMAP); if (nparts && (isdir(INSTALL) == 0)) { - (void) strcat(cmd, " "); - (void) strcat(cmd, INSTALL); + (void) strlcat(cmd, " ", sizeof (cmd)); + (void) strlcat(cmd, INSTALL, sizeof (cmd)); } } else - (void) sprintf(cmd, "find %s", PKGINFO); + (void) snprintf(cmd, sizeof (cmd), "find %s", PKGINFO); if (nparts > 1) { - (void) sprintf(temp, "%s.%d", RELOC, part); + (void) snprintf(temp, sizeof (temp), + "%s.%d", RELOC, part); if (iscpio(temp, &iscomp) || isdir(temp) == 0) { - (void) strcat(cmd, " "); - (void) strcat(cmd, temp); + (void) strlcat(cmd, " ", sizeof (cmd)); + (void) strlcat(cmd, temp, sizeof (cmd)); } - (void) sprintf(temp, "%s.%d", ROOT, part); + (void) snprintf(temp, sizeof (temp), + "%s.%d", ROOT, part); if (iscpio(temp, &iscomp) || isdir(temp) == 0) { - (void) strcat(cmd, " "); - (void) strcat(cmd, temp); + (void) strlcat(cmd, " ", sizeof (cmd)); + (void) strlcat(cmd, temp, sizeof (cmd)); } - (void) sprintf(temp, "%s.%d", ARCHIVE, part); + (void) snprintf(temp, sizeof (temp), + "%s.%d", ARCHIVE, part); if (isdir(temp) == 0) { - (void) strcat(cmd, " "); - (void) strcat(cmd, temp); + (void) strlcat(cmd, " ", sizeof (cmd)); + (void) strlcat(cmd, temp, sizeof (cmd)); } } else if (nparts) { for (i = 0; reloc_names[i] != NULL; i++) { if (iscpio(reloc_names[i], &iscomp) || isdir(reloc_names[i]) == 0) { - (void) strcat(cmd, " "); - (void) strcat(cmd, reloc_names[i]); + (void) strlcat(cmd, " ", sizeof (cmd)); + (void) strlcat(cmd, reloc_names[i], + sizeof (cmd)); } } for (i = 0; root_names[i] != NULL; i++) { if (iscpio(root_names[i], &iscomp) || isdir(root_names[i]) == 0) { - (void) strcat(cmd, " "); - (void) strcat(cmd, root_names[i]); + (void) strlcat(cmd, " ", sizeof (cmd)); + (void) strlcat(cmd, root_names[i], + sizeof (cmd)); } } if (isdir(ARCHIVE) == 0) { - (void) strcat(cmd, " "); - (void) strcat(cmd, ARCHIVE); + (void) strlcat(cmd, " ", sizeof (cmd)); + (void) strlcat(cmd, ARCHIVE, sizeof (cmd)); } } if (options & PT_ODTSTREAM) { -#ifndef SUNOS41 - (void) sprintf(cmd+strlen(cmd), + (void) snprintf(cmd + strlen(cmd), + sizeof (cmd) - strlen(cmd), " -print | %s -ocD -C %d", -#else - (void) sprintf(cmd+strlen(cmd), - " -print | %s -oc -C %d", -#endif - CPIOPROC, (int)BLK_SIZE); + CPIOPROC, (int)BLK_SIZE); } else { if (statvfs64(dstdir, &svfsb) == -1) { progerr(pkg_gt(ERR_TRANSFER)); @@ -1575,11 +1573,16 @@ if ((has_comp_size ? compressedsize : maxpartsize) > free_blocks) { progerr(pkg_gt(ERR_TRANSFER)); - logerr(pkg_gt(MSG_NOSPACE)); + logerr(pkg_gt(MSG_NOSPACE), + has_comp_size ? + (long)compressedsize : (long)maxpartsize, + free_blocks); return (1); } - (void) sprintf(cmd+strlen(cmd), " -print | %s -pdum %s", - CPIOPROC, dstdir); + (void) snprintf(cmd + strlen(cmd), + sizeof (cmd) - strlen(cmd), + " -print | %s -pdum %s", + CPIOPROC, dstdir); } n = esystem(cmd, -1, (options & PT_ODTSTREAM) ? ds_fd : -1); @@ -1604,14 +1607,14 @@ return (n); if (chdir(srcdir)) { progerr(pkg_gt(ERR_TRANSFER)); - logerr(pkg_gt(MSG_CORRUPT), srcdir); + logerr(pkg_gt(MSG_CORRUPT)); (void) chdir("/"); - pkgumount(&srcdev); + (void) pkgumount(&srcdev); continue; } if (ckvolseq(srcdir, part, nparts)) { (void) chdir("/"); - pkgumount(&srcdev); + (void) pkgumount(&srcdev); continue; } break; @@ -1667,7 +1670,7 @@ (void) sscanf(volnos, "%d %[ 0-9]", &index, tmpvol); - (void) strcpy(volnos, tmpvol); + (void) strlcpy(volnos, tmpvol, sizeof (volnos)); curpartcnt += index; } } @@ -1738,8 +1741,8 @@ (void) snprintf(cmd, CMDSIZE, "find %s %s", PKGINFO, PKGMAP); if (nparts && (isdir(INSTALL) == 0)) { - (void) strcat(cmd, " "); - (void) strcat(cmd, INSTALL); + (void) strlcat(cmd, " ", sizeof (cmd)); + (void) strlcat(cmd, INSTALL, sizeof (cmd)); } } else (void) snprintf(cmd, CMDSIZE, "find %s", PKGINFO); @@ -1784,14 +1787,10 @@ } } -#ifndef SUNOS41 - (void) sprintf(cmd+strlen(cmd), + (void) snprintf(cmd + strlen(cmd), + sizeof (cmd) - strlen(cmd), " -print | %s -ocD -C %d", -#else - (void) sprintf(cmd+strlen(cmd), - " -print | %s -oc -C %d", -#endif - CPIOPROC, (int)BLK_SIZE); + CPIOPROC, (int)BLK_SIZE); /* * execute the command, dumping all standard output * to the BIO. @@ -1812,37 +1811,38 @@ static void sigtrap(int signo) { + _NOTE(ARGUNUSED(signo)); signal_received++; } static void cleanup(void) { - chdir("/"); + (void) chdir("/"); if (tmpdir) { - rrmdir(tmpdir); + (void) rrmdir(tmpdir); free(tmpdir); tmpdir = NULL; } if (tmppath) { /* remove any previous tmppath stuff */ - rrmdir(tmppath); + (void) rrmdir(tmppath); free(tmppath); tmppath = NULL; } if (tmpsymdir) { /* remove temp symbolic links made for signed pkg */ - rrmdir(tmpsymdir); + (void) rrmdir(tmpsymdir); free(tmpsymdir); tmpsymdir = NULL; } if (srcdev.mount && !ids_name) - pkgumount(&srcdev); + (void) pkgumount(&srcdev); if (dstdev.mount && !ods_name) - pkgumount(&dstdev); + (void) pkgumount(&dstdev); (void) ds_close(1); } @@ -1871,7 +1871,7 @@ /* write out the header to the signature stream */ for (block_cnt = 0; block_cnt < hdr->allocation; block_cnt += BLK_SIZE) { - BIO_write(bio, (hdr->text_buffer + block_cnt), BLK_SIZE); + (void) BIO_write(bio, (hdr->text_buffer + block_cnt), BLK_SIZE); } /* save current directory */ @@ -1941,11 +1941,11 @@ /* read output in chunks, transfer to BIO */ while (fread(buf, BLK_SIZE, 1, fp) == 1) { if (BIO_write(bio, buf, BLK_SIZE) != BLK_SIZE) { - sighold(SIGINT); - sighold(SIGHUP); + (void) sighold(SIGINT); + (void) sighold(SIGHUP); (void) epclose(fp); - sigrelse(SIGINT); - sigrelse(SIGHUP); + (void) sigrelse(SIGINT); + (void) sigrelse(SIGHUP); rpterr(); return (1); } @@ -1959,11 +1959,11 @@ } /* done, close stream, report any errors */ - sighold(SIGINT); - sighold(SIGHUP); + (void) sighold(SIGINT); + (void) sighold(SIGHUP); rc = epclose(fp); - sigrelse(SIGINT); - sigrelse(SIGHUP); + (void) sigrelse(SIGINT); + (void) sigrelse(SIGHUP); if (rc != 0) { rpterr(); return (1); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/pkgweb.c --- a/usr/src/lib/libpkg/common/pkgweb.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/pkgweb.c Mon Nov 15 20:03:27 2010 -0800 @@ -617,6 +617,7 @@ * * Returns : none */ +/*PRINTFLIKE2*/ void echo_out(int nointeract, char *fmt, ...) { @@ -941,6 +942,7 @@ /* some other error. print them all. */ while ((errcode = ERR_get_error_line_data(NULL, NULL, &err_data, &err_flags)) != 0) { + size_t errsz; err_reason = ERR_reason_error_string(errcode); if (err_reason == NULL) { @@ -952,11 +954,11 @@ err_data = gettext(ERR_SIG_INT); } - err_string = - xmalloc(strlen(err_reason) + - strlen(err_data) + 3); - (void) sprintf(err_string, "%s: %s", - err_reason, err_data); + errsz = strlen(err_reason) + + strlen(err_data) + 3; + err_string = xmalloc(errsz); + (void) snprintf(err_string, errsz, + "%s: %s", err_reason, err_data); pkgerr_add(err, PKGERR_VERIFY, gettext(ERR_VERIFY_SIG), signer_sname, signer_iname, @@ -1263,7 +1265,7 @@ } /* add nonce */ - OCSP_request_add1_nonce(req, NULL, -1); + (void) OCSP_request_add1_nonce(req, NULL, -1); /* connect to host, or proxy */ if (proxy != NULL) { @@ -2823,7 +2825,7 @@ } /* remove first quote */ - memmove(str, str + 1, strlen(str) - 1); + (void) memmove(str, str + 1, strlen(str) - 1); /* * scan string looking for ending quote. @@ -3022,7 +3024,7 @@ initted = B_TRUE; } - backoff = drand48() * (double)cur_backoff; + backoff = (int)(drand48() * (double)cur_backoff); (void) sleep(backoff); if (cur_backoff < MAX_BACKOFF) { /* @@ -3157,7 +3159,7 @@ */ /* make a copy (getpassphrase overwrites) */ - strlcpy(passphrase_copy, passphrase, + (void) strlcpy(passphrase_copy, passphrase, MAX_PHRASELEN + 1); if (((passlen = snprintf(prompt_copy, @@ -3233,6 +3235,6 @@ return (-1); } - strlcpy(buf, passphrase, size); + (void) strlcpy(buf, passphrase, size); return (strlen(buf)); } diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/pkgxpand.c --- a/usr/src/lib/libpkg/common/pkgxpand.c Wed Nov 10 12:47:49 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 - */ - -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - - -#include -#include -#include -#include -#include -#include "pkglib.h" -#include "pkglocale.h" - -extern char *fpkginst(char *pkg, ...); /* libadm.a */ -extern char *pkgdir; /* WHERE? */ - -#define ispkgalias(p) (*p == '+') -#define LSIZE 512 -#define MALSIZ 16 - -char ** -pkgalias(char *pkg) -{ - FILE *fp; - char path[PATH_MAX], *pkginst; - char *mypkg, *myarch, *myvers, **pkglist; - char line[LSIZE]; - int n, errflg; - - pkglist = (char **)calloc(MALSIZ, sizeof (char *)); - if (pkglist == NULL) - return ((char **)0); - - (void) sprintf(path, "%s/%s/pkgmap", pkgdir, pkg); - if ((fp = fopen(path, "r")) == NULL) - return ((char **)0); - - n = errflg = 0; - while (fgets(line, LSIZE, fp)) { - mypkg = strtok(line, " \t\n"); - myarch = strtok(NULL, "( \t\n)"); - myvers = strtok(NULL, "\n"); - - (void) fpkginst(NULL); - pkginst = fpkginst(mypkg, myarch, myvers); - if (pkginst == NULL) { - logerr( - pkg_gt("no package instance for [%s]"), mypkg); - errflg++; - continue; - } - if (errflg) - continue; - - pkglist[n] = strdup(pkginst); - if ((++n % MALSIZ) == 0) { - pkglist = (char **)realloc(pkglist, - (n+MALSIZ)*sizeof (char *)); - if (pkglist == NULL) - return ((char **)0); - } - } - pkglist[n] = NULL; - - (void) fclose(fp); - if (errflg) { - while (n-- >= 0) - free(pkglist[n]); - free(pkglist); - return ((char **)0); - } - return (pkglist); -} - -#if 0 -char ** -pkgxpand(char *pkg[]) -{ - static int level = 0; - char **pkglist; - int i; - - if (++level >= 0) - printf(pkg_gt("too deep")); - for (i = 0; pkg[i]; i++) { - if (ispkgalias(pkg[i])) { - pkglist = pkgxpand(&pkg[i]); - pkgexpand(pkglist); - } - } -} -#endif /* 0 */ diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/ppkgmap.c --- a/usr/src/lib/libpkg/common/ppkgmap.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/ppkgmap.c Mon Nov 15 20:03:27 2010 -0800 @@ -65,40 +65,20 @@ } if (strchr("cb", ept->ftype)) { -#ifdef SUNOS41 - if (ept->ainfo.xmajor == BADMAJOR) { - if (fprintf(fp, " ?") < 0) - return (-1); - } else { - if (fprintf(fp, " %d", ept->ainfo.xmajor) < 0) - return (-1); - } -#else if (ept->ainfo.major == BADMAJOR) { if (fprintf(fp, " ?") < 0) return (-1); } else { - if (fprintf(fp, " %d", ept->ainfo.major) < 0) + if (fprintf(fp, " %ld", ept->ainfo.major) < 0) return (-1); } -#endif -#ifdef SUNOS41 - if (ept->ainfo.xminor == BADMINOR) { - if (fprintf(fp, " ?") < 0) - return (-1); - } else { - if (fprintf(fp, " %d", ept->ainfo.xminor) < 0) - return (-1); - } -#else if (ept->ainfo.minor == BADMINOR) { if (fprintf(fp, " ?") < 0) return (-1); } else { - if (fprintf(fp, " %d", ept->ainfo.minor) < 0) + if (fprintf(fp, " %ld", ept->ainfo.minor) < 0) return (-1); } -#endif } if (strchr("dxcbpfve", ept->ftype)) { diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/progerr.c --- a/usr/src/lib/libpkg/common/progerr.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/progerr.c Mon Nov 15 20:03:27 2010 -0800 @@ -74,7 +74,7 @@ } -/*VARARGS*/ +/*PRINTFLIKE1*/ void progerr(char *fmt, ...) { diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/putcfile.c --- a/usr/src/lib/libpkg/common/putcfile.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/putcfile.c Mon Nov 15 20:03:27 2010 -0800 @@ -103,7 +103,7 @@ return (-1); } } else { - if (fprintf(a_fp, " %d", a_ept->ainfo.major) < 0) + if (fprintf(a_fp, " %ld", a_ept->ainfo.major) < 0) return (-1); } @@ -116,7 +116,7 @@ return (-1); } } else { - if (fprintf(a_fp, " %d", a_ept->ainfo.minor) < 0) + if (fprintf(a_fp, " %ld", a_ept->ainfo.minor) < 0) return (-1); } } diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/runcmd.c --- a/usr/src/lib/libpkg/common/runcmd.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/runcmd.c Mon Nov 15 20:03:27 2010 -0800 @@ -62,30 +62,6 @@ static char errfile[L_tmpnam+1]; /* - * This is the "argument array" definition that is returned by e_new_args and is - * used by e_add_args, e_free_args, etc. - */ - -struct _argArray_t { - long _aaNumArgs; /* number of arguments set */ - long _aaMaxArgs; /* number of arguments allocated */ - char **_aaArgs; /* actual arguments */ -}; - -typedef struct _argArray_t argArray_t; - -/* - * Private Methods - */ -static void e_free_args(argArray_t *a_args); -static argArray_t *e_new_args(int initialCount); -/*PRINTFLIKE2*/ -static boolean_t e_add_arg(argArray_t *a_args, char *a_format, ...); -static int e_get_argc(argArray_t *a_args); -static char **e_get_argv(argArray_t *a_args); - - -/* * Public Methods */ @@ -99,7 +75,7 @@ if (errfile[0]) { if (fp = fopen(errfile, "r")) { while ((c = getc(fp)) != EOF) - putc(c, stderr); + (void) putc(c, stderr); (void) fclose(fp); } (void) unlink(errfile); @@ -170,7 +146,7 @@ i = open(errfile, O_WRONLY|O_CREAT|O_TRUNC, 0666); if (i >= 0) { - dup2(i, STDERR_FILENO); + (void) dup2(i, STDERR_FILENO); } /* Close all open files except standard i/o */ @@ -179,7 +155,7 @@ /* execute target executable */ - execl("/sbin/sh", "/sbin/sh", "-c", cmd, NULL); + (void) execl("/sbin/sh", "/sbin/sh", "-c", cmd, NULL); progerr(pkg_gt("exec of <%s> failed, errno=%d"), cmd, errno); _exit(99); } else if (pid < 0) { @@ -193,9 +169,9 @@ * this is the parent process */ - sighold(SIGINT); + (void) sighold(SIGINT); pid = waitpid(pid, &status, 0); - sigrelse(SIGINT); + (void) sigrelse(SIGINT); if (pid < 0) { return (-1); /* probably interrupted */ @@ -229,7 +205,7 @@ if (errfile[0]) { /* cleanup previous errfile */ - unlink(errfile); + (void) unlink(errfile); } perrfile = tmpnam(NULL); @@ -596,213 +572,3 @@ return (e_ExecCmdArray(r_status, r_results, a_inputFile, a_cmd, array)); } - -/* - * Name: e_new_args - * Description: create a new argument array for use in exec() calls - * Arguments: initialCount - [RO, *RO] - (int) - * Initial number of elements to populate the - * argument array with - use best guess - * Returns: argArray_t * - * Pointer to argument array that can be used in other - * functions that accept it as an argument - * == (argArray_t *)NULL - error - * NOTE: you must call e_free_args() when the returned argument array is - * no longer needed so that all storage used can be freed up. - */ - -argArray_t * -e_new_args(int initialCount) -{ - argArray_t *aa; - - /* allocate new argument array structure */ - - aa = (argArray_t *)calloc(1, sizeof (argArray_t)); - if (aa == (argArray_t *)NULL) { - progerr(ERR_MALLOC, strerror(errno), sizeof (argArray_t), - ""); - return ((argArray_t *)NULL); - } - - /* allocate initial argument array */ - - aa->_aaArgs = (char **)calloc(initialCount+1, sizeof (char *)); - if (aa->_aaArgs == (char **)NULL) { - progerr(ERR_MALLOC, strerror(errno), - (initialCount+1)*sizeof (char *), ""); - return ((argArray_t *)NULL); - } - - /* initialize argument indexes */ - - aa->_aaNumArgs = 0; - aa->_aaMaxArgs = initialCount; - - return (aa); -} - -/* - * Name: e_add_arg - * Description: add new argument to argument array for use in exec() calls - * Arguments: a_args - [RO, *RW] - (argArray_t *) - * Pointer to argument array (previously allocated via - * a call to e_new_args) to add the argument to - * a_format - [RO, *RO] - (char *) - * Pointer to "printf" style format argument - * ... - [RO, *RO] - (varies) - * Arguments as appropriate for format statement - * Returns: boolean_t - * B_TRUE - success - * B_FALSE - failure - * Examples: - * - to add an argument that specifies a file descriptor: - * int fd; - * e_add_arg(aa, "/proc/self/fd/%d", fd); - * - to add a flag or other known text: - * e_add_arg(aa, "-s") - * - to add random text: - * char *random_text; - * e_add_arg(aa, "%s", random_text); - */ - -/*PRINTFLIKE2*/ -boolean_t -e_add_arg(argArray_t *a_args, char *a_format, ...) -{ - char *rstr = (char *)NULL; - char bfr[MAX_CANON]; - size_t vres = 0; - va_list ap; - - /* - * double argument array if array is full - */ - - if (a_args->_aaNumArgs >= a_args->_aaMaxArgs) { - int newMax; - char **newArgs; - - newMax = a_args->_aaMaxArgs * 2; - newArgs = (char **)realloc(a_args->_aaArgs, - (newMax+1) * sizeof (char *)); - if (newArgs == (char **)NULL) { - progerr(ERR_MALLOC, strerror(errno), - ((newMax+1) * sizeof (char *)), ""); - return (B_FALSE); - } - a_args->_aaArgs = newArgs; - a_args->_aaMaxArgs = newMax; - } - - /* determine size of argument to add to list */ - - va_start(ap, a_format); - vres = vsnprintf(bfr, sizeof (bfr), a_format, ap); - va_end(ap); - - /* if it fit in the built in buffer, use that */ - if (vres < sizeof (bfr)) { - /* dup text already generated in bfr */ - rstr = strdup(bfr); - if (rstr == (char *)NULL) { - progerr(ERR_MALLOC, strerror(errno), vres+2, - ""); - return (B_FALSE); - } - } else { - /* allocate space for argument to add */ - - rstr = (char *)malloc(vres+2); - if (rstr == (char *)NULL) { - progerr(ERR_MALLOC, strerror(errno), vres+2, - ""); - return (B_FALSE); - } - - /* generate argument to add */ - - va_start(ap, a_format); - vres = vsnprintf(rstr, vres+1, a_format, ap); - va_end(ap); - } - - /* add argument to the end of the argument array */ - - a_args->_aaArgs[a_args->_aaNumArgs++] = rstr; - a_args->_aaArgs[a_args->_aaNumArgs] = (char *)NULL; - - return (B_TRUE); -} - -/* - * Name: e_get_argv - * Description: return (char **)argv pointer from argument array - * Arguments: a_args - [RO, *RW] - (argArray_t *) - * Pointer to argument array (previously allocated via - * a call to e_new_args) to return argv pointer for - * Returns: char ** - * Pointer to (char **)argv pointer suitable for use - * in an exec*() call - * NOTE: the actual character array is always terminated with a (char *)NULL - */ - -char ** -e_get_argv(argArray_t *a_args) -{ - return (a_args->_aaArgs); -} - -/* - * Name: e_get_argc - * Description: return (int) argc count from argument array - * Arguments: a_args - [RO, *RW] - (argArray_t *) - * Pointer to argument array (previously allocated via - * a call to e_new_args) to return argc count for - * Returns: int - * Count of the number of arguments in the argument array - * suitable for use in an exec*() call - */ - -int -e_get_argc(argArray_t *a_args) -{ - return (a_args->_aaNumArgs); -} - -/* - * Name: e_free_args - * Description: free all storage contained in an argument array previously - * allocated by a call to e_new_args - * Arguments: a_args - [RO, *RW] - (argArray_t *) - * Pointer to argument array (previously allocated via - * a call to e_new_args) to free - * Returns: void - * NOTE: preserves errno (usually called right after e_execCmd*()) - */ - -void -e_free_args(argArray_t *a_args) -{ - int i; - int lerrno = errno; - - /* free all arguments in the argument array */ - - for (i = (a_args->_aaNumArgs-1); i >= 0; i--) { - (void) free(a_args->_aaArgs[i]); - a_args->_aaArgs[i] = (char *)NULL; - } - - /* free argument array */ - - (void) free(a_args->_aaArgs); - - /* free argument array structure */ - - (void) free(a_args); - - /* restore errno */ - - errno = lerrno; -} diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/tputcfent.c --- a/usr/src/lib/libpkg/common/tputcfent.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/tputcfent.c Mon Nov 15 20:03:27 2010 -0800 @@ -95,14 +95,14 @@ (void) fprintf(fp, pkg_gt("Major device number: %s\n"), MSG_INVALID); else - (void) fprintf(fp, pkg_gt("Major device number: %d\n"), + (void) fprintf(fp, pkg_gt("Major device number: %ld\n"), ept->ainfo.major); if (ept->ainfo.minor == BADMINOR) (void) fprintf(fp, pkg_gt("Minor device number: %s\n"), MSG_INVALID); else - (void) fprintf(fp, pkg_gt("Minor device number: %d\n"), + (void) fprintf(fp, pkg_gt("Minor device number: %ld\n"), ept->ainfo.minor); break; @@ -131,7 +131,7 @@ (void) fprintf(fp, pkg_gt("Expected mode: %s\n"), "?"); else - (void) fprintf(fp, pkg_gt("Expected mode: %04o\n"), + (void) fprintf(fp, pkg_gt("Expected mode: %04lo\n"), ept->ainfo.mode); (void) fprintf(fp, pkg_gt("Expected owner: %s\n"), @@ -148,10 +148,10 @@ ept->cinfo.cksum); if (ept->cinfo.modtime > 0) { timep = localtime(&(ept->cinfo.modtime)); - strftime(timeb, sizeof (timeb), + (void) strftime(timeb, sizeof (timeb), pkg_gt("Expected last modification: %b %d %X %Y\n"), timep); - (void) fprintf(fp, timeb); + (void) fputs(timeb, fp); } else (void) fprintf(fp, pkg_gt("Expected last modification: ?\n")); diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/verify.c --- a/usr/src/lib/libpkg/common/verify.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/verify.c Mon Nov 15 20:03:27 2010 -0800 @@ -106,7 +106,6 @@ ptln = sizeof (theErrBuf); } va_start(ap, fmt); - /* LINTED variable format specifier to vsnprintf() */ (void) vsnprintf(pt, ptln, fmt, ap); va_end(ap); } @@ -421,7 +420,7 @@ /* Get copy of the current working directory */ if (getcwd(cwd, MAXPATHLEN) == NULL) { - reperr(pkg_gt(ERR_GETWD), ainfo->local); + reperr(pkg_gt(ERR_GETWD)); return (VE_FAIL); } @@ -434,7 +433,7 @@ if (c) { /* bugid 4247895 */ if (strcmp(cd, c) == 0) - strcpy(cd, "/"); + (void) strcpy(cd, "/"); else *c = NULL; @@ -454,7 +453,7 @@ * directory. */ if (!isdir(ainfo->local)) { - chdir(cwd); + (void) chdir(cwd); reperr(pkg_gt(ERR_LINKISDIR), ainfo->local); return (VE_FAIL); @@ -464,7 +463,7 @@ return (VE_FAIL); if (link(ainfo->local, path)) { - chdir(cwd); + (void) chdir(cwd); reperr(pkg_gt(ERR_LINKFAIL), ainfo->local); return (VE_FAIL); @@ -660,11 +659,7 @@ } if (mknod(path, ainfo->mode | S_IFCHR, -#ifdef SUNOS41 - makedev(ainfo->xmajor, ainfo->xminor)) || -#else makedev(ainfo->major, ainfo->minor)) || -#endif (stat(path, &status) < 0)) { reperr(pkg_gt(ERR_CDEVFAIL)); return (VE_FAIL); @@ -694,11 +689,7 @@ } if (mknod(path, ainfo->mode | S_IFBLK, -#ifdef SUNOS41 - makedev(ainfo->xmajor, ainfo->xminor)) || -#else makedev(ainfo->major, ainfo->minor)) || -#endif (stat(path, &status) < 0)) { reperr(pkg_gt(ERR_BDEVFAIL)); return (VE_FAIL); @@ -723,19 +714,6 @@ retcode = 0; if ((myftype == 'c') || (myftype == 'b')) { -#ifdef SUNOS41 - if (setval || (ainfo->xmajor < 0)) - ainfo->xmajor = ((status.st_rdev>>8)&0377); - if (setval || (ainfo->xminor < 0)) - ainfo->xminor = (status.st_rdev&0377); - /* check major & minor */ - if (status.st_rdev != makedev(ainfo->xmajor, ainfo->xminor)) { - reperr(pkg_gt(ERR_MAJMIN), ainfo->xmajor, - ainfo->xminor, - (status.st_rdev>>8)&0377, status.st_rdev&0377); - retcode = VE_CONT; - } -#else if (setval || (ainfo->major == BADMAJOR)) ainfo->major = major(status.st_rdev); if (setval || (ainfo->minor == BADMINOR)) @@ -746,7 +724,6 @@ major(status.st_rdev), minor(status.st_rdev)); retcode = VE_CONT; } -#endif } /* compare specified mode w/ actual mode excluding sticky bit */ diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libpkg/common/vfpops.c --- a/usr/src/lib/libpkg/common/vfpops.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libpkg/common/vfpops.c Mon Nov 15 20:03:27 2010 -0800 @@ -911,7 +911,7 @@ /* copy contents of VFP to checkpoint to checkpointed VFP */ - memcpy(vfp, avfp, sizeof (VFP_T)); + (void) memcpy(vfp, avfp, sizeof (VFP_T)); /* free contents of VFP to checkpoint */ diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libzonecfg/common/libzonecfg.c --- a/usr/src/lib/libzonecfg/common/libzonecfg.c Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libzonecfg/common/libzonecfg.c Mon Nov 15 20:03:27 2010 -0800 @@ -92,7 +92,6 @@ #define DTD_ELEM_PSET (const xmlChar *) "pset" #define DTD_ELEM_MCAP (const xmlChar *) "mcap" #define DTD_ELEM_PACKAGE (const xmlChar *) "package" -#define DTD_ELEM_PATCH (const xmlChar *) "patch" #define DTD_ELEM_OBSOLETES (const xmlChar *) "obsoletes" #define DTD_ELEM_DEV_PERM (const xmlChar *) "dev-perm" #define DTD_ELEM_ADMIN (const xmlChar *) "admin" @@ -561,8 +560,7 @@ next = child->next; if (child->name == NULL) continue; - if (xmlStrcmp(child->name, DTD_ELEM_PACKAGE) == 0 || - xmlStrcmp(child->name, DTD_ELEM_PATCH) == 0) { + if (xmlStrcmp(child->name, DTD_ELEM_PACKAGE) == 0) { next = child->next; xmlUnlinkNode(child); xmlFreeNode(child); @@ -3497,36 +3495,6 @@ return (Z_OK); } -int -zonecfg_add_patch(zone_dochandle_t handle, char *id, void **pnode) -{ - xmlNodePtr node = (xmlNodePtr)*pnode; - xmlNodePtr cur; - int err; - - if ((err = operation_prep(handle)) != Z_OK) - return (err); - - cur = handle->zone_dh_cur; - node = xmlNewTextChild(cur, NULL, DTD_ELEM_PATCH, NULL); - if ((err = newprop(node, DTD_ATTR_ID, id)) != Z_OK) - return (err); - *pnode = (void *)node; - return (Z_OK); -} - -int -zonecfg_add_patch_obs(char *id, void *cur) -{ - xmlNodePtr node; - int err; - - node = xmlNewTextChild((xmlNodePtr)cur, NULL, DTD_ELEM_OBSOLETES, NULL); - if ((err = newprop(node, DTD_ATTR_ID, id)) != Z_OK) - return (err); - return (Z_OK); -} - char * zonecfg_strerror(int errnum) { @@ -6998,19 +6966,10 @@ } /* - * Get the full tree of pkg/patch metadata in a set of nested AVL trees. - * pkgs_avl is an AVL tree of pkgs. Each pkg element contains a - * zpe_patches_avl member which holds an AVL tree of patches for that pkg. - * The patch elements have the same zpe_patches_avl member, each of which can - * hold an AVL tree of patches that are obsoleted by the patch. + * Get the full tree of pkg metadata in a set of nested AVL trees. + * pkgs_avl is an AVL tree of pkgs. * - * The zone xml data contains DTD_ELEM_PACKAGE elements, followed by - * DTD_ELEM_PATCH elements. The DTD_ELEM_PATCH patch element applies to the - * DTD_ELEM_PACKAGE that precedes it. The DTD_ELEM_PATCH element may have - * child DTD_ELEM_OBSOLETES nodes associated with it. The DTD_ELEM_PACKAGE - * really should have had the DTD_ELEM_PATCH elements as children but it - * was not defined that way initially so we are stuck with the DTD definition - * now. However, we can safely assume the ordering for compatibility. + * The zone xml data contains DTD_ELEM_PACKAGE elements. */ int zonecfg_getpkgdata(zone_dochandle_t handle, uu_avl_pool_t *pkg_pool, @@ -7064,8 +7023,6 @@ goto done; } - pkg->zpe_patches_avl = NULL; - uu_avl_node_init(pkg, &pkg->zpe_entry, pkg_pool); if (uu_avl_find(pkgs_avl, pkg, NULL, &where) != NULL) { free(pkg->zpe_name); @@ -7074,131 +7031,6 @@ } else { uu_avl_insert(pkgs_avl, pkg, where); } - - } else if (xmlStrcmp(cur->name, DTD_ELEM_PATCH) == 0) { - zone_pkg_entry_t *patch; - uu_avl_index_t where; - char *p; - char *dashp = NULL; - xmlNodePtr child; - - if ((res = fetchprop(cur, DTD_ATTR_ID, name, - sizeof (name))) != Z_OK) - goto done; - - if ((patch = (zone_pkg_entry_t *) - malloc(sizeof (zone_pkg_entry_t))) == NULL) { - res = Z_NOMEM; - goto done; - } - - if ((p = strchr(name, '-')) != NULL) { - dashp = p; - *p++ = '\0'; - } else { - p = ""; - } - - if ((patch->zpe_name = strdup(name)) == NULL) { - free(patch); - res = Z_NOMEM; - goto done; - } - - if ((patch->zpe_vers = strdup(p)) == NULL) { - free(patch->zpe_name); - free(patch); - res = Z_NOMEM; - goto done; - } - - if (dashp != NULL) - *dashp = '-'; - - patch->zpe_patches_avl = NULL; - - if (pkg->zpe_patches_avl == NULL) { - pkg->zpe_patches_avl = uu_avl_create(pkg_pool, - NULL, UU_DEFAULT); - if (pkg->zpe_patches_avl == NULL) { - free(patch->zpe_name); - free(patch->zpe_vers); - free(patch); - res = Z_NOMEM; - goto done; - } - } - - uu_avl_node_init(patch, &patch->zpe_entry, pkg_pool); - if (uu_avl_find(pkg->zpe_patches_avl, patch, NULL, - &where) != NULL) { - free(patch->zpe_name); - free(patch->zpe_vers); - free(patch); - } else { - uu_avl_insert(pkg->zpe_patches_avl, patch, - where); - } - - /* Add any patches this patch obsoletes. */ - for (child = cur->xmlChildrenNode; child != NULL; - child = child->next) { - zone_pkg_entry_t *obs; - - if (xmlStrcmp(child->name, DTD_ELEM_OBSOLETES) - != 0) - continue; - - if ((res = fetchprop(child, DTD_ATTR_ID, - name, sizeof (name))) != Z_OK) - goto done; - - if ((obs = (zone_pkg_entry_t *)malloc( - sizeof (zone_pkg_entry_t))) == NULL) { - res = Z_NOMEM; - goto done; - } - - if ((obs->zpe_name = strdup(name)) == NULL) { - free(obs); - res = Z_NOMEM; - goto done; - } - /* - * The version doesn't matter for obsoleted - * patches. - */ - obs->zpe_vers = NULL; - obs->zpe_patches_avl = NULL; - - /* - * If this is the first obsolete patch, add an - * AVL tree to the parent patch element. - */ - if (patch->zpe_patches_avl == NULL) { - patch->zpe_patches_avl = - uu_avl_create(pkg_pool, NULL, - UU_DEFAULT); - if (patch->zpe_patches_avl == NULL) { - free(obs->zpe_name); - free(obs); - res = Z_NOMEM; - goto done; - } - } - - /* Insert obsolete patch into the AVL tree. */ - uu_avl_node_init(obs, &obs->zpe_entry, - pkg_pool); - if (uu_avl_find(patch->zpe_patches_avl, obs, - NULL, &where) != NULL) { - free(obs->zpe_name); - free(obs); - } else { - uu_avl_insert(patch->zpe_patches_avl, - obs, where); - } - } } } diff -r f82e1d54cdbd -r 35f707bf8b40 usr/src/lib/libzonecfg/common/mapfile-vers --- a/usr/src/lib/libzonecfg/common/mapfile-vers Wed Nov 10 12:47:49 2010 -0800 +++ b/usr/src/lib/libzonecfg/common/mapfile-vers Mon Nov 15 20:03:27 2010 -0800 @@ -53,8 +53,6 @@ zonecfg_add_fs_option; zonecfg_add_admin; zonecfg_add_nwif; - zonecfg_add_patch; - zonecfg_add_patch_obs; zonecfg_add_pkg; zonecfg_add_pset; zonecfg_add_rctl;