]> git.ipfire.org Git - thirdparty/glibc.git/blob - sunrpc/key_prot.c
tunables: Fix environment variable processing for setuid binaries (bz #21073)
[thirdparty/glibc.git] / sunrpc / key_prot.c
1 /* Copyright (c) 2010, Oracle America, Inc.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 *
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.
16 *
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.
29 */
30
31 #include <rpc/key_prot.h>
32
33 bool_t
34 xdr_keystatus (XDR * xdrs, keystatus * objp)
35 {
36 if (!xdr_enum (xdrs, (enum_t *) objp))
37 return FALSE;
38
39 return TRUE;
40 }
41 libc_hidden_nolink_sunrpc (xdr_keystatus, GLIBC_2_0)
42
43 bool_t
44 xdr_keybuf (XDR * xdrs, keybuf objp)
45 {
46 if (!xdr_opaque (xdrs, objp, HEXKEYBYTES))
47 return FALSE;
48
49 return TRUE;
50 }
51 libc_hidden_nolink_sunrpc (xdr_keybuf, GLIBC_2_0)
52
53 bool_t
54 xdr_netnamestr (XDR * xdrs, netnamestr * objp)
55 {
56 if (!xdr_string (xdrs, objp, MAXNETNAMELEN))
57 return FALSE;
58
59 return TRUE;
60 }
61 libc_hidden_nolink_sunrpc (xdr_netnamestr, GLIBC_2_1)
62
63 bool_t
64 xdr_cryptkeyarg (XDR * xdrs, cryptkeyarg * objp)
65 {
66 if (!xdr_netnamestr (xdrs, &objp->remotename))
67 return FALSE;
68
69 if (!xdr_des_block (xdrs, &objp->deskey))
70 return FALSE;
71
72 return TRUE;
73 }
74 libc_hidden_nolink_sunrpc (xdr_cryptkeyarg, GLIBC_2_0)
75
76 bool_t
77 xdr_cryptkeyarg2 (XDR * xdrs, cryptkeyarg2 * objp)
78 {
79 if (!xdr_netnamestr (xdrs, &objp->remotename))
80 return FALSE;
81 if (!xdr_netobj (xdrs, &objp->remotekey))
82 return FALSE;
83 if (!xdr_des_block (xdrs, &objp->deskey))
84 return FALSE;
85 return TRUE;
86 }
87 libc_hidden_nolink_sunrpc (xdr_cryptkeyarg2, GLIBC_2_0)
88
89 bool_t
90 xdr_cryptkeyres (XDR * xdrs, cryptkeyres * objp)
91 {
92 if (!xdr_keystatus (xdrs, &objp->status))
93 return FALSE;
94 switch (objp->status)
95 {
96 case KEY_SUCCESS:
97 if (!xdr_des_block (xdrs, &objp->cryptkeyres_u.deskey))
98 return FALSE;
99 break;
100 default:
101 break;
102 }
103 return TRUE;
104 }
105 libc_hidden_nolink_sunrpc (xdr_cryptkeyres, GLIBC_2_0)
106
107 bool_t
108 xdr_unixcred (XDR * xdrs, unixcred * objp)
109 {
110 if (!xdr_u_int (xdrs, &objp->uid))
111 return FALSE;
112 if (!xdr_u_int (xdrs, &objp->gid))
113 return FALSE;
114 if (!xdr_array (xdrs, (void *) &objp->gids.gids_val,
115 (u_int *) & objp->gids.gids_len, MAXGIDS,
116 sizeof (u_int), (xdrproc_t) xdr_u_int))
117 return FALSE;
118 return TRUE;
119 }
120 libc_hidden_nolink_sunrpc (xdr_unixcred, GLIBC_2_1)
121
122 bool_t
123 xdr_getcredres (XDR * xdrs, getcredres * objp)
124 {
125 if (!xdr_keystatus (xdrs, &objp->status))
126 return FALSE;
127 switch (objp->status)
128 {
129 case KEY_SUCCESS:
130 if (!xdr_unixcred (xdrs, &objp->getcredres_u.cred))
131 return FALSE;
132 break;
133 default:
134 break;
135 }
136 return TRUE;
137 }
138 libc_hidden_nolink_sunrpc (xdr_getcredres, GLIBC_2_1)
139
140 bool_t
141 xdr_key_netstarg (XDR * xdrs, key_netstarg * objp)
142 {
143 if (!xdr_keybuf (xdrs, objp->st_priv_key))
144 return FALSE;
145 if (!xdr_keybuf (xdrs, objp->st_pub_key))
146 return FALSE;
147 if (!xdr_netnamestr (xdrs, &objp->st_netname))
148 return FALSE;
149 return TRUE;
150 }
151 libc_hidden_nolink_sunrpc (xdr_key_netstarg, GLIBC_2_0)
152
153 bool_t
154 xdr_key_netstres (XDR * xdrs, key_netstres * objp)
155 {
156 if (!xdr_keystatus (xdrs, &objp->status))
157 return FALSE;
158 switch (objp->status)
159 {
160 case KEY_SUCCESS:
161 if (!xdr_key_netstarg (xdrs, &objp->key_netstres_u.knet))
162 return FALSE;
163 break;
164 default:
165 break;
166 }
167 return TRUE;
168 }
169 libc_hidden_nolink_sunrpc (xdr_key_netstres, GLIBC_2_0)