1*7c478bd9Sstevel@tonic-gate# 2*7c478bd9Sstevel@tonic-gate# Copyright 2005 Sun Microsystems, Inc. All rights reserved. 3*7c478bd9Sstevel@tonic-gate# Use is subject to license terms. 4*7c478bd9Sstevel@tonic-gate# 5*7c478bd9Sstevel@tonic-gate# CDDL HEADER START 6*7c478bd9Sstevel@tonic-gate# 7*7c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 8*7c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 9*7c478bd9Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 10*7c478bd9Sstevel@tonic-gate# with the License. 11*7c478bd9Sstevel@tonic-gate# 12*7c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 13*7c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 14*7c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 15*7c478bd9Sstevel@tonic-gate# and limitations under the License. 16*7c478bd9Sstevel@tonic-gate# 17*7c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 18*7c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 19*7c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 20*7c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 21*7c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 22*7c478bd9Sstevel@tonic-gate# 23*7c478bd9Sstevel@tonic-gate# CDDL HEADER END 24*7c478bd9Sstevel@tonic-gate# 25*7c478bd9Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" 26*7c478bd9Sstevel@tonic-gate# 27*7c478bd9Sstevel@tonic-gate# This file generates three different C files: 28*7c478bd9Sstevel@tonic-gate# 29*7c478bd9Sstevel@tonic-gate# <sys/priv_const.h> 30*7c478bd9Sstevel@tonic-gate# An implementation private set of manifest integer constant 31*7c478bd9Sstevel@tonic-gate# for privileges and privilege sets and manifest constants for 32*7c478bd9Sstevel@tonic-gate# set size, number of sets, number of privileges 33*7c478bd9Sstevel@tonic-gate# 34*7c478bd9Sstevel@tonic-gate# os/priv_const.c 35*7c478bd9Sstevel@tonic-gate# A C source file containing the set names, privilege names 36*7c478bd9Sstevel@tonic-gate# arrays for the name <-> number mappings 37*7c478bd9Sstevel@tonic-gate# 38*7c478bd9Sstevel@tonic-gate# <sys/priv_names.h> 39*7c478bd9Sstevel@tonic-gate# A public header file containing the PRIV_* defines 40*7c478bd9Sstevel@tonic-gate# that map to strings; these are for convenience. 41*7c478bd9Sstevel@tonic-gate# (it's easy to misspell a string, harder to misspell a 42*7c478bd9Sstevel@tonic-gate# manifest constant) 43*7c478bd9Sstevel@tonic-gate# 44*7c478bd9Sstevel@tonic-gate# /etc/security/priv_names 45*7c478bd9Sstevel@tonic-gate# A privilege name to explanation mapping. 46*7c478bd9Sstevel@tonic-gate# 47*7c478bd9Sstevel@tonic-gate# 48*7c478bd9Sstevel@tonic-gate# The files are output on the awk variable privhfile, pubhfile, cfile, 49*7c478bd9Sstevel@tonic-gate# and pnamesfile respectively 50*7c478bd9Sstevel@tonic-gate# 51*7c478bd9Sstevel@tonic-gate# The input file should contain a standard Sun comment and ident string 52*7c478bd9Sstevel@tonic-gate# which is copied verbatim and lines of 53*7c478bd9Sstevel@tonic-gate# 54*7c478bd9Sstevel@tonic-gate# [keyword] privilege PRIV_<privilege> 55*7c478bd9Sstevel@tonic-gate# set PRIV_<set> 56*7c478bd9Sstevel@tonic-gate# 57*7c478bd9Sstevel@tonic-gate# Which are converted to privileges and privilege sets 58*7c478bd9Sstevel@tonic-gate# 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gateBEGIN { 62*7c478bd9Sstevel@tonic-gate # Number of privileges read 63*7c478bd9Sstevel@tonic-gate npriv = 0 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate # Number of privilege sets 66*7c478bd9Sstevel@tonic-gate nset = 0 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate # Length of all strings concatenated, including \0 69*7c478bd9Sstevel@tonic-gate privbytes = 0 70*7c478bd9Sstevel@tonic-gate setbytes = 0 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate # Number of reserved privilege slots 73*7c478bd9Sstevel@tonic-gate slack = 10 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate privhcmt = \ 76*7c478bd9Sstevel@tonic-gate " * Privilege constant definitions; these constants are subject to\n" \ 77*7c478bd9Sstevel@tonic-gate " * change, including renumbering, without notice and should not be\n" \ 78*7c478bd9Sstevel@tonic-gate " * used in any code. Privilege names must be used instead.\n" \ 79*7c478bd9Sstevel@tonic-gate " * Privileges and privilege sets must not be stored in binary\n" \ 80*7c478bd9Sstevel@tonic-gate " * form; privileges and privileges sets must be converted to\n" \ 81*7c478bd9Sstevel@tonic-gate " * textual representation before being committed to persistent store." 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate ccmt = \ 84*7c478bd9Sstevel@tonic-gate " * Privilege name table and size definitions." 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate pubhcmt = \ 87*7c478bd9Sstevel@tonic-gate " * Privilege constant definitions. Privileges and privilege sets\n" \ 88*7c478bd9Sstevel@tonic-gate " * are only known by name and should be mapped at runtime." 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate pnamescmt = \ 91*7c478bd9Sstevel@tonic-gate "#\n" \ 92*7c478bd9Sstevel@tonic-gate "# Privilege name explanation file\n" \ 93*7c478bd9Sstevel@tonic-gate "# The format of entries is a privilege name starting at the\n" \ 94*7c478bd9Sstevel@tonic-gate "# beginning of a line directly folowed by a new line followed\n" \ 95*7c478bd9Sstevel@tonic-gate "# by several lines of texts starting with white space terminated\n" \ 96*7c478bd9Sstevel@tonic-gate "# by a line with a single newline or not starting with white space\n" \ 97*7c478bd9Sstevel@tonic-gate "#\n" 98*7c478bd9Sstevel@tonic-gate} 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate# 101*7c478bd9Sstevel@tonic-gate# Privilege strings are represented as lower case strings; 102*7c478bd9Sstevel@tonic-gate# PRIV_ is stripped from the strings. 103*7c478bd9Sstevel@tonic-gate# 104*7c478bd9Sstevel@tonic-gate/^([A-Za-z]* )?privilege / { 105*7c478bd9Sstevel@tonic-gate if (NF == 3) { 106*7c478bd9Sstevel@tonic-gate key = toupper($1) 107*7c478bd9Sstevel@tonic-gate priv = toupper($3) 108*7c478bd9Sstevel@tonic-gate if (set[key] != "") 109*7c478bd9Sstevel@tonic-gate set[key] = set[key] ";" 110*7c478bd9Sstevel@tonic-gate set[key] = set[key] "\\\n\t\tPRIV_ASSERT((set), " priv ")" 111*7c478bd9Sstevel@tonic-gate } else { 112*7c478bd9Sstevel@tonic-gate priv = toupper($2); 113*7c478bd9Sstevel@tonic-gate } 114*7c478bd9Sstevel@tonic-gate privs[npriv] = tolower(substr(priv, 6)); 115*7c478bd9Sstevel@tonic-gate inset = 0 116*7c478bd9Sstevel@tonic-gate inpriv = 1 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate privind[npriv] = privbytes; 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate tabs = (32 - length(priv) - 1)/8 121*7c478bd9Sstevel@tonic-gate # length + \0 - PRIV_ 122*7c478bd9Sstevel@tonic-gate privbytes += length(priv) - 4 123*7c478bd9Sstevel@tonic-gate pdef[npriv] = "#define\t" priv substr("\t\t\t\t\t", 1, tabs) 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate npriv++ 126*7c478bd9Sstevel@tonic-gate next 127*7c478bd9Sstevel@tonic-gate} 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate# 130*7c478bd9Sstevel@tonic-gate# Set strings are represented as strings with an initial cap; 131*7c478bd9Sstevel@tonic-gate# PRIV_ is stripped from the strings. 132*7c478bd9Sstevel@tonic-gate# 133*7c478bd9Sstevel@tonic-gate/^set / { 134*7c478bd9Sstevel@tonic-gate $2 = toupper($2) 135*7c478bd9Sstevel@tonic-gate sets[nset] = toupper(substr($2, 6, 1)) tolower(substr($2, 7)); 136*7c478bd9Sstevel@tonic-gate inset = 1 137*7c478bd9Sstevel@tonic-gate inpriv = 0 138*7c478bd9Sstevel@tonic-gate 139*7c478bd9Sstevel@tonic-gate setind[nset] = setbytes 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate # length + \0 - PRIV_ 142*7c478bd9Sstevel@tonic-gate setbytes += length($2) - 4 143*7c478bd9Sstevel@tonic-gate tabs = (32 - length($2) - 1)/8 144*7c478bd9Sstevel@tonic-gate sdef[nset] = "#define\t" $2 substr("\t\t\t\t\t", 1, tabs) 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate nset++ 147*7c478bd9Sstevel@tonic-gate next 148*7c478bd9Sstevel@tonic-gate} 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate/INSERT COMMENT/ { 151*7c478bd9Sstevel@tonic-gate acmt = " *\n * THIS FILE WAS GENERATED; DO NOT EDIT" 152*7c478bd9Sstevel@tonic-gate if (cfile) { 153*7c478bd9Sstevel@tonic-gate print ccmt > cfile 154*7c478bd9Sstevel@tonic-gate print acmt > cfile 155*7c478bd9Sstevel@tonic-gate } 156*7c478bd9Sstevel@tonic-gate if (privhfile) { 157*7c478bd9Sstevel@tonic-gate print privhcmt > privhfile 158*7c478bd9Sstevel@tonic-gate print acmt > privhfile 159*7c478bd9Sstevel@tonic-gate } 160*7c478bd9Sstevel@tonic-gate if (pubhfile) { 161*7c478bd9Sstevel@tonic-gate print pubhcmt > pubhfile 162*7c478bd9Sstevel@tonic-gate print acmt > pubhfile 163*7c478bd9Sstevel@tonic-gate } 164*7c478bd9Sstevel@tonic-gate next 165*7c478bd9Sstevel@tonic-gate} 166*7c478bd9Sstevel@tonic-gate/^#pragma/ { 167*7c478bd9Sstevel@tonic-gate pragma = $0; 168*7c478bd9Sstevel@tonic-gate if (pnamesfile) { 169*7c478bd9Sstevel@tonic-gate print "#" substr($0, 9) > pnamesfile 170*7c478bd9Sstevel@tonic-gate } 171*7c478bd9Sstevel@tonic-gate next; 172*7c478bd9Sstevel@tonic-gate} 173*7c478bd9Sstevel@tonic-gate 174*7c478bd9Sstevel@tonic-gate/^#/ && ! /^#pragma/{ 175*7c478bd9Sstevel@tonic-gate # Comments, ignore 176*7c478bd9Sstevel@tonic-gate next 177*7c478bd9Sstevel@tonic-gate} 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate{ 180*7c478bd9Sstevel@tonic-gate # 181*7c478bd9Sstevel@tonic-gate # Comments describing privileges and sets follow the definitions. 182*7c478bd9Sstevel@tonic-gate # 183*7c478bd9Sstevel@tonic-gate if (inset || inpriv) { 184*7c478bd9Sstevel@tonic-gate sub("^[ ]*", "") 185*7c478bd9Sstevel@tonic-gate sub("[ ]*$", "") 186*7c478bd9Sstevel@tonic-gate if (/^$/) next; 187*7c478bd9Sstevel@tonic-gate } 188*7c478bd9Sstevel@tonic-gate if (inset) { 189*7c478bd9Sstevel@tonic-gate setcmt[nset - 1] = setcmt[nset - 1] " * " $0 "\n" 190*7c478bd9Sstevel@tonic-gate next 191*7c478bd9Sstevel@tonic-gate } else if (inpriv) { 192*7c478bd9Sstevel@tonic-gate sub("^[ ]*", "") 193*7c478bd9Sstevel@tonic-gate privcmt[npriv - 1] = privcmt[npriv - 1] " * " $0 "\n" 194*7c478bd9Sstevel@tonic-gate privncmt[npriv - 1] = privncmt[npriv - 1] "\t" $0 "\n" 195*7c478bd9Sstevel@tonic-gate next 196*7c478bd9Sstevel@tonic-gate } 197*7c478bd9Sstevel@tonic-gate 198*7c478bd9Sstevel@tonic-gate if (cfile) 199*7c478bd9Sstevel@tonic-gate print > cfile 200*7c478bd9Sstevel@tonic-gate if (privhfile) 201*7c478bd9Sstevel@tonic-gate print > privhfile 202*7c478bd9Sstevel@tonic-gate if (pubhfile) 203*7c478bd9Sstevel@tonic-gate print > pubhfile 204*7c478bd9Sstevel@tonic-gate if (pnamesfile) { 205*7c478bd9Sstevel@tonic-gate sub("^/\\*", "#") 206*7c478bd9Sstevel@tonic-gate sub("^ \\*/", "") 207*7c478bd9Sstevel@tonic-gate sub("^ \\*", "#") 208*7c478bd9Sstevel@tonic-gate if (/^$/) next; 209*7c478bd9Sstevel@tonic-gate print > pnamesfile 210*7c478bd9Sstevel@tonic-gate } 211*7c478bd9Sstevel@tonic-gate} 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gateEND { 214*7c478bd9Sstevel@tonic-gate 215*7c478bd9Sstevel@tonic-gate if (!pubhfile && !privhfile && !cfile && !pnamesfile) { 216*7c478bd9Sstevel@tonic-gate print "Output file parameter not set" > "/dev/stderr" 217*7c478bd9Sstevel@tonic-gate exit 1 218*7c478bd9Sstevel@tonic-gate } 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate setsize = int((npriv + slack)/(8 * 4)) + 1 221*7c478bd9Sstevel@tonic-gate maxnpriv = setsize * 8 * 4 222*7c478bd9Sstevel@tonic-gate # Assume allocated privileges are on average "NSDQ" bytes larger. 223*7c478bd9Sstevel@tonic-gate maxprivbytes = int((privbytes / npriv + 5.5)) * (maxnpriv - npriv) 224*7c478bd9Sstevel@tonic-gate maxprivbytes += privbytes 225*7c478bd9Sstevel@tonic-gate 226*7c478bd9Sstevel@tonic-gate if (cfile) { 227*7c478bd9Sstevel@tonic-gate print "\n" > cfile 228*7c478bd9Sstevel@tonic-gate print pragma "\n"> cfile 229*7c478bd9Sstevel@tonic-gate print "#include <sys/types.h>" > cfile 230*7c478bd9Sstevel@tonic-gate print "#include <sys/priv_const.h>" > cfile 231*7c478bd9Sstevel@tonic-gate print "#include <sys/priv_impl.h>" > cfile 232*7c478bd9Sstevel@tonic-gate print "#include <sys/priv.h>" > cfile 233*7c478bd9Sstevel@tonic-gate print "#include <sys/sysmacros.h>" > cfile 234*7c478bd9Sstevel@tonic-gate print "\n" > cfile 235*7c478bd9Sstevel@tonic-gate # 236*7c478bd9Sstevel@tonic-gate # Create the entire priv info structure here. 237*7c478bd9Sstevel@tonic-gate # When adding privileges, the kernel needs to update 238*7c478bd9Sstevel@tonic-gate # too many fields as the number of privileges is kept in 239*7c478bd9Sstevel@tonic-gate # many places. 240*7c478bd9Sstevel@tonic-gate # 241*7c478bd9Sstevel@tonic-gate print \ 242*7c478bd9Sstevel@tonic-gate "static struct _info {\n" \ 243*7c478bd9Sstevel@tonic-gate " priv_impl_info_t impl_info;\n" \ 244*7c478bd9Sstevel@tonic-gate " priv_info_t settype;\n" \ 245*7c478bd9Sstevel@tonic-gate " int nsets;\n" \ 246*7c478bd9Sstevel@tonic-gate " const char sets[" setbytes "];\n" \ 247*7c478bd9Sstevel@tonic-gate " priv_info_t privtype;\n" \ 248*7c478bd9Sstevel@tonic-gate " int nprivs;\n" \ 249*7c478bd9Sstevel@tonic-gate " char privs[" maxprivbytes "];\n" \ 250*7c478bd9Sstevel@tonic-gate " priv_info_t sysset;\n" \ 251*7c478bd9Sstevel@tonic-gate " priv_set_t basicset;\n" \ 252*7c478bd9Sstevel@tonic-gate "} info = {\n" \ 253*7c478bd9Sstevel@tonic-gate " { sizeof (priv_impl_info_t), 0, PRIV_NSET, " \ 254*7c478bd9Sstevel@tonic-gate "PRIV_SETSIZE, " npriv ",\n" \ 255*7c478bd9Sstevel@tonic-gate "\t\tsizeof (priv_info_uint_t),\n" \ 256*7c478bd9Sstevel@tonic-gate "\t\tsizeof (info) - sizeof (info.impl_info)},\n" \ 257*7c478bd9Sstevel@tonic-gate " { PRIV_INFO_SETNAMES,\n" \ 258*7c478bd9Sstevel@tonic-gate " offsetof(struct _info, privtype) - " \ 259*7c478bd9Sstevel@tonic-gate "offsetof(struct _info, settype)},\n\tPRIV_NSET," > cfile 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate sep = "\t\"" 262*7c478bd9Sstevel@tonic-gate len = 9; 263*7c478bd9Sstevel@tonic-gate for (i = 0; i < nset; i++) { 264*7c478bd9Sstevel@tonic-gate if (len + length(sets[i]) > 80) { 265*7c478bd9Sstevel@tonic-gate sep = "\\0\"\n\t\"" 266*7c478bd9Sstevel@tonic-gate len = 9 267*7c478bd9Sstevel@tonic-gate } 268*7c478bd9Sstevel@tonic-gate printf sep sets[i] > cfile 269*7c478bd9Sstevel@tonic-gate len += length(sets[i]) + length(sep); 270*7c478bd9Sstevel@tonic-gate sep = "\\0" 271*7c478bd9Sstevel@tonic-gate } 272*7c478bd9Sstevel@tonic-gate print "\\0\"," > cfile 273*7c478bd9Sstevel@tonic-gate 274*7c478bd9Sstevel@tonic-gate print "\t{ PRIV_INFO_PRIVNAMES,\n\t " \ 275*7c478bd9Sstevel@tonic-gate "offsetof(struct _info, sysset) - " \ 276*7c478bd9Sstevel@tonic-gate "offsetof(struct _info, privtype)},\n\t" npriv "," \ 277*7c478bd9Sstevel@tonic-gate > cfile 278*7c478bd9Sstevel@tonic-gate 279*7c478bd9Sstevel@tonic-gate sep = "\t\"" 280*7c478bd9Sstevel@tonic-gate len = 9; 281*7c478bd9Sstevel@tonic-gate for (i = 0; i < npriv; i++) { 282*7c478bd9Sstevel@tonic-gate if (len + length(privs[i]) > 80) { 283*7c478bd9Sstevel@tonic-gate sep = "\\0\"\n\t\"" 284*7c478bd9Sstevel@tonic-gate len = 9 285*7c478bd9Sstevel@tonic-gate } 286*7c478bd9Sstevel@tonic-gate printf sep privs[i] > cfile 287*7c478bd9Sstevel@tonic-gate len += length(privs[i]) + length(sep); 288*7c478bd9Sstevel@tonic-gate sep = "\\0" 289*7c478bd9Sstevel@tonic-gate } 290*7c478bd9Sstevel@tonic-gate print "\\0\"," > cfile 291*7c478bd9Sstevel@tonic-gate 292*7c478bd9Sstevel@tonic-gate print "\t{ PRIV_INFO_BASICPRIVS, sizeof (info) - " \ 293*7c478bd9Sstevel@tonic-gate "offsetof(struct _info, sysset)}," > cfile 294*7c478bd9Sstevel@tonic-gate 295*7c478bd9Sstevel@tonic-gate print "};\n" > cfile 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate print "\nconst char *priv_names[" maxnpriv "] =\n{" > cfile 298*7c478bd9Sstevel@tonic-gate for (i = 0; i < npriv; i++) 299*7c478bd9Sstevel@tonic-gate print "\t&info.privs[" privind[i] "]," > cfile 300*7c478bd9Sstevel@tonic-gate 301*7c478bd9Sstevel@tonic-gate print "};\n" > cfile 302*7c478bd9Sstevel@tonic-gate 303*7c478bd9Sstevel@tonic-gate print "\nconst char *priv_setnames[" nset "] =\n{" > cfile 304*7c478bd9Sstevel@tonic-gate for (i = 0; i < nset; i++) 305*7c478bd9Sstevel@tonic-gate print "\t&info.sets[" setind[i] "]," > cfile 306*7c478bd9Sstevel@tonic-gate 307*7c478bd9Sstevel@tonic-gate print "};\n" > cfile 308*7c478bd9Sstevel@tonic-gate 309*7c478bd9Sstevel@tonic-gate print "int nprivs = " npriv ";" > cfile 310*7c478bd9Sstevel@tonic-gate print "int privbytes = " privbytes ";" > cfile 311*7c478bd9Sstevel@tonic-gate print "int maxprivbytes = " maxprivbytes ";" > cfile 312*7c478bd9Sstevel@tonic-gate print "size_t privinfosize = sizeof (info);" > cfile 313*7c478bd9Sstevel@tonic-gate print "char *priv_str = info.privs;" > cfile 314*7c478bd9Sstevel@tonic-gate print "priv_set_t *priv_basic = &info.basicset;" > cfile 315*7c478bd9Sstevel@tonic-gate print "priv_impl_info_t *priv_info = &info.impl_info;" > cfile 316*7c478bd9Sstevel@tonic-gate print "priv_info_names_t *priv_ninfo = " \ 317*7c478bd9Sstevel@tonic-gate "(priv_info_names_t *)&info.privtype;" > cfile 318*7c478bd9Sstevel@tonic-gate close(cfile) 319*7c478bd9Sstevel@tonic-gate } 320*7c478bd9Sstevel@tonic-gate 321*7c478bd9Sstevel@tonic-gate # Kernel private 322*7c478bd9Sstevel@tonic-gate if (privhfile) { 323*7c478bd9Sstevel@tonic-gate print "#ifndef _SYS_PRIV_CONST_H" > privhfile 324*7c478bd9Sstevel@tonic-gate print "#define\t_SYS_PRIV_CONST_H\n" > privhfile 325*7c478bd9Sstevel@tonic-gate print pragma "\n"> privhfile 326*7c478bd9Sstevel@tonic-gate print "\n#include <sys/types.h>\n\n" > privhfile 327*7c478bd9Sstevel@tonic-gate print "#ifdef __cplusplus\nextern \"C\" {\n#endif\n" > privhfile 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate print "#if defined(_KERNEL) || defined(_KMEMUSER)" > privhfile 330*7c478bd9Sstevel@tonic-gate print "#define\tPRIV_NSET\t\t\t " nset > privhfile 331*7c478bd9Sstevel@tonic-gate print "#define\tPRIV_SETSIZE\t\t\t " setsize > privhfile 332*7c478bd9Sstevel@tonic-gate print "#endif\n\n#ifdef _KERNEL" > privhfile 333*7c478bd9Sstevel@tonic-gate print "#define\t__PRIV_CONST_IMPL\n" > privhfile 334*7c478bd9Sstevel@tonic-gate print "extern const char *priv_names[];" > privhfile 335*7c478bd9Sstevel@tonic-gate print "extern const char *priv_setnames[];" > privhfile 336*7c478bd9Sstevel@tonic-gate 337*7c478bd9Sstevel@tonic-gate print "extern int nprivs;" > privhfile 338*7c478bd9Sstevel@tonic-gate print "extern int privbytes;" > privhfile 339*7c478bd9Sstevel@tonic-gate print "extern int maxprivbytes;" > privhfile 340*7c478bd9Sstevel@tonic-gate print "extern size_t privinfosize;" > privhfile 341*7c478bd9Sstevel@tonic-gate print "extern char *priv_str;" > privhfile 342*7c478bd9Sstevel@tonic-gate print "extern struct priv_set *priv_basic;" > privhfile 343*7c478bd9Sstevel@tonic-gate print "extern struct priv_impl_info *priv_info;" > privhfile 344*7c478bd9Sstevel@tonic-gate print "extern struct priv_info_names *priv_ninfo;" > privhfile 345*7c478bd9Sstevel@tonic-gate 346*7c478bd9Sstevel@tonic-gate print "\n/* Privileges */" > privhfile 347*7c478bd9Sstevel@tonic-gate 348*7c478bd9Sstevel@tonic-gate for (i = 0; i < npriv; i++) 349*7c478bd9Sstevel@tonic-gate print pdef[i] sprintf("%3d", i) > privhfile 350*7c478bd9Sstevel@tonic-gate 351*7c478bd9Sstevel@tonic-gate print "\n/* Privilege sets */" > privhfile 352*7c478bd9Sstevel@tonic-gate for (i = 0; i < nset; i++) 353*7c478bd9Sstevel@tonic-gate print sdef[i] sprintf("%3d", i) > privhfile 354*7c478bd9Sstevel@tonic-gate 355*7c478bd9Sstevel@tonic-gate print "\n#define\tMAX_PRIVILEGE\t\t\t " setsize * 32 \ 356*7c478bd9Sstevel@tonic-gate > privhfile 357*7c478bd9Sstevel@tonic-gate 358*7c478bd9Sstevel@tonic-gate # Special privilege categories. 359*7c478bd9Sstevel@tonic-gate for (s in set) 360*7c478bd9Sstevel@tonic-gate print "\n#define\tPRIV_" s "_ASSERT(set)" set[s] \ 361*7c478bd9Sstevel@tonic-gate > privhfile 362*7c478bd9Sstevel@tonic-gate 363*7c478bd9Sstevel@tonic-gate print "\n#endif /* _KERNEL */" > privhfile 364*7c478bd9Sstevel@tonic-gate print "\n#ifdef __cplusplus\n}\n#endif" > privhfile 365*7c478bd9Sstevel@tonic-gate print "\n#endif /* _SYS_PRIV_CONST_H */" > privhfile 366*7c478bd9Sstevel@tonic-gate close(privhfile) 367*7c478bd9Sstevel@tonic-gate } 368*7c478bd9Sstevel@tonic-gate 369*7c478bd9Sstevel@tonic-gate if (pubhfile) { 370*7c478bd9Sstevel@tonic-gate cast="((const char *)" 371*7c478bd9Sstevel@tonic-gate print "#ifndef _SYS_PRIV_NAMES_H" > pubhfile 372*7c478bd9Sstevel@tonic-gate print "#define\t_SYS_PRIV_NAMES_H\n" > pubhfile 373*7c478bd9Sstevel@tonic-gate 374*7c478bd9Sstevel@tonic-gate print pragma "\n" > pubhfile 375*7c478bd9Sstevel@tonic-gate print "#ifdef __cplusplus\nextern \"C\" {\n#endif\n" > pubhfile 376*7c478bd9Sstevel@tonic-gate 377*7c478bd9Sstevel@tonic-gate print "#ifndef __PRIV_CONST_IMPL" > pubhfile 378*7c478bd9Sstevel@tonic-gate print "/*\n * Privilege names\n */" > pubhfile 379*7c478bd9Sstevel@tonic-gate for (i = 0; i < npriv; i++) { 380*7c478bd9Sstevel@tonic-gate print "/*\n" privcmt[i] " */" > pubhfile 381*7c478bd9Sstevel@tonic-gate print pdef[i] cast "\"" privs[i] "\")\n" > pubhfile 382*7c478bd9Sstevel@tonic-gate } 383*7c478bd9Sstevel@tonic-gate 384*7c478bd9Sstevel@tonic-gate print "" > pubhfile 385*7c478bd9Sstevel@tonic-gate 386*7c478bd9Sstevel@tonic-gate print "/*\n * Privilege set names\n */" > pubhfile 387*7c478bd9Sstevel@tonic-gate for (i = 0; i < nset; i++) { 388*7c478bd9Sstevel@tonic-gate print "/*\n" setcmt[i] " */" > pubhfile 389*7c478bd9Sstevel@tonic-gate print sdef[i] cast "\"" sets[i] "\")\n" > pubhfile 390*7c478bd9Sstevel@tonic-gate } 391*7c478bd9Sstevel@tonic-gate 392*7c478bd9Sstevel@tonic-gate print "\n#endif /* __PRIV_CONST_IMPL */" > pubhfile 393*7c478bd9Sstevel@tonic-gate print "\n#ifdef __cplusplus\n}\n#endif" > pubhfile 394*7c478bd9Sstevel@tonic-gate print "\n#endif /* _SYS_PRIV_NAMES_H */" > pubhfile 395*7c478bd9Sstevel@tonic-gate close(pubhfile) 396*7c478bd9Sstevel@tonic-gate } 397*7c478bd9Sstevel@tonic-gate 398*7c478bd9Sstevel@tonic-gate if (pnamesfile) { 399*7c478bd9Sstevel@tonic-gate print pnamescmt > pnamesfile 400*7c478bd9Sstevel@tonic-gate for (i = 0; i < npriv; i++) { 401*7c478bd9Sstevel@tonic-gate print privs[i] > pnamesfile 402*7c478bd9Sstevel@tonic-gate print privncmt[i] > pnamesfile 403*7c478bd9Sstevel@tonic-gate } 404*7c478bd9Sstevel@tonic-gate } 405*7c478bd9Sstevel@tonic-gate 406*7c478bd9Sstevel@tonic-gate} 407