Changeset 740 for vendor/current/lib/nss_wrapper
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- Location:
- vendor/current/lib/nss_wrapper
- Files:
-
- 2 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/lib/nss_wrapper/nss_wrapper.c
r414 r740 34 34 35 35 #ifdef _SAMBA_BUILD_ 36 37 /* defining this gives us the posix getpwnam_r() calls on solaris 38 Thanks to heimdal for this */ 39 #define _POSIX_PTHREAD_SEMANTICS 36 40 37 41 #define NSS_WRAPPER_NOT_REPLACE … … 208 212 }; 209 213 210 /* proto ypes for files backend */214 /* prototypes for files backend */ 211 215 212 216 … … 246 250 static void nwrap_files_endgrent(struct nwrap_backend *b); 247 251 248 /* proto ypes for module backend */252 /* prototypes for module backend */ 249 253 250 254 static struct passwd *nwrap_module_getpwent(struct nwrap_backend *b); … … 461 465 struct nwrap_backend **backends) 462 466 { 467 struct nwrap_backend *b; 468 463 469 *backends = (struct nwrap_backend *)realloc(*backends, 464 470 sizeof(struct nwrap_backend) * ((*num_backends) + 1)); … … 469 475 } 470 476 471 (*backends)[*num_backends].name = name; 472 (*backends)[*num_backends].ops = ops; 473 (*backends)[*num_backends].so_path = so_path; 474 (*backends)[*num_backends].so_handle = nwrap_load_module(so_path); 475 (*backends)[*num_backends].fns = nwrap_load_module_fns(&((*backends)[*num_backends])); 477 b = &((*backends)[*num_backends]); 478 479 b->name = name; 480 b->ops = ops; 481 b->so_path = so_path; 482 483 if (so_path != NULL) { 484 b->so_handle = nwrap_load_module(so_path); 485 b->fns = nwrap_load_module_fns(b); 486 if (b->fns == NULL) { 487 return false; 488 } 489 } else { 490 b->so_handle = NULL; 491 b->fns = NULL; 492 } 476 493 477 494 (*num_backends)++; … … 2169 2186 gid_t *groups_tmp; 2170 2187 int count = 1; 2171 const char *name_of_group = NULL;2188 const char *name_of_group = ""; 2172 2189 2173 2190 if (!nwrap_enabled()) { -
vendor/current/lib/nss_wrapper/nss_wrapper.pl
r414 r740 14 14 my $opt_name = undef; 15 15 my $opt_member = undef; 16 my $opt_gid = 65534;# nogroup gid 16 17 17 18 my $passwdfn = undef; … … 20 21 my $actionfn = undef; 21 22 22 sub passwd_add($$$$ );23 sub passwd_delete($$$$ );24 sub group_add($$$$ );25 sub group_delete($$$$ );26 sub member_add($$$$ );27 sub member_delete($$$$ );23 sub passwd_add($$$$$); 24 sub passwd_delete($$$$$); 25 sub group_add($$$$$); 26 sub group_delete($$$$$); 27 sub member_add($$$$$); 28 sub member_delete($$$$$); 28 29 29 30 sub check_path($$); … … 36 37 'type=s' => \$opt_type, 37 38 'name=s' => \$opt_name, 38 'member=s' => \$opt_member 39 'member=s' => \$opt_member, 40 'gid=i' => \$opt_gid 39 41 ); 40 42 … … 59 61 60 62 --member <member> The name of the member. 63 64 --gid <gid> Primary Group ID for new users. 61 65 "; 62 66 exit($ret); … … 111 115 } 112 116 113 exit $actionfn->($opt_fullpath_passwd, $opt_member, $opt_fullpath_group, $opt_name );117 exit $actionfn->($opt_fullpath_passwd, $opt_member, $opt_fullpath_group, $opt_name, $opt_gid); 114 118 115 119 sub check_path($$) … … 389 393 } 390 394 391 sub passwd_add($$$$ )392 { 393 my ($path, $dummy, $dummy2, $name ) = @_;395 sub passwd_add($$$$$) 396 { 397 my ($path, $dummy, $dummy2, $name, $gid) = @_; 394 398 395 399 #print "passwd_add: '$name' in '$path'\n"; … … 401 405 402 406 my $uid = passwd_get_free_uid($passwd); 403 my $gid = 65534;# nogroup gid404 407 405 408 my $pwent = $name.":x:".$uid.":".$gid.":".$name." gecos:/nodir:/bin/false"; … … 412 415 } 413 416 414 sub passwd_delete($$$$ )415 { 416 my ($path, $dummy, $dummy2, $name ) = @_;417 sub passwd_delete($$$$$) 418 { 419 my ($path, $dummy, $dummy2, $name, $dummy3) = @_; 417 420 418 421 #print "passwd_delete: '$name' in '$path'\n"; … … 430 433 } 431 434 432 sub group_add($$$$ )433 { 434 my ($dummy, $dummy2, $path, $name ) = @_;435 sub group_add($$$$$) 436 { 437 my ($dummy, $dummy2, $path, $name, $dummy3) = @_; 435 438 436 439 #print "group_add: '$name' in '$path'\n"; … … 454 457 } 455 458 456 sub group_delete($$$$ )457 { 458 my ($dummy, $dummy2, $path, $name ) = @_;459 sub group_delete($$$$$) 460 { 461 my ($dummy, $dummy2, $path, $name, $dummy3) = @_; 459 462 460 463 #print "group_delete: '$name' in '$path'\n"; … … 472 475 } 473 476 474 sub member_add($$$$ )475 { 476 my ($passwd_path, $username, $group_path, $groupname ) = @_;477 sub member_add($$$$$) 478 { 479 my ($passwd_path, $username, $group_path, $groupname, $dummy) = @_; 477 480 478 481 #print "member_add: adding '$username' in '$passwd_path' to '$groupname' in '$group_path'\n"; … … 495 498 } 496 499 497 sub member_delete($$$$ )498 { 499 my ($passwd_path, $username, $group_path, $groupname ) = @_;500 sub member_delete($$$$$) 501 { 502 my ($passwd_path, $username, $group_path, $groupname, $dummy) = @_; 500 503 501 504 #print "member_delete: removing '$username' in '$passwd_path' from '$groupname' in '$group_path'\n"; -
vendor/current/lib/nss_wrapper/testsuite.c
r414 r740 4 4 local testing of the nss wrapper 5 5 6 Copyright (C) Guenther Deschner 2009 6 Copyright (C) Guenther Deschner 2009-2010 7 7 8 8 This program is free software; you can redistribute it and/or modify … … 21 21 22 22 #include "includes.h" 23 24 #ifndef NSS_WRAPPER 25 #define NSS_WRAPPER 26 #endif 27 23 28 #include "torture/torture.h" 24 29 #include "lib/replace/system/passwd.h" 25 #include "lib/nss_wrapper/nss_wrapper.h"26 30 27 31 static bool copy_passwd(struct torture_context *tctx, … … 176 180 (unsigned long)grp->gr_gid); 177 181 178 if ( !grp->gr_mem[0]) {182 if ((grp->gr_mem == NULL) || !grp->gr_mem[0]) { 179 183 printf("\n"); 180 184 return; … … 773 777 774 778 if (!old_pwd || !old_group) { 779 torture_comment(tctx, "ENV NSS_WRAPPER_PASSWD or NSS_WRAPPER_GROUP not set\n"); 775 780 torture_skip(tctx, "nothing to test\n"); 776 return true;777 781 } 778 782 … … 798 802 799 803 if (!old_pwd || !old_group) { 804 torture_comment(tctx, "ENV NSS_WRAPPER_PASSWD or NSS_WRAPPER_GROUP not set\n"); 800 805 torture_skip(tctx, "nothing to test\n"); 801 return true;802 806 } 803 807 … … 816 820 817 821 if (!old_pwd || !old_group) { 822 torture_comment(tctx, "ENV NSS_WRAPPER_PASSWD or NSS_WRAPPER_GROUP not set\n"); 818 823 torture_skip(tctx, "nothing to test\n"); 819 return true;820 824 } 821 825 … … 836 840 837 841 if (!old_pwd || !old_group) { 842 torture_comment(tctx, "ENV NSS_WRAPPER_PASSWD or NSS_WRAPPER_GROUP not set\n"); 838 843 torture_skip(tctx, "nothing to test\n"); 839 return true;840 844 } 841 845 … … 850 854 } 851 855 856 static bool test_nwrap_passwd_duplicates(struct torture_context *tctx) 857 { 858 int i, d; 859 struct passwd *pwd; 860 size_t num_pwd; 861 int duplicates = 0; 862 863 torture_assert(tctx, test_nwrap_enum_passwd(tctx, &pwd, &num_pwd), 864 "failed to enumerate passwd"); 865 866 for (i=0; i < num_pwd; i++) { 867 const char *current_name = pwd[i].pw_name; 868 for (d=0; d < num_pwd; d++) { 869 const char *dup_name = pwd[d].pw_name; 870 if (d == i) { 871 continue; 872 } 873 if (!strequal(current_name, dup_name)) { 874 continue; 875 } 876 877 torture_warning(tctx, "found duplicate names:"); 878 print_passwd(&pwd[d]); 879 print_passwd(&pwd[i]); 880 duplicates++; 881 } 882 } 883 884 if (duplicates) { 885 torture_fail(tctx, talloc_asprintf(tctx, "found %d duplicate names", duplicates)); 886 } 887 888 return true; 889 } 890 891 static bool test_nwrap_group_duplicates(struct torture_context *tctx) 892 { 893 int i, d; 894 struct group *grp; 895 size_t num_grp; 896 int duplicates = 0; 897 898 torture_assert(tctx, test_nwrap_enum_group(tctx, &grp, &num_grp), 899 "failed to enumerate group"); 900 901 for (i=0; i < num_grp; i++) { 902 const char *current_name = grp[i].gr_name; 903 for (d=0; d < num_grp; d++) { 904 const char *dup_name = grp[d].gr_name; 905 if (d == i) { 906 continue; 907 } 908 if (!strequal(current_name, dup_name)) { 909 continue; 910 } 911 912 torture_warning(tctx, "found duplicate names:"); 913 print_group(&grp[d]); 914 print_group(&grp[i]); 915 duplicates++; 916 } 917 } 918 919 if (duplicates) { 920 torture_fail(tctx, talloc_asprintf(tctx, "found %d duplicate names", duplicates)); 921 } 922 923 return true; 924 } 925 926 927 static bool test_nwrap_duplicates(struct torture_context *tctx) 928 { 929 const char *old_pwd = getenv("NSS_WRAPPER_PASSWD"); 930 const char *old_group = getenv("NSS_WRAPPER_GROUP"); 931 932 if (!old_pwd || !old_group) { 933 torture_comment(tctx, "ENV NSS_WRAPPER_PASSWD or NSS_WRAPPER_GROUP not set\n"); 934 torture_skip(tctx, "nothing to test\n"); 935 } 936 937 torture_assert(tctx, test_nwrap_passwd_duplicates(tctx), 938 "failed to test users"); 939 torture_assert(tctx, test_nwrap_group_duplicates(tctx), 940 "failed to test groups"); 941 942 return true; 943 } 944 945 852 946 struct torture_suite *torture_local_nss_wrapper(TALLOC_CTX *mem_ctx) 853 947 { 854 struct torture_suite *suite = torture_suite_create(mem_ctx, " NSS-WRAPPER");948 struct torture_suite *suite = torture_suite_create(mem_ctx, "nss-wrapper"); 855 949 856 950 torture_suite_add_simple_test(suite, "enumeration", test_nwrap_enumeration); … … 858 952 torture_suite_add_simple_test(suite, "reentrant enumeration crosschecks", test_nwrap_reentrant_enumeration_crosschecks); 859 953 torture_suite_add_simple_test(suite, "membership", test_nwrap_membership); 954 torture_suite_add_simple_test(suite, "duplicates", test_nwrap_duplicates); 860 955 861 956 return suite;
Note:
See TracChangeset
for help on using the changeset viewer.