5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * CDDL HEADER START
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * The contents of this file are subject to the terms of the
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * Common Development and Distribution License (the "License").
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * You may not use this file except in compliance with the License.
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * or http://www.opensolaris.org/os/licensing.
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * See the License for the specific language governing permissions
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * and limitations under the License.
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * When distributing Covered Code, include this CDDL HEADER in each
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * If applicable, add the following below this CDDL HEADER, with the
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * fields enclosed by brackets "[]" replaced with your own identifying
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * information: Portions Copyright [yyyy] [name of copyright owner]
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * CDDL HEADER END
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * Use is subject to license terms.
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland/* All Rights Reserved */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland#define ERR_MAJOR "invalid major number <%s> specified for <%s>"
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland#define ERR_MINOR "invalid minor number <%s> specified for <%s>"
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland#define ERR_MODE "invalid mode <%s> specified for <%s>"
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland#define ERR_RELPATH "relative pathname <%s> not permitted"
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland#define ERR_NULLPATH "NULL or garbled pathname"
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland#define ERR_LINK "invalid link specification <%s>"
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland#define ERR_LINKFTYPE "ftype <%c> does not match link specification <%s>"
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland#define ERR_LINKARGS "extra arguments in link specification <%s>"
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland#define ERR_LINKREL "relative pathname in link specification <%s>"
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland#define ERR_FTYPE "invalid ftype <%c> for <%s>"
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland#define ERR_ARGC "invalid number of arguments for <%s>"
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland#define ERR_SPECALL "ftype <%c> requires all fields to be specified"
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterlandstatic int validate(struct cfextra *ext, int argc, char *argv[]);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland usage(); /* at least pathname is required */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland extlist = calloc(2, sizeof (struct cfextra *));
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland extlist[0] = new = calloc(1, sizeof (struct cfextra));
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland /* There is only one filename on the command line. */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland /* Read stdin to obtain entries, which need to be sorted. */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland extlist = calloc(MALSIZ, sizeof (struct cfextra *));
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland while (fgets(line, LSIZE, stdin) != NULL) {
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland usage(); /* at least pathname is required */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland (sizeof (struct cfextra *) * (eptnum+MALSIZ)));
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland qsort((char *)extlist, (unsigned)eptnum, sizeof (struct cfextra *),
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterlandvalidate(struct cfextra *ext, int argc, char *argv[])
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland /* initialize cfent structure */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland (void) gpkgmapvfp(ept, (VFP_T *)NULL); /* This just clears stuff. */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland (void) strncpy(ept->pkg_class, classname, CLSSIZ);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland if (argv[n] == NULL || *(argv[n]) == '\000') {
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * It would be a good idea to figure out how to get much of
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * this done using facilities in procmap.c - JST
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland *pt = '\0'; /* cut off pathname at the = sign */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland /* get the pathnames */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland if (eval_path(&(ext->server_path), &(ext->client_path),
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland /* This isn't likely to happen; but, better safe than sorry. */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland /* links specifications should be handled right here */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland ept->ftype = ((n >= argc) ? 'l' : argv[n++][0]);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland /* If nothing follows the '=', it's invalid */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland /* Test for an argument after the link. */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * If it's a link but it's neither hard nor symbolic then
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland progerr(gettext(ERR_LINKFTYPE), ept->ftype, ept->path);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland } else if (n >= argc) {
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland /* we are expecting to change object's contents */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland } else if (!strchr("?fvedxcbp", ept->ftype)) {
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland progerr(gettext(ERR_FTYPE), ept->ftype, ept->path);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland if (ept->ftype == 'b' || ept->ftype == 'c') {
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland ept->ainfo.major = strtol(argv[n++], &ret, 0);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland ept->ainfo.minor = strtol(argv[n++], &ret, 0);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland ept->ainfo.mode = strtol(argv[n++], &ret, 8);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland progerr(gettext(ERR_MODE), argv[n-1], ept->path);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland (void) strncpy(ept->ainfo.owner, argv[n++], ATRSIZ);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland (void) strncpy(ept->ainfo.group, argv[n++], ATRSIZ);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland if (strchr("dxbcp", ept->ftype) && !allspec) {
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland struct cfextra *ext1 = *((struct cfextra **)p1);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland struct cfextra *ext2 = *((struct cfextra **)p2);
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland return (strcmp(ext1->cf_ent.path, ext2->cf_ent.path));
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * If the path at argv[0] has the value of
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * PKG_INSTALL_ROOT prepended, remove it
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * Note- No local copy of argv is needed since this
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * function is guaranteed to replace argv with a subset of
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland * the original argv.
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland /* We only want to canonize the path if it contains multiple '/'s */
5c51f1241dbbdf2656d0e10011981411ed0c9673Moriah Waterland if (strncmp(argv[0], root, rootLen) == 0) {