1*0c3983b2SBen Gras /* $NetBSD: compat_passwd.c,v 1.2 2009/01/11 02:57:18 christos Exp $ */
2*0c3983b2SBen Gras
3*0c3983b2SBen Gras /*-
4*0c3983b2SBen Gras * Copyright (c) 2008 The NetBSD Foundation, Inc.
5*0c3983b2SBen Gras * All rights reserved.
6*0c3983b2SBen Gras *
7*0c3983b2SBen Gras * This code is derived from software contributed to The NetBSD Foundation
8*0c3983b2SBen Gras * by Christos Zoulas.
9*0c3983b2SBen Gras *
10*0c3983b2SBen Gras * Redistribution and use in source and binary forms, with or without
11*0c3983b2SBen Gras * modification, are permitted provided that the following conditions
12*0c3983b2SBen Gras * are met:
13*0c3983b2SBen Gras * 1. Redistributions of source code must retain the above copyright
14*0c3983b2SBen Gras * notice, this list of conditions and the following disclaimer.
15*0c3983b2SBen Gras * 2. Redistributions in binary form must reproduce the above copyright
16*0c3983b2SBen Gras * notice, this list of conditions and the following disclaimer in the
17*0c3983b2SBen Gras * documentation and/or other materials provided with the distribution.
18*0c3983b2SBen Gras * 3. All advertising materials mentioning features or use of this software
19*0c3983b2SBen Gras * must display the following acknowledgement:
20*0c3983b2SBen Gras * This product includes software developed by the NetBSD
21*0c3983b2SBen Gras * Foundation, Inc. and its contributors.
22*0c3983b2SBen Gras * 4. Neither the name of The NetBSD Foundation nor the names of its
23*0c3983b2SBen Gras * contributors may be used to endorse or promote products derived
24*0c3983b2SBen Gras * from this software without specific prior written permission.
25*0c3983b2SBen Gras *
26*0c3983b2SBen Gras * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27*0c3983b2SBen Gras * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28*0c3983b2SBen Gras * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29*0c3983b2SBen Gras * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30*0c3983b2SBen Gras * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31*0c3983b2SBen Gras * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32*0c3983b2SBen Gras * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33*0c3983b2SBen Gras * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34*0c3983b2SBen Gras * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35*0c3983b2SBen Gras * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36*0c3983b2SBen Gras * POSSIBILITY OF SUCH DAMAGE.
37*0c3983b2SBen Gras */
38*0c3983b2SBen Gras #include <sys/cdefs.h>
39*0c3983b2SBen Gras #if defined(LIBC_SCCS) && !defined(lint)
40*0c3983b2SBen Gras __RCSID("$NetBSD: compat_passwd.c,v 1.2 2009/01/11 02:57:18 christos Exp $");
41*0c3983b2SBen Gras #endif /* LIBC_SCCS and not lint */
42*0c3983b2SBen Gras
43*0c3983b2SBen Gras #define __LIBC12_SOURCE__
44*0c3983b2SBen Gras
45*0c3983b2SBen Gras #include <stdint.h>
46*0c3983b2SBen Gras #include <stdlib.h>
47*0c3983b2SBen Gras #include <string.h>
48*0c3983b2SBen Gras #include <pwd.h>
49*0c3983b2SBen Gras #include <compat/include/pwd.h>
50*0c3983b2SBen Gras #include <util.h>
51*0c3983b2SBen Gras #include <compat/util.h>
52*0c3983b2SBen Gras
53*0c3983b2SBen Gras __warn_references(pw_scan,
54*0c3983b2SBen Gras "warning: reference to compatibility pw_scan(); "
55*0c3983b2SBen Gras "include <pwd.h> to generate correct reference")
56*0c3983b2SBen Gras __warn_references(pw_copy,
57*0c3983b2SBen Gras "warning: reference to compatibility pw_copy(); "
58*0c3983b2SBen Gras "include <util.h> to generate correct reference")
59*0c3983b2SBen Gras __warn_references(pw_copyx,
60*0c3983b2SBen Gras "warning: reference to compatibility pw_copyx(); "
61*0c3983b2SBen Gras "include <util.h> to generate correct reference")
62*0c3983b2SBen Gras __warn_references(pw_getpwconf,
63*0c3983b2SBen Gras "warning: reference to compatibility pw_getpwconf(); "
64*0c3983b2SBen Gras "include <pwd.h> to generate correct reference")
65*0c3983b2SBen Gras
66*0c3983b2SBen Gras int
pw_scan(char * buf,struct passwd50 * p,int * flags)67*0c3983b2SBen Gras pw_scan(char *buf, struct passwd50 *p, int *flags)
68*0c3983b2SBen Gras {
69*0c3983b2SBen Gras struct passwd px;
70*0c3983b2SBen Gras int rv = __pw_scan50(buf, &px, flags);
71*0c3983b2SBen Gras passwd_to_passwd50(&px, p);
72*0c3983b2SBen Gras return rv;
73*0c3983b2SBen Gras }
74*0c3983b2SBen Gras
75*0c3983b2SBen Gras void
pw_copy(int ffd,int tfd,struct passwd50 * pw50,struct passwd50 * opw50)76*0c3983b2SBen Gras pw_copy(int ffd, int tfd, struct passwd50 *pw50, struct passwd50 *opw50)
77*0c3983b2SBen Gras {
78*0c3983b2SBen Gras struct passwd pw, opw;
79*0c3983b2SBen Gras passwd50_to_passwd(pw50, &pw);
80*0c3983b2SBen Gras if (opw50)
81*0c3983b2SBen Gras passwd50_to_passwd(opw50, &opw);
82*0c3983b2SBen Gras __pw_copy50(ffd, tfd, &pw, opw50 ? &opw : NULL);
83*0c3983b2SBen Gras }
84*0c3983b2SBen Gras
85*0c3983b2SBen Gras int
pw_copyx(int ffd,int tfd,struct passwd50 * pw50,struct passwd50 * opw50,char * errbuf,size_t errbufsiz)86*0c3983b2SBen Gras pw_copyx(int ffd, int tfd, struct passwd50 *pw50, struct passwd50 *opw50,
87*0c3983b2SBen Gras char *errbuf, size_t errbufsiz)
88*0c3983b2SBen Gras {
89*0c3983b2SBen Gras struct passwd pw, opw;
90*0c3983b2SBen Gras passwd50_to_passwd(pw50, &pw);
91*0c3983b2SBen Gras if (opw50)
92*0c3983b2SBen Gras passwd50_to_passwd(opw50, &opw);
93*0c3983b2SBen Gras return __pw_copyx50(ffd, tfd, &pw, opw50 ? &opw : NULL, errbuf,
94*0c3983b2SBen Gras errbufsiz);
95*0c3983b2SBen Gras }
96*0c3983b2SBen Gras
97*0c3983b2SBen Gras void
pw_getpwconf(char * buf,size_t len,const struct passwd50 * p,const char * opt)98*0c3983b2SBen Gras pw_getpwconf(char *buf, size_t len, const struct passwd50 *p, const char *opt)
99*0c3983b2SBen Gras {
100*0c3983b2SBen Gras struct passwd px;
101*0c3983b2SBen Gras passwd50_to_passwd(p, &px);
102*0c3983b2SBen Gras __pw_getpwconf50(buf, len, &px, opt);
103*0c3983b2SBen Gras }
104