Print this page
OS-2837 lx brand only works with shared IP stacks

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_door.c
          +++ new/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_door.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
       24 + * Copyright 2014, Joyent, Inc. All rights reserved.
  24   25   */
  25   26  
  26   27  /*
  27   28   * Main door handler functions used by ipmgmtd to process the different door
  28   29   * call requests, issued by the library libipadm.so.
  29   30   */
  30   31  
  31   32  #include <alloca.h>
  32   33  #include <pwd.h>
  33   34  #include <auth_attr.h>
↓ open down ↓ 71 lines elided ↑ open up ↑
 105  106                          break;
 106  107                  }
 107  108          }
 108  109  
 109  110          if (infop == NULL) {
 110  111                  ipmgmt_log(LOG_ERR, "Invalid door command specified");
 111  112                  err = EINVAL;
 112  113                  goto fail;
 113  114          }
 114  115  
 115      -        /* check for solaris.network.interface.config authorization */
      116 +        /*
      117 +         * if not root, check for solaris.network.interface.config authorization
      118 +         */
 116  119          if (infop->idi_set) {
 117  120                  uid_t           uid;
 118  121                  struct passwd   pwd;
 119  122                  char            buf[1024];
 120  123  
 121  124                  if (door_ucred(&cred) != 0) {
 122  125                          err = errno;
 123  126                          ipmgmt_log(LOG_ERR, "Could not get user credentials.");
 124  127                          goto fail;
 125  128                  }
 126  129                  uid = ucred_getruid(cred);
      130 +                ucred_free(cred);
 127  131                  if ((int)uid < 0) {
 128  132                          err = errno;
 129  133                          ipmgmt_log(LOG_ERR, "Could not get user id.");
 130  134                          goto fail;
 131  135                  }
 132      -                if (getpwuid_r(uid, &pwd, buf, sizeof (buf)) ==
 133      -                    NULL) {
 134      -                        err = errno;
 135      -                        ipmgmt_log(LOG_ERR, "Could not get password entry.");
 136      -                        goto fail;
      136 +
      137 +                /*
      138 +                 * Branded zones may have different auth, but root always
      139 +                 * allowed.
      140 +                 */
      141 +                if (uid != 0) {
      142 +                        if (getpwuid_r(uid, &pwd, buf, sizeof (buf)) == NULL) {
      143 +                                err = errno;
      144 +                                ipmgmt_log(LOG_ERR,
      145 +                                    "Could not get password entry.");
      146 +                                goto fail;
      147 +                        }
      148 +                        if (chkauthattr(NETWORK_INTERFACE_CONFIG_AUTH,
      149 +                            pwd.pw_name) != 1) {
      150 +                                err = EPERM;
      151 +                                ipmgmt_log(LOG_ERR,
      152 +                                    "Not authorized for operation.");
      153 +                                goto fail;
      154 +                        }
 137  155                  }
 138      -                if (chkauthattr(NETWORK_INTERFACE_CONFIG_AUTH,
 139      -                    pwd.pw_name) != 1) {
 140      -                        err = EPERM;
 141      -                        ipmgmt_log(LOG_ERR, "Not authorized for operation.");
 142      -                        goto fail;
 143      -                }
 144      -                ucred_free(cred);
 145  156          }
 146  157  
 147  158          /* individual handlers take care of calling door_return */
 148  159          infop->idi_handler((void *)argp);
 149  160          return;
 150  161  fail:
 151  162          ucred_free(cred);
 152  163          retval.ir_err = err;
 153  164          (void) door_return((char *)&retval, sizeof (retval), NULL, 0);
 154  165  }
↓ open down ↓ 710 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX