summaryrefslogtreecommitdiff
path: root/test/pwd_grp/getgroups.c
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@uclibc-ng.org>2016-10-28 20:29:21 +0200
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-10-28 20:31:55 +0200
commit99ef2719fb3d703fe38c4113cd7f5adec516dd3a (patch)
tree2c1f77cb41b60ccbf8faa77a3640491a3546b546 /test/pwd_grp/getgroups.c
parent543308f6c46cf2edf8a524bc9c631e472570fe72 (diff)
test: remove test suite
The test suite is now a developed in a separate git repository. See here: http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng-test.git The test suite should be just like every other software compiled with the cross-toolchain. In the past strange problems where found when the test suite got build in the toolchain creation step.
Diffstat (limited to 'test/pwd_grp/getgroups.c')
-rw-r--r--test/pwd_grp/getgroups.c100
1 files changed, 0 insertions, 100 deletions
diff --git a/test/pwd_grp/getgroups.c b/test/pwd_grp/getgroups.c
deleted file mode 100644
index c34355215..000000000
--- a/test/pwd_grp/getgroups.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/* This test was ripped out of GNU 'id' from coreutils-5.0
- * by Erik Andersen.
- *
- *
- * id is Copyright (C) 1989-2003 Free Software Foundation, Inc.
- * and licensed under the GPL v2 or later, and was written by
- * Arnold Robbins, with a major rewrite by David MacKenzie,
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <pwd.h>
-#include <grp.h>
-
-/* The number of errors encountered so far. */
-static int problems = 0;
-
-/* Print the name or value of group ID GID. */
-static void print_group(gid_t gid)
-{
- struct group *grp = NULL;
-
- grp = getgrgid(gid);
- if (grp == NULL) {
- fprintf(stderr, "cannot find name for group ID %u\n", gid);
- problems++;
- }
-
- if (grp == NULL)
- printf("%u", (unsigned)gid);
- else
- printf("%s", grp->gr_name);
-}
-
-static int xgetgroups(gid_t gid, int *n_groups, gid_t ** groups)
-{
- int max_n_groups;
- int ng;
- gid_t *g;
- int fail = 0;
-
- max_n_groups = getgroups(0, NULL);
-
- /* Add 1 just in case max_n_groups is zero. */
- g = (gid_t *) malloc(max_n_groups * sizeof(gid_t) + 1);
- if (g == NULL) {
- fprintf(stderr, "out of memory\n");
- exit(EXIT_FAILURE);
- }
- ng = getgroups(max_n_groups, g);
-
- if (ng < 0) {
- fprintf(stderr, "cannot get supplemental group list\n");
- ++fail;
- free(g);
- }
- if (!fail) {
- *n_groups = ng;
- *groups = g;
- }
- return fail;
-}
-
-/* Print all of the distinct groups the user is in. */
-int main(int argc, char *argv[])
-{
- struct passwd *pwd;
-
- pwd = getpwuid(getuid());
- if (pwd == NULL)
- problems++;
-
- print_group(getgid());
- if (getegid() != getgid()) {
- putchar(' ');
- print_group(getegid());
- }
-
- {
- int n_groups = 0;
- gid_t *groups;
- register int i;
-
- if (xgetgroups((pwd ? pwd->pw_gid : (gid_t) - 1),
- &n_groups, &groups)) {
- return ++problems;
- }
-
- for (i = 0; i < n_groups; i++)
- if (groups[i] != getgid() && groups[i] != getegid()) {
- putchar(' ');
- print_group(groups[i]);
- }
- free(groups);
- }
- putchar('\n');
- return (problems != 0);
-}