コード例 #1
0
struct utmpx *
getutxid(const struct utmpx *id)
{
	struct futx fu;

	for (;;) {
		if (getfutxent(&fu) != 0)
			return (NULL);

		switch (fu.fu_type) {
		case USER_PROCESS:
		case INIT_PROCESS:
		case LOGIN_PROCESS:
		case DEAD_PROCESS:
			switch (id->ut_type) {
			case USER_PROCESS:
			case INIT_PROCESS:
			case LOGIN_PROCESS:
			case DEAD_PROCESS:
				if (memcmp(fu.fu_id, id->ut_id,
				    MIN(sizeof(fu.fu_id), sizeof(id->ut_id))) ==
				    0)
					goto found;
			}
			break;
		default:
			if (fu.fu_type == id->ut_type)
				goto found;
			break;
		}
	}

found:
	return (futx_to_utx(&fu));
}
コード例 #2
0
struct utmpx *
getutxent(void)
{
	struct futx fu;

	if (getfutxent(&fu) != 0)
		return (NULL);
	return (futx_to_utx(&fu));
}
コード例 #3
0
ファイル: pututxline.c プロジェクト: AhmadTux/freebsd
struct utmpx *
pututxline(const struct utmpx *utmpx)
{
	struct futx fu;
	int bad;

	bad = 0;

	utx_to_futx(utmpx, &fu);

	switch (fu.fu_type) {
	case BOOT_TIME:
		utx_active_init(&fu);
		utx_lastlogin_upgrade();
		break;
	case SHUTDOWN_TIME:
		utx_active_purge();
		break;
	case OLD_TIME:
	case NEW_TIME:
		break;
	case USER_PROCESS:
		bad |= utx_active_add(&fu);
		bad |= utx_lastlogin_add(&fu);
		break;
#if 0 /* XXX: Are these records of any use to us? */
	case INIT_PROCESS:
	case LOGIN_PROCESS:
		bad |= utx_active_add(&fu);
		break;
#endif
	case DEAD_PROCESS:
		/*
		 * In case writing a logout entry fails, never attempt
		 * to write it to utx.log.  The logout entry's ut_id
		 * might be invalid.
		 */
		if (utx_active_remove(&fu) != 0)
			return (NULL);
		break;
	default:
		errno = EINVAL;
		return (NULL);
	}

	bad |= utx_log_add(&fu);
	return (bad ? NULL : futx_to_utx(&fu));
}
コード例 #4
0
struct utmpx *
getutxuser(const char *user)
{
	struct futx fu;

	for (;;) {
		if (getfutxent(&fu) != 0)
			return (NULL);

		switch (fu.fu_type) {
		case USER_PROCESS:
			if (strncmp(fu.fu_user, user, sizeof(fu.fu_user)) == 0)
				goto found;
			break;
		}
	}

found:
	return (futx_to_utx(&fu));
}
コード例 #5
0
struct utmpx *
getutxline(const struct utmpx *line)
{
	struct futx fu;

	for (;;) {
		if (getfutxent(&fu) != 0)
			return (NULL);

		switch (fu.fu_type) {
		case USER_PROCESS:
		case LOGIN_PROCESS:
			if (strncmp(fu.fu_line, line->ut_line,
			    MIN(sizeof(fu.fu_line), sizeof(line->ut_line))) ==
			    0)
				goto found;
			break;
		}
	}

found:
	return (futx_to_utx(&fu));
}