/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
/*
* utmpx.c - utmpx utility routines
*
* Since svc.startd(1M) places utmpx records for its launched instances, it must
* also mark them as dead once completed.
*/
#include <errno.h>
#include <pthread.h>
#include <sac.h>
#include <string.h>
#include <strings.h>
#include <time.h>
#include <unistd.h>
#include <utmpx.h>
#include <fcntl.h>
#include "startd.h"
static int n_prev[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
static int utmpx_truncated = 0;
int
{
int tmplen;
int ret;
/*
* Clean out any preexisting records for this PID, as they must be
* inaccurate.
*/
/*
* Construct a new record with the appropriate prefix.
*/
for (;;) {
setutxent();
/*
* Copy in the old "line" and "host" fields.
*/
}
break;
(void) sleep(1);
}
endutxent();
return (ret);
}
void
{
int logged = 0;
for (;;) {
int found = 0;
setutxent();
found = 1;
/*
* Cleaned up elsewhere.
*/
endutxent();
return;
}
/*
* Now attempt to add to the end of the
* wtmp and wtmpx files. Do not create
* if they don't already exist.
*/
endutxent();
return;
}
}
}
endutxent();
return;
if (!logged) {
"%ld\n", pid);
logged++;
}
(void) sleep(1);
}
}
static void
{
S_IROTH);
S_IROTH);
}
/*
* Retrieve the runlevel utmpx entry if there is one; used to recover
* state when svc.startd is restarted.
*/
char
utmpx_get_runlevel(void)
{
setutxent();
break;
}
endutxent();
return (rl);
}
void
{
struct utmpx u;
int i;
if (runlevel == 's')
runlevel = 'S';
if (oldrl == 's')
oldrl = 'S';
u.ut_pid = 0;
setutxent();
if (tmplen)
else
u.ut_syslen = 0;
}
if (oldrl != '\0')
else
for (i = 0; rlevels[i] != '\0'; ++i) {
break;
}
if (do_bump) {
for (i = 0; rlevels[i] != '\0'; ++i) {
break;
}
++n_prev[i];
}
if (pututxline(&u) == NULL) {
endutxent();
return;
}
updwtmpx(WTMPX_FILE, &u);
endutxent();
utmpx_check();
}
static void
{
struct utmpx u;
u.ut_pid = 0;
setutxent();
if (tmplen)
else
u.ut_syslen = 0;
}
if (pututxline(&u) == NULL) {
endutxent();
return;
}
updwtmpx(WTMPX_FILE, &u);
endutxent();
utmpx_check();
}
void
utmpx_write_boottime(void)
{
/*
* The DOWN_TIME record tracks when the OS became unavailable
* during the previous boot. We stat(2) WTMPX and check its
* attributes to determine when (and how) the OS became
* unavailable. If the file is empty, skip writing a DOWN_TIME
* record. Otherwise, check the access and modify times and
* use whichever is latest as the time that the OS became
* unavailable. If st_atime is latest, the instance crashed or
* the machine lost power. If st_mtime is latest, the shutdown
* was controlled.
*/
}
/*
* The boot time (or start time, for a non-global zone) is retrieved in
* log_init().
*/
}
/*
* void utmpx_clear_old(void)
* At boot and only at boot, truncate the utmpx file.
*
*/
void
utmpx_clear_old(void)
{
int fd;
return;
} else {
}
utmpx_truncated = 1;
}
void
{
}
void
{
/*
* The libc utmpx routines are entirely MT-unsafe; we must assure
* that no other thread is in these routines when we fork lest we
* leave the child with inconsistent library state.
*/
}
void
{
}