1 | /* Copyright (c) 1997-2023 Free Software Foundation, Inc. |
2 | This file is part of the GNU C Library. |
3 | |
4 | The GNU C Library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2.1 of the License, or (at your option) any later version. |
8 | |
9 | The GNU C Library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Lesser General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Lesser General Public |
15 | License along with the GNU C Library; if not, see |
16 | <https://www.gnu.org/licenses/>. */ |
17 | |
18 | #include <string.h> |
19 | #include <rpcsvc/nis.h> |
20 | #include <shlib-compat.h> |
21 | |
22 | #include "nis_xdr.h" |
23 | #include "nis_intern.h" |
24 | |
25 | nis_result * |
26 | nis_checkpoint (const_nis_name dirname) |
27 | { |
28 | nis_result *res; |
29 | |
30 | res = calloc (1, sizeof (nis_result)); |
31 | if (res == NULL) |
32 | return NULL; |
33 | |
34 | if (dirname != NULL) |
35 | { |
36 | nis_result *res2; |
37 | u_int i; |
38 | |
39 | res2 = nis_lookup (dirname, EXPAND_NAME); |
40 | if (NIS_RES_STATUS (res2) != NIS_SUCCESS) |
41 | { |
42 | free (res); |
43 | return res2; |
44 | } |
45 | |
46 | /* Check if obj is really a diryectory object */ |
47 | if (__type_of (NIS_RES_OBJECT (res2)) != NIS_DIRECTORY_OBJ) |
48 | { |
49 | nis_freeresult (res2); |
50 | NIS_RES_STATUS (res) = NIS_INVALIDOBJ; |
51 | return res; |
52 | } |
53 | |
54 | for (i = 0; |
55 | i < NIS_RES_OBJECT (res2)->DI_data.do_servers.do_servers_len; ++i) |
56 | { |
57 | cp_result cpres; |
58 | |
59 | memset (&cpres, '\0', sizeof (cp_result)); |
60 | if (__do_niscall2 (&NIS_RES_OBJECT(res2)->DI_data.do_servers.do_servers_val[i], |
61 | 1, NIS_CHECKPOINT, (xdrproc_t) _xdr_nis_name, |
62 | (caddr_t) &dirname, (xdrproc_t) _xdr_cp_result, |
63 | (caddr_t) &cpres, 0, NULL) != NIS_SUCCESS) |
64 | NIS_RES_STATUS (res) = NIS_RPCERROR; |
65 | else |
66 | { |
67 | NIS_RES_STATUS (res) = cpres.cp_status; |
68 | res->zticks += cpres.cp_zticks; |
69 | res->dticks += cpres.cp_dticks; |
70 | } |
71 | } |
72 | nis_freeresult (res2); |
73 | } |
74 | else |
75 | NIS_RES_STATUS (res) = NIS_NOSUCHNAME; |
76 | |
77 | return res; |
78 | } |
79 | libnsl_hidden_nolink_def (nis_checkpoint, GLIBC_2_1) |
80 | |