Make shadow_logfd and Prog not extern
Closes #444 Closes #465 Signed-off-by: Serge Hallyn <serge@hallyn.com>
This commit is contained in:
@@ -36,6 +36,8 @@ libshadow_la_SOURCES = \
|
||||
nss.c \
|
||||
nscd.c \
|
||||
nscd.h \
|
||||
shadowlog.c \
|
||||
shadowlog.h \
|
||||
sssd.c \
|
||||
sssd.h \
|
||||
pam_defs.h \
|
||||
|
@@ -51,6 +51,7 @@
|
||||
#endif /* WITH_TCB */
|
||||
#include "prototypes.h"
|
||||
#include "commonio.h"
|
||||
#include "shadowlog_internal.h"
|
||||
|
||||
/* local function prototypes */
|
||||
static int lrename (const char *, const char *);
|
||||
|
@@ -39,6 +39,7 @@
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "shadowlog_internal.h"
|
||||
|
||||
/*@exposed@*//*@null@*/char *pw_encrypt (const char *clear, const char *salt)
|
||||
{
|
||||
|
@@ -44,6 +44,7 @@
|
||||
#include <libeconf.h>
|
||||
#endif
|
||||
#include "getdef.h"
|
||||
#include "shadowlog_internal.h"
|
||||
/*
|
||||
* A configuration item definition.
|
||||
*/
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
#include "nscd.h"
|
||||
#include "shadowlog_internal.h"
|
||||
|
||||
#define MSG_NSCD_FLUSH_CACHE_FAILED "%s: Failed to flush the nscd cache.\n"
|
||||
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <stdatomic.h>
|
||||
#include "prototypes.h"
|
||||
#include "../libsubid/subid.h"
|
||||
#include "shadowlog_internal.h"
|
||||
|
||||
#define NSSWITCH "/etc/nsswitch.conf"
|
||||
|
||||
|
@@ -59,9 +59,6 @@
|
||||
#include "defines.h"
|
||||
#include "commonio.h"
|
||||
|
||||
extern /*@observer@*/ const char *Prog; /* Program name showed in error messages */
|
||||
extern FILE *shadow_logfd; /* file descripter to which error messages are printed */
|
||||
|
||||
/* addgrps.c */
|
||||
#if defined (HAVE_SETGROUPS) && ! defined (USE_PAM)
|
||||
extern int add_groups (const char *);
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <lib/prototypes.h>
|
||||
#include "shadowlog_internal.h"
|
||||
|
||||
int run_part (char *script_path, char *name, char *action)
|
||||
{
|
||||
|
@@ -38,6 +38,8 @@
|
||||
#include <selinux/label.h>
|
||||
#include "prototypes.h"
|
||||
|
||||
#include "shadowlog_internal.h"
|
||||
|
||||
static bool selinux_checked = false;
|
||||
static bool selinux_enabled;
|
||||
static /*@null@*/struct selabel_handle *selabel_hnd = NULL;
|
||||
|
@@ -43,6 +43,7 @@
|
||||
#include <semanage/semanage.h>
|
||||
#include "prototypes.h"
|
||||
|
||||
#include "shadowlog_internal.h"
|
||||
|
||||
#ifndef DEFAULT_SERANGE
|
||||
#define DEFAULT_SERANGE "s0"
|
||||
|
28
lib/shadowlog.c
Normal file
28
lib/shadowlog.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "shadowlog.h"
|
||||
|
||||
#include "lib/shadowlog_internal.h"
|
||||
|
||||
void log_set_progname(const char *progname)
|
||||
{
|
||||
Prog = progname;
|
||||
}
|
||||
|
||||
const char *log_get_progname(void)
|
||||
{
|
||||
return Prog;
|
||||
}
|
||||
|
||||
void log_set_logfd(FILE *fd)
|
||||
{
|
||||
if (NULL != fd)
|
||||
shadow_logfd = fd;
|
||||
else
|
||||
shadow_logfd = stderr;
|
||||
}
|
||||
|
||||
FILE *log_get_logfd(void)
|
||||
{
|
||||
if (shadow_logfd != NULL)
|
||||
return shadow_logfd;
|
||||
return stderr;
|
||||
}
|
41
lib/shadowlog.h
Normal file
41
lib/shadowlog.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2021 , Serge Hallyn
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the copyright holders or contributors may not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
#ifndef _LOG_H
|
||||
#define _LOG_H
|
||||
#include <stdio.h>
|
||||
|
||||
extern void log_set_progname(const char *);
|
||||
extern const char *log_get_progname(void);
|
||||
extern void log_set_logfd(FILE *fd);
|
||||
extern FILE *log_get_logfd(void);
|
||||
extern void log_dolog(char *, ...);
|
||||
|
||||
#endif
|
2
lib/shadowlog_internal.h
Normal file
2
lib/shadowlog_internal.h
Normal file
@@ -0,0 +1,2 @@
|
||||
const char *Prog; /* Program name showed in error messages */
|
||||
FILE *shadow_logfd; /* file descripter to which error messages are printed */
|
@@ -38,6 +38,8 @@
|
||||
#include "exitcodes.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
#include "shadowlog_internal.h"
|
||||
|
||||
int run_command (const char *cmd, const char *argv[],
|
||||
/*@null@*/const char *envp[], /*@out@*/int *status)
|
||||
{
|
||||
|
@@ -11,6 +11,8 @@
|
||||
#include "prototypes.h"
|
||||
#include "sssd.h"
|
||||
|
||||
#include "shadowlog_internal.h"
|
||||
|
||||
#define MSG_SSSD_FLUSH_CACHE_FAILED "%s: Failed to flush the sssd cache."
|
||||
|
||||
int sssd_flush_cache (int dbflags)
|
||||
|
@@ -38,6 +38,8 @@
|
||||
#include "shadowio.h"
|
||||
#include "tcbfuncs.h"
|
||||
|
||||
#include "shadowlog_internal.h"
|
||||
|
||||
#define SHADOWTCB_HASH_BY 1000
|
||||
#define SHADOWTCB_LOCK_SUFFIX ".lock"
|
||||
|
||||
|
Reference in New Issue
Block a user