aboutsummaryrefslogtreecommitdiff
path: root/nss/getent.c
diff options
context:
space:
mode:
authorAurelien Jarno <aurelien@aurel32.net>2009-06-15 17:49:35 -0700
committerUlrich Drepper <drepper@redhat.com>2009-06-15 17:49:35 -0700
commitc518f9a4b442af13bc5ac79011eb73a05585e0a9 (patch)
tree85df87f8af47e1c6b53b4f840e2d30a748b7b74d /nss/getent.c
parent233a182b9ee2a48eddbb15f70af8bc24add24af3 (diff)
downloadglibc-c518f9a4b442af13bc5ac79011eb73a05585e0a9.zip
glibc-c518f9a4b442af13bc5ac79011eb73a05585e0a9.tar.gz
glibc-c518f9a4b442af13bc5ac79011eb73a05585e0a9.tar.bz2
Extend getent to handle the shadow database.
BZ #10207
Diffstat (limited to 'nss/getent.c')
-rw-r--r--nss/getent.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/nss/getent.c b/nss/getent.c
index ea5608f..dbcae26 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -24,6 +24,7 @@
#include <ctype.h>
#include <error.h>
#include <grp.h>
+#include <gshadow.h>
#include <libintl.h>
#include <locale.h>
#include <mcheck.h>
@@ -232,6 +233,70 @@ group_keys (int number, char *key[])
return result;
}
+/* This is for gshadow */
+static void
+print_gshadow (struct sgrp *sg)
+{
+ unsigned int i = 0;
+
+ printf ("%s:%s:",
+ sg->sg_namp ? sg->sg_namp : "",
+ sg->sg_passwd ? sg->sg_passwd : "");
+
+ while (sg->sg_adm[i] != NULL)
+ {
+ fputs_unlocked (sg->sg_adm[i], stdout);
+ ++i;
+ if (sg->sg_adm[i] != NULL)
+ putchar_unlocked (',');
+ }
+
+ putchar_unlocked (':');
+
+ i = 0;
+ while (sg->sg_mem[i] != NULL)
+ {
+ fputs_unlocked (sg->sg_mem[i], stdout);
+ ++i;
+ if (sg->sg_mem[i] != NULL)
+ putchar_unlocked (',');
+ }
+
+ putchar_unlocked ('\n');
+}
+
+static int
+gshadow_keys (int number, char *key[])
+{
+ int result = 0;
+ int i;
+
+ if (number == 0)
+ {
+ struct sgrp *sg;
+
+ setsgent ();
+ while ((sg = getsgent ()) != NULL)
+ print_gshadow (sg);
+ endsgent ();
+ return result;
+ }
+
+ for (i = 0; i < number; ++i)
+ {
+ struct sgrp *sg;
+
+ sg = getsgnam (key[i]);
+
+ if (sg == NULL)
+ result = 2;
+ else
+ print_gshadow (sg);
+ }
+
+ return result;
+}
+
/* This is for hosts */
static void
print_hosts (struct hostent *host)
@@ -756,6 +821,7 @@ D(ahostsv6)
D(aliases)
D(ethers)
D(group)
+D(gshadow)
D(hosts)
D(netgroup)
D(networks)