12208eadfSEd Schouten /*- 22208eadfSEd Schouten * Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org> 32208eadfSEd Schouten * All rights reserved. 42208eadfSEd Schouten * 52208eadfSEd Schouten * Redistribution and use in source and binary forms, with or without 62208eadfSEd Schouten * modification, are permitted provided that the following conditions 72208eadfSEd Schouten * are met: 82208eadfSEd Schouten * 1. Redistributions of source code must retain the above copyright 92208eadfSEd Schouten * notice, this list of conditions and the following disclaimer. 102208eadfSEd Schouten * 2. Redistributions in binary form must reproduce the above copyright 112208eadfSEd Schouten * notice, this list of conditions and the following disclaimer in the 122208eadfSEd Schouten * documentation and/or other materials provided with the distribution. 132208eadfSEd Schouten * 142208eadfSEd Schouten * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 152208eadfSEd Schouten * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 162208eadfSEd Schouten * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 172208eadfSEd Schouten * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 182208eadfSEd Schouten * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 192208eadfSEd Schouten * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 202208eadfSEd Schouten * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 212208eadfSEd Schouten * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 222208eadfSEd Schouten * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 232208eadfSEd Schouten * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 242208eadfSEd Schouten * SUCH DAMAGE. 252208eadfSEd Schouten * 262208eadfSEd Schouten * $FreeBSD$ 272208eadfSEd Schouten */ 282208eadfSEd Schouten 292208eadfSEd Schouten #ifndef _ULOG_H_ 302208eadfSEd Schouten #define _ULOG_H_ 312208eadfSEd Schouten 322208eadfSEd Schouten #include <sys/cdefs.h> 332208eadfSEd Schouten #include <sys/_timeval.h> 342208eadfSEd Schouten 352208eadfSEd Schouten /* 362208eadfSEd Schouten * libulog. 372208eadfSEd Schouten * 382208eadfSEd Schouten * This library is provided as a migratory tool towards <utmpx.h>. We 392208eadfSEd Schouten * cannot yet implement <utmpx.h>, because our on-disk file format lacks 402208eadfSEd Schouten * various fields. <utmpx.h> also has some shortcomings. Ideally we 412208eadfSEd Schouten * want to allow logging of user login records generated by unprivileged 422208eadfSEd Schouten * processes as well, provided that they hold a file descriptor to a 432208eadfSEd Schouten * pseudo-terminal master device. 442208eadfSEd Schouten * 452208eadfSEd Schouten * Unlike struct utmpx, the buffers containing the strings are not 462208eadfSEd Schouten * stored inside struct ulog_utmpx itself. Processes should never 472208eadfSEd Schouten * handcraft these structures anyway. 482208eadfSEd Schouten * 492208eadfSEd Schouten * This library (or at least parts of it) will hopefully deprecate over 502208eadfSEd Schouten * time, when we provide the <utmpx.h> API. 512208eadfSEd Schouten */ 522208eadfSEd Schouten 532208eadfSEd Schouten #define _UTX_USERDISPSIZE 16 542208eadfSEd Schouten #define _UTX_LINEDISPSIZE 8 552208eadfSEd Schouten #define _UTX_HOSTDISPSIZE 16 562208eadfSEd Schouten 572208eadfSEd Schouten struct ulog_utmpx { 582208eadfSEd Schouten char *ut_user; 592208eadfSEd Schouten #if 0 602208eadfSEd Schouten char *ut_id; 612208eadfSEd Schouten #endif 622208eadfSEd Schouten char *ut_line; 632208eadfSEd Schouten char *ut_host; 642208eadfSEd Schouten #if 0 652208eadfSEd Schouten pid_t ut_pid; 662208eadfSEd Schouten short ut_type; 672208eadfSEd Schouten #endif 682208eadfSEd Schouten struct timeval ut_tv; 692208eadfSEd Schouten }; 702208eadfSEd Schouten 712208eadfSEd Schouten __BEGIN_DECLS 722208eadfSEd Schouten void ulog_endutxent(void); 732208eadfSEd Schouten struct ulog_utmpx *ulog_getutxent(void); 742208eadfSEd Schouten #if 0 752208eadfSEd Schouten struct ulog_utmpx *ulog_getutxid(const struct ulog_utmpx *id); 762208eadfSEd Schouten struct ulog_utmpx *ulog_getutxline(const struct ulog_utmpx *line); 772208eadfSEd Schouten struct ulog_utmpx *ulog_pututxline(const struct ulog_utmpx *utmpx); 782208eadfSEd Schouten #endif 792208eadfSEd Schouten void ulog_setutxent(void); 802208eadfSEd Schouten 812208eadfSEd Schouten void ulog_login(const char *, const char *, const char *); 822208eadfSEd Schouten void ulog_login_pseudo(int, const char *); 832208eadfSEd Schouten void ulog_logout(const char *); 842208eadfSEd Schouten void ulog_logout_pseudo(int); 852208eadfSEd Schouten __END_DECLS 862208eadfSEd Schouten 872208eadfSEd Schouten #endif /* !_ULOG_H_ */ 88