Print this page
3946 ::gcore
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>


   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 /*
  27  * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  28  * Copyright (c) 2013, Joyent, Inc. All rights reserved.

  29  */
  30 
  31 #define _STRUCTURED_PROC        1
  32 
  33 #include <stdlib.h>
  34 #include <ctype.h>
  35 #include <string.h>
  36 #include <strings.h>
  37 #include <errno.h>
  38 #include <procfs.h>
  39 #include <priv.h>
  40 #include <sys/elf.h>
  41 #include <sys/machelf.h>
  42 #include <sys/sysmacros.h>
  43 #include <sys/systeminfo.h>
  44 #include <sys/proc.h>
  45 #include <sys/utsname.h>
  46 
  47 #include <sys/old_procfs.h>
  48 


1340                 size_t size = sizeof (prcred_t);
1341 
1342                 if (Pcred(P, &cred, 0) != 0)
1343                         goto err;
1344 
1345                 if (cred.pr_ngroups > 0)
1346                         size += sizeof (gid_t) * (cred.pr_ngroups - 1);
1347                 if ((cp = malloc(size)) == NULL)
1348                         goto err;
1349 
1350                 if (Pcred(P, cp, cred.pr_ngroups) != 0 ||
1351                     write_note(fd, NT_PRCRED, cp, size, &doff) != 0) {
1352                         free(cp);
1353                         goto err;
1354                 }
1355 
1356                 free(cp);
1357         }
1358 
1359         {
1360                 prpriv_t *ppriv;
1361                 const priv_impl_info_t *pinfo;
1362                 size_t pprivsz, pinfosz;
1363 
1364                 if ((ppriv = proc_get_priv(P->pid)) == NULL)
1365                         goto err;
1366                 pprivsz = PRIV_PRPRIV_SIZE(ppriv);
1367 
1368                 if (write_note(fd, NT_PRPRIV, ppriv, pprivsz, &doff) != 0) {
1369                         free(ppriv);
1370                         goto err;
1371                 }
1372                 free(ppriv);
1373 
1374                 if ((pinfo = getprivimplinfo()) == NULL)
1375                         goto err;
1376                 pinfosz = PRIV_IMPL_INFO_SIZE(pinfo);
1377 
1378                 if (write_note(fd, NT_PRPRIVINFO, pinfo, pinfosz, &doff) != 0)
1379                         goto err;
1380         }
1381 
1382         if (write_note(fd, NT_ZONENAME, zonename, strlen(zonename) + 1,
1383             &doff) != 0)
1384                 goto err;




   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 /*
  27  * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  28  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  29  * Copyright (c) 2013 by Delphix. All rights reserved.
  30  */
  31 
  32 #define _STRUCTURED_PROC        1
  33 
  34 #include <stdlib.h>
  35 #include <ctype.h>
  36 #include <string.h>
  37 #include <strings.h>
  38 #include <errno.h>
  39 #include <procfs.h>
  40 #include <priv.h>
  41 #include <sys/elf.h>
  42 #include <sys/machelf.h>
  43 #include <sys/sysmacros.h>
  44 #include <sys/systeminfo.h>
  45 #include <sys/proc.h>
  46 #include <sys/utsname.h>
  47 
  48 #include <sys/old_procfs.h>
  49 


1341                 size_t size = sizeof (prcred_t);
1342 
1343                 if (Pcred(P, &cred, 0) != 0)
1344                         goto err;
1345 
1346                 if (cred.pr_ngroups > 0)
1347                         size += sizeof (gid_t) * (cred.pr_ngroups - 1);
1348                 if ((cp = malloc(size)) == NULL)
1349                         goto err;
1350 
1351                 if (Pcred(P, cp, cred.pr_ngroups) != 0 ||
1352                     write_note(fd, NT_PRCRED, cp, size, &doff) != 0) {
1353                         free(cp);
1354                         goto err;
1355                 }
1356 
1357                 free(cp);
1358         }
1359 
1360         {
1361                 prpriv_t *ppriv = NULL;
1362                 const priv_impl_info_t *pinfo;
1363                 size_t pprivsz, pinfosz;
1364 
1365                 if (Ppriv(P, &ppriv) == -1)
1366                         goto err;
1367                 pprivsz = PRIV_PRPRIV_SIZE(ppriv);
1368 
1369                 if (write_note(fd, NT_PRPRIV, ppriv, pprivsz, &doff) != 0) {
1370                         free(ppriv);
1371                         goto err;
1372                 }
1373                 free(ppriv);
1374 
1375                 if ((pinfo = getprivimplinfo()) == NULL)
1376                         goto err;
1377                 pinfosz = PRIV_IMPL_INFO_SIZE(pinfo);
1378 
1379                 if (write_note(fd, NT_PRPRIVINFO, pinfo, pinfosz, &doff) != 0)
1380                         goto err;
1381         }
1382 
1383         if (write_note(fd, NT_ZONENAME, zonename, strlen(zonename) + 1,
1384             &doff) != 0)
1385                 goto err;