xref: /freebsd/usr.sbin/pwd_mkdb/bootstrap/pwd.h (revision dfb98e350cd4d018417efa772a203229fe0bc1d0)
1*dfb98e35SAlex Richardson /*-
2*dfb98e35SAlex Richardson  * SPDX-License-Identifier: BSD-2-Clause
3*dfb98e35SAlex Richardson  *
4*dfb98e35SAlex Richardson  * Copyright 2018-2020 Alex Richardson <arichardson@FreeBSD.org>
5*dfb98e35SAlex Richardson  *
6*dfb98e35SAlex Richardson  * This software was developed by SRI International and the University of
7*dfb98e35SAlex Richardson  * Cambridge Computer Laboratory (Department of Computer Science and
8*dfb98e35SAlex Richardson  * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the
9*dfb98e35SAlex Richardson  * DARPA SSITH research programme.
10*dfb98e35SAlex Richardson  *
11*dfb98e35SAlex Richardson  * This software was developed by SRI International and the University of
12*dfb98e35SAlex Richardson  * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
13*dfb98e35SAlex Richardson  * ("CTSRD"), as part of the DARPA CRASH research programme.
14*dfb98e35SAlex Richardson  *
15*dfb98e35SAlex Richardson  * Redistribution and use in source and binary forms, with or without
16*dfb98e35SAlex Richardson  * modification, are permitted provided that the following conditions
17*dfb98e35SAlex Richardson  * are met:
18*dfb98e35SAlex Richardson  * 1. Redistributions of source code must retain the above copyright
19*dfb98e35SAlex Richardson  *    notice, this list of conditions and the following disclaimer.
20*dfb98e35SAlex Richardson  * 2. Redistributions in binary form must reproduce the above copyright
21*dfb98e35SAlex Richardson  *    notice, this list of conditions and the following disclaimer in the
22*dfb98e35SAlex Richardson  *    documentation and/or other materials provided with the distribution.
23*dfb98e35SAlex Richardson  *
24*dfb98e35SAlex Richardson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25*dfb98e35SAlex Richardson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26*dfb98e35SAlex Richardson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27*dfb98e35SAlex Richardson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
28*dfb98e35SAlex Richardson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29*dfb98e35SAlex Richardson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30*dfb98e35SAlex Richardson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31*dfb98e35SAlex Richardson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32*dfb98e35SAlex Richardson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33*dfb98e35SAlex Richardson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34*dfb98e35SAlex Richardson  * SUCH DAMAGE.
35*dfb98e35SAlex Richardson  *
36*dfb98e35SAlex Richardson  * $FreeBSD$
37*dfb98e35SAlex Richardson  */
38*dfb98e35SAlex Richardson 
39*dfb98e35SAlex Richardson /*
40*dfb98e35SAlex Richardson  * When building pwd_mkdb we need to use target systems definition of
41*dfb98e35SAlex Richardson  * struct passwd. This protects against future changes to struct passwd and
42*dfb98e35SAlex Richardson  * is essential to allow cross-building from Linux/macOS hosts since the
43*dfb98e35SAlex Richardson  * structure is not compatible there.
44*dfb98e35SAlex Richardson  */
45*dfb98e35SAlex Richardson #include <stdint.h>
46*dfb98e35SAlex Richardson #include <stddef.h>
47*dfb98e35SAlex Richardson /*
48*dfb98e35SAlex Richardson  * Note: pwd_mkdb always stores uint32_t for all integer fields (including
49*dfb98e35SAlex Richardson  * time_t!) so these definitions do not need to match sys/sys/_types.h
50*dfb98e35SAlex Richardson  */
51*dfb98e35SAlex Richardson typedef	uint32_t	_bootstrap_gid_t;
52*dfb98e35SAlex Richardson typedef	uint32_t	_bootstrap_uid_t;
53*dfb98e35SAlex Richardson typedef	uint64_t	_bootstrap_time_t;
54*dfb98e35SAlex Richardson #define	_GID_T_DECLARED
55*dfb98e35SAlex Richardson #define	_TIME_T_DECLARED
56*dfb98e35SAlex Richardson #define	_UID_T_DECLARED
57*dfb98e35SAlex Richardson #define	_SIZE_T_DECLARED
58*dfb98e35SAlex Richardson 
59*dfb98e35SAlex Richardson #define	gid_t	_bootstrap_gid_t
60*dfb98e35SAlex Richardson #define	uid_t	_bootstrap_uid_t
61*dfb98e35SAlex Richardson #define	time_t	_bootstrap_time_t
62*dfb98e35SAlex Richardson #define	passwd	_bootstrap_passwd
63*dfb98e35SAlex Richardson #include "../../include/pwd.h"
64*dfb98e35SAlex Richardson #undef gid_t
65*dfb98e35SAlex Richardson #undef uid_t
66*dfb98e35SAlex Richardson #undef time_t
67