1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * autod_lookup.c 24 * 25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 */ 28 29/* 30 * Portions Copyright 2007-2011 Apple Inc. 31 */ 32 33#pragma ident "@(#)autod_lookup.c 1.13 05/06/08 SMI" 34 35#include <stdio.h> 36#include <ctype.h> 37#include <string.h> 38#include <syslog.h> 39#include <errno.h> 40#include <locale.h> 41#include <stdlib.h> 42#include <unistd.h> 43#include <assert.h> 44#include "automount.h" 45 46int 47do_lookup1(const autofs_pathname mapname, const char *key, 48 const autofs_pathname subdir, const autofs_opts mapopts, 49 boolean_t isdirect, uid_t sendereuid, int *node_type) 50{ 51 struct mapent *mapents = NULL; 52 int err; 53 bool_t isrestricted = hasrestrictopt(mapopts); 54 55 /* 56 * call parser w default mount_access = TRUE 57 */ 58 mapents = parse_entry(key, mapname, mapopts, subdir, isdirect, 59 node_type, isrestricted, TRUE, &err); 60 if (err) { 61 /* 62 * The entry wasn't found in the map; err was set to 63 * the appropriate value by parse_entry(). 64 * 65 * Now we indulge in a bit of hanky-panky. If the 66 * name begins with an "=" then we assume that 67 * the name is an undocumented control message 68 * for the daemon. This is accessible only 69 * to superusers. 70 */ 71 if (*key == '=' && sendereuid == 0) { 72 if (isdigit(*(key+1))) { 73 /* 74 * If next character is a digit 75 * then set the trace level. 76 */ 77 trace = atoi(key+1); 78 trace_prt(1, "Automountd: trace level = %d\n", 79 trace); 80 } else if (*(key+1) == 'v') { 81 /* 82 * If it's a "v" then 83 * toggle verbose mode. 84 */ 85 verbose = !verbose; 86 trace_prt(1, "Automountd: verbose %s\n", 87 verbose ? "on" : "off"); 88 } 89 } 90 return (err); 91 } 92 93 /* 94 * The entry was found in the map; err was set to 0 95 * by parse_entry(). 96 */ 97 if (mapents) 98 free_mapent(mapents); 99 100 if (trace > 1) { 101 trace_prt(1, " do_lookup1: node_type=0x%08x error=%d\n", 102 *node_type, err); 103 } 104 return (err); 105} 106