Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

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  
    3434
    3535#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
    3640
    3741#define NSS_WRAPPER_NOT_REPLACE
     
    208212};
    209213
    210 /* protoypes for files backend */
     214/* prototypes for files backend */
    211215
    212216
     
    246250static void nwrap_files_endgrent(struct nwrap_backend *b);
    247251
    248 /* protoypes for module backend */
     252/* prototypes for module backend */
    249253
    250254static struct passwd *nwrap_module_getpwent(struct nwrap_backend *b);
     
    461465                              struct nwrap_backend **backends)
    462466{
     467        struct nwrap_backend *b;
     468
    463469        *backends = (struct nwrap_backend *)realloc(*backends,
    464470                sizeof(struct nwrap_backend) * ((*num_backends) + 1));
     
    469475        }
    470476
    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        }
    476493
    477494        (*num_backends)++;
     
    21692186        gid_t *groups_tmp;
    21702187        int count = 1;
    2171         const char *name_of_group = NULL;
     2188        const char *name_of_group = "";
    21722189
    21732190        if (!nwrap_enabled()) {
  • vendor/current/lib/nss_wrapper/nss_wrapper.pl

    r414 r740  
    1414my $opt_name = undef;
    1515my $opt_member = undef;
     16my $opt_gid = 65534;# nogroup gid
    1617
    1718my $passwdfn = undef;
     
    2021my $actionfn = undef;
    2122
    22 sub passwd_add($$$$);
    23 sub passwd_delete($$$$);
    24 sub group_add($$$$);
    25 sub group_delete($$$$);
    26 sub member_add($$$$);
    27 sub member_delete($$$$);
     23sub passwd_add($$$$$);
     24sub passwd_delete($$$$$);
     25sub group_add($$$$$);
     26sub group_delete($$$$$);
     27sub member_add($$$$$);
     28sub member_delete($$$$$);
    2829
    2930sub check_path($$);
     
    3637        'type=s'        => \$opt_type,
    3738        'name=s'        => \$opt_name,
    38         'member=s'      => \$opt_member
     39        'member=s'      => \$opt_member,
     40        'gid=i'         => \$opt_gid
    3941);
    4042
     
    5961
    6062        --member <member>       The name of the member.
     63
     64        --gid <gid>             Primary Group ID for new users.
    6165";
    6266        exit($ret);
     
    111115}
    112116
    113 exit $actionfn->($opt_fullpath_passwd, $opt_member, $opt_fullpath_group, $opt_name);
     117exit $actionfn->($opt_fullpath_passwd, $opt_member, $opt_fullpath_group, $opt_name, $opt_gid);
    114118
    115119sub check_path($$)
     
    389393}
    390394
    391 sub passwd_add($$$$)
    392 {
    393         my ($path, $dummy, $dummy2, $name) = @_;
     395sub passwd_add($$$$$)
     396{
     397        my ($path, $dummy, $dummy2, $name, $gid) = @_;
    394398
    395399        #print "passwd_add: '$name' in '$path'\n";
     
    401405
    402406        my $uid = passwd_get_free_uid($passwd);
    403         my $gid = 65534;# nogroup gid
    404407
    405408        my $pwent = $name.":x:".$uid.":".$gid.":".$name." gecos:/nodir:/bin/false";
     
    412415}
    413416
    414 sub passwd_delete($$$$)
    415 {
    416         my ($path, $dummy, $dummy2, $name) = @_;
     417sub passwd_delete($$$$$)
     418{
     419        my ($path, $dummy, $dummy2, $name, $dummy3) = @_;
    417420
    418421        #print "passwd_delete: '$name' in '$path'\n";
     
    430433}
    431434
    432 sub group_add($$$$)
    433 {
    434         my ($dummy, $dummy2, $path, $name) = @_;
     435sub group_add($$$$$)
     436{
     437        my ($dummy, $dummy2, $path, $name, $dummy3) = @_;
    435438
    436439        #print "group_add: '$name' in '$path'\n";
     
    454457}
    455458
    456 sub group_delete($$$$)
    457 {
    458         my ($dummy, $dummy2, $path, $name) = @_;
     459sub group_delete($$$$$)
     460{
     461        my ($dummy, $dummy2, $path, $name, $dummy3) = @_;
    459462
    460463        #print "group_delete: '$name' in '$path'\n";
     
    472475}
    473476
    474 sub member_add($$$$)
    475 {
    476         my ($passwd_path, $username, $group_path, $groupname) = @_;
     477sub member_add($$$$$)
     478{
     479        my ($passwd_path, $username, $group_path, $groupname, $dummy) = @_;
    477480
    478481        #print "member_add: adding '$username' in '$passwd_path' to '$groupname' in '$group_path'\n";
     
    495498}
    496499
    497 sub member_delete($$$$)
    498 {
    499         my ($passwd_path, $username, $group_path, $groupname) = @_;
     500sub member_delete($$$$$)
     501{
     502        my ($passwd_path, $username, $group_path, $groupname, $dummy) = @_;
    500503
    501504        #print "member_delete: removing '$username' in '$passwd_path' from '$groupname' in '$group_path'\n";
  • vendor/current/lib/nss_wrapper/testsuite.c

    r414 r740  
    44   local testing of the nss wrapper
    55
    6    Copyright (C) Guenther Deschner 2009
     6   Copyright (C) Guenther Deschner 2009-2010
    77
    88   This program is free software; you can redistribute it and/or modify
     
    2121
    2222#include "includes.h"
     23
     24#ifndef NSS_WRAPPER
     25#define NSS_WRAPPER
     26#endif
     27
    2328#include "torture/torture.h"
    2429#include "lib/replace/system/passwd.h"
    25 #include "lib/nss_wrapper/nss_wrapper.h"
    2630
    2731static bool copy_passwd(struct torture_context *tctx,
     
    176180               (unsigned long)grp->gr_gid);
    177181
    178         if (!grp->gr_mem[0]) {
     182        if ((grp->gr_mem == NULL) || !grp->gr_mem[0]) {
    179183                printf("\n");
    180184                return;
     
    773777
    774778        if (!old_pwd || !old_group) {
     779                torture_comment(tctx, "ENV NSS_WRAPPER_PASSWD or NSS_WRAPPER_GROUP not set\n");
    775780                torture_skip(tctx, "nothing to test\n");
    776                 return true;
    777781        }
    778782
     
    798802
    799803        if (!old_pwd || !old_group) {
     804                torture_comment(tctx, "ENV NSS_WRAPPER_PASSWD or NSS_WRAPPER_GROUP not set\n");
    800805                torture_skip(tctx, "nothing to test\n");
    801                 return true;
    802806        }
    803807
     
    816820
    817821        if (!old_pwd || !old_group) {
     822                torture_comment(tctx, "ENV NSS_WRAPPER_PASSWD or NSS_WRAPPER_GROUP not set\n");
    818823                torture_skip(tctx, "nothing to test\n");
    819                 return true;
    820824        }
    821825
     
    836840
    837841        if (!old_pwd || !old_group) {
     842                torture_comment(tctx, "ENV NSS_WRAPPER_PASSWD or NSS_WRAPPER_GROUP not set\n");
    838843                torture_skip(tctx, "nothing to test\n");
    839                 return true;
    840844        }
    841845
     
    850854}
    851855
     856static 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
     891static 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
     927static 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
    852946struct torture_suite *torture_local_nss_wrapper(TALLOC_CTX *mem_ctx)
    853947{
    854         struct torture_suite *suite = torture_suite_create(mem_ctx, "NSS-WRAPPER");
     948        struct torture_suite *suite = torture_suite_create(mem_ctx, "nss-wrapper");
    855949
    856950        torture_suite_add_simple_test(suite, "enumeration", test_nwrap_enumeration);
     
    858952        torture_suite_add_simple_test(suite, "reentrant enumeration crosschecks", test_nwrap_reentrant_enumeration_crosschecks);
    859953        torture_suite_add_simple_test(suite, "membership", test_nwrap_membership);
     954        torture_suite_add_simple_test(suite, "duplicates", test_nwrap_duplicates);
    860955
    861956        return suite;
Note: See TracChangeset for help on using the changeset viewer.