Changeset 2432 for trunk


Ignore:
Timestamp:
Jun 13, 2013, 6:01:30 AM (11 years ago)
Author:
andersk
Message:
Update nss_nonlocal to 2.1

- Support Automake 1.12.
- Guard one-time initialization with memory barriers.
- Make initgroups_dyn succeed when adding only magic groups.

Location:
trunk/server
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/common/oursrc/nss_nonlocal/Makefile.am

    r1825 r2432  
    22libnss_nonlocal_la_SOURCES = \
    33    nonlocal-passwd.c nonlocal-group.c nonlocal-shadow.c \
    4     nonlocal.h nsswitch-internal.h
     4    nonlocal.h nsswitch-internal.h walk_nss.h
    55libnss_nonlocal_la_LDFLAGS = \
    66    -version-info 2:0:0 \
     
    1111        rm -f $(DESTDIR)$(libdir)/libnss_nonlocal.so
    1212        rm -f $(DESTDIR)$(libdir)/libnss_nonlocal.la
     13
     14uninstall-local:
     15        rm -f $(DESTDIR)$(libdir)/libnss_nonlocal.so.*
  • trunk/server/common/oursrc/nss_nonlocal/configure.ac

    r1825 r2432  
    1 AC_INIT([nss_nonlocal], [2.0], [andersk@mit.edu])
     1AC_INIT([nss_nonlocal], [2.1], [andersk@mit.edu])
    22AC_CANONICAL_TARGET
    33AM_INIT_AUTOMAKE([-Wall -Werror foreign])
     
    77AC_DISABLE_STATIC
    88AC_PROG_CC
    9 AC_PROG_INSTALL
     9m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
    1010AC_PROG_LIBTOOL
    1111
  • trunk/server/common/oursrc/nss_nonlocal/nonlocal-group.c

    r1825 r2432  
    2525
    2626#define _GNU_SOURCE
     27
    2728#include <sys/types.h>
    28 #include <unistd.h>
    29 #include <stdlib.h>
    30 #include <stdint.h>
    31 #include <string.h>
    3229#include <dlfcn.h>
    33 #include <stdio.h>
    34 #include <syslog.h>
    3530#include <errno.h>
    36 #include <pwd.h>
    3731#include <grp.h>
    3832#include <nss.h>
     33#include <pwd.h>
     34#include <stdbool.h>
     35#include <stddef.h>
     36#include <stdlib.h>
     37#include <string.h>
     38#include <syslog.h>
     39#include <unistd.h>
     40
    3941#include "nsswitch-internal.h"
    4042#include "nonlocal.h"
     
    170172}
    171173
     174static bool grent_initialized = false;
    172175static service_user *grent_startp, *grent_nip;
    173176static void *grent_fct_start;
     
    194197        return status;
    195198
    196     if (grent_fct_start == NULL)
     199    if (!grent_initialized) {
    197200        __nss_group_nonlocal_lookup(&grent_startp, grent_fct_name,
    198201                                    &grent_fct_start);
     202        __sync_synchronize();
     203        grent_initialized = true;
     204    }
    199205    grent_nip = grent_startp;
    200206    grent_fct.ptr = grent_fct_start;
     
    208214    const struct walk_nss w = {
    209215        .lookup = &__nss_group_nonlocal_lookup, .fct_name = "endgrent",
    210         .status = &status
     216        .status = &status, .all_values = 1,
    211217    };
    212218    const __typeof__(&_nss_nonlocal_endgrent) self = NULL;
     
    356362    const struct walk_nss w = {
    357363        .lookup = &__nss_group_nonlocal_lookup, .fct_name = "initgroups_dyn",
    358         .status = &status, .errnop = errnop
     364        .status = &status, .all_values = 1, .errnop = errnop
    359365    };
    360366    const __typeof__(&_nss_nonlocal_initgroups_dyn) self = NULL;
     
    445451#include "walk_nss.h"
    446452#undef args
    447     if (status != NSS_STATUS_SUCCESS)
     453    if (status == NSS_STATUS_NOTFOUND || status == NSS_STATUS_UNAVAIL)
     454        return NSS_STATUS_SUCCESS;
     455    else if (status != NSS_STATUS_SUCCESS)
    448456        return status;
    449457
  • trunk/server/common/oursrc/nss_nonlocal/nonlocal-passwd.c

    r1825 r2432  
    2626
    2727#define _GNU_SOURCE
     28
    2829#include <sys/types.h>
     30#include <dlfcn.h>
     31#include <errno.h>
     32#include <nss.h>
     33#include <pwd.h>
     34#include <stdbool.h>
     35#include <stddef.h>
     36#include <stdlib.h>
     37#include <string.h>
     38#include <syslog.h>
    2939#include <unistd.h>
    30 #include <stdlib.h>
    31 #include <stdint.h>
    32 #include <string.h>
    33 #include <dlfcn.h>
    34 #include <stdio.h>
    35 #include <syslog.h>
    36 #include <errno.h>
    37 #include <pwd.h>
    38 #include <grp.h>
    39 #include <nss.h>
     40
    4041#include "nsswitch-internal.h"
    4142#include "nonlocal.h"
     
    162163
    163164
     165static bool pwent_initialized = false;
    164166static service_user *pwent_startp, *pwent_nip;
    165167static void *pwent_fct_start;
     
    186188        return status;
    187189
    188     if (pwent_fct_start == NULL)
     190    if (!pwent_initialized) {
    189191        __nss_passwd_nonlocal_lookup(&pwent_startp, pwent_fct_name,
    190192                                     &pwent_fct_start);
     193        __sync_synchronize();
     194        pwent_initialized = true;
     195    }
    191196    pwent_nip = pwent_startp;
    192197    pwent_fct.ptr = pwent_fct_start;
     
    200205    const struct walk_nss w = {
    201206        .lookup = &__nss_passwd_nonlocal_lookup, .fct_name = "endpwent",
    202         .status = &status
     207        .status = &status, .all_values = 1,
    203208    };
    204209    const __typeof__(&_nss_nonlocal_endpwent) self = NULL;
  • trunk/server/common/oursrc/nss_nonlocal/nonlocal-shadow.c

    r1825 r2432  
    2424
    2525#define _GNU_SOURCE
     26
    2627#include <sys/types.h>
    27 #include <unistd.h>
     28#include <dlfcn.h>
     29#include <errno.h>
     30#include <nss.h>
     31#include <shadow.h>
     32#include <stdbool.h>
     33#include <stddef.h>
    2834#include <stdlib.h>
    29 #include <stdint.h>
    3035#include <string.h>
    31 #include <dlfcn.h>
    32 #include <stdio.h>
    3336#include <syslog.h>
    34 #include <errno.h>
    35 #include <shadow.h>
    36 #include <nss.h>
    3737
    3838#include "nsswitch-internal.h"
     
    5959
    6060
     61static bool spent_initialized = false;
    6162static service_user *spent_startp, *spent_nip;
    6263static void *spent_fct_start;
     
    8384        return status;
    8485
    85     if (spent_fct_start == NULL)
     86    if (!spent_initialized) {
    8687        __nss_shadow_nonlocal_lookup(&spent_startp, spent_fct_name,
    8788                                     &spent_fct_start);
     89        __sync_synchronize();
     90        spent_initialized = true;
     91    }
    8892    spent_nip = spent_startp;
    8993    spent_fct.ptr = spent_fct_start;
     
    114118{
    115119    enum nss_status status;
     120
     121    char *nonlocal_ignore = getenv(NONLOCAL_IGNORE_ENV);
     122    if (nonlocal_ignore != NULL && nonlocal_ignore[0] != '\0')
     123        return NSS_STATUS_UNAVAIL;
     124
    116125    if (spent_nip == NULL) {
    117126        status = _nss_nonlocal_setspent(0);
  • trunk/server/common/oursrc/nss_nonlocal/nonlocal.h

    r1825 r2432  
    5050struct walk_nss {
    5151    enum nss_status *status;
     52    int all_values;
    5253    int (*lookup)(service_user **ni, const char *fct_name,
    5354                  void **fctp) internal_function;
  • trunk/server/common/oursrc/nss_nonlocal/walk_nss.h

    r1825 r2432  
     1/*
     2 * walk_nss.h
     3 * NSS walking template for nss_nonlocal proxy
     4 *
     5 * Copyright © 2011 Anders Kaseorg <andersk@mit.edu> and Tim Abbott
     6 * <tabbott@mit.edu>
     7 *
     8 * This file is part of nss_nonlocal.
     9 *
     10 * nss_nonlocal is free software; you can redistribute it and/or
     11 * modify it under the terms of the GNU Lesser General Public License
     12 * as published by the Free Software Foundation; either version 2.1 of
     13 * the License, or (at your option) any later version.
     14 *
     15 * nss_nonlocal is distributed in the hope that it will be useful, but
     16 * WITHOUT ANY WARRANTY; without even the implied warranty of
     17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     18 * Lesser General Public License for more details.
     19 *
     20 * You should have received a copy of the GNU Lesser General Public
     21 * License along with nss_nonlocal; if not, write to the Free Software
     22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
     23 * 02110-1301  USA
     24 */
     25
    126{
    2     static service_user *startp = NULL;
    3     static void *fct_start = NULL;
     27    static bool initialized = false;
     28    static service_user *startp;
     29    static void *fct_start;
    430
    531    service_user *nip;
     
    1036    int old_errno = errno;
    1137
    12     if (fct_start == NULL &&
    13         w.lookup(&startp, w.fct_name, &fct_start) != 0) {
    14         *w.status = NSS_STATUS_UNAVAIL;
    15         goto walk_nss_out;
     38    if (!initialized) {
     39        if (w.lookup(&startp, w.fct_name, &fct_start) != 0) {
     40            *w.status = NSS_STATUS_UNAVAIL;
     41            goto walk_nss_out;
     42        }
     43        __sync_synchronize();
     44        initialized = true;
    1645    }
    1746
     
    5180            goto walk_nss_morebuf;
    5281        }
    53     } while (__nss_next(&nip, w.fct_name, &fct.ptr, *w.status, 0) == 0);
     82    } while (__nss_next(&nip, w.fct_name, &fct.ptr, *w.status, w.all_values) ==
     83             0);
    5484
    5585    if (w.buf != NULL && *w.status != NSS_STATUS_SUCCESS) {
  • trunk/server/fedora/specs/nss_nonlocal.spec

    r1825 r2432  
    22Group: System Environment/Libraries
    33Name: nss_nonlocal
    4 Version: 2.0
     4Version: 2.1
    55Release: 1
    66URL: http://debathena.mit.edu/nss_nonlocal/
     
    6363%changelog
    6464
     65* Thu Jun 13 2013 Anders Kaseorg <andersk@mit.edu> 2.1-1
     66- New upstream version.
     67
    6568* Tue Mar 29 2011 Anders Kaseorg <andersk@mit.edu> 2.0-1
    6669- New upstream version.
Note: See TracChangeset for help on using the changeset viewer.