Print this page
uts: add a concept of a 'default' set of privileges, separate from 'basic'
uts: give privilege macros more sensible names

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/privs.awk
          +++ new/usr/src/uts/common/os/privs.awk
↓ open down ↓ 99 lines elided ↑ open up ↑
 100  100  #
 101  101  # Privilege strings are represented as lower case strings;
 102  102  # PRIV_ is stripped from the strings.
 103  103  #
 104  104  /^([A-Za-z]* )?privilege / {
 105  105          if (NF == 3) {
 106  106                  key = toupper($1)
 107  107                  priv = toupper($3)
 108  108                  if (set[key] != "")
 109  109                          set[key] = set[key] ";"
 110      -                set[key] = set[key] "\\\n\t\tPRIV_ASSERT((set), " priv ")"
      110 +                set[key] = set[key] "\\\n\t\tPRIV_ADDSET((set), " priv ")"
 111  111          } else {
 112  112                  priv = toupper($2);
 113  113          }
 114  114          privs[npriv] = tolower(substr(priv, 6));
 115  115          inset = 0
 116  116          inpriv = 1
 117  117  
 118  118          privind[npriv] = privbytes;
 119  119  
 120  120          tabs = (32 - length(priv) - 1)/8
↓ open down ↓ 121 lines elided ↑ open up ↑
 242  242                      "static struct _info {\n" \
 243  243                      "   priv_impl_info_t        impl_info;\n" \
 244  244                      "   priv_info_t             settype;\n" \
 245  245                      "   int                     nsets;\n" \
 246  246                      "   const char              sets[" setbytes "];\n" \
 247  247                      "   priv_info_t             privtype;\n" \
 248  248                      "   int                     nprivs;\n" \
 249  249                      "   char                    privs[" maxprivbytes "];\n" \
 250  250                      "   priv_info_t             sysset;\n" \
 251  251                      "   priv_set_t              basicset;\n" \
      252 +                    "   priv_info_t             defset;\n" \
      253 +                    "   priv_set_t              defaultset;\n" \
 252  254                      "} info = {\n" \
 253  255                      "   { sizeof (priv_impl_info_t), 0, PRIV_NSET, " \
 254  256                          "PRIV_SETSIZE, " npriv ",\n" \
 255  257                          "\t\tsizeof (priv_info_uint_t),\n" \
 256  258                          "\t\tsizeof (info) - sizeof (info.impl_info)},\n" \
 257  259                      "   { PRIV_INFO_SETNAMES,\n" \
 258  260                      "       offsetof(struct _info, privtype) - " \
 259  261                      "offsetof(struct _info, settype)},\n\tPRIV_NSET," > cfile
 260  262  
 261  263                  sep = "\t\""
↓ open down ↓ 20 lines elided ↑ open up ↑
 282  284                          if (len + length(privs[i]) > 80) {
 283  285                                  sep = "\\0\"\n\t\""
 284  286                                  len = 9
 285  287                          }
 286  288                          printf sep privs[i]  > cfile
 287  289                          len += length(privs[i]) + length(sep);
 288  290                          sep = "\\0"
 289  291                  }
 290  292                  print "\\0\"," > cfile
 291  293  
 292      -                print "\t{ PRIV_INFO_BASICPRIVS, sizeof (info) - " \
 293      -                        "offsetof(struct _info, sysset)},"  > cfile
      294 +                print "\t{ PRIV_INFO_BASICPRIVS, offsetof (struct _info, defset) - " \
      295 +                    "offsetof(struct _info, sysset)},"  > cfile
      296 +                print "\t{ 0 },\n" > cfile
      297 +                print "\t{ PRIV_INFO_DEFAULTPRIVS, sizeof (info) - " \
      298 +                    "offsetof(struct _info, defset)}" > cfile
 294  299  
 295  300                  print "};\n" > cfile
 296  301  
 297  302                  print "\nconst char *priv_names[" maxnpriv "] =\n{" > cfile
 298  303                  for (i = 0; i < npriv; i++)
 299  304                          print "\t&info.privs[" privind[i] "]," > cfile
 300  305  
 301  306                  print "};\n" > cfile
 302  307  
 303  308                  print "\nconst char *priv_setnames[" nset "] =\n{" > cfile
