Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/nscd/nscd_selfcred.c
          +++ new/usr/src/cmd/nscd/nscd_selfcred.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright 2012 Milan Jurik. All rights reserved.
       25 + * Copyright 2018 Joyent Inc.
  25   26   */
  26   27  
  27   28  #include <stdio.h>
  28   29  #include <stdlib.h>
  29   30  #include <synch.h>
  30   31  #include <thread.h>
  31   32  #include <string.h>
  32   33  #include <errno.h>
  33   34  #include <dlfcn.h>
  34   35  #include <door.h>
↓ open down ↓ 383 lines elided ↑ open up ↑
 418  419  
 419  420  /*ARGSUSED*/
 420  421  static void *
 421  422  forker_monitor(
 422  423          void            *arg)
 423  424  {
 424  425          pid_t           fpid;
 425  426          char            *fmri;
 426  427          char            *me = "forker_monitor";
 427  428  
      429 +        (void) thr_setname(thr_self(), me);
      430 +
 428  431          /* wait until forker exits */
 429  432          fpid = forker_pid;
 430  433          (void) selfcred_pulse(forking_door);
 431  434  
 432  435          _NSCD_LOG(NSCD_LOG_SELF_CRED, NSCD_LOG_LEVEL_DEBUG)
 433  436          (me, "forker (pid = %d) exited or crashed, "
 434  437              "killing all child processes\n", fpid);
 435  438  
 436  439          (void) mutex_lock(&forking_lock);
 437  440          forking_door = -1;
↓ open down ↓ 971 lines elided ↑ open up ↑
1409 1412  }
1410 1413  
1411 1414  static int
1412 1415  check_uid(char *pid_name)
1413 1416  {
1414 1417          char            pname[PATH_MAX];
1415 1418          static pid_t    pid = 0;
1416 1419          static uid_t    uid = 0;
1417 1420          static uid_t    euid = 0;
1418 1421          int             pfd; /* file descriptor for /proc/<pid>/psinfo */
1419      -        psinfo_t        info;  /* process information from /proc */
     1422 +        psinfo_t        info;  /* process information from /proc */
1420 1423  
1421 1424          if (uid == 0)  {
1422 1425                  pid = getpid();
1423 1426                  uid = getuid();
1424 1427                  euid = geteuid();
1425 1428          }
1426 1429  
1427 1430          (void) snprintf(pname, sizeof (pname), "/proc/%s/psinfo", pid_name);
1428 1431  retry:
1429 1432          if ((pfd = open(pname, O_RDONLY)) == -1) {
↓ open down ↓ 29 lines elided ↑ open up ↑
1459 1462  /*ARGSUSED*/
1460 1463  static void *
1461 1464  check_user_process(void *arg)
1462 1465  {
1463 1466  
1464 1467          DIR             *dp;
1465 1468          struct dirent   *ep;
1466 1469          int             found;
1467 1470          char            *me = "check_user_process";
1468 1471  
     1472 +        (void) thr_setname(thr_self(), me);
     1473 +
1469 1474          for (;;) {
1470 1475                  (void) sleep(60);
1471 1476  
1472 1477                  found = 0;
1473 1478  
1474 1479                  /*
1475 1480                   * search the /proc directory and look at each process
1476 1481                   */
1477 1482                  if ((dp = opendir("/proc")) == NULL) {
1478 1483                          _NSCD_LOG(NSCD_LOG_SELF_CRED, NSCD_LOG_LEVEL_ERROR)
↓ open down ↓ 101 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX