URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/or1k/trunk/linux/uClibc/test/pwd_grp
- from Rev 1325 to Rev 1765
- ↔ Reverse comparison
Rev 1325 → Rev 1765
/pwcat.c
0,0 → 1,26
/* |
* pwcat.c |
* |
* Generate a printable version of the password database |
*/ |
/* |
* Arnold Robbins, arnold@gnu.org, May 1993 |
* Public Domain |
*/ |
|
#include <stdio.h> |
#include <pwd.h> |
#include <stdlib.h> |
|
int main(int argc, char **argv) |
{ |
struct passwd *p; |
|
while ((p = getpwent()) != NULL) |
printf("%s:%s:%ld:%ld:%s:%s:%s\n", |
p->pw_name, p->pw_passwd, (long) p->pw_uid, |
(long) p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell); |
|
endpwent(); |
return 0; |
} |
/getgroups.c
0,0 → 1,108
/* 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> |
#include <err.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) |
{ |
warn("cannot find name for group ID %u", 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) |
err(EXIT_FAILURE, "out of memory"); |
ng = getgroups (max_n_groups, g); |
|
if (ng < 0) |
{ |
warn("cannot get supplemental group list"); |
++fail; |
free (groups); |
} |
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; |
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); |
} |
|
/grcat.c
0,0 → 1,32
/* |
* grcat.c |
* |
* Generate a printable version of the group database |
*/ |
/* |
* Arnold Robbins, arnold@gnu.org, May 1993 |
* Public Domain |
*/ |
|
#include <stdlib.h> |
#include <stdio.h> |
#include <grp.h> |
|
int main(int argc, char **argv) |
{ |
struct group *g; |
int i; |
|
while ((g = getgrent()) != NULL) { |
printf("%s:%s:%ld:", g->gr_name, g->gr_passwd, |
(long) g->gr_gid); |
for (i = 0; g->gr_mem[i] != NULL; i++) { |
printf("%s", g->gr_mem[i]); |
if (g->gr_mem[i+1] != NULL) |
putchar(','); |
} |
putchar('\n'); |
} |
endgrent(); |
return 0; |
} |
/test_grp.c
0,0 → 1,100
/* |
* test_grp.c - This file is part of the libc-8086/grp package for ELKS, |
* Copyright (C) 1995, 1996 Nat Friedman <ndf@linux.mit.edu>. |
* |
* This library is free software; you can redistribute it and/or |
* modify it under the terms of the GNU Library General Public |
* License as published by the Free Software Foundation; either |
* version 2 of the License, or (at your option) any later version. |
* |
* This library is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
* Library General Public License for more details. |
* |
* You should have received a copy of the GNU Library General Public |
* License along with this library; if not, write to the Free |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
* |
*/ |
|
#include <unistd.h> |
#include <stdio.h> |
#include <fcntl.h> |
#include <grp.h> |
|
int main(int argc, char **argv) |
{ |
struct group *group; |
char **tmp_mem; |
int test_gid; |
|
fprintf(stdout, "Beginning test of libc/grp...\n"); |
|
fprintf(stdout, "=> Testing setgrent(), getgrent(), endgrent()...\n"); |
fprintf(stdout, "-> setgrent()...\n"); |
setgrent(); |
fprintf(stdout, "-> getgrent()...\n"); |
printf |
("********************************************************************************\n"); |
while ((group = getgrent()) != NULL) { |
printf("gr_name\t\t: %s\n", group->gr_name); |
printf("gr_passwd\t: %s\n", group->gr_passwd); |
printf("gr_gid\t\t: %d\n", (int) group->gr_gid); |
printf("gr_mem\t\t: "); |
fflush(stdout); |
tmp_mem = group->gr_mem; |
while (*tmp_mem != NULL) { |
printf("%s, ", *tmp_mem); |
tmp_mem++; |
} |
printf |
("\n********************************************************************************\n"); |
} |
fprintf(stdout, "-> endgrent()...\n"); |
endgrent(); |
fprintf(stdout, |
"=> Test of setgrent(), getgrent(), endgrent() complete.\n"); |
fprintf(stdout, "=> Testing getgrid(), getgrnam()...\n"); |
fprintf(stdout, "-> getgrgid()...\n"); |
printf |
("********************************************************************************\n"); |
for (test_gid = 0; test_gid < 100; test_gid++) { |
fprintf(stdout, "-> getgrgid(%d)...\n", test_gid); |
group = getgrgid((gid_t) test_gid); |
if (group != NULL) { |
printf("gr_name\t: %s\n", group->gr_name); |
printf("gr_passwd\t: %s\n", group->gr_passwd); |
printf("gr_gid\t: %d\n", (int) group->gr_gid); |
printf("gr_mem\t\t: "); |
fflush(stdout); |
tmp_mem = group->gr_mem; |
while (*tmp_mem != NULL) { |
printf("%s, ", *tmp_mem); |
tmp_mem++; |
} |
} |
printf |
("\n********************************************************************************\n"); |
} |
fprintf(stdout, "-> getgrnam()...\n"); |
group = getgrnam("root"); |
if (group == NULL) { |
printf(">NULL<\n"); |
} else { |
printf("gr_name\t: %s\n", group->gr_name); |
printf("gr_passwd\t: %s\n", group->gr_passwd); |
printf("gr_gid\t: %d\n", (int) group->gr_gid); |
printf("gr_mem\t\t: "); |
fflush(stdout); |
tmp_mem = group->gr_mem; |
while (*tmp_mem != NULL) { |
printf("%s, ", *tmp_mem); |
tmp_mem++; |
} |
printf("\n"); |
} |
|
|
return 0; |
} |
/test_pwd.c
0,0 → 1,87
/* |
* test_pwd.c - This file is part of the libc-8086/pwd package for ELKS, |
* Copyright (C) 1995, 1996 Nat Friedman <ndf@linux.mit.edu>. |
* |
* This library is free software; you can redistribute it and/or |
* modify it under the terms of the GNU Library General Public |
* License as published by the Free Software Foundation; either |
* version 2 of the License, or (at your option) any later version. |
* |
* This library is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
* Library General Public License for more details. |
* |
* You should have received a copy of the GNU Library General Public |
* License along with this library; if not, write to the Free |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
* |
*/ |
|
#include <unistd.h> |
#include <stdio.h> |
#include <fcntl.h> |
#include <pwd.h> |
|
int main(int argc, char **argv) |
{ |
struct passwd *passwd; |
int test_uid; |
|
fprintf(stdout, "Beginning test of libc/pwd...\n"); |
|
fprintf(stdout, "=> Testing setpwent(), getpwent(), endpwent()...\n"); |
fprintf(stdout, "-> setpwent()...\n"); |
setpwent(); |
fprintf(stdout, "-> getpwent()...\n"); |
printf |
("********************************************************************************\n"); |
while ((passwd = getpwent()) != NULL) { |
printf("pw_name\t\t: %s\n", passwd->pw_name); |
printf("pw_passwd\t: %s\n", passwd->pw_passwd); |
printf("pw_uid\t\t: %d\n", (int) passwd->pw_uid); |
printf("pw_gid\t\t: %d\n", (int) passwd->pw_gid); |
printf("pw_gecos\t: %s\n", passwd->pw_gecos); |
printf("pw_dir\t\t: %s\n", passwd->pw_dir); |
printf("pw_shell\t: %s\n", passwd->pw_shell); |
printf |
("********************************************************************************\n"); |
} |
fprintf(stdout, "-> endpwent()...\n"); |
endpwent(); |
fprintf(stdout, |
"=> Test of setpwent(), getpwent(), endpwent() complete.\n"); |
fprintf(stdout, "=> Testing getpwuid(), getpwnam()...\n"); |
fprintf(stdout, "-> getpwuid()...\n"); |
printf |
("********************************************************************************\n"); |
for (test_uid = 0; test_uid < 1000; test_uid++) { |
fprintf(stdout, "-> getpwuid(%d)...\n", test_uid); |
passwd = getpwuid((uid_t) test_uid); |
if (passwd != NULL) { |
printf("pw_name\t\t: %s\n", passwd->pw_name); |
printf("pw_passwd\t: %s\n", passwd->pw_passwd); |
printf("pw_uid\t\t: %d\n", (int) passwd->pw_uid); |
printf("pw_gid\t\t: %d\n", (int) passwd->pw_gid); |
printf("pw_gecos\t: %s\n", passwd->pw_gecos); |
printf("pw_dir\t\t: %s\n", passwd->pw_dir); |
printf("pw_shell\t: %s\n", passwd->pw_shell); |
printf |
("********************************************************************************\n"); |
} |
} |
fprintf(stdout, "-> getpwnam()...\n"); |
passwd = getpwnam("root"); |
if (passwd == NULL) { |
printf(">NULL<\n"); |
} else { |
printf("pw_name\t\t: %s\n", passwd->pw_name); |
printf("pw_passwd\t: %s\n", passwd->pw_passwd); |
printf("pw_uid\t\t: %d\n", (int) passwd->pw_uid); |
printf("pw_gid\t\t: %d\n", (int) passwd->pw_gid); |
printf("pw_gecos\t: %s\n", passwd->pw_gecos); |
printf("pw_dir\t\t: %s\n", passwd->pw_dir); |
printf("pw_shell\t: %s\n", passwd->pw_shell); |
} |
return 0; |
} |
/Makefile
0,0 → 1,185
# Makefile for uClibc |
# |
# Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.org> |
# |
# This program is free software; you can redistribute it and/or modify it under |
# the terms of the GNU Library General Public License as published by the Free |
# Software Foundation; either version 2 of the License, or (at your option) any |
# later version. |
# |
# This program is distributed in the hope that it will be useful, but WITHOUT |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more |
# details. |
# |
# You should have received a copy of the GNU Library General Public License |
# along with this program; if not, write to the Free Software Foundation, Inc., |
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
TESTDIR=../ |
include $(TESTDIR)/Rules.mak |
|
|
TARGETS=test_pwd test_pwd_glibc |
TARGETS+=test_grp test_grp_glibc |
TARGETS+=pwcat pwcat_glibc |
TARGETS+=grcat grcat_glibc |
TARGETS+=getgroups getgroups_glibc |
TARGETS+=test_pwd_diff test_grp_diff pwcat_diff grcat_diff getgroups_diff |
|
all: $(TARGETS) |
|
test_pwd: test_pwd.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak |
-@ echo "-------" |
-@ echo " " |
-@ echo "Compiling vs uClibc: " |
-@ echo " " |
$(CC) $(CFLAGS) -c $< -o $@.o |
$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS) |
$(STRIPTOOL) -x -R .note -R .comment $@ |
-./$@ 2>&1 >test_pwd.out |
-@ echo " " |
|
test_pwd_glibc: test_pwd.c Makefile |
-@ echo "-------" |
-@ echo " " |
-@ echo "Compiling vs GNU libc: " |
-@ echo " " |
$(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o |
$(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ |
$(STRIPTOOL) -x -R .note -R .comment $@ |
-./$@ 2>&1 >test_pwd_glibc.out |
-@ echo " " |
|
test_grp: test_grp.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak |
-@ echo "-------" |
-@ echo " " |
-@ echo "Compiling vs uClibc: " |
-@ echo " " |
$(CC) $(CFLAGS) -c $< -o $@.o |
$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS) |
$(STRIPTOOL) -x -R .note -R .comment $@ |
-./$@ 2>&1 >test_grp.out |
-@ echo " " |
|
test_grp_glibc: test_grp.c Makefile |
-@ echo "-------" |
-@ echo " " |
-@ echo "Compiling vs GNU libc: " |
-@ echo " " |
$(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o |
$(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ |
$(STRIPTOOL) -x -R .note -R .comment $@ |
-./$@ 2>&1 >test_grp_glibc.out |
-@ echo " " |
|
pwcat: pwcat.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak |
-@ echo "-------" |
-@ echo " " |
-@ echo "Compiling vs uClibc: " |
-@ echo " " |
$(CC) $(CFLAGS) -c $< -o $@.o |
$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS) |
$(STRIPTOOL) -x -R .note -R .comment $@ |
-./$@ 2>&1 >pwcat.out |
-@ echo " " |
|
pwcat_glibc: pwcat.c Makefile |
-@ echo "-------" |
-@ echo " " |
-@ echo "Compiling vs GNU libc: " |
-@ echo " " |
$(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o |
$(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ |
$(STRIPTOOL) -x -R .note -R .comment $@ |
-./$@ 2>&1 >pwcat_glibc.out |
-@ echo " " |
|
grcat: grcat.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak |
-@ echo "-------" |
-@ echo " " |
-@ echo "Compiling vs uClibc: " |
-@ echo " " |
$(CC) $(CFLAGS) -c $< -o $@.o |
$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS) |
$(STRIPTOOL) -x -R .note -R .comment $@ |
-./$@ 2>&1 >grcat.out |
-@ echo " " |
|
grcat_glibc: grcat.c Makefile |
-@ echo "-------" |
-@ echo " " |
-@ echo "Compiling vs GNU libc: " |
-@ echo " " |
$(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o |
$(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ |
$(STRIPTOOL) -x -R .note -R .comment $@ |
-./$@ 2>&1 >grcat_glibc.out |
-@ echo " " |
|
getgroups: getgroups.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak |
-@ echo "-------" |
-@ echo " " |
-@ echo "Compiling vs uClibc: " |
-@ echo " " |
$(CC) $(CFLAGS) -c $< -o $@.o |
$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS) |
$(STRIPTOOL) -x -R .note -R .comment $@ |
-./$@ 2>&1 >getgroups.out |
-@ echo " " |
|
getgroups_glibc: getgroups.c Makefile |
-@ echo "-------" |
-@ echo " " |
-@ echo "Compiling vs GNU libc: " |
-@ echo " " |
$(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o |
$(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ |
$(STRIPTOOL) -x -R .note -R .comment $@ |
-./$@ 2>&1 >getgroups_glibc.out |
-@ echo " " |
|
test_pwd_diff: test_pwd_glibc test_pwd |
-@ echo "-------" |
-@ echo " " |
-@ echo "Diffing output: " |
-@ echo " " |
-diff -u test_pwd_glibc.out test_pwd.out |
-@ echo " " |
|
test_grp_diff: test_grp_glibc test_grp |
-@ echo "-------" |
-@ echo " " |
-@ echo "Diffing output: " |
-@ echo " " |
-diff -u test_grp_glibc.out test_grp.out |
-@ echo " " |
|
pwcat_diff: pwcat_glibc pwcat |
-@ echo "-------" |
-@ echo " " |
-@ echo "Diffing output: " |
-@ echo " " |
-diff -u pwcat_glibc.out pwcat.out |
-@ echo " " |
|
grcat_diff: grcat_glibc grcat |
-@ echo "-------" |
-@ echo " " |
-@ echo "Diffing output: " |
-@ echo " " |
-diff -u grcat_glibc.out grcat.out |
-@ echo " " |
|
getgroups_diff: getgroups_glibc getgroups |
-@ echo "-------" |
-@ echo " " |
-@ echo "Diffing output: " |
-@ echo " " |
-diff -u getgroups_glibc.out getgroups.out |
-@ echo " " |
|
clean: |
$(RM) *.[oa] *~ core $(TARGETS) *.out |
|
|
/.indent.pro
0,0 → 1,33
--blank-lines-after-declarations |
--blank-lines-after-procedures |
--break-before-boolean-operator |
--no-blank-lines-after-commas |
--braces-on-if-line |
--braces-on-struct-decl-line |
--comment-indentation25 |
--declaration-comment-column25 |
--no-comment-delimiters-on-blank-lines |
--cuddle-else |
--continuation-indentation4 |
--case-indentation0 |
--else-endif-column33 |
--space-after-cast |
--line-comments-indentation0 |
--declaration-indentation1 |
--dont-format-first-column-comments |
--dont-format-comments |
--honour-newlines |
--indent-level4 |
/* changed from 0 to 4 */ |
--parameter-indentation4 |
--line-length78 /* changed from 75 */ |
--continue-at-parentheses |
--no-space-after-function-call-names |
--dont-break-procedure-type |
--dont-star-comments |
--leave-optional-blank-lines |
--dont-space-special-semicolon |
--tab-size4 |
/* additions by Mark */ |
--case-brace-indentation0 |
--leave-preprocessor-space |
.
Property changes :
Added: svn:ignore
## -0,0 +1,20 ##
+test_grp
+test_grp.out
+test_grp_glibc
+test_grp_glibc.out
+test_pwd
+test_pwd.out
+test_pwd_glibc
+test_pwd_glibc.out
+pwcat
+pwcat.out
+pwcat_glibc
+pwcat_glibc.out
+grcat
+grcat.out
+grcat_glibc
+grcat_glibc.out
+getgroups
+getgroups.out
+getgroups_glibc
+getgroups_glibc.out