nss.c \
nscd.c \
nscd.h \
+ shadowlog.c \
+ shadowlog.h \
sssd.c \
sssd.h \
pam_defs.h \
#endif /* WITH_TCB */
#include "prototypes.h"
#include "commonio.h"
+#include "shadowlog_internal.h"
/* local function prototypes */
static int lrename (const char *, const char *);
#include "prototypes.h"
#include "defines.h"
+#include "shadowlog_internal.h"
/*@exposed@*//*@null@*/char *pw_encrypt (const char *clear, const char *salt)
{
#include <libeconf.h>
#endif
#include "getdef.h"
+#include "shadowlog_internal.h"
/*
* A configuration item definition.
*/
#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"
#include <stdatomic.h>
#include "prototypes.h"
#include "../libsubid/subid.h"
+#include "shadowlog_internal.h"
#define NSSWITCH "/etc/nsswitch.conf"
#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 *);
#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)
{
#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;
#include <semanage/semanage.h>
#include "prototypes.h"
+#include "shadowlog_internal.h"
#ifndef DEFAULT_SERANGE
#define DEFAULT_SERANGE "s0"
--- /dev/null
+#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;
+}
--- /dev/null
+/*
+ * 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
--- /dev/null
+const char *Prog; /* Program name showed in error messages */
+FILE *shadow_logfd; /* file descripter to which error messages are printed */
#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)
{
#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)
#include "shadowio.h"
#include "tcbfuncs.h"
+#include "shadowlog_internal.h"
+
#define SHADOWTCB_HASH_BY 1000
#define SHADOWTCB_LOCK_SUFFIX ".lock"
#include <stdio.h>
#include <grp.h>
#include <errno.h>
+#include "shadowlog.h"
#ident "$Id$"
char *token;
char buf[1024];
int ret;
+ FILE *shadow_logfd = log_get_logfd();
if (strlen (list) >= sizeof (buf)) {
errno = EINVAL;
#include <errno.h>
#include <stdio.h>
#include "prototypes.h"
+#include "shadowlog.h"
int audit_fd;
void audit_help_open (void)
return;
}
(void) fputs (_("Cannot open audit interface - aborting.\n"),
- shadow_logfd);
+ log_get_logfd());
exit (EXIT_FAILURE);
}
}
#include "defines.h"
#include <pwd.h>
#include "getdef.h"
+#include "shadowlog.h"
/*
* chown_tty() sets the login tty to be owned by the new user ID
if ( (fchown (STDIN_FILENO, info->pw_uid, gid) != 0)
|| (fchmod (STDIN_FILENO, (mode_t)getdef_num ("TTYPERM", 0600)) != 0)) {
int err = errno;
+ FILE *shadow_logfd = log_get_logfd();
fprintf (shadow_logfd,
_("Unable to change owner or mode of tty stdin: %s"),
#include "groupio.h"
#include "sgroupio.h"
#include "prototypes.h"
+#include "shadowlog.h"
/*
* cleanup_report_add_group - Report failure to add a group to the system
SYSLOG ((LOG_ERR, "failed to add group %s", name));
#ifdef WITH_AUDIT
- audit_logger (AUDIT_ADD_GROUP, Prog,
+ audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
"",
name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
SYSLOG ((LOG_ERR, "failed to remove group %s", name));
#ifdef WITH_AUDIT
- audit_logger (AUDIT_DEL_GROUP, Prog,
+ audit_logger (AUDIT_DEL_GROUP, log_get_progname(),
"",
name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
gr_dbname (),
info->action));
#ifdef WITH_AUDIT
- audit_logger (AUDIT_USER_ACCT, Prog,
+ audit_logger (AUDIT_USER_ACCT, log_get_progname(),
info->audit_msg,
info->name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
sgr_dbname (),
info->action));
#ifdef WITH_AUDIT
- audit_logger (AUDIT_USER_ACCT, Prog,
+ audit_logger (AUDIT_USER_ACCT, log_get_progname(),
info->audit_msg,
info->name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
SYSLOG ((LOG_ERR, "failed to add group %s to %s", name, gr_dbname ()));
#ifdef WITH_AUDIT
- audit_logger (AUDIT_ADD_GROUP, Prog,
+ audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
"adding group to /etc/group",
name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
SYSLOG ((LOG_ERR, "failed to add group %s to %s", name, sgr_dbname ()));
#ifdef WITH_AUDIT
- audit_logger (AUDIT_ADD_GROUP, Prog,
+ audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
"adding group to /etc/gshadow",
name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
"failed to remove group %s from %s",
name, gr_dbname ()));
#ifdef WITH_AUDIT
- audit_logger (AUDIT_ADD_GROUP, Prog,
+ audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
"removing group from /etc/group",
name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
"failed to remove group %s from %s",
name, sgr_dbname ()));
#ifdef WITH_AUDIT
- audit_logger (AUDIT_ADD_GROUP, Prog,
+ audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
"removing group from /etc/gshadow",
name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
void cleanup_unlock_group (unused void *arg)
{
if (gr_unlock () == 0) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: failed to unlock %s\n"),
- Prog, gr_dbname ());
+ log_get_progname(), gr_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
#ifdef WITH_AUDIT
audit_logger_message ("unlocking group file",
void cleanup_unlock_gshadow (unused void *arg)
{
if (sgr_unlock () == 0) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: failed to unlock %s\n"),
- Prog, sgr_dbname ());
+ log_get_progname(), sgr_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
#ifdef WITH_AUDIT
audit_logger_message ("unlocking gshadow file",
#include "pwio.h"
#include "shadowio.h"
#include "prototypes.h"
+#include "shadowlog.h"
/*
* cleanup_report_add_user - Report failure to add an user to the system
SYSLOG ((LOG_ERR, "failed to add user %s", name));
#ifdef WITH_AUDIT
- audit_logger (AUDIT_ADD_USER, Prog,
+ audit_logger (AUDIT_ADD_USER, log_get_progname(),
"",
name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
pw_dbname (),
info->action));
#ifdef WITH_AUDIT
- audit_logger (AUDIT_USER_ACCT, Prog,
+ audit_logger (AUDIT_USER_ACCT, log_get_progname(),
info->audit_msg,
info->name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
SYSLOG ((LOG_ERR, "failed to add user %s to %s", name, pw_dbname ()));
#ifdef WITH_AUDIT
- audit_logger (AUDIT_ADD_USER, Prog,
+ audit_logger (AUDIT_ADD_USER, log_get_progname(),
"adding user to /etc/passwd",
name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
SYSLOG ((LOG_ERR, "failed to add user %s to %s", name, spw_dbname ()));
#ifdef WITH_AUDIT
- audit_logger (AUDIT_ADD_USER, Prog,
+ audit_logger (AUDIT_ADD_USER, log_get_progname(),
"adding user to /etc/shadow",
name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
void cleanup_unlock_passwd (unused void *arg)
{
if (pw_unlock () == 0) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: failed to unlock %s\n"),
- Prog, pw_dbname ());
+ log_get_progname(), pw_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
#ifdef WITH_AUDIT
audit_logger_message ("unlocking passwd file",
void cleanup_unlock_shadow (unused void *arg)
{
if (spw_unlock () == 0) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: failed to unlock %s\n"),
- Prog, spw_dbname ());
+ log_get_progname(), spw_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
#ifdef WITH_AUDIT
audit_logger_message ("unlocking shadow file",
#ifdef WITH_ATTR
#include <attr/libattr.h>
#endif /* WITH_ATTR */
+#include "shadowlog.h"
static /*@null@*/const char *src_orig;
static void error_acl (struct error_context *ctx, const char *fmt, ...)
{
va_list ap;
+ FILE *shadow_logfd = log_get_logfd();
/* ignore the case when destination does not support ACLs
* or extended attributes */
}
va_start (ap, fmt);
- (void) fprintf (shadow_logfd, _("%s: "), Prog);
+ (void) fprintf (shadow_logfd, _("%s: "), log_get_progname());
if (vfprintf (shadow_logfd, fmt, ap) != 0) {
(void) fputs (_(": "), shadow_logfd);
}
}
if (!S_ISDIR (sb.st_mode)) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
"%s: %s is not a directory",
- Prog, src_root);
+ log_get_progname(), src_root);
return -1;
}
#include <string.h>
#include "prototypes.h"
#include "defines.h"
+#include "shadowlog.h"
/*
* NEWENVP_STEP must be a power of two. This is the number
* of (char *) pointers to allocate at a time, to avoid using
}
newenvp = __newenvp;
} else {
- (void) fputs (_("Environment overflow\n"), shadow_logfd);
+ (void) fputs (_("Environment overflow\n"), log_get_logfd());
newenvc--;
free (newenvp[newenvc]);
}
#include "prototypes.h"
#include "groupio.h"
#include "getdef.h"
+#include "shadowlog.h"
/*
* get_ranges - Get the minimum and maximum ID ranges for the search
/* Check that the ranges make sense */
if (*max_id < *min_id) {
- (void) fprintf (shadow_logfd,
+ (void) fprintf (log_get_logfd(),
_("%s: Invalid configuration: SYS_GID_MIN (%lu), "
"GID_MIN (%lu), SYS_GID_MAX (%lu)\n"),
- Prog, (unsigned long) *min_id,
+ log_get_progname(), (unsigned long) *min_id,
getdef_ulong ("GID_MIN", 1000UL),
(unsigned long) *max_id);
return EINVAL;
/* Check that the ranges make sense */
if (*max_id < *min_id) {
- (void) fprintf (shadow_logfd,
+ (void) fprintf (log_get_logfd(),
_("%s: Invalid configuration: GID_MIN (%lu), "
"GID_MAX (%lu)\n"),
- Prog, (unsigned long) *min_id,
+ log_get_progname(), (unsigned long) *min_id,
(unsigned long) *max_id);
return EINVAL;
}
* more likely to want to stop and address the
* issue.
*/
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Encountered error attempting to use "
"preferred GID: %s\n"),
- Prog, strerror (result));
+ log_get_progname(), strerror (result));
return -1;
}
}
/* Create an array to hold all of the discovered GIDs */
used_gids = malloc (sizeof (bool) * (gid_max +1));
if (NULL == used_gids) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: failed to allocate memory: %s\n"),
- Prog, strerror (errno));
+ log_get_progname(), strerror (errno));
return -1;
}
memset (used_gids, false, sizeof (bool) * (gid_max + 1));
*
*/
if (!nospam) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Can't get unique system GID (%s). "
"Suppressing additional messages.\n"),
- Prog, strerror (result));
+ log_get_progname(), strerror (result));
SYSLOG ((LOG_ERR,
"Error checking available GIDs: %s",
strerror (result)));
*
*/
if (!nospam) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Can't get unique system GID (%s). "
"Suppressing additional messages.\n"),
- Prog, strerror (result));
+ log_get_progname(), strerror (result));
SYSLOG ((LOG_ERR,
"Error checking available GIDs: %s",
strerror (result)));
*
*/
if (!nospam) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Can't get unique GID (%s). "
"Suppressing additional messages.\n"),
- Prog, strerror (result));
+ log_get_progname(), strerror (result));
SYSLOG ((LOG_ERR,
"Error checking available GIDs: %s",
strerror (result)));
*
*/
if (!nospam) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Can't get unique GID (%s). "
"Suppressing additional messages.\n"),
- Prog, strerror (result));
+ log_get_progname(), strerror (result));
SYSLOG ((LOG_ERR,
"Error checking available GIDs: %s",
strerror (result)));
}
/* The code reached here and found no available IDs in the range */
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Can't get unique GID (no more available GIDs)\n"),
- Prog);
+ log_get_progname());
SYSLOG ((LOG_WARN, "no more available GIDs on the system"));
free (used_gids);
return -1;
#include "prototypes.h"
#include "subordinateio.h"
#include "getdef.h"
+#include "shadowlog.h"
/*
* find_new_sub_gids - Find a new unused range of GIDs.
count = getdef_ulong ("SUB_GID_COUNT", 65536);
if (min > max || count >= max || (min + count - 1) > max) {
- (void) fprintf (shadow_logfd,
+ (void) fprintf (log_get_logfd(),
_("%s: Invalid configuration: SUB_GID_MIN (%lu),"
" SUB_GID_MAX (%lu), SUB_GID_COUNT (%lu)\n"),
- Prog, min, max, count);
+ log_get_progname(), min, max, count);
return -1;
}
start = sub_gid_find_free_range(min, max, count);
if (start == (gid_t)-1) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Can't get unique subordinate GID range\n"),
- Prog);
+ log_get_progname());
SYSLOG ((LOG_WARN, "no more available subordinate GIDs on the system"));
return -1;
}
#include "prototypes.h"
#include "subordinateio.h"
#include "getdef.h"
+#include "shadowlog.h"
/*
* find_new_sub_uids - Find a new unused range of UIDs.
count = getdef_ulong ("SUB_UID_COUNT", 65536);
if (min > max || count >= max || (min + count - 1) > max) {
- (void) fprintf (shadow_logfd,
+ (void) fprintf (log_get_logfd(),
_("%s: Invalid configuration: SUB_UID_MIN (%lu),"
" SUB_UID_MAX (%lu), SUB_UID_COUNT (%lu)\n"),
- Prog, min, max, count);
+ log_get_progname(), min, max, count);
return -1;
}
start = sub_uid_find_free_range(min, max, count);
if (start == (uid_t)-1) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Can't get unique subordinate UID range\n"),
- Prog);
+ log_get_progname());
SYSLOG ((LOG_WARN, "no more available subordinate UIDs on the system"));
return -1;
}
#include "prototypes.h"
#include "pwio.h"
#include "getdef.h"
+#include "shadowlog.h"
/*
* get_ranges - Get the minimum and maximum ID ranges for the search
/* Check that the ranges make sense */
if (*max_id < *min_id) {
- (void) fprintf (shadow_logfd,
+ (void) fprintf (log_get_logfd(),
_("%s: Invalid configuration: SYS_UID_MIN (%lu), "
"UID_MIN (%lu), SYS_UID_MAX (%lu)\n"),
- Prog, (unsigned long) *min_id,
+ log_get_progname(), (unsigned long) *min_id,
getdef_ulong ("UID_MIN", 1000UL),
(unsigned long) *max_id);
return EINVAL;
/* Check that the ranges make sense */
if (*max_id < *min_id) {
- (void) fprintf (shadow_logfd,
+ (void) fprintf (log_get_logfd(),
_("%s: Invalid configuration: UID_MIN (%lu), "
"UID_MAX (%lu)\n"),
- Prog, (unsigned long) *min_id,
+ log_get_progname(), (unsigned long) *min_id,
(unsigned long) *max_id);
return EINVAL;
}
* more likely to want to stop and address the
* issue.
*/
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Encountered error attempting to use "
"preferred UID: %s\n"),
- Prog, strerror (result));
+ log_get_progname(), strerror (result));
return -1;
}
}
/* Create an array to hold all of the discovered UIDs */
used_uids = malloc (sizeof (bool) * (uid_max +1));
if (NULL == used_uids) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: failed to allocate memory: %s\n"),
- Prog, strerror (errno));
+ log_get_progname(), strerror (errno));
return -1;
}
memset (used_uids, false, sizeof (bool) * (uid_max + 1));
*
*/
if (!nospam) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Can't get unique system UID (%s). "
"Suppressing additional messages.\n"),
- Prog, strerror (result));
+ log_get_progname(), strerror (result));
SYSLOG ((LOG_ERR,
"Error checking available UIDs: %s",
strerror (result)));
*
*/
if (!nospam) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Can't get unique system UID (%s). "
"Suppressing additional messages.\n"),
- Prog, strerror (result));
+ log_get_progname(), strerror (result));
SYSLOG((LOG_ERR,
"Error checking available UIDs: %s",
strerror (result)));
*
*/
if (!nospam) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Can't get unique UID (%s). "
"Suppressing additional messages.\n"),
- Prog, strerror (result));
+ log_get_progname(), strerror (result));
SYSLOG ((LOG_ERR,
"Error checking available UIDs: %s",
strerror (result)));
*
*/
if (!nospam) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Can't get unique UID (%s). "
"Suppressing additional messages.\n"),
- Prog, strerror (result));
+ log_get_progname(), strerror (result));
SYSLOG ((LOG_ERR,
"Error checking available UIDs: %s",
strerror (result)));
}
/* The code reached here and found no available IDs in the range */
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: Can't get unique UID (no more available UIDs)\n"),
- Prog);
+ log_get_progname());
SYSLOG ((LOG_WARN, "no more available UIDs on the system"));
free (used_uids);
return -1;
#include <stdio.h>
#include "defines.h"
#include "prototypes.h"
+#include "shadowlog.h"
/*
* gettime() returns the time as the number of seconds since the Epoch
char *source_date_epoch;
time_t fallback;
unsigned long long epoch;
+ FILE *shadow_logfd = log_get_logfd();
fallback = time (NULL);
source_date_epoch = shadow_getenv ("SOURCE_DATE_EPOCH");
#include <sys/prctl.h>
#include <sys/capability.h>
#endif
+#include "shadowlog.h"
struct map_range *get_map_ranges(int ranges, int argc, char **argv)
{
int idx, argidx;
if (ranges < 0 || argc < 0) {
- fprintf(shadow_logfd, "%s: error calculating number of arguments\n", Prog);
+ fprintf(log_get_logfd(), "%s: error calculating number of arguments\n", log_get_progname());
return NULL;
}
if (ranges != ((argc + 2) / 3)) {
- fprintf(shadow_logfd, "%s: ranges: %u is wrong for argc: %d\n", Prog, ranges, argc);
+ fprintf(log_get_logfd(), "%s: ranges: %u is wrong for argc: %d\n", log_get_progname(), ranges, argc);
return NULL;
}
if ((ranges * 3) > argc) {
- fprintf(shadow_logfd, "ranges: %u argc: %d\n",
+ fprintf(log_get_logfd(), "ranges: %u argc: %d\n",
ranges, argc);
- fprintf(shadow_logfd,
+ fprintf(log_get_logfd(),
_( "%s: Not enough arguments to form %u mappings\n"),
- Prog, ranges);
+ log_get_progname(), ranges);
return NULL;
}
mappings = calloc(ranges, sizeof(*mappings));
if (!mappings) {
- fprintf(shadow_logfd, _( "%s: Memory allocation failure\n"),
- Prog);
+ fprintf(log_get_logfd(), _( "%s: Memory allocation failure\n"),
+ log_get_progname());
exit(EXIT_FAILURE);
}
return NULL;
}
if (ULONG_MAX - mapping->upper <= mapping->count || ULONG_MAX - mapping->lower <= mapping->count) {
- fprintf(shadow_logfd, _( "%s: subuid overflow detected.\n"), Prog);
+ fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
exit(EXIT_FAILURE);
}
if (mapping->upper > UINT_MAX ||
mapping->lower > UINT_MAX ||
mapping->count > UINT_MAX) {
- fprintf(shadow_logfd, _( "%s: subuid overflow detected.\n"), Prog);
+ fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
exit(EXIT_FAILURE);
}
if (mapping->lower + mapping->count > UINT_MAX ||
mapping->upper + mapping->count > UINT_MAX) {
- fprintf(shadow_logfd, _( "%s: subuid overflow detected.\n"), Prog);
+ fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
exit(EXIT_FAILURE);
}
if (mapping->lower + mapping->count < mapping->lower ||
mapping->upper + mapping->count < mapping->upper) {
/* this one really shouldn't be possible given previous checks */
- fprintf(shadow_logfd, _( "%s: subuid overflow detected.\n"), Prog);
+ fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
exit(EXIT_FAILURE);
}
}
} else if (strcmp(map_file, "gid_map") == 0) {
cap = CAP_SETGID;
} else {
- fprintf(shadow_logfd, _("%s: Invalid map file %s specified\n"), Prog, map_file);
+ fprintf(log_get_logfd(), _("%s: Invalid map file %s specified\n"), log_get_progname(), map_file);
exit(EXIT_FAILURE);
}
/* Align setuid- and fscaps-based new{g,u}idmap behavior. */
if (geteuid() == 0 && geteuid() != ruid) {
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) {
- fprintf(shadow_logfd, _("%s: Could not prctl(PR_SET_KEEPCAPS)\n"), Prog);
+ fprintf(log_get_logfd(), _("%s: Could not prctl(PR_SET_KEEPCAPS)\n"), log_get_progname());
exit(EXIT_FAILURE);
}
if (seteuid(ruid) < 0) {
- fprintf(shadow_logfd, _("%s: Could not seteuid to %d\n"), Prog, ruid);
+ fprintf(log_get_logfd(), _("%s: Could not seteuid to %d\n"), log_get_progname(), ruid);
exit(EXIT_FAILURE);
}
}
data[0].effective |= CAP_TO_MASK(CAP_SETFCAP);
data[0].permitted = data[0].effective;
if (capset(&hdr, data) < 0) {
- fprintf(shadow_logfd, _("%s: Could not set caps\n"), Prog);
+ fprintf(log_get_logfd(), _("%s: Could not set caps\n"), log_get_progname());
exit(EXIT_FAILURE);
}
#endif
mapping->lower,
mapping->count);
if ((written <= 0) || (written >= (bufsize - (pos - buf)))) {
- fprintf(shadow_logfd, _("%s: snprintf failed!\n"), Prog);
+ fprintf(log_get_logfd(), _("%s: snprintf failed!\n"), log_get_progname());
exit(EXIT_FAILURE);
}
pos += written;
/* Write the mapping to the mapping file */
fd = openat(proc_dir_fd, map_file, O_WRONLY);
if (fd < 0) {
- fprintf(shadow_logfd, _("%s: open of %s failed: %s\n"),
- Prog, map_file, strerror(errno));
+ fprintf(log_get_logfd(), _("%s: open of %s failed: %s\n"),
+ log_get_progname(), map_file, strerror(errno));
exit(EXIT_FAILURE);
}
if (write(fd, buf, pos - buf) != (pos - buf)) {
- fprintf(shadow_logfd, _("%s: write to %s failed: %s\n"),
- Prog, map_file, strerror(errno));
+ fprintf(log_get_logfd(), _("%s: write to %s failed: %s\n"),
+ log_get_progname(), map_file, strerror(errno));
exit(EXIT_FAILURE);
}
close(fd);
#include "defines.h"
#include <pwd.h>
#include "getdef.h"
+#include "shadowlog.h"
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#define LIMITS
#ifdef LIMITS
if (info->pw_uid != 0) {
if ((setup_user_limits (info->pw_name) & LOGIN_ERROR_LOGIN) != 0) {
- (void) fputs (_("Too many logins.\n"), shadow_logfd);
+ (void) fputs (_("Too many logins.\n"), log_get_logfd());
(void) sleep (2); /* XXX: Should be FAIL_DELAY */
exit (EXIT_FAILURE);
}
#include "defines.h"
#include "pam_defs.h"
#include "prototypes.h"
+#include "shadowlog.h"
void do_pam_passwd (const char *user, bool silent, bool change_expired)
{
pam_handle_t *pamh = NULL;
int flags = 0, ret;
+ FILE *shadow_logfd = log_get_logfd();
if (silent)
flags |= PAM_SILENT;
#include <stdlib.h>
#include <security/pam_appl.h>
#include "prototypes.h"
+#include "shadowlog.h"
/*@null@*/ /*@only@*/static const char *non_interactive_password = NULL;
static int ni_conv (int num_msg,
switch (msg[count]->msg_style) {
case PAM_PROMPT_ECHO_ON:
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: PAM modules requesting echoing are not supported.\n"),
- Prog);
+ log_get_progname());
goto failed_conversation;
case PAM_PROMPT_ECHO_OFF:
responses[count].resp = strdup (non_interactive_password);
break;
case PAM_ERROR_MSG:
if ( (NULL == msg[count]->msg)
- || (fprintf (shadow_logfd, "%s\n", msg[count]->msg) <0)) {
+ || (fprintf (log_get_logfd(), "%s\n", msg[count]->msg) <0)) {
goto failed_conversation;
}
responses[count].resp = NULL;
responses[count].resp = NULL;
break;
default:
- (void) fprintf (shadow_logfd,
+ (void) fprintf (log_get_logfd(),
_("%s: conversation type %d not supported.\n"),
- Prog, msg[count]->msg_style);
+ log_get_progname(), msg[count]->msg_style);
goto failed_conversation;
}
}
ret = pam_start (pam_service, username, &non_interactive_pam_conv, &pamh);
if (ret != PAM_SUCCESS) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: (user %s) pam_start failure %d\n"),
- Prog, username, ret);
+ log_get_progname(), username, ret);
return 1;
}
non_interactive_password = password;
ret = pam_chauthtok (pamh, 0);
if (ret != PAM_SUCCESS) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: (user %s) pam_chauthtok() failed, error:\n"
"%s\n"),
- Prog, username, pam_strerror (pamh, ret));
+ log_get_progname(), username, pam_strerror (pamh, ret));
}
(void) pam_end (pamh, PAM_SUCCESS);
#include "subordinateio.h"
#endif /* ENABLE_SUBIDS */
#include "getdef.h"
+#include "shadowlog.h"
static char *passwd_db_file = NULL;
static char *spw_db_file = NULL;
&& (val = argv[i] + 9))
|| (strcmp (argv[i], short_opt) == 0)) {
if (NULL != prefix) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: multiple --prefix options\n"),
- Prog);
+ log_get_progname());
exit (E_BAD_ARG);
}
if (val) {
prefix = val;
} else if (i + 1 == argc) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: option '%s' requires an argument\n"),
- Prog, argv[i]);
+ log_get_progname(), argv[i]);
exit (E_BAD_ARG);
} else {
prefix = argv[++ i];
/* should we prevent symbolic link from being used as a prefix? */
if ( prefix[0] != '/') {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: prefix must be an absolute path\n"),
- Prog);
+ log_get_progname());
exit (E_BAD_ARG);
}
size_t len;
#include "prototypes.h"
#include "defines.h"
#include "pwauth.h"
+#include "shadowlog.h"
void passwd_check (const char *user, const char *passwd, unused const char *progname)
{
if (pw_auth (passwd, user, PW_LOGIN, (char *) 0) != 0) {
SYSLOG ((LOG_WARN, "incorrect password for `%s'", user));
(void) sleep (1);
- fprintf (shadow_logfd, _("Incorrect password for %s.\n"), user);
+ fprintf (log_get_logfd(), _("Incorrect password for %s.\n"), user);
exit (EXIT_FAILURE);
}
}
#include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
static void change_root (const char* newroot);
&& (val = argv[i] + 7))
|| (strcmp (argv[i], short_opt) == 0)) {
if (NULL != newroot) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: multiple --root options\n"),
- Prog);
+ log_get_progname());
exit (E_BAD_ARG);
}
if (val) {
newroot = val;
} else if (i + 1 == argc) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: option '%s' requires an argument\n"),
- Prog, argv[i]);
+ log_get_progname(), argv[i]);
exit (E_BAD_ARG);
} else {
newroot = argv[++ i];
/* Drop privileges */
if ( (setregid (getgid (), getgid ()) != 0)
|| (setreuid (getuid (), getuid ()) != 0)) {
- fprintf (shadow_logfd, _("%s: failed to drop privileges (%s)\n"),
- Prog, strerror (errno));
+ fprintf (log_get_logfd(), _("%s: failed to drop privileges (%s)\n"),
+ log_get_progname(), strerror (errno));
exit (EXIT_FAILURE);
}
if ('/' != newroot[0]) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: invalid chroot path '%s'\n"),
- Prog, newroot);
+ log_get_progname(), newroot);
exit (E_BAD_ARG);
}
if (access (newroot, F_OK) != 0) {
- fprintf(shadow_logfd,
+ fprintf(log_get_logfd(),
_("%s: cannot access chroot directory %s: %s\n"),
- Prog, newroot, strerror (errno));
+ log_get_progname(), newroot, strerror (errno));
exit (E_BAD_ARG);
}
if (chdir (newroot) != 0) {
- fprintf(shadow_logfd,
+ fprintf(log_get_logfd(),
_("%s: cannot chdir to chroot directory %s: %s\n"),
- Prog, newroot, strerror (errno));
+ log_get_progname(), newroot, strerror (errno));
exit (E_BAD_ARG);
}
if (chroot (newroot) != 0) {
- fprintf(shadow_logfd,
+ fprintf(log_get_logfd(),
_("%s: unable to chroot to directory %s: %s\n"),
- Prog, newroot, strerror (errno));
+ log_get_progname(), newroot, strerror (errno));
exit (E_BAD_ARG);
}
}
#include "prototypes.h"
#include "defines.h"
#include "getdef.h"
+#include "shadowlog.h"
#if (defined CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY && \
CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY)
#endif
fail:
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("Unable to obtain random bytes.\n"));
exit (1);
SHA_salt_rounds_to_buf (result, rounds);
#endif /* USE_SHA_CRYPT */
} else if (0 != strcmp (method, "DES")) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("Invalid ENCRYPT_METHOD value: '%s'.\n"
"Defaulting to DES.\n"),
method);
/* Should not happen, but... */
if (NULL == retval) {
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("Unable to generate a salt from setting "
"\"%s\", check your settings in "
"ENCRYPT_METHOD and the corresponding "
#include "defines.h"
#include <pwd.h>
#include "getdef.h"
+#include "shadowlog.h"
#ifndef USE_PAM
static void
static char temp_pw_dir[] = "/";
if (!getdef_bool ("DEFAULT_HOME") || chdir ("/") == -1) {
- fprintf (shadow_logfd, _("Unable to cd to '%s'\n"),
+ fprintf (log_get_logfd(), _("Unable to cd to '%s'\n"),
info->pw_dir);
SYSLOG ((LOG_WARN,
"unable to cd to `%s' for user `%s'\n",
#ifdef ENABLE_SUBIDS
#include "subordinateio.h"
#endif /* ENABLE_SUBIDS */
+#include "shadowlog.h"
#ifdef __linux__
static int check_status (const char *name, const char *sname, uid_t uid);
continue;
}
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: user %s is currently logged in\n"),
- Prog, name);
+ log_get_progname(), name);
return 1;
}
#ifdef ENABLE_SUBIDS
sub_uid_close();
#endif
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: user %s is currently used by process %d\n"),
- Prog, name, pid);
+ log_get_progname(), name, pid);
return 1;
}
#ifdef ENABLE_SUBIDS
sub_uid_close();
#endif
- fprintf (shadow_logfd,
+ fprintf (log_get_logfd(),
_("%s: user %s is currently used by process %d\n"),
- Prog, name, pid);
+ log_get_progname(), name, pid);
return 1;
}
}
#include <stdio.h>
#include <errno.h>
#include "prototypes.h"
+#include "shadowlog.h"
#define XFUNCTION_NAME XPREFIX (FUNCTION_NAME)
#define XPREFIX(name) XPREFIX1 (name)
result = malloc(sizeof(LOOKUP_TYPE));
if (NULL == result) {
- fprintf (shadow_logfd, _("%s: out of memory\n"),
+ fprintf (log_get_logfd(), _("%s: out of memory\n"),
"x" STRINGIZE(FUNCTION_NAME));
exit (13);
}
LOOKUP_TYPE *resbuf = NULL;
buffer = (char *)realloc (buffer, length);
if (NULL == buffer) {
- fprintf (shadow_logfd, _("%s: out of memory\n"),
+ fprintf (log_get_logfd(), _("%s: out of memory\n"),
"x" STRINGIZE(FUNCTION_NAME));
exit (13);
}
if (result) {
result = DUP_FUNCTION(result);
if (NULL == result) {
- fprintf (shadow_logfd, _("%s: out of memory\n"),
+ fprintf (log_get_logfd(), _("%s: out of memory\n"),
"x" STRINGIZE(FUNCTION_NAME));
exit (13);
}
#include <errno.h>
#include "defines.h"
#include "prototypes.h"
+#include "shadowlog.h"
/*@maynotreturn@*/ /*@only@*//*@out@*//*@notnull@*/char *xmalloc (size_t size)
{
ptr = (char *) malloc (size);
if (NULL == ptr) {
- (void) fprintf (shadow_logfd,
+ (void) fprintf (log_get_logfd(),
_("%s: failed to allocate memory: %s\n"),
- Prog, strerror (errno));
+ log_get_progname(), strerror (errno));
exit (13);
}
return ptr;
#include "subordinateio.h"
#include "idmapping.h"
#include "subid.h"
+#include "shadowlog.h"
static const char *Prog = "(libsubid)";
-static FILE *shadow_logfd;
bool subid_init(const char *progname, FILE * logfd)
{
+ FILE *shadow_logfd;
if (progname) {
progname = strdup(progname);
if (progname)
}
if (logfd) {
- shadow_logfd = logfd;
+ log_set_logfd(logfd);
return true;
}
shadow_logfd = fopen("/dev/null", "w");
if (!shadow_logfd) {
- shadow_logfd = stderr;
+ log_set_logfd(stderr);
return false;
}
+ log_set_logfd(shadow_logfd);
return true;
}
#include "defines.h"
#include "pwio.h"
#include "shadowio.h"
+#include "shadowlog.h"
#ifdef WITH_TCB
#include "tcbfuncs.h"
#endif
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool
dflg = false, /* set last password change date */
* Get the program name so that error messages can use it.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
sanitize_env ();
(void) setlocale (LC_ALL, "");
#include "prototypes.h"
#include "subordinateio.h"
#include "idmapping.h"
+#include "shadowlog.h"
const char *Prog;
-FILE *shadow_logfd = NULL;
int main(int argc, char **argv)
{
unsigned long start, count;
bool check_uids;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
if (argc != 5)
exit(1);
#include "pwio.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables.
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static char fullnm[BUFSIZ];
static char roomno[BUFSIZ];
static char workph[BUFSIZ];
* prefix to most error messages.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
sanitize_env ();
(void) setlocale (LC_ALL, "");
#endif
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool eflg = false;
static bool md5flg = false;
#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
int line = 0;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#include "shadowio.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool eflg = false;
static bool md5flg = false;
#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
int line = 0;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#endif
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
#ifndef SHELLS_FILE
#define SHELLS_FILE "/etc/shells"
* Global variables
*/
const char *Prog; /* Program name */
-FILE *shadow_logfd = NULL;
static bool amroot; /* Real UID is root */
static char loginsh[BUFSIZ]; /* Name of new login shell */
/* command line options */
* most error messages.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/* Global variables */
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool cflg = false;
/* local function prototypes */
struct spwd *spwd;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
sanitize_env ();
#include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/* local function prototypes */
static /*@noreturn@*/void usage (int status);
* Global variables
*/
const char *Prog; /* Program name */
-FILE *shadow_logfd = NULL;
static FILE *fail; /* failure file stream */
static time_t seconds; /* that number of days in seconds */
static unsigned long umin; /* if uflg and has_umin, only display users with uid >= umin */
* most error messages.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#include "subid.h"
#include "stdlib.h"
#include "prototypes.h"
+#include "shadowlog.h"
/* Test program for the subid freeing routine */
const char *Prog;
-FILE *shadow_logfd = NULL;
void usage(void)
{
bool group = false; // get subuids by default
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
while ((c = getopt(argc, argv, "g")) != EOF) {
switch(c) {
case 'g': group = true; break;
#include "subid.h"
#include "stdlib.h"
#include "prototypes.h"
+#include "shadowlog.h"
const char *Prog;
-FILE *shadow_logfd = NULL;
void usage(void)
{
uid_t *uids;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
if (argc < 2) {
usage();
}
#include <stdlib.h>
#include "subid.h"
#include "prototypes.h"
+#include "shadowlog.h"
const char *Prog;
-FILE *shadow_logfd = NULL;
void usage(void)
{
const char *owner;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
if (argc < 2)
usage();
owner = argv[1];
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
/* The name of this command, as it is invoked */
const char *Prog;
-FILE *shadow_logfd = NULL;
#ifdef SHADOWGRP
/* Indicate if shadow groups are enabled on the system
*/
bywho = getuid ();
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
OPENLOG ("gpasswd");
setbuf (stdout, NULL);
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
+#include "shadowlog.h"
/*
* exit status values
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static /*@null@*/char *group_name;
static gid_t group_id;
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static char *group_name;
static gid_t group_id = -1;
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
+#include "shadowlog.h"
/* Exit Status Values */
/*@-exitarg@*/
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static char *adduser = NULL;
static char *deluser = NULL;
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
+#include "shadowlog.h"
/*
* exit status values
*/
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
#ifdef SHADOWGRP
static bool is_shadow_grp;
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#include <stdio.h>
#include "defines.h"
#include "prototypes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
/* local function prototypes */
static void print_groups (const char *member);
* Get the program name so that error messages can use it.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
if (argc == 1) {
#include "nscd.h"
#include "sssd.h"
#include "prototypes.h"
+#include "shadowlog.h"
#ifdef SHADOWGRP
#include "sgroupio.h"
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static const char *grp_file = GROUP_FILE;
static bool use_system_grp_file = true;
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#ifdef SHADOWGRP
#include "groupio.h"
#include "sgroupio.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool gr_locked = false;
static bool sgr_locked = false;
struct sgrp sgent;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#ifdef SHADOWGRP
#include "groupio.h"
#include "sgroupio.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool gr_locked = false;
static bool sgr_locked = false;
const struct sgrp *sg;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#include "getdef.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Needed for MkLinux DR1/2/2.1 - J.
* Global variables
*/
const char *Prog; /* Program name */
-FILE *shadow_logfd = NULL;
static FILE *lastlogfile; /* lastlog file stream */
static unsigned long umin; /* if uflg and has_umin, only display users with uid >= umin */
static bool has_umin = false;
* most error messages.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#include "pwauth.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
#ifdef USE_PAM
#include "pam_defs.h"
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static const char *hostname = "";
static /*@null@*/ /*@only@*/char *username = NULL;
amroot = (getuid () == 0);
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
if (geteuid() != 0) {
fprintf (stderr, _("%s: Cannot possibly work without effective root\n"), Prog);
#include <sys/types.h>
#include "defines.h"
#include "prototypes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
#ifndef DEFAULT_HUP_MESG
#define DEFAULT_HUP_MESG _("login time exceeded\n\n")
* Start syslogging everything
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
OPENLOG ("logoutd");
#include "subid.h"
#include "stdlib.h"
#include "prototypes.h"
+#include "shadowlog.h"
/* Test program for the subid creation routine */
const char *Prog;
-FILE *shadow_logfd = NULL;
void usage(void)
{
bool ok;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
while ((c = getopt(argc, argv, "gn")) != EOF) {
switch(c) {
case 'n': makenew = true; break;
#include "subordinateio.h"
#include "getdef.h"
#include "idmapping.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool verify_range(struct passwd *pw, struct map_range *range, bool *allow_setgroups)
bool allow_setgroups = false;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
/*
* The valid syntax are
#include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
extern char **newenvp;
extern char **environ;
* don't need to re-exec anything. -- JWP
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
is_newgrp = (strcmp (Prog, "newgrp") == 0);
OPENLOG (is_newgrp ? "newgrp" : "sg");
argc--;
#include "subordinateio.h"
#include "getdef.h"
#include "idmapping.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool verify_range(struct passwd *pw, struct map_range *range)
{
int written;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
/*
* The valid syntax are
#include "subordinateio.h"
#endif /* ENABLE_SUBIDS */
#include "chkname.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool rflg = false; /* create a system account */
#ifndef USE_PAM
#endif /* USE_PAM */
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#include "pwauth.h"
#include "pwio.h"
#include "shadowio.h"
+#include "shadowlog.h"
/*
* exit status values
* Global variables
*/
const char *Prog; /* Program name */
-FILE *shadow_logfd = NULL;
static char *name; /* The name of user whose password is being changed */
static char *myname; /* The current user's name */
* most error messages.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#ifdef WITH_TCB
#include "tcbfuncs.h"
#endif /* WITH_TCB */
+#include "shadowlog.h"
/*
* Exit codes
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool use_system_pw_file = true;
static bool use_system_spw_file = true;
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#include "shadowio.h"
#include "nscd.h"
#include "sssd.h"
+#include "shadowlog.h"
/*
* exit status values
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool spw_locked = false;
static bool pw_locked = false;
struct spwd spent;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#include "shadowio.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool spw_locked = false;
static bool pw_locked = false;
const struct spwd *spwd;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#endif /* USE_PAM */
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static /*@observer@*/const char *caller_tty = NULL; /* Name of tty SU is run from */
static bool caller_is_root = false;
static uid_t caller_uid;
* most error messages.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
caller_uid = getuid ();
caller_is_root = (caller_uid == 0);
#include "pwauth.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static char name[BUFSIZ];
static char pass[BUFSIZ];
#endif
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE);
#ifdef WITH_TCB
#include "tcbfuncs.h"
#endif
+#include "shadowlog.h"
#ifndef SKEL_DIR
#define SKEL_DIR "/etc/skel"
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
/*
* These defaults are used if there is no defaults file.
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#ifdef ENABLE_SUBIDS
#include "subordinateio.h"
#endif /* ENABLE_SUBIDS */
+#include "shadowlog.h"
/*
* exit status values
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static char *user_name;
static uid_t user_id;
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE);
#ifdef WITH_TCB
#include "tcbfuncs.h"
#endif
+#include "shadowlog.h"
/*
* exit status values
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static char *user_name;
static char *user_newname;
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
#include <tcb.h>
#include "tcbfuncs.h"
#endif /* WITH_TCB */
+#include "shadowlog.h"
#define MSG_WARN_EDIT_OTHER_FILE _( \
"You have modified %s.\n"\
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static const char *filename, *fileeditname;
static bool filelocked = false;
bool do_vipw;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);