mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-10 05:03:06 +03:00
Move nss_compat from nis to nss subdir and install it unconditionally
This has been tested that local lookup still works with and without an installed libnss_nis, and that NIS lookup works when libnss_nis is available.
This commit is contained in:
22
ChangeLog
22
ChangeLog
@@ -1,3 +1,25 @@
|
|||||||
|
2017-10-04 Andreas Schwab <schwab@suse.de>
|
||||||
|
|
||||||
|
* nis/Makefile (services): Remove compat.
|
||||||
|
(libnss_compat-routines, libnss_compat-inhibit-o): Don't define.
|
||||||
|
($(objpfx)libnss_compat.so): Remove rule.
|
||||||
|
* nis/Versions (libnss_compat): Remove.
|
||||||
|
* nss/Makefile (services): Add compat.
|
||||||
|
(libnss_compat-routines, libnss_compat-inhibit-o): Define.
|
||||||
|
* nss/Versions (libnss_compat): Define.
|
||||||
|
* nss/nss_compat/compat-grp.c: Moved here from nis/nss_compat.
|
||||||
|
Don't include <rpc/types.h>. Replace bool_t by bool.
|
||||||
|
* nss/nss_compat/compat-initgroups.c: Likewise.
|
||||||
|
* nss/nss_compat/compat-pwd.c: Likewise. Include "nisdomain.h"
|
||||||
|
instead of <rpcsrv/ypclnt.h>.
|
||||||
|
(getpwent_next_nss_netgr): Use __nss_get_default_domain instead of
|
||||||
|
yp_get_default_domain.
|
||||||
|
* nss/nss_compat/compat-pwd.c: Likewise.
|
||||||
|
(getspent_next_nss_netgr): Use __nss_get_default_domain instead of
|
||||||
|
yp_get_default_domain.
|
||||||
|
* nss/nss_compat/nisdomain.c: New file.
|
||||||
|
* nss/nss_compat/nisdomain.h: Likewise.
|
||||||
|
|
||||||
2017-10-04 Szabolcs Nagy <szabolcs.nagy@arm.com>
|
2017-10-04 Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||||
|
|
||||||
[BZ #22244]
|
[BZ #22244]
|
||||||
|
@@ -33,7 +33,7 @@ databases = proto service hosts network grp pwd rpc ethers \
|
|||||||
spwd netgrp alias publickey
|
spwd netgrp alias publickey
|
||||||
|
|
||||||
# Specify rules for the nss_* modules.
|
# Specify rules for the nss_* modules.
|
||||||
services := nis nisplus compat
|
services := nis nisplus
|
||||||
endif
|
endif
|
||||||
|
|
||||||
extra-libs = libnsl
|
extra-libs = libnsl
|
||||||
@@ -63,9 +63,6 @@ libnsl-routines = yp_xdr ypclnt ypupdate_xdr \
|
|||||||
nis_clone_res nss-default
|
nis_clone_res nss-default
|
||||||
|
|
||||||
ifeq ($(build-obsolete-nsl),yes)
|
ifeq ($(build-obsolete-nsl),yes)
|
||||||
libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups)
|
|
||||||
libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes))
|
|
||||||
|
|
||||||
libnss_nis-routines := $(addprefix nis-,$(databases)) nis-initgroups \
|
libnss_nis-routines := $(addprefix nis-,$(databases)) nis-initgroups \
|
||||||
nss-nis
|
nss-nis
|
||||||
libnss_nis-inhibit-o = $(filter-out .os,$(object-suffixes))
|
libnss_nis-inhibit-o = $(filter-out .os,$(object-suffixes))
|
||||||
@@ -79,7 +76,6 @@ include ../Rules
|
|||||||
|
|
||||||
|
|
||||||
ifeq ($(build-obsolete-nsl),yes)
|
ifeq ($(build-obsolete-nsl),yes)
|
||||||
$(objpfx)libnss_compat.so: $(objpfx)libnsl.so$(libnsl.so-version)
|
|
||||||
$(objpfx)libnss_nis.so: $(objpfx)libnsl.so$(libnsl.so-version) \
|
$(objpfx)libnss_nis.so: $(objpfx)libnsl.so$(libnsl.so-version) \
|
||||||
$(common-objpfx)nss/libnss_files.so
|
$(common-objpfx)nss/libnss_files.so
|
||||||
$(objpfx)libnss_nisplus.so: $(objpfx)libnsl.so$(libnsl.so-version)
|
$(objpfx)libnss_nisplus.so: $(objpfx)libnsl.so$(libnsl.so-version)
|
||||||
|
11
nis/Versions
11
nis/Versions
@@ -63,17 +63,6 @@ libnsl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
libnss_compat {
|
|
||||||
GLIBC_PRIVATE {
|
|
||||||
_nss_compat_endgrent; _nss_compat_endpwent; _nss_compat_endspent;
|
|
||||||
_nss_compat_getgrent_r; _nss_compat_getgrgid_r; _nss_compat_getgrnam_r;
|
|
||||||
_nss_compat_getpwent_r; _nss_compat_getpwnam_r; _nss_compat_getpwuid_r;
|
|
||||||
_nss_compat_getspent_r; _nss_compat_getspnam_r;
|
|
||||||
_nss_compat_setgrent; _nss_compat_setpwent; _nss_compat_setspent;
|
|
||||||
_nss_compat_initgroups_dyn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
libnss_nis {
|
libnss_nis {
|
||||||
GLIBC_PRIVATE {
|
GLIBC_PRIVATE {
|
||||||
_nss_nis_endaliasent; _nss_nis_endetherent; _nss_nis_endgrent;
|
_nss_nis_endaliasent; _nss_nis_endetherent; _nss_nis_endgrent;
|
||||||
|
@@ -72,7 +72,7 @@ tests += tst-cancel-getpwuid_r
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
# Specify rules for the nss_* modules. We have some services.
|
# Specify rules for the nss_* modules. We have some services.
|
||||||
services := files db
|
services := files db compat
|
||||||
|
|
||||||
extra-libs = $(services:%=libnss_%)
|
extra-libs = $(services:%=libnss_%)
|
||||||
# These libraries will be built in the `others' pass rather than
|
# These libraries will be built in the `others' pass rather than
|
||||||
@@ -95,11 +95,15 @@ libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string
|
|||||||
generated += $(filter-out db-alias.c db-netgrp.c, \
|
generated += $(filter-out db-alias.c db-netgrp.c, \
|
||||||
$(addsuffix .c,$(libnss_db-dbs)))
|
$(addsuffix .c,$(libnss_db-dbs)))
|
||||||
|
|
||||||
|
libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups) \
|
||||||
|
nisdomain
|
||||||
|
|
||||||
install-others += $(inst_vardbdir)/Makefile
|
install-others += $(inst_vardbdir)/Makefile
|
||||||
|
|
||||||
# Build static module into libc if requested
|
# Build static module into libc if requested
|
||||||
libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
|
libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
|
||||||
libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
|
libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
|
||||||
|
libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes))
|
||||||
ifeq ($(build-static-nss),yes)
|
ifeq ($(build-static-nss),yes)
|
||||||
routines += $(libnss_files-routines)
|
routines += $(libnss_files-routines)
|
||||||
static-only-routines += $(libnss_files-routines)
|
static-only-routines += $(libnss_files-routines)
|
||||||
|
11
nss/Versions
11
nss/Versions
@@ -162,3 +162,14 @@ libnss_db {
|
|||||||
_nss_db_init;
|
_nss_db_init;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
libnss_compat {
|
||||||
|
GLIBC_PRIVATE {
|
||||||
|
_nss_compat_endgrent; _nss_compat_endpwent; _nss_compat_endspent;
|
||||||
|
_nss_compat_getgrent_r; _nss_compat_getgrgid_r; _nss_compat_getgrnam_r;
|
||||||
|
_nss_compat_getpwent_r; _nss_compat_getpwnam_r; _nss_compat_getpwuid_r;
|
||||||
|
_nss_compat_getspent_r; _nss_compat_getspnam_r;
|
||||||
|
_nss_compat_setgrent; _nss_compat_setpwent; _nss_compat_setspent;
|
||||||
|
_nss_compat_initgroups_dyn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
#include <nsswitch.h>
|
#include <nsswitch.h>
|
||||||
#include <stdio_ext.h>
|
#include <stdio_ext.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <rpc/types.h>
|
|
||||||
#include <libc-lock.h>
|
#include <libc-lock.h>
|
||||||
#include <kernel-features.h>
|
#include <kernel-features.h>
|
||||||
|
|
||||||
@@ -58,21 +57,21 @@ struct blacklist_t
|
|||||||
|
|
||||||
struct ent_t
|
struct ent_t
|
||||||
{
|
{
|
||||||
bool_t files;
|
bool files;
|
||||||
enum nss_status setent_status;
|
enum nss_status setent_status;
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
struct blacklist_t blacklist;
|
struct blacklist_t blacklist;
|
||||||
};
|
};
|
||||||
typedef struct ent_t ent_t;
|
typedef struct ent_t ent_t;
|
||||||
|
|
||||||
static ent_t ext_ent = { TRUE, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }};
|
static ent_t ext_ent = { true, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }};
|
||||||
|
|
||||||
/* Protect global state against multiple changers. */
|
/* Protect global state against multiple changers. */
|
||||||
__libc_lock_define_initialized (static, lock)
|
__libc_lock_define_initialized (static, lock)
|
||||||
|
|
||||||
/* Prototypes for local functions. */
|
/* Prototypes for local functions. */
|
||||||
static void blacklist_store_name (const char *, ent_t *);
|
static void blacklist_store_name (const char *, ent_t *);
|
||||||
static int in_blacklist (const char *, int, ent_t *);
|
static bool in_blacklist (const char *, int, ent_t *);
|
||||||
|
|
||||||
/* Initialize the NSS interface/functions. The calling function must
|
/* Initialize the NSS interface/functions. The calling function must
|
||||||
hold the lock. */
|
hold the lock. */
|
||||||
@@ -94,7 +93,7 @@ internal_setgrent (ent_t *ent, int stayopen, int needent)
|
|||||||
{
|
{
|
||||||
enum nss_status status = NSS_STATUS_SUCCESS;
|
enum nss_status status = NSS_STATUS_SUCCESS;
|
||||||
|
|
||||||
ent->files = TRUE;
|
ent->files = true;
|
||||||
|
|
||||||
if (ent->blacklist.data != NULL)
|
if (ent->blacklist.data != NULL)
|
||||||
{
|
{
|
||||||
@@ -321,7 +320,7 @@ getgrent_next_file (struct group *result, ent_t *ent,
|
|||||||
/* +:... */
|
/* +:... */
|
||||||
if (result->gr_name[0] == '+' && result->gr_name[1] == '\0')
|
if (result->gr_name[0] == '+' && result->gr_name[1] == '\0')
|
||||||
{
|
{
|
||||||
ent->files = FALSE;
|
ent->files = false;
|
||||||
|
|
||||||
return getgrent_next_nss (result, ent, buffer, buflen, errnop);
|
return getgrent_next_nss (result, ent, buffer, buflen, errnop);
|
||||||
}
|
}
|
||||||
@@ -466,7 +465,7 @@ enum nss_status
|
|||||||
_nss_compat_getgrnam_r (const char *name, struct group *grp,
|
_nss_compat_getgrnam_r (const char *name, struct group *grp,
|
||||||
char *buffer, size_t buflen, int *errnop)
|
char *buffer, size_t buflen, int *errnop)
|
||||||
{
|
{
|
||||||
ent_t ent = { TRUE, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }};
|
ent_t ent = { true, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }};
|
||||||
enum nss_status result;
|
enum nss_status result;
|
||||||
|
|
||||||
if (name[0] == '-' || name[0] == '+')
|
if (name[0] == '-' || name[0] == '+')
|
||||||
@@ -598,7 +597,7 @@ enum nss_status
|
|||||||
_nss_compat_getgrgid_r (gid_t gid, struct group *grp,
|
_nss_compat_getgrgid_r (gid_t gid, struct group *grp,
|
||||||
char *buffer, size_t buflen, int *errnop)
|
char *buffer, size_t buflen, int *errnop)
|
||||||
{
|
{
|
||||||
ent_t ent = { TRUE, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }};
|
ent_t ent = { true, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }};
|
||||||
enum nss_status result;
|
enum nss_status result;
|
||||||
|
|
||||||
__libc_lock_lock (lock);
|
__libc_lock_lock (lock);
|
||||||
@@ -665,15 +664,15 @@ blacklist_store_name (const char *name, ent_t *ent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns TRUE if ent->blacklist contains name, else FALSE */
|
/* Return whether ent->blacklist contains name. */
|
||||||
static bool_t
|
static bool
|
||||||
in_blacklist (const char *name, int namelen, ent_t *ent)
|
in_blacklist (const char *name, int namelen, ent_t *ent)
|
||||||
{
|
{
|
||||||
char buf[namelen + 3];
|
char buf[namelen + 3];
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
if (ent->blacklist.data == NULL)
|
if (ent->blacklist.data == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
buf[0] = '|';
|
buf[0] = '|';
|
||||||
cp = stpcpy (&buf[1], name);
|
cp = stpcpy (&buf[1], name);
|
@@ -24,7 +24,6 @@
|
|||||||
#include <stdio_ext.h>
|
#include <stdio_ext.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <rpc/types.h>
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <nsswitch.h>
|
#include <nsswitch.h>
|
||||||
#include <libc-lock.h>
|
#include <libc-lock.h>
|
||||||
@@ -79,7 +78,7 @@ typedef struct ent_t ent_t;
|
|||||||
|
|
||||||
/* Prototypes for local functions. */
|
/* Prototypes for local functions. */
|
||||||
static void blacklist_store_name (const char *, ent_t *);
|
static void blacklist_store_name (const char *, ent_t *);
|
||||||
static int in_blacklist (const char *, int, ent_t *);
|
static bool in_blacklist (const char *, int, ent_t *);
|
||||||
|
|
||||||
/* Initialize the NSS interface/functions. The calling function must
|
/* Initialize the NSS interface/functions. The calling function must
|
||||||
hold the lock. */
|
hold the lock. */
|
||||||
@@ -558,15 +557,15 @@ blacklist_store_name (const char *name, ent_t *ent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns TRUE if ent->blacklist contains name, else FALSE */
|
/* Return whether ent->blacklist contains name. */
|
||||||
static bool_t
|
static bool
|
||||||
in_blacklist (const char *name, int namelen, ent_t *ent)
|
in_blacklist (const char *name, int namelen, ent_t *ent)
|
||||||
{
|
{
|
||||||
char buf[namelen + 3];
|
char buf[namelen + 3];
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
if (ent->blacklist.data == NULL)
|
if (ent->blacklist.data == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
buf[0] = '|';
|
buf[0] = '|';
|
||||||
cp = stpcpy (&buf[1], name);
|
cp = stpcpy (&buf[1], name);
|
@@ -25,12 +25,11 @@
|
|||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio_ext.h>
|
#include <stdio_ext.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <rpc/types.h>
|
|
||||||
#include <rpcsvc/ypclnt.h>
|
|
||||||
#include <libc-lock.h>
|
#include <libc-lock.h>
|
||||||
#include <kernel-features.h>
|
#include <kernel-features.h>
|
||||||
|
|
||||||
#include "netgroup.h"
|
#include "netgroup.h"
|
||||||
|
#include "nisdomain.h"
|
||||||
|
|
||||||
static service_user *ni;
|
static service_user *ni;
|
||||||
static enum nss_status (*nss_setpwent) (int stayopen);
|
static enum nss_status (*nss_setpwent) (int stayopen);
|
||||||
@@ -82,7 +81,7 @@ __libc_lock_define_initialized (static, lock)
|
|||||||
|
|
||||||
/* Prototypes for local functions. */
|
/* Prototypes for local functions. */
|
||||||
static void blacklist_store_name (const char *, ent_t *);
|
static void blacklist_store_name (const char *, ent_t *);
|
||||||
static int in_blacklist (const char *, int, ent_t *);
|
static bool in_blacklist (const char *, int, ent_t *);
|
||||||
|
|
||||||
/* Initialize the NSS interface/functions. The calling function must
|
/* Initialize the NSS interface/functions. The calling function must
|
||||||
hold the lock. */
|
hold the lock. */
|
||||||
@@ -346,7 +345,7 @@ getpwent_next_nss_netgr (const char *name, struct passwd *result, ent_t *ent,
|
|||||||
if (domain != NULL)
|
if (domain != NULL)
|
||||||
{
|
{
|
||||||
if (curdomain == NULL
|
if (curdomain == NULL
|
||||||
&& yp_get_default_domain (&curdomain) != YPERR_SUCCESS)
|
&& __nss_get_default_domain (&curdomain) != 0)
|
||||||
{
|
{
|
||||||
__internal_endnetgrent (&ent->netgrdata);
|
__internal_endnetgrent (&ent->netgrdata);
|
||||||
ent->netgroup = false;
|
ent->netgroup = false;
|
||||||
@@ -1114,15 +1113,15 @@ blacklist_store_name (const char *name, ent_t *ent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns TRUE if ent->blacklist contains name, else FALSE. */
|
/* Returns whether ent->blacklist contains name. */
|
||||||
static bool_t
|
static bool
|
||||||
in_blacklist (const char *name, int namelen, ent_t *ent)
|
in_blacklist (const char *name, int namelen, ent_t *ent)
|
||||||
{
|
{
|
||||||
char buf[namelen + 3];
|
char buf[namelen + 3];
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
if (ent->blacklist.data == NULL)
|
if (ent->blacklist.data == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
buf[0] = '|';
|
buf[0] = '|';
|
||||||
cp = stpcpy (&buf[1], name);
|
cp = stpcpy (&buf[1], name);
|
@@ -25,12 +25,11 @@
|
|||||||
#include <shadow.h>
|
#include <shadow.h>
|
||||||
#include <stdio_ext.h>
|
#include <stdio_ext.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <rpc/types.h>
|
|
||||||
#include <rpcsvc/ypclnt.h>
|
|
||||||
#include <libc-lock.h>
|
#include <libc-lock.h>
|
||||||
#include <kernel-features.h>
|
#include <kernel-features.h>
|
||||||
|
|
||||||
#include "netgroup.h"
|
#include "netgroup.h"
|
||||||
|
#include "nisdomain.h"
|
||||||
|
|
||||||
static service_user *ni;
|
static service_user *ni;
|
||||||
static enum nss_status (*nss_setspent) (int stayopen);
|
static enum nss_status (*nss_setspent) (int stayopen);
|
||||||
@@ -79,7 +78,7 @@ __libc_lock_define_initialized (static, lock)
|
|||||||
|
|
||||||
/* Prototypes for local functions. */
|
/* Prototypes for local functions. */
|
||||||
static void blacklist_store_name (const char *, ent_t *);
|
static void blacklist_store_name (const char *, ent_t *);
|
||||||
static int in_blacklist (const char *, int, ent_t *);
|
static bool in_blacklist (const char *, int, ent_t *);
|
||||||
|
|
||||||
/* Initialize the NSS interface/functions. The calling function must
|
/* Initialize the NSS interface/functions. The calling function must
|
||||||
hold the lock. */
|
hold the lock. */
|
||||||
@@ -306,7 +305,7 @@ getspent_next_nss_netgr (const char *name, struct spwd *result, ent_t *ent,
|
|||||||
if (domain != NULL)
|
if (domain != NULL)
|
||||||
{
|
{
|
||||||
if (curdomain == NULL
|
if (curdomain == NULL
|
||||||
&& yp_get_default_domain (&curdomain) != YPERR_SUCCESS)
|
&& __nss_get_default_domain (&curdomain) != 0)
|
||||||
{
|
{
|
||||||
__internal_endnetgrent (&ent->netgrdata);
|
__internal_endnetgrent (&ent->netgrdata);
|
||||||
ent->netgroup = false;
|
ent->netgroup = false;
|
||||||
@@ -840,8 +839,8 @@ blacklist_store_name (const char *name, ent_t *ent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Returns TRUE if ent->blacklist contains name, else FALSE. */
|
/* Returns whether ent->blacklist contains name. */
|
||||||
static bool_t
|
static bool
|
||||||
in_blacklist (const char *name, int namelen, ent_t *ent)
|
in_blacklist (const char *name, int namelen, ent_t *ent)
|
||||||
{
|
{
|
||||||
char buf[namelen + 3];
|
char buf[namelen + 3];
|
58
nss/nss_compat/nisdomain.c
Normal file
58
nss/nss_compat/nisdomain.c
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/* Copyright (C) 2017 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <libc-lock.h>
|
||||||
|
#include "nisdomain.h"
|
||||||
|
|
||||||
|
#define MAXDOMAINNAMELEN 1024
|
||||||
|
|
||||||
|
static char domainname[MAXDOMAINNAMELEN];
|
||||||
|
|
||||||
|
__libc_lock_define_initialized (static, domainname_lock)
|
||||||
|
|
||||||
|
int
|
||||||
|
__nss_get_default_domain (char **outdomain)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
*outdomain = NULL;
|
||||||
|
|
||||||
|
__libc_lock_lock (domainname_lock);
|
||||||
|
|
||||||
|
if (domainname[0] != '\0')
|
||||||
|
{
|
||||||
|
if (getdomainname (domainname, MAXDOMAINNAMELEN) < 0)
|
||||||
|
result = errno;
|
||||||
|
else if (strcmp (domainname, "(none)") == 0)
|
||||||
|
{
|
||||||
|
/* If domainname is not set, some systems will return "(none)" */
|
||||||
|
domainname[0] = '\0';
|
||||||
|
result = ENOENT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*outdomain = domainname;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*outdomain = domainname;
|
||||||
|
|
||||||
|
__libc_lock_unlock (domainname_lock);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
20
nss/nss_compat/nisdomain.h
Normal file
20
nss/nss_compat/nisdomain.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/* Copyright (C) 2017 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
/* Set OUTDOMAIN to a pointer to the current NIS domain name, or NULL if
|
||||||
|
not set. Return zero on success, an error number on failure. */
|
||||||
|
extern int __nss_get_default_domain (char **outdomain);
|
Reference in New Issue
Block a user