2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2N/A/* All Rights Reserved */ 2N/A * These determine how gpkgmap() deals with mode, owner and group defaults. 2N/A * It is assumed that the owner and group arguments represent static fields 2N/A * which will persist until attrdefault() is called. 2N/A * This determines how gpkgmap() deals with environment variables in the 2N/A * mode, owner and group. Path is evaluated at a higher level based upon 2N/A * other circumstances. 2N/A/* This is the external query interface for mapmode. */ 2N/A * Unpack the pkgmap or the contents file or whatever file is in that format. 2N/A * Based upon mapmode, environment parameters will be resolved for mode, 2N/A /* default attributes were supplied, so don't reset */ 2N/A * If the first character is not a digit, we assume that the 2N/A * volume number is 1. 2N/A * Since we are going to scan the next line, 2N/A * we need to reset volume number and first_char. 2N/A /* content info might exist */ 2N/A if ((c !=
EOF) && (c !=
'\n'))
2N/A * Links and information files don't have attributes associated with 2N/A * them. The following either resolves potential variables or passes 2N/A * them through. Mode is tested for validity to some degree. BAD??? 2N/A * is returned to indicate that no meaningful mode was provided. A 2N/A * higher authority will decide if that's OK or not. CUR??? means that 2N/A * the prototype file specifically requires a wildcard ('?') for 2N/A * that entry. We issue an error if attributes were entered wrong. 2N/A * We just return BAD??? if there was no entry at all. 2N/A goto end;
/* nothing else on the line */ 2N/A /* owner & group should be here */ 2N/A goto end;
/* no owner or group - warning */ 2N/A goto end;
/* no group - warning */ 2N/A /* Resolve the parameters if required. */ 2N/A /* look for content description */ 2N/A * Get and validate the mode attribute. This returns an error if 2N/A * 1. the mode string is too long 2N/A * 2. the mode string includes alpha characters 2N/A * 3. the mode string is not octal 2N/A * 4. mode string is an install parameter 2N/A * 5. mode is an unresolved build parameter and MAPBUILD is 2N/A * If the mode is a build parameter, it is 2N/A * 1. returned as is if MAPNONE is in effect 2N/A * 2. evaluated if MAPBUILD is in effect 2N/A * NOTE : We use "mapmode!=MAPBUILD" to gather that it is install 2N/A * time. At install time we just fix a mode with bad bits set by 2N/A * setting it to CURMODE. This should be an error in a few releases 2N/A * (2.8 maybe) but faulty modes are so common in existing packages 2N/A * that this is a reasonable exception. -- JST 1994-11-9 2N/A * 0 if mode is being returned as a valid value 2N/A * 1 if no attributes are present on the line 2N/A * 2 if there was a fundamental error 2N/A * If it isn't a '?' (meaning go with whatever mode is 2N/A * there), validate the mode and convert it to a mode_t. The 2N/A * "bad" variable here is a misnomer. It doesn't necessarily 2N/A * Mode may not be an install parameter or a 2N/A * non-build parameter. 2N/A * At this point it's supposed to be 2N/A * something we can convert to a number. 2N/A * We reject it if it contains nonnumbers or 2N/A * We reject it if it contains inappropriate 2N/A /* leading white space ignored */ 2N/A /* leading white space ignored */ 2N/A * Get a string from the file. Returns 2N/A * 1 if nothing there 2N/A * -1 if string is too long 2N/A /* leading white space ignored */ 2N/A if ((c ==
EOF) || (c ==
'\n')) {
2N/A return (
1);
/* nothing there */ 2N/A /* fill up string until space, tab, or separator */ 2N/A return (-
1);
/* too long */ 2N/A if ((c ==
EOF) || (c ==
'\n'))
2N/A break;
/* no more on this line */ 2N/A }
while (c !=
'\n');
2N/A /* this test works around a side effect of getc() */ 2N/A while ((c ==
' ') || (c ==
'\t'));
2N/A /* return error if no vfp specified */ 2N/A * If the first character is not a digit, we assume that the 2N/A * volume number is 1. 2N/A * In case of hsfs the zero-padding of partial pages 2N/A * returned by mmap is not done properly. A separate bug has been filed 2N/A * Since we are going to scan the next line, 2N/A * we need to reset volume number and first_char. 2N/A /* content info might exist */ 2N/A if ((c !=
'\0') && (c !=
'\n'))
2N/A * Links and information files don't have attributes associated with 2N/A * them. The following either resolves potential variables or passes 2N/A * them through. Mode is tested for validity to some degree. BAD??? 2N/A * is returned to indicate that no meaningful mode was provided. A 2N/A * higher authority will decide if that's OK or not. CUR??? means that 2N/A * the prototype file specifically requires a wildcard ('?') for 2N/A * that entry. We issue an error if attributes were entered wrong. 2N/A * We just return BAD??? if there was no entry at all. 2N/A goto end;
/* nothing else on the line */ 2N/A /* owner & group should be here */ 2N/A goto end;
/* no owner or group - warning */ 2N/A goto end;
/* no group - warning */ 2N/A /* Resolve the parameters if required. */ 2N/A /* look for content description */ 2N/A * Get and validate the mode attribute. This returns an error if 2N/A * 1. the mode string is too long 2N/A * 2. the mode string includes alpha characters 2N/A * 3. the mode string is not octal 2N/A * 4. mode string is an install parameter 2N/A * 5. mode is an unresolved build parameter and MAPBUILD is 2N/A * If the mode is a build parameter, it is 2N/A * 1. returned as is if MAPNONE is in effect 2N/A * 2. evaluated if MAPBUILD is in effect 2N/A * NOTE : We use "mapmode!=MAPBUILD" to gather that it is install 2N/A * time. At install time we just fix a mode with bad bits set by 2N/A * setting it to CURMODE. This should be an error in a few releases 2N/A * (2.8 maybe) but faulty modes are so common in existing packages 2N/A * that this is a reasonable exception. -- JST 1994-11-9 2N/A * 0 if mode is being returned as a valid value 2N/A * 1 if no attributes are present on the line 2N/A * 2 if there was a fundamental error 2N/A * If it isn't a '?' (meaning go with whatever mode is 2N/A * there), validate the mode and convert it to a mode_t. The 2N/A * "bad" variable here is a misnomer. It doesn't necessarily 2N/A * Mode may not be an install parameter or a 2N/A * non-build parameter. 2N/A /* it's supposed to be something we can convert to a number */ 2N/A /* reject it if it contains nonnumbers or it's not octal */ 2N/A * We reject it if it contains inappropriate 2N/A /* leading white space ignored */ 2N/A /* leading white space ignored */ 2N/A /* leading white space ignored */ 2N/A if ((c ==
'\0') || (c ==
'\n')) {
2N/A return (
1);
/* nothing there */ 2N/A /* generate complete list of delimiters to scan for */ 2N/A /* compute length based on delimiter found or not */ 2N/A /* if string will fit in result buffer copy string and return success */ 2N/A /* result buffer too small; copy partial string, return error */ 2N/A * Description: Locate the end of the current line given a pointer into a buffer 2N/A * containing characters that is null terminated. 2N/A * Arguments: char **cp - pointer to pointer to null-terminated string buffer 2N/A * Returns: int == 0 -- no non-space characters preceded the newline 2N/A * != 0 -- one or more non-space characters preceded newline 2N/A * Effects: cp is updated to point to the first character PAST the first new 2N/A * line character found. If no newline character is found, cp is 2N/A * updated to point to the '\0' at the end of the buffer. 2N/A /* if at end of buffer return no more characters left */ 2N/A /* find the first null or end of line character */ 2N/A while ((*p !=
'\0') && (*p !=
'\n')) {
2N/A /* if at newline, increment pointer to first character past newline */ 2N/A /* set return pointer to null or first character past newline */ 2N/A * Description: Locate the end of the current line given a pointer into a buffer 2N/A * containing characters that is null terminated. 2N/A * Arguments: char **cp - pointer to pointer to null-terminated string buffer 2N/A * Effects: cp is updated to point to the first character PAST the first new 2N/A * line character found. If no newline character is found, cp is 2N/A * updated to point to the '\0' at the end of the buffer. 2N/A /* if at end of buffer return no more characters left */ 2N/A /* find the end of the line */ 2N/A /* no newline found - point to null terminator */