1 /* Copyright (c) 1997-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
24 #include <rpcsvc/nis.h>
25 #include <shlib-compat.h>
28 nis_nstype2str (const nstype type
)
31 /* Name service names mustn't be translated, only UNKNOWN needs it */
57 print_ttl (const uint32_t ttl
)
59 uint32_t time
, s
, m
, h
;
68 printf ("%u:%u:%u\n", h
, m
, s
);
72 print_flags (const unsigned int flags
)
76 if (flags
& TA_SEARCHABLE
)
77 fputs ("SEARCHABLE, ", stdout
);
79 if (flags
& TA_BINARY
)
81 fputs ("BINARY DATA", stdout
);
83 fputs (", XDR ENCODED", stdout
);
85 fputs (", ASN.1 ENCODED", stdout
);
87 fputs (", ENCRYPTED", stdout
);
91 fputs ("TEXTUAL DATA", stdout
);
92 if (flags
& TA_SEARCHABLE
)
95 fputs (", CASE INSENSITIVE", stdout
);
97 fputs (", CASE SENSITIVE", stdout
);
101 fputs (")\n", stdout
);
105 nis_print_objtype (enum zotypes type
)
110 fputs (_("BOGUS OBJECT\n"), stdout
);
113 fputs (_("NO OBJECT\n"), stdout
);
115 case NIS_DIRECTORY_OBJ
:
116 fputs (_("DIRECTORY\n"), stdout
);
119 fputs (_("GROUP\n"), stdout
);
122 fputs (_("TABLE\n"), stdout
);
125 fputs (_("ENTRY\n"), stdout
);
128 fputs (_("LINK\n"), stdout
);
130 case NIS_PRIVATE_OBJ
:
131 fputs (_("PRIVATE\n"), stdout
);
134 fputs (_("(Unknown object)\n"), stdout
);
140 nis_print_rights (const unsigned int access
)
146 acc
= access
; /* Parameter is const ! */
147 result
[i
= 16] = '\0';
151 result
[i
+ 0] = (acc
& NIS_READ_ACC
) ? 'r' : '-';
152 result
[i
+ 1] = (acc
& NIS_MODIFY_ACC
) ? 'm' : '-';
153 result
[i
+ 2] = (acc
& NIS_CREATE_ACC
) ? 'c' : '-';
154 result
[i
+ 3] = (acc
& NIS_DESTROY_ACC
) ? 'd' : '-';
158 fputs (result
, stdout
);
160 libnsl_hidden_nolink_def (nis_print_rights
, GLIBC_2_1
)
163 nis_print_directory (const directory_obj
*dir
)
168 printf (_("Name : `%s'\n"), dir
->do_name
);
169 printf (_("Type : %s\n"), nis_nstype2str (dir
->do_type
));
170 sptr
= dir
->do_servers
.do_servers_val
;
171 for (i
= 0; i
< dir
->do_servers
.do_servers_len
; i
++)
174 fputs (_("Master Server :\n"), stdout
);
176 fputs (_("Replicate :\n"), stdout
);
177 printf (_("\tName : %s\n"), sptr
->name
);
178 fputs (_("\tPublic Key : "), stdout
);
179 switch (sptr
->key_type
)
182 fputs (_("None.\n"), stdout
);
185 printf (_("Diffie-Hellmann (%d bits)\n"),
186 (sptr
->pkey
.n_len
- 1) * 4);
187 /* sptr->pkey.n_len counts the last 0, too */
190 printf (_("RSA (%d bits)\n"), (sptr
->pkey
.n_len
- 1) * 4);
193 fputs (_("Kerberos.\n"), stdout
);
196 printf (_("Unknown (type = %d, bits = %d)\n"), sptr
->key_type
,
197 (sptr
->pkey
.n_len
- 1) * 4);
201 if (sptr
->ep
.ep_len
!= 0)
206 ptr
= sptr
->ep
.ep_val
;
207 printf (_("\tUniversal addresses (%u)\n"), sptr
->ep
.ep_len
);
208 for (j
= 0; j
< sptr
->ep
.ep_len
; j
++)
210 printf ("\t[%d] - ", j
+ 1);
211 if (ptr
->proto
!= NULL
&& ptr
->proto
[0] != '\0')
212 printf ("%s, ", ptr
->proto
);
215 if (ptr
->family
!= NULL
&& ptr
->family
[0] != '\0')
216 printf ("%s, ", ptr
->family
);
219 if (ptr
->uaddr
!= NULL
&& ptr
->uaddr
[0] != '\0')
220 printf ("%s\n", ptr
->uaddr
);
222 fputs ("-\n", stdout
);
229 fputs (_("Time to live : "), stdout
);
230 print_ttl (dir
->do_ttl
);
231 fputs (_("Default Access rights :\n"), stdout
);
232 if (dir
->do_armask
.do_armask_len
!= 0)
236 ptr
= dir
->do_armask
.do_armask_val
;
237 for (i
= 0; i
< dir
->do_armask
.do_armask_len
; i
++)
239 nis_print_rights (ptr
->oa_rights
);
240 printf (_("\tType : %s\n"), nis_nstype2str (ptr
->oa_otype
));
241 fputs (_("\tAccess rights: "), stdout
);
242 nis_print_rights (ptr
->oa_rights
);
243 fputs ("\n", stdout
);
248 libnsl_hidden_nolink_def (nis_print_directory
, GLIBC_2_1
)
251 nis_print_group (const group_obj
*obj
)
255 fputs (_("Group Flags :"), stdout
);
257 printf ("0x%08X", obj
->gr_flags
);
258 fputs (_("\nGroup Members :\n"), stdout
);
260 for (i
= 0; i
< obj
->gr_members
.gr_members_len
; i
++)
261 printf ("\t%s\n", obj
->gr_members
.gr_members_val
[i
]);
263 libnsl_hidden_nolink_def (nis_print_group
, GLIBC_2_1
)
266 nis_print_table (const table_obj
*obj
)
270 printf (_("Table Type : %s\n"), obj
->ta_type
);
271 printf (_("Number of Columns : %d\n"), obj
->ta_maxcol
);
272 printf (_("Character Separator : %c\n"), obj
->ta_sep
);
273 printf (_("Search Path : %s\n"), obj
->ta_path
);
274 fputs (_("Columns :\n"), stdout
);
275 for (i
= 0; i
< obj
->ta_cols
.ta_cols_len
; i
++)
277 printf (_("\t[%d]\tName : %s\n"), i
,
278 obj
->ta_cols
.ta_cols_val
[i
].tc_name
);
279 fputs (_("\t\tAttributes : "), stdout
);
280 print_flags (obj
->ta_cols
.ta_cols_val
[i
].tc_flags
);
281 fputs (_("\t\tAccess Rights : "), stdout
);
282 nis_print_rights (obj
->ta_cols
.ta_cols_val
[i
].tc_rights
);
283 fputc ('\n', stdout
);
286 libnsl_hidden_nolink_def (nis_print_table
, GLIBC_2_1
)
289 nis_print_link (const link_obj
*obj
)
291 fputs (_("Linked Object Type : "), stdout
);
292 nis_print_objtype (obj
->li_rtype
);
293 printf (_("Linked to : %s\n"), obj
->li_name
);
294 /* XXX Print the attributes here, if they exists */
296 libnsl_hidden_nolink_def (nis_print_link
, GLIBC_2_1
)
299 nis_print_entry (const entry_obj
*obj
)
303 printf (_("\tEntry data of type %s\n"), obj
->en_type
);
304 for (i
= 0; i
< obj
->en_cols
.en_cols_len
; i
++)
306 printf (_("\t[%u] - [%u bytes] "), i
,
307 obj
->en_cols
.en_cols_val
[i
].ec_value
.ec_value_len
);
308 if ((obj
->en_cols
.en_cols_val
[i
].ec_flags
& EN_CRYPT
) == EN_CRYPT
)
309 fputs (_("Encrypted data\n"), stdout
);
310 else if ((obj
->en_cols
.en_cols_val
[i
].ec_flags
& EN_BINARY
) == EN_BINARY
)
311 fputs (_("Binary data\n"), stdout
);
312 else if (obj
->en_cols
.en_cols_val
[i
].ec_value
.ec_value_len
== 0)
313 fputs ("'(nil)'\n", stdout
);
316 (int)obj
->en_cols
.en_cols_val
[i
].ec_value
.ec_value_len
,
317 obj
->en_cols
.en_cols_val
[i
].ec_value
.ec_value_val
);
320 libnsl_hidden_nolink_def (nis_print_entry
, GLIBC_2_1
)
323 nis_print_object (const nis_object
* obj
)
327 printf (_("Object Name : %s\n"), obj
->zo_name
);
328 printf (_("Directory : %s\n"), obj
->zo_domain
);
329 printf (_("Owner : %s\n"), obj
->zo_owner
);
330 printf (_("Group : %s\n"), obj
->zo_group
);
331 fputs (_("Access Rights : "), stdout
);
332 nis_print_rights (obj
->zo_access
);
333 printf (_("\nTime to Live : "));
334 print_ttl (obj
->zo_ttl
);
335 buf
= obj
->zo_oid
.ctime
;
336 printf (_("Creation Time : %s"), ctime (&buf
));
337 buf
= obj
->zo_oid
.mtime
;
338 printf (_("Mod. Time : %s"), ctime (&buf
));
339 fputs (_("Object Type : "), stdout
);
340 nis_print_objtype (obj
->zo_data
.zo_type
);
341 switch (obj
->zo_data
.zo_type
)
343 case NIS_DIRECTORY_OBJ
:
344 nis_print_directory (&obj
->zo_data
.objdata_u
.di_data
);
347 nis_print_group (&obj
->zo_data
.objdata_u
.gr_data
);
350 nis_print_table (&obj
->zo_data
.objdata_u
.ta_data
);
353 nis_print_entry (&obj
->zo_data
.objdata_u
.en_data
);
356 nis_print_link (&obj
->zo_data
.objdata_u
.li_data
);
358 case NIS_PRIVATE_OBJ
:
359 printf (_(" Data Length = %u\n"),
360 obj
->zo_data
.objdata_u
.po_data
.po_data_len
);
366 libnsl_hidden_nolink_def (nis_print_object
, GLIBC_2_1
)
369 nis_print_result (const nis_result
*res
)
373 printf (_("Status : %s\n"), nis_sperrno (NIS_RES_STATUS (res
)));
374 printf (_("Number of objects : %u\n"), res
->objects
.objects_len
);
376 for (i
= 0; i
< res
->objects
.objects_len
; i
++)
378 printf (_("Object #%d:\n"), i
);
379 nis_print_object (&res
->objects
.objects_val
[i
]);
382 libnsl_hidden_nolink_def (nis_print_result
, GLIBC_2_1
)