Changeset 745 for trunk/server/lib/nss_wrapper/testsuite.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/lib/nss_wrapper/testsuite.c
r414 r745 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.