nss-systemd: initialize logging
This commit is contained in:
parent
55679e291c
commit
3339381f22
|
@ -6,6 +6,7 @@
|
||||||
#include "env-util.h"
|
#include "env-util.h"
|
||||||
#include "errno-util.h"
|
#include "errno-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
|
#include "log.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "nss-systemd.h"
|
#include "nss-systemd.h"
|
||||||
#include "nss-util.h"
|
#include "nss-util.h"
|
||||||
|
@ -72,6 +73,20 @@ static GetentData getgrent_data = {
|
||||||
.mutex = PTHREAD_MUTEX_INITIALIZER
|
.mutex = PTHREAD_MUTEX_INITIALIZER
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void setup_logging(void) {
|
||||||
|
/* We need a dummy function because log_parse_environment is a macro. */
|
||||||
|
log_parse_environment();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setup_logging_once(void) {
|
||||||
|
static pthread_once_t once = PTHREAD_ONCE_INIT;
|
||||||
|
assert_se(pthread_once(&once, setup_logging) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define NSS_ENTRYPOINT_BEGIN \
|
||||||
|
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK); \
|
||||||
|
setup_logging_once()
|
||||||
|
|
||||||
NSS_GETPW_PROTOTYPES(systemd);
|
NSS_GETPW_PROTOTYPES(systemd);
|
||||||
NSS_GETGR_PROTOTYPES(systemd);
|
NSS_GETGR_PROTOTYPES(systemd);
|
||||||
NSS_PWENT_PROTOTYPES(systemd);
|
NSS_PWENT_PROTOTYPES(systemd);
|
||||||
|
@ -88,7 +103,7 @@ enum nss_status _nss_systemd_getpwnam_r(
|
||||||
int e;
|
int e;
|
||||||
|
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
|
NSS_ENTRYPOINT_BEGIN;
|
||||||
|
|
||||||
assert(name);
|
assert(name);
|
||||||
assert(pwd);
|
assert(pwd);
|
||||||
|
@ -139,7 +154,7 @@ enum nss_status _nss_systemd_getpwuid_r(
|
||||||
int e;
|
int e;
|
||||||
|
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
|
NSS_ENTRYPOINT_BEGIN;
|
||||||
|
|
||||||
assert(pwd);
|
assert(pwd);
|
||||||
assert(errnop);
|
assert(errnop);
|
||||||
|
@ -188,7 +203,7 @@ enum nss_status _nss_systemd_getgrnam_r(
|
||||||
int e;
|
int e;
|
||||||
|
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
|
NSS_ENTRYPOINT_BEGIN;
|
||||||
|
|
||||||
assert(name);
|
assert(name);
|
||||||
assert(gr);
|
assert(gr);
|
||||||
|
@ -236,7 +251,7 @@ enum nss_status _nss_systemd_getgrgid_r(
|
||||||
int e;
|
int e;
|
||||||
|
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
|
NSS_ENTRYPOINT_BEGIN;
|
||||||
|
|
||||||
assert(gr);
|
assert(gr);
|
||||||
assert(errnop);
|
assert(errnop);
|
||||||
|
@ -275,7 +290,7 @@ enum nss_status _nss_systemd_getgrgid_r(
|
||||||
|
|
||||||
static enum nss_status nss_systemd_endent(GetentData *p) {
|
static enum nss_status nss_systemd_endent(GetentData *p) {
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
|
NSS_ENTRYPOINT_BEGIN;
|
||||||
|
|
||||||
assert(p);
|
assert(p);
|
||||||
|
|
||||||
|
@ -298,7 +313,7 @@ enum nss_status _nss_systemd_endgrent(void) {
|
||||||
|
|
||||||
enum nss_status _nss_systemd_setpwent(int stayopen) {
|
enum nss_status _nss_systemd_setpwent(int stayopen) {
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
|
NSS_ENTRYPOINT_BEGIN;
|
||||||
|
|
||||||
if (_nss_systemd_is_blocked())
|
if (_nss_systemd_is_blocked())
|
||||||
return NSS_STATUS_NOTFOUND;
|
return NSS_STATUS_NOTFOUND;
|
||||||
|
@ -322,7 +337,7 @@ enum nss_status _nss_systemd_setpwent(int stayopen) {
|
||||||
|
|
||||||
enum nss_status _nss_systemd_setgrent(int stayopen) {
|
enum nss_status _nss_systemd_setgrent(int stayopen) {
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
|
NSS_ENTRYPOINT_BEGIN;
|
||||||
|
|
||||||
if (_nss_systemd_is_blocked())
|
if (_nss_systemd_is_blocked())
|
||||||
return NSS_STATUS_NOTFOUND;
|
return NSS_STATUS_NOTFOUND;
|
||||||
|
@ -349,7 +364,7 @@ enum nss_status _nss_systemd_getpwent_r(
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
|
NSS_ENTRYPOINT_BEGIN;
|
||||||
|
|
||||||
assert(result);
|
assert(result);
|
||||||
assert(errnop);
|
assert(errnop);
|
||||||
|
@ -396,7 +411,7 @@ enum nss_status _nss_systemd_getgrent_r(
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
|
NSS_ENTRYPOINT_BEGIN;
|
||||||
|
|
||||||
assert(result);
|
assert(result);
|
||||||
assert(errnop);
|
assert(errnop);
|
||||||
|
@ -525,7 +540,7 @@ enum nss_status _nss_systemd_initgroups_dyn(
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
BLOCK_SIGNALS(NSS_SIGNALS_BLOCK);
|
NSS_ENTRYPOINT_BEGIN;
|
||||||
|
|
||||||
assert(user_name);
|
assert(user_name);
|
||||||
assert(start);
|
assert(start);
|
||||||
|
|
Loading…
Reference in a new issue