Ignore:
Timestamp:
Jun 7, 2011, 12:58:14 PM (13 years ago)
Author:
achernya
Message:
Merge r1803-1877 from trunk to branches/fc15-dev
Location:
branches/fc15-dev
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/fc15-dev

  • branches/fc15-dev/server/common/oursrc/nss_nonlocal/nonlocal-shadow.c

    r1553 r1878  
    4040
    4141
    42 static service_user *
    43 nss_shadow_nonlocal_database(void)
     42static service_user *__nss_shadow_nonlocal_database;
     43
     44static int
     45internal_function
     46__nss_shadow_nonlocal_lookup(service_user **ni, const char *fct_name,
     47                            void **fctp)
    4448{
    45     static service_user *nip = NULL;
    46     if (nip == NULL)
    47         __nss_database_lookup("shadow_nonlocal", NULL, "", &nip);
     49    if (__nss_shadow_nonlocal_database == NULL
     50        && __nss_database_lookup("shadow_nonlocal", NULL, NULL,
     51                                 &__nss_shadow_nonlocal_database) < 0)
     52        return -1;
    4853
    49     return nip;
     54    *ni = __nss_shadow_nonlocal_database;
     55
     56    *fctp = __nss_lookup_function(*ni, fct_name);
     57    return 0;
    5058}
    5159
    5260
    53 static service_user *spent_nip = NULL;
     61static service_user *spent_startp, *spent_nip;
    5462static void *spent_fct_start;
    5563static union {
     
    6371_nss_nonlocal_setspent(int stayopen)
    6472{
    65     static const char *fct_name = "setspent";
    66     static void *fct_start = NULL;
    6773    enum nss_status status;
    68     service_user *nip;
    69     union {
    70         enum nss_status (*l)(int stayopen);
    71         void *ptr;
    72     } fct;
    73 
    74     nip = nss_shadow_nonlocal_database();
    75     if (nip == NULL)
    76         return NSS_STATUS_UNAVAIL;
    77     if (fct_start == NULL)
    78         fct_start = __nss_lookup_function(nip, fct_name);
    79     fct.ptr = fct_start;
    80     do {
    81         if (fct.ptr == NULL)
    82             status = NSS_STATUS_UNAVAIL;
    83         else
    84             status = DL_CALL_FCT(fct.l, (stayopen));
    85     } while (__nss_next(&nip, fct_name, &fct.ptr, status, 0) == 0);
     74    const struct walk_nss w = {
     75        .lookup = &__nss_shadow_nonlocal_lookup, .fct_name = "setspent",
     76        .status = &status
     77    };
     78    const __typeof__(&_nss_nonlocal_setspent) self = NULL;
     79#define args (stayopen)
     80#include "walk_nss.h"
     81#undef args
    8682    if (status != NSS_STATUS_SUCCESS)
    8783        return status;
    8884
    89     spent_nip = nip;
    9085    if (spent_fct_start == NULL)
    91         spent_fct_start = __nss_lookup_function(nip, spent_fct_name);
     86        __nss_shadow_nonlocal_lookup(&spent_startp, spent_fct_name,
     87                                     &spent_fct_start);
     88    spent_nip = spent_startp;
    9289    spent_fct.ptr = spent_fct_start;
    9390    return NSS_STATUS_SUCCESS;
     
    9794_nss_nonlocal_endspent(void)
    9895{
    99     static const char *fct_name = "endspent";
    100     static void *fct_start = NULL;
    10196    enum nss_status status;
    102     service_user *nip;
    103     union {
    104         enum nss_status (*l)(void);
    105         void *ptr;
    106     } fct;
     97    const struct walk_nss w = {
     98        .lookup = &__nss_shadow_nonlocal_lookup, .fct_name = "endspent",
     99        .status = &status
     100    };
     101    const __typeof__(&_nss_nonlocal_endspent) self = NULL;
    107102
    108103    spent_nip = NULL;
    109104
    110     nip = nss_shadow_nonlocal_database();
    111     if (nip == NULL)
    112         return NSS_STATUS_UNAVAIL;
    113     if (fct_start == NULL)
    114         fct_start = __nss_lookup_function(nip, fct_name);
    115     fct.ptr = fct_start;
    116     do {
    117         if (fct.ptr == NULL)
    118             status = NSS_STATUS_UNAVAIL;
    119         else
    120             status = DL_CALL_FCT(fct.l, ());
    121     } while (__nss_next(&nip, fct_name, &fct.ptr, status, 0) == 0);
     105#define args ()
     106#include "walk_nss.h"
     107#undef args
    122108    return status;
    123109}
     
    154140                         char *buffer, size_t buflen, int *errnop)
    155141{
    156     static const char *fct_name = "getspnam_r";
    157     static void *fct_start = NULL;
    158142    enum nss_status status;
    159     service_user *nip;
    160     union {
    161         enum nss_status (*l)(const char *name, struct spwd *pwd,
    162                              char *buffer, size_t buflen, int *errnop);
    163         void *ptr;
    164     } fct;
    165 
    166     nip = nss_shadow_nonlocal_database();
    167     if (nip == NULL)
    168         return NSS_STATUS_UNAVAIL;
    169     if (fct_start == NULL)
    170         fct_start = __nss_lookup_function(nip, fct_name);
    171     fct.ptr = fct_start;
    172     do {
    173         if (fct.ptr == NULL)
    174             status = NSS_STATUS_UNAVAIL;
    175         else
    176             status = DL_CALL_FCT(fct.l, (name, pwd, buffer, buflen, errnop));
    177         if (status == NSS_STATUS_TRYAGAIN && *errnop == ERANGE)
    178             break;
    179     } while (__nss_next(&nip, fct_name, &fct.ptr, status, 0) == 0);
     143    const struct walk_nss w = {
     144        .lookup = __nss_shadow_nonlocal_lookup, .fct_name = "getspnam_r",
     145        .status = &status, .errnop = errnop
     146    };
     147    const __typeof__(&_nss_nonlocal_getspnam_r) self = NULL;
     148#define args (name, pwd, buffer, buflen, errnop)
     149#include "walk_nss.h"
     150#undef args
    180151    if (status != NSS_STATUS_SUCCESS)
    181152        return status;
Note: See TracChangeset for help on using the changeset viewer.