Print this page
3124 Remove any existing references to utmp, use utmpx instead


 297 
 298         if (zid != getzoneid()) {
 299                 root[0] = '\0';
 300                 (void) getzonenamebyid(zid, zonename, ZONENAME_MAX);
 301                 (void) zone_get_rootpath(zonename, root, sizeof (root));
 302                 (void) strlcat(root, UTMPX_FILE, sizeof (root));
 303                 if (!utmpxname(root)) {
 304                         (void) fprintf(stderr, "Cannot open %s\n", root);
 305                         return;
 306                 }
 307         } else {
 308                 (void) utmpxname(UTMPX_FILE);
 309         }
 310         setutxent();
 311         while ((p = getutxent()) != NULL) {
 312                 if (p->ut_type != USER_PROCESS)
 313                         continue;
 314                 /*
 315                  * if (-a option OR NOT pty window login), send the message
 316                  */
 317                 if (aflag || !nonuser(*p))
 318                         sendmes(p, zid);
 319         }
 320         endutxent();
 321 
 322         (void) alarm(60);
 323         do {
 324                 i = (int)wait((int *)0);
 325         } while (i != -1 || errno != ECHILD);
 326 
 327 }
 328 
 329 /*
 330  * Note to future maintainers: with the change of wall to use the
 331  * getutxent() API, the forked children (created by this function)
 332  * must call _exit as opposed to exit. This is necessary to avoid
 333  * unwanted fflushing of getutxent's stdio stream (caused by atexit
 334  * processing).
 335  */
 336 static void
 337 sendmes(struct utmpx *p, zoneid_t zid)




 297 
 298         if (zid != getzoneid()) {
 299                 root[0] = '\0';
 300                 (void) getzonenamebyid(zid, zonename, ZONENAME_MAX);
 301                 (void) zone_get_rootpath(zonename, root, sizeof (root));
 302                 (void) strlcat(root, UTMPX_FILE, sizeof (root));
 303                 if (!utmpxname(root)) {
 304                         (void) fprintf(stderr, "Cannot open %s\n", root);
 305                         return;
 306                 }
 307         } else {
 308                 (void) utmpxname(UTMPX_FILE);
 309         }
 310         setutxent();
 311         while ((p = getutxent()) != NULL) {
 312                 if (p->ut_type != USER_PROCESS)
 313                         continue;
 314                 /*
 315                  * if (-a option OR NOT pty window login), send the message
 316                  */
 317                 if (aflag || !nonuserx(*p))
 318                         sendmes(p, zid);
 319         }
 320         endutxent();
 321 
 322         (void) alarm(60);
 323         do {
 324                 i = (int)wait((int *)0);
 325         } while (i != -1 || errno != ECHILD);
 326 
 327 }
 328 
 329 /*
 330  * Note to future maintainers: with the change of wall to use the
 331  * getutxent() API, the forked children (created by this function)
 332  * must call _exit as opposed to exit. This is necessary to avoid
 333  * unwanted fflushing of getutxent's stdio stream (caused by atexit
 334  * processing).
 335  */
 336 static void
 337 sendmes(struct utmpx *p, zoneid_t zid)