-/* Copyright (c) 1998-2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+/* Copyright (c) 1998-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* getent: get entries from administrative database. */
/* Supported options. */
static const struct argp_option args_options[] =
{
- { "service", 's', "CONFIG", 0, N_("Service configuration to be used") },
+ { "service", 's', N_("CONFIG"), 0, N_("Service configuration to be used") },
{ "no-idn", 'i', NULL, 0, N_("disable IDN encoding") },
{ NULL, 0, NULL, 0, NULL },
};
static void
print_version (FILE *stream, struct argp_state *state)
{
- fprintf (stream, "getent (GNU %s) %s\n", PACKAGE, VERSION);
+ fprintf (stream, "getent %s%s\n", PKGVERSION, VERSION);
fprintf (stream, gettext ("\
Copyright (C) %s Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
-"), "2011");
+"), "2015");
fprintf (stream, gettext ("Written by %s.\n"), "Thorsten Kukuk");
}
/* This is for aliases */
-static inline void
+static void
print_aliases (struct aliasent *alias)
{
unsigned int i = 0;
}
/* This is for group */
-static inline void
+static void
print_group (struct group *grp)
{
unsigned int i = 0;
size_t grpslen = ngrps * sizeof (gid_t);
gid_t *grps = alloca (grpslen);
+ if (number == 0)
+ {
+ fprintf (stderr, _("Enumeration not supported on %s\n"), "initgroups");
+ return 3;
+ }
+
for (int i = 0; i < number; ++i)
{
int no = ngrps;
}
/* Now is all for passwd */
-static inline void
+static void
print_passwd (struct passwd *pwd)
{
printf ("%s:%s:%lu:%lu:%s:%s:%s\n",
}
/* This is for protocols */
-static inline void
+static void
print_protocols (struct protoent *proto)
{
unsigned int i;
}
/* Now is all for rpc */
-static inline void
+static void
print_rpc (struct rpcent *rpc)
{
int i;
if (proto != NULL)
*proto++ = '\0';
- if (isdigit (key[i][0]))
- serv = getservbyport (htons (atol (key[i])), proto);
+ char *endptr;
+ long port = strtol (key[i], &endptr, 10);
+
+ if (isdigit (key[i][0]) && *endptr == '\0'
+ && 0 <= port && port <= 65535)
+ serv = getservbyport (htons (port), proto);
else
serv = getservbyname (key[i], proto);
setspent ();
while ((sp = getspent ()) != NULL)
print_shadow (sp);
- endpwent ();
+ endspent ();
return result;
}
fputs ("\n\n", fp);
- fputs (gettext ("\
+ fprintf (fp, gettext ("\
For bug reporting instructions, please see:\n\
-<http://www.gnu.org/software/libc/bugs.html>.\n"), fp);
+%s.\n"), REPORT_BUGS_TO);
if (fclose (fp) == 0)
return doc;