]> git.ipfire.org Git - thirdparty/glibc.git/blame - sunrpc/key_prot.c
powerpc: Fix build of wcscpy with --disable-multi-arch
[thirdparty/glibc.git] / sunrpc / key_prot.c
CommitLineData
a7ab6ec8 1/* Copyright (c) 2010, Oracle America, Inc.
800d775e 2 *
a7ab6ec8
UD
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
800d775e 6 *
a7ab6ec8
UD
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 * * Neither the name of the "Oracle America, Inc." nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
800d775e 16 *
a7ab6ec8
UD
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
800d775e 29 */
800d775e 30
7b57bfe5 31#include <rpc/key_prot.h>
82f43dd2 32#include <shlib-compat.h>
800d775e
UD
33
34bool_t
35xdr_keystatus (XDR * xdrs, keystatus * objp)
36{
7b57bfe5 37 if (!xdr_enum (xdrs, (enum_t *) objp))
800d775e
UD
38 return FALSE;
39
40 return TRUE;
41}
021db4be 42libc_hidden_nolink_sunrpc (xdr_keystatus, GLIBC_2_0)
800d775e
UD
43
44bool_t
45xdr_keybuf (XDR * xdrs, keybuf objp)
46{
7b57bfe5 47 if (!xdr_opaque (xdrs, objp, HEXKEYBYTES))
800d775e
UD
48 return FALSE;
49
50 return TRUE;
51}
021db4be 52libc_hidden_nolink_sunrpc (xdr_keybuf, GLIBC_2_0)
800d775e
UD
53
54bool_t
55xdr_netnamestr (XDR * xdrs, netnamestr * objp)
56{
7b57bfe5 57 if (!xdr_string (xdrs, objp, MAXNETNAMELEN))
800d775e
UD
58 return FALSE;
59
60 return TRUE;
61}
021db4be 62libc_hidden_nolink_sunrpc (xdr_netnamestr, GLIBC_2_1)
800d775e
UD
63
64bool_t
65xdr_cryptkeyarg (XDR * xdrs, cryptkeyarg * objp)
66{
7b57bfe5 67 if (!xdr_netnamestr (xdrs, &objp->remotename))
800d775e
UD
68 return FALSE;
69
7b57bfe5 70 if (!xdr_des_block (xdrs, &objp->deskey))
800d775e
UD
71 return FALSE;
72
73 return TRUE;
74}
021db4be 75libc_hidden_nolink_sunrpc (xdr_cryptkeyarg, GLIBC_2_0)
800d775e
UD
76
77bool_t
78xdr_cryptkeyarg2 (XDR * xdrs, cryptkeyarg2 * objp)
79{
7b57bfe5 80 if (!xdr_netnamestr (xdrs, &objp->remotename))
800d775e 81 return FALSE;
7b57bfe5 82 if (!xdr_netobj (xdrs, &objp->remotekey))
800d775e 83 return FALSE;
7b57bfe5 84 if (!xdr_des_block (xdrs, &objp->deskey))
800d775e
UD
85 return FALSE;
86 return TRUE;
87}
021db4be 88libc_hidden_nolink_sunrpc (xdr_cryptkeyarg2, GLIBC_2_0)
800d775e
UD
89
90bool_t
91xdr_cryptkeyres (XDR * xdrs, cryptkeyres * objp)
92{
7b57bfe5 93 if (!xdr_keystatus (xdrs, &objp->status))
800d775e
UD
94 return FALSE;
95 switch (objp->status)
96 {
97 case KEY_SUCCESS:
7b57bfe5 98 if (!xdr_des_block (xdrs, &objp->cryptkeyres_u.deskey))
800d775e
UD
99 return FALSE;
100 break;
101 default:
102 break;
103 }
104 return TRUE;
105}
021db4be 106libc_hidden_nolink_sunrpc (xdr_cryptkeyres, GLIBC_2_0)
800d775e
UD
107
108bool_t
109xdr_unixcred (XDR * xdrs, unixcred * objp)
110{
7b57bfe5 111 if (!xdr_u_int (xdrs, &objp->uid))
800d775e 112 return FALSE;
7b57bfe5 113 if (!xdr_u_int (xdrs, &objp->gid))
800d775e 114 return FALSE;
7b57bfe5
UD
115 if (!xdr_array (xdrs, (void *) &objp->gids.gids_val,
116 (u_int *) & objp->gids.gids_len, MAXGIDS,
117 sizeof (u_int), (xdrproc_t) xdr_u_int))
800d775e
UD
118 return FALSE;
119 return TRUE;
120}
021db4be 121libc_hidden_nolink_sunrpc (xdr_unixcred, GLIBC_2_1)
800d775e
UD
122
123bool_t
124xdr_getcredres (XDR * xdrs, getcredres * objp)
125{
7b57bfe5 126 if (!xdr_keystatus (xdrs, &objp->status))
800d775e
UD
127 return FALSE;
128 switch (objp->status)
129 {
130 case KEY_SUCCESS:
7b57bfe5 131 if (!xdr_unixcred (xdrs, &objp->getcredres_u.cred))
800d775e
UD
132 return FALSE;
133 break;
134 default:
135 break;
136 }
137 return TRUE;
138}
021db4be 139libc_hidden_nolink_sunrpc (xdr_getcredres, GLIBC_2_1)
800d775e
UD
140
141bool_t
142xdr_key_netstarg (XDR * xdrs, key_netstarg * objp)
143{
7b57bfe5 144 if (!xdr_keybuf (xdrs, objp->st_priv_key))
800d775e 145 return FALSE;
7b57bfe5 146 if (!xdr_keybuf (xdrs, objp->st_pub_key))
800d775e 147 return FALSE;
7b57bfe5 148 if (!xdr_netnamestr (xdrs, &objp->st_netname))
800d775e
UD
149 return FALSE;
150 return TRUE;
151}
021db4be 152libc_hidden_nolink_sunrpc (xdr_key_netstarg, GLIBC_2_0)
800d775e
UD
153
154bool_t
155xdr_key_netstres (XDR * xdrs, key_netstres * objp)
156{
7b57bfe5 157 if (!xdr_keystatus (xdrs, &objp->status))
800d775e
UD
158 return FALSE;
159 switch (objp->status)
160 {
161 case KEY_SUCCESS:
7b57bfe5 162 if (!xdr_key_netstarg (xdrs, &objp->key_netstres_u.knet))
800d775e
UD
163 return FALSE;
164 break;
165 default:
166 break;
167 }
168 return TRUE;
169}
021db4be 170libc_hidden_nolink_sunrpc (xdr_key_netstres, GLIBC_2_0)