↓ open down ↓ 1 lines elided ↑ open up ↑
 305  310                          print "\t&info.sets[" setind[i] "]," > cfile
 306  311  
 307  312                  print "};\n" > cfile
 308  313  
 309  314                  print "int nprivs = " npriv ";" > cfile
 310  315                  print "int privbytes = " privbytes ";" > cfile
 311  316                  print "int maxprivbytes = " maxprivbytes ";" > cfile
 312  317                  print "size_t privinfosize = sizeof (info);" > cfile
 313  318                  print "char *priv_str = info.privs;" > cfile
 314  319                  print "priv_set_t *priv_basic = &info.basicset;" > cfile
      320 +                print "priv_set_t *priv_default = &info.defaultset;" > cfile
 315  321                  print "priv_impl_info_t *priv_info = &info.impl_info;" > cfile
 316  322                  print "priv_info_names_t *priv_ninfo = " \
 317  323                          "(priv_info_names_t *)&info.privtype;" > cfile
 318  324                  close(cfile)
 319  325          }
 320  326  
 321  327          # Kernel private
 322  328          if (privhfile) {
 323  329                  print "#ifndef _SYS_PRIV_CONST_H" > privhfile
 324  330                  print "#define\t_SYS_PRIV_CONST_H\n" > privhfile
↓ open down ↓ 8 lines elided ↑ open up ↑
 333  339                  print "#define\t__PRIV_CONST_IMPL\n" > privhfile
 334  340                  print "extern const char *priv_names[];" > privhfile
 335  341                  print "extern const char *priv_setnames[];" > privhfile
 336  342  
 337  343                  print "extern int nprivs;" > privhfile
 338  344                  print "extern int privbytes;" > privhfile
 339  345                  print "extern int maxprivbytes;" > privhfile
 340  346                  print "extern size_t privinfosize;" > privhfile
 341  347                  print "extern char *priv_str;" > privhfile
 342  348                  print "extern struct priv_set *priv_basic;" > privhfile
      349 +                print "extern struct priv_set *priv_default;" > privhfile
 343  350                  print "extern struct priv_impl_info *priv_info;" > privhfile
 344  351                  print "extern struct priv_info_names *priv_ninfo;" > privhfile
 345  352  
 346  353                  print "\n/* Privileges */" > privhfile
 347  354                   
 348  355                  for (i = 0; i < npriv; i++)
 349  356                          print pdef[i] sprintf("%3d", i) > privhfile
 350  357  
 351  358                  print "\n/* Privilege sets */" > privhfile
 352  359                  for (i = 0; i < nset; i++)
 353  360                          print sdef[i] sprintf("%3d", i) > privhfile
 354  361  
 355  362                  print "\n#define\tMAX_PRIVILEGE\t\t\t "  setsize * 32 \
 356  363                          > privhfile
 357  364  
 358  365                  # Special privilege categories.
 359  366                  for (s in set)
 360      -                        print "\n#define\tPRIV_" s "_ASSERT(set)" set[s] \
      367 +                        print "\n#define\tPRIV_" s "_ADDSET(set)" set[s] \
 361  368                                  > privhfile
 362  369  
 363  370                  print "\n#endif /* _KERNEL */" > privhfile
 364  371                  print "\n#ifdef __cplusplus\n}\n#endif" > privhfile
 365  372                  print "\n#endif /* _SYS_PRIV_CONST_H */" > privhfile
 366  373                  close(privhfile)
 367  374          }
 368  375  
 369  376          if (pubhfile) {
 370  377                  cast="((const char *)"
↓ open down ↓ 36 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX