1 /* Copyright (c) 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@suse.de>, 1999.
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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 /* nscd_nischeck: Check, if everybody has read permissions for NIS+ table.
22 0: Everybody can read the NIS+ table
23 1: Only authenticated users could read the NIS+ table */
30 #include <rpcsvc/nis.h>
32 /* Get libc version number. */
35 #define PACKAGE _libc_intl_domainname
37 /* Name and version of program. */
38 static void print_version (FILE *stream
, struct argp_state
*state
);
39 void (*argp_program_version_hook
) (FILE *, struct argp_state
*) = print_version
;
41 /* Data structure to communicate with argp functions. */
42 static struct argp argp
=
44 NULL
, NULL
, NULL
, NULL
,
48 main (int argc
, char **argv
)
54 /* Set locale via LC_ALL. */
55 setlocale (LC_ALL
, "");
56 /* Set the text message domain. */
59 /* Parse and process arguments. */
60 argp_parse (&argp
, argc
, argv
, 0, &remaining
, NULL
);
62 if (remaining
+ 1 != argc
)
64 error (0, 0, gettext ("wrong number of arguments"));
65 argp_help (&argp
, stdout
, ARGP_HELP_SEE
, program_invocation_short_name
);
69 tablename
= alloca (strlen (argv
[1]) + 10);
70 cp
= stpcpy (tablename
, argv
[1]);
71 strcpy (cp
, ".org_dir");
73 res
= nis_lookup (tablename
, EXPAND_NAME
|FOLLOW_LINKS
);
76 (res
->status
!= NIS_SUCCESS
&& res
->status
!= NIS_S_SUCCESS
))
79 if (NIS_NOBODY(NIS_RES_OBJECT(res
)->zo_access
, NIS_READ_ACC
))
85 /* Print the version information. */
87 print_version (FILE *stream
, struct argp_state
*state
)
89 fprintf (stream
, "nscd_nischeck (GNU %s) %s\n", PACKAGE
, VERSION
);
90 fprintf (stream
, gettext ("\
91 Copyright (C) %s Free Software Foundation, Inc.\n\
92 This is free software; see the source for copying conditions. There is NO\n\
93 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
95 fprintf (stream
, gettext ("Written by %s.\n"), "Thorsten Kukuk");