]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Make shadow_logfd and Prog not extern 471/head
authorSerge Hallyn <serge@hallyn.com>
Sun, 28 Nov 2021 23:37:53 +0000 (17:37 -0600)
committerSerge Hallyn <serge@hallyn.com>
Thu, 23 Dec 2021 21:18:07 +0000 (15:18 -0600)
Closes #444
Closes #465

Signed-off-by: Serge Hallyn <serge@hallyn.com>
79 files changed:
lib/Makefile.am
lib/commonio.c
lib/encrypt.c
lib/getdef.c
lib/nscd.c
lib/nss.c
lib/prototypes.h
lib/run_part.c
lib/selinux.c
lib/semanage.c
lib/shadowlog.c [new file with mode: 0644]
lib/shadowlog.h [new file with mode: 0644]
lib/shadowlog_internal.h [new file with mode: 0644]
lib/spawn.c
lib/sssd.c
lib/tcbfuncs.c
libmisc/addgrps.c
libmisc/audit_help.c
libmisc/chowntty.c
libmisc/cleanup_group.c
libmisc/cleanup_user.c
libmisc/copydir.c
libmisc/env.c
libmisc/find_new_gid.c
libmisc/find_new_sub_gids.c
libmisc/find_new_sub_uids.c
libmisc/find_new_uid.c
libmisc/gettime.c
libmisc/idmapping.c
libmisc/limits.c
libmisc/pam_pass.c
libmisc/pam_pass_non_interactive.c
libmisc/prefix_flag.c
libmisc/pwdcheck.c
libmisc/root_flag.c
libmisc/salt.c
libmisc/setupenv.c
libmisc/user_busy.c
libmisc/xgetXXbyYY.c
libmisc/xmalloc.c
libsubid/api.c
src/chage.c
src/check_subid_range.c
src/chfn.c
src/chgpasswd.c
src/chpasswd.c
src/chsh.c
src/expiry.c
src/faillog.c
src/free_subid_range.c
src/get_subid_owners.c
src/getsubids.c
src/gpasswd.c
src/groupadd.c
src/groupdel.c
src/groupmems.c
src/groupmod.c
src/groups.c
src/grpck.c
src/grpconv.c
src/grpunconv.c
src/lastlog.c
src/login.c
src/logoutd.c
src/new_subid_range.c
src/newgidmap.c
src/newgrp.c
src/newuidmap.c
src/newusers.c
src/passwd.c
src/pwck.c
src/pwconv.c
src/pwunconv.c
src/su.c
src/sulogin.c
src/useradd.c
src/userdel.c
src/usermod.c
src/vipw.c

index 582f843c5987c5d96961b3d52fde6dacec4c1b41..7421083fb57e253f00727b7371d5df9bcda57b9d 100644 (file)
@@ -36,6 +36,8 @@ libshadow_la_SOURCES = \
        nss.c \
        nscd.c \
        nscd.h \
+       shadowlog.c \
+       shadowlog.h \
        sssd.c \
        sssd.h \
        pam_defs.h \
index 3caddf1a5ded0832e60e244e6c478625b094283d..10317b0e1c953c1d6b2dcf82a7b0e870e129b373 100644 (file)
@@ -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 *);
index 66c52f2d8718f4d26864d2cede4b34ff7dbc6ead..94c72fb560fe927585d0433cbeb2946766842202 100644 (file)
@@ -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)
 {
index 80eb18c4f373671c03fe54cd148e86858be33ec7..596b23f716d4292ffbd66a2fbaa765b7007ede2a 100644 (file)
@@ -44,6 +44,7 @@
 #include <libeconf.h>
 #endif
 #include "getdef.h"
+#include "shadowlog_internal.h"
 /*
  * A configuration item definition.
  */
index 397212e22083ca6f58cab47af4b9c7748c8e5f12..693b40712e23f6fdfecebb5d7d966d20a707f574 100644 (file)
@@ -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"
 
index 7c082758ecfc62bd61d6a01768f5a84bb35b1ea6..af3e95ac8336fc65130b5c06a92afc5d29c9c33e 100644 (file)
--- a/lib/nss.c
+++ b/lib/nss.c
@@ -8,6 +8,7 @@
 #include <stdatomic.h>
 #include "prototypes.h"
 #include "../libsubid/subid.h"
+#include "shadowlog_internal.h"
 
 #define NSSWITCH "/etc/nsswitch.conf"
 
index b697e0ecc521e227ef76945a9cb6d80646dae7fa..535c671fc4591ef84c3d81af770c391a6a16706d 100644 (file)
@@ -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 *);
index f69da887716161681fc3cfc872ca5c5b9b398c0d..1ce06be0476cfd149733aaaf08dc7fdc68848186 100644 (file)
@@ -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)
 {
index b075d4c04df4c5c99b70f87489d2198617a39b9b..890fee4fb79dc793c84d8449ab5f6d8cb034f2c4 100644 (file)
@@ -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;
index a5bf921858fdfd77d69e516ec3fee7442bedf449..27b1d5606a39746a8a91e943ba6257ddbfb20cc5 100644 (file)
@@ -43,6 +43,7 @@
 #include <semanage/semanage.h>
 #include "prototypes.h"
 
+#include "shadowlog_internal.h"
 
 #ifndef DEFAULT_SERANGE
 #define DEFAULT_SERANGE "s0"
diff --git a/lib/shadowlog.c b/lib/shadowlog.c
new file mode 100644 (file)
index 0000000..5feaef2
--- /dev/null
@@ -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;
+}
diff --git a/lib/shadowlog.h b/lib/shadowlog.h
new file mode 100644 (file)
index 0000000..bf8be85
--- /dev/null
@@ -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
diff --git a/lib/shadowlog_internal.h b/lib/shadowlog_internal.h
new file mode 100644 (file)
index 0000000..cf96fae
--- /dev/null
@@ -0,0 +1,2 @@
+const char *Prog; /* Program name showed in error messages */
+FILE *shadow_logfd;  /* file descripter to which error messages are printed */
index c53742ccda50288117f03f7798111a6581462372..6983e28f6d391dbeed35d5fce2ef58d12a28f019 100644 (file)
@@ -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)
 {
index f864ce68920e1f77447db6ce08515d7702bf7198..f66fd88a894b9aa5a2c3e8ebd5661cd7b1bb1ad7 100644 (file)
@@ -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)
index b68b15b3227fa7466921d7676e016df75d0a17d7..8bcc5dc28ffc7c89f2bd508c9f932362c2f34154 100644 (file)
@@ -38,6 +38,8 @@
 #include "shadowio.h"
 #include "tcbfuncs.h"
 
+#include "shadowlog_internal.h"
+
 #define SHADOWTCB_HASH_BY 1000
 #define SHADOWTCB_LOCK_SUFFIX ".lock"
 
index 76c172a5b8be2e8bec707913b490f8713d4ffa7c..084369699fe393ca59d0efc3714574bba569ec19 100644 (file)
@@ -40,6 +40,7 @@
 #include <stdio.h>
 #include <grp.h>
 #include <errno.h>
+#include "shadowlog.h"
 
 #ident "$Id$"
 
@@ -58,6 +59,7 @@ int add_groups (const char *list)
        char *token;
        char buf[1024];
        int ret;
+       FILE *shadow_logfd = log_get_logfd();
 
        if (strlen (list) >= sizeof (buf)) {
                errno = EINVAL;
index c5cd87d65854dd901d03e35acdb26efb26ae35b6..4355cbacb6f2affa84e64dccd4442ac8a60aebf0 100644 (file)
@@ -45,6 +45,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include "prototypes.h"
+#include "shadowlog.h"
 int audit_fd;
 
 void audit_help_open (void)
@@ -59,7 +60,7 @@ void audit_help_open (void)
                        return;
                }
                (void) fputs (_("Cannot open audit interface - aborting.\n"),
-                             shadow_logfd);
+                             log_get_logfd());
                exit (EXIT_FAILURE);
        }
 }
index a42ab6220f1a467b794fdf736dd27e8066d2f46c..001e40a5ac18705d126e6263a6b21b882714b536 100644 (file)
@@ -43,6 +43,7 @@
 #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
@@ -75,6 +76,7 @@ void chown_tty (const struct passwd *info)
        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"),
index a1233eac4cc762f4f4607338ce61c25e6c265255..b1889764da274330db8109a535b34c53beb10e8e 100644 (file)
@@ -36,6 +36,7 @@
 #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
@@ -48,7 +49,7 @@ void cleanup_report_add_group (void *group_name)
 
        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);
@@ -66,7 +67,7 @@ void cleanup_report_del_group (void *group_name)
 
        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);
@@ -83,7 +84,7 @@ void cleanup_report_mod_group (void *cleanup_info)
                 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);
@@ -101,7 +102,7 @@ void cleanup_report_mod_gshadow (void *cleanup_info)
                 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);
@@ -121,7 +122,7 @@ void cleanup_report_add_group_group (void *group_name)
 
        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);
@@ -141,7 +142,7 @@ void cleanup_report_add_group_gshadow (void *group_name)
 
        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);
@@ -164,7 +165,7 @@ void cleanup_report_del_group_group (void *group_name)
                 "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);
@@ -187,7 +188,7 @@ void cleanup_report_del_group_gshadow (void *group_name)
                 "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);
@@ -203,9 +204,9 @@ void cleanup_report_del_group_gshadow (void *group_name)
 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",
@@ -223,9 +224,9 @@ void cleanup_unlock_group (unused void *arg)
 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",
index 7422846a789cea30a19ddeca98339312a6380d4c..d943f17205494a6967f10c579beceee6a0a001ec 100644 (file)
@@ -36,6 +36,7 @@
 #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
@@ -48,7 +49,7 @@ void cleanup_report_add_user (void *user_name)
 
        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);
@@ -65,7 +66,7 @@ void cleanup_report_mod_passwd (void *cleanup_info)
                 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);
@@ -85,7 +86,7 @@ void cleanup_report_add_user_passwd (void *user_name)
 
        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);
@@ -105,7 +106,7 @@ void cleanup_report_add_user_shadow (void *user_name)
 
        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);
@@ -120,9 +121,9 @@ void cleanup_report_add_user_shadow (void *user_name)
 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",
@@ -139,9 +140,9 @@ void cleanup_unlock_passwd (unused void *arg)
 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",
index 66dc792049c8429d2cc3507099e2e0b4be992ace..f2130bcacad26d4ad1168faf9ae5077d58ad6113 100644 (file)
@@ -55,6 +55,7 @@
 #ifdef WITH_ATTR
 #include <attr/libattr.h>
 #endif                         /* WITH_ATTR */
+#include "shadowlog.h"
 
 
 static /*@null@*/const char *src_orig;
@@ -116,6 +117,7 @@ static int fchown_if_needed (int fdst, const struct stat *statp,
 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 */
@@ -125,7 +127,7 @@ static void error_acl (struct error_context *ctx, const char *fmt, ...)
        }
 
        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);
        }
@@ -248,9 +250,9 @@ int copy_tree (const char *src_root, const char *dst_root,
                }
 
                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;
                }
 
index 47a5558431f2e968b5d1adbd8ebefd6128d56357..357b62bc948c4942ead521f5e6ddc7c05a030245 100644 (file)
@@ -40,6 +40,7 @@
 #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
@@ -171,7 +172,7 @@ void addenv (const char *string, /*@null@*/const char *value)
                        }
                        newenvp = __newenvp;
                } else {
-                       (void) fputs (_("Environment overflow\n"), shadow_logfd);
+                       (void) fputs (_("Environment overflow\n"), log_get_logfd());
                        newenvc--;
                        free (newenvp[newenvc]);
                }
index 45c68be982a74527af1127ca0ef6a00540d4139d..ac2a621a1ac435e78ecea920b8b7c1a08abdd061 100644 (file)
@@ -38,6 +38,7 @@
 #include "prototypes.h"
 #include "groupio.h"
 #include "getdef.h"
+#include "shadowlog.h"
 
 /*
  * get_ranges - Get the minimum and maximum ID ranges for the search
@@ -74,10 +75,10 @@ static int get_ranges (bool sys_group, gid_t *min_id, gid_t *max_id,
 
                /* 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;
@@ -97,10 +98,10 @@ static int get_ranges (bool sys_group, gid_t *min_id, gid_t *max_id,
 
                /* 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;
                }
@@ -213,10 +214,10 @@ int find_new_gid (bool sys_group,
                         * 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;
                }
        }
@@ -243,9 +244,9 @@ int find_new_gid (bool sys_group,
        /* 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));
@@ -323,10 +324,10 @@ int find_new_gid (bool sys_group,
                                 *
                                 */
                                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)));
@@ -366,10 +367,10 @@ int find_new_gid (bool sys_group,
                                         *
                                         */
                                        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)));
@@ -426,10 +427,10 @@ int find_new_gid (bool sys_group,
                                 *
                                 */
                                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)));
@@ -469,10 +470,10 @@ int find_new_gid (bool sys_group,
                                         *
                                         */
                                        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)));
@@ -488,9 +489,9 @@ int find_new_gid (bool sys_group,
        }
 
        /* 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;
index 6f418cda4dbf8fd67f0dff72724ea9913695cfc6..65f42c0cb8f03b42ec4381aabf6ce309db646398 100644 (file)
@@ -37,6 +37,7 @@
 #include "prototypes.h"
 #include "subordinateio.h"
 #include "getdef.h"
+#include "shadowlog.h"
 
 /*
  * find_new_sub_gids - Find a new unused range of GIDs.
@@ -60,18 +61,18 @@ int find_new_sub_gids (gid_t *range_start, unsigned long *range_count)
        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;
        }
index 346ec893c803d5e5fa1459e80089387760d1c8b8..d59f9eb6c06779ddb0f9a673a049f681b4867ce0 100644 (file)
@@ -37,6 +37,7 @@
 #include "prototypes.h"
 #include "subordinateio.h"
 #include "getdef.h"
+#include "shadowlog.h"
 
 /*
  * find_new_sub_uids - Find a new unused range of UIDs.
@@ -60,18 +61,18 @@ int find_new_sub_uids (uid_t *range_start, unsigned long *range_count)
        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;
        }
index 1d85036c5139946e9c67a26a03089c8f586c73cc..7f8b09084324b0fb1738306000317e63142b1ea6 100644 (file)
@@ -38,6 +38,7 @@
 #include "prototypes.h"
 #include "pwio.h"
 #include "getdef.h"
+#include "shadowlog.h"
 
 /*
  * get_ranges - Get the minimum and maximum ID ranges for the search
@@ -74,10 +75,10 @@ static int get_ranges (bool sys_user, uid_t *min_id, uid_t *max_id,
 
                /* 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;
@@ -97,10 +98,10 @@ static int get_ranges (bool sys_user, uid_t *min_id, uid_t *max_id,
 
                /* 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;
                }
@@ -213,10 +214,10 @@ int find_new_uid(bool sys_user,
                         * 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;
                }
        }
@@ -243,9 +244,9 @@ int find_new_uid(bool sys_user,
        /* 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));
@@ -323,10 +324,10 @@ int find_new_uid(bool sys_user,
                                 *
                                 */
                                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)));
@@ -366,10 +367,10 @@ int find_new_uid(bool sys_user,
                                         *
                                         */
                                        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)));
@@ -426,10 +427,10 @@ int find_new_uid(bool sys_user,
                                 *
                                 */
                                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)));
@@ -469,10 +470,10 @@ int find_new_uid(bool sys_user,
                                         *
                                         */
                                        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)));
@@ -488,9 +489,9 @@ int find_new_uid(bool sys_user,
        }
 
        /* 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;
index e882300c7adbf58b540b4bc8e3fdf975c289ceef..99a69f7ab20ad97d1776ac171becd600449ff060 100644 (file)
@@ -36,6 +36,7 @@
 #include <stdio.h>
 #include "defines.h"
 #include "prototypes.h"
+#include "shadowlog.h"
 
 /*
  * gettime() returns the time as the number of seconds since the Epoch
@@ -50,6 +51,7 @@
        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");
index 5c501c812a1edc4488ca28ceb456730b602055b0..2af7b49aaca09e5b6174670aab715d9f48e27d08 100644 (file)
@@ -40,6 +40,7 @@
 #include <sys/prctl.h>
 #include <sys/capability.h>
 #endif
+#include "shadowlog.h"
 
 struct map_range *get_map_ranges(int ranges, int argc, char **argv)
 {
@@ -47,28 +48,28 @@ 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);
        }
 
@@ -88,24 +89,24 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv)
                        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);
                }
        }
@@ -176,19 +177,19 @@ void write_mapping(int proc_dir_fd, int ranges, struct map_range *mappings,
        } 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);
                }
        }
@@ -204,7 +205,7 @@ void write_mapping(int proc_dir_fd, int ranges, struct map_range *mappings,
                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
@@ -222,7 +223,7 @@ void write_mapping(int proc_dir_fd, int ranges, struct map_range *mappings,
                        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;
@@ -231,13 +232,13 @@ void write_mapping(int proc_dir_fd, int ranges, struct map_range *mappings,
        /* 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);
index 17f9ecd71e30f08833fa7bd7dcf230be035834f2..e14c99c13a3765643b3bf7cd1d641365c811fe7d 100644 (file)
@@ -50,6 +50,7 @@
 #include "defines.h"
 #include <pwd.h>
 #include "getdef.h"
+#include "shadowlog.h"
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #define LIMITS
@@ -548,7 +549,7 @@ void setup_limits (const struct passwd *info)
 #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);
                        }
index 58a3d3f6e00f0279da328f22a14071cb14d64504..50d8e3a6e8c99cf7f44d2122933e1c9d05776c91 100644 (file)
 #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;
index 3c95c88cfedf25a2005b6f0d0520b0711b48a575..ccc3c1e448475cd71d11ebbcd4fb98ad78809f29 100644 (file)
@@ -38,6 +38,7 @@
 #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,
@@ -76,9 +77,9 @@ 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);
@@ -88,7 +89,7 @@ static int ni_conv (int num_msg,
                        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;
@@ -101,9 +102,9 @@ static int ni_conv (int num_msg,
                        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;
                }
        }
@@ -143,19 +144,19 @@ int do_pam_passwd_non_interactive (const char *pam_service,
 
        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);
index b6628ac492669b8b6bd6ab615eb8945e0585ba5d..4c9021d9a65dc7bd0b7f90ebe02d3137385ca376 100644 (file)
@@ -48,6 +48,7 @@
 #include "subordinateio.h"
 #endif                         /* ENABLE_SUBIDS */
 #include "getdef.h"
+#include "shadowlog.h"
 
 static char *passwd_db_file = NULL;
 static char *spw_db_file = NULL;
@@ -83,18 +84,18 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char **
                        && (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];
@@ -110,9 +111,9 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char **
                /* 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;
index bc6b66f8a90a3e42d77c9270612bfb0bda01a372..7b66ac7d70146d28a1b366b94c5fd0584091d313 100644 (file)
@@ -39,6 +39,7 @@
 #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)
 {
@@ -51,7 +52,7 @@ void passwd_check (const char *user, const char *passwd, unused const char *prog
        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);
        }
 }
index e9a97d44035ae700550798aaf4688d14a0ed55d1..e48d13447136d81961db5c3a299c312e7a9073e9 100644 (file)
@@ -38,6 +38,7 @@
 #include "prototypes.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
+#include "shadowlog.h"
 
 static void change_root (const char* newroot);
 
@@ -65,18 +66,18 @@ extern void process_root_flag (const char* short_opt, int argc, char **argv)
                        && (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];
@@ -94,36 +95,36 @@ static void change_root (const char* newroot)
        /* 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);
        }
 }
index 30eefb9c1ef36e165e1b0b1c9f7d97e4d9ca5a0e..a6a614e0d2e2f0bc23473e95941e72f3ce054ec4 100644 (file)
@@ -21,6 +21,7 @@
 #include "prototypes.h"
 #include "defines.h"
 #include "getdef.h"
+#include "shadowlog.h"
 
 #if (defined CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY && \
      CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY)
@@ -178,7 +179,7 @@ static long read_random_bytes (void)
 #endif
 
 fail:
-       fprintf (shadow_logfd,
+       fprintf (log_get_logfd(),
                 _("Unable to obtain random bytes.\n"));
        exit (1);
 
@@ -506,7 +507,7 @@ static /*@observer@*/const char *gensalt (size_t salt_size)
                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);
@@ -532,7 +533,7 @@ static /*@observer@*/const char *gensalt (size_t salt_size)
 
        /* 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 "
index 74b18723aeec231596d31e9e58e0037b0d0674ea..d56227ec739937cb01655d63b65c7cc0e146a5a5 100644 (file)
@@ -47,6 +47,7 @@
 #include "defines.h"
 #include <pwd.h>
 #include "getdef.h"
+#include "shadowlog.h"
 
 #ifndef USE_PAM
 static void
@@ -219,7 +220,7 @@ void setup_env (struct passwd *info)
                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",
index 3deebfc33c2a196af40f8fcfe666cc373b96daa1..f63ecc63e228604b94f245de6376fbd61b7fc121 100644 (file)
@@ -45,6 +45,7 @@
 #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);
@@ -96,9 +97,9 @@ static int user_busy_utmp (const char *name)
                        continue;
                }
 
-               fprintf (shadow_logfd,
+               fprintf (log_get_logfd(),
                         _("%s: user %s is currently logged in\n"),
-                        Prog, name);
+                        log_get_progname(), name);
                return 1;
        }
 
@@ -249,9 +250,9 @@ static int user_busy_processes (const char *name, uid_t uid)
 #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;
                }
 
@@ -273,9 +274,9 @@ static int user_busy_processes (const char *name, uid_t uid)
 #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;
                                }
                        }
index 11f45fc478ba08aa210dd62a9e55a5d89bfa5884..5697212db88d519cb4f663e13da45a7eb1f3a50a 100644 (file)
@@ -54,6 +54,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include "prototypes.h"
+#include "shadowlog.h"
 
 #define XFUNCTION_NAME XPREFIX (FUNCTION_NAME)
 #define XPREFIX(name) XPREFIX1 (name)
@@ -74,7 +75,7 @@
 
        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);
        }
@@ -84,7 +85,7 @@
                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);
                }
index 6d6861452b5fdf0e8d62f817dfa6762de3927a13..e8cf7b0ea337a8d59188fc7249ddf2c8e3173c3b 100644 (file)
@@ -47,6 +47,7 @@
 #include <errno.h>
 #include "defines.h"
 #include "prototypes.h"
+#include "shadowlog.h"
 
 /*@maynotreturn@*/ /*@only@*//*@out@*//*@notnull@*/char *xmalloc (size_t size)
 {
@@ -54,9 +55,9 @@
 
        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;
index 99d7969c1a5df1deac889a67241aa2b19485e717..7a0ebaa5db4e10b0b824b5b260b5ceabf64df31c 100644 (file)
 #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)
@@ -53,14 +54,15 @@ bool subid_init(const char *progname, FILE * logfd)
        }
 
        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;
 }
 
index c74908013711165d209d60477fa8cff1ac5048e6..df34da1de0ca827972aff5a13c6f467a65139987 100644 (file)
@@ -52,6 +52,7 @@
 #include "defines.h"
 #include "pwio.h"
 #include "shadowio.h"
+#include "shadowlog.h"
 #ifdef WITH_TCB
 #include "tcbfuncs.h"
 #endif
@@ -62,7 +63,6 @@
  * Global variables
  */
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 static bool
     dflg = false,              /* set last password change date */
@@ -815,7 +815,8 @@ int main (int argc, char **argv)
         * 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, "");
index 8a9d5258efe997fed9998348ad8594aff7616ff7..38703b60301cabb8d183ff303cfa1bbf71aec985 100644 (file)
@@ -16,9 +16,9 @@
 #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)
 {
@@ -26,7 +26,8 @@ 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);
index 323fd43f52f140b5d45e979b8444150c7ae65c1c..77c76fad03de629d2310a51589e18e0594362194 100644 (file)
 #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];
@@ -640,7 +640,8 @@ int main (int argc, char **argv)
         * 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, "");
index 25dfc2461d2dc5f29367de4599fc5f28549cae65..fe68d58cf08c02bb2a70e18aa23a989038efd073 100644 (file)
 #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)
@@ -438,7 +438,8 @@ int main (int argc, char **argv)
        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);
index d55a47ddbf764d13f11442349e0cb4f4a566888c..efbfa045be0da06a240a3474ffd6b5d59e69f0d8 100644 (file)
 #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)
@@ -430,7 +430,8 @@ int main (int argc, char **argv)
        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);
index 1cafb8b629ad01d22272f7f6a87dbe52e1100a33..92b5e5d9ab7d6ea78507575e320b71dc8243707b 100644 (file)
@@ -51,6 +51,7 @@
 #endif
 /*@-exitarg@*/
 #include "exitcodes.h"
+#include "shadowlog.h"
 
 #ifndef SHELLS_FILE
 #define SHELLS_FILE "/etc/shells"
@@ -59,7 +60,6 @@
  * 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 */
@@ -442,7 +442,8 @@ int main (int argc, char **argv)
         * 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);
index 79db32ff4f15fab20b30819e3525268c103ff9dc..31604a6da35f75189430fb494453e6cda0bbfe74 100644 (file)
 #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 */
@@ -145,7 +145,8 @@ int main (int argc, char **argv)
        struct spwd *spwd;
 
        Prog = Basename (argv[0]);
-       shadow_logfd = stderr;
+       log_set_progname(Prog);
+       log_set_logfd(stderr);
 
        sanitize_env ();
 
index d09f151137007bf1b91ffcb04f24021b8fa3a1b8..db4fc72b7bccca8d57f2c4084d969f9adf37e713 100644 (file)
@@ -46,6 +46,7 @@
 #include "prototypes.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
+#include "shadowlog.h"
 
 /* local function prototypes */
 static /*@noreturn@*/void usage (int status);
@@ -62,7 +63,6 @@ static void reset (void);
  * 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 */
@@ -574,7 +574,8 @@ int main (int argc, char **argv)
         * 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);
index 97fff6ad7a1c1acd565b5db63310f2c670711731..c08d5fcc78f408540c098bb7b49a36d58f0e2b4f 100644 (file)
@@ -3,11 +3,11 @@
 #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)
 {
@@ -24,7 +24,8 @@ int main(int argc, char *argv[])
        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;
index 338a5a8bc1d1fa20ea439d6f296ff3376718d2d8..14a89ca07fcf7672919e6ec2cd66ab4842cf7767 100644 (file)
@@ -2,9 +2,9 @@
 #include "subid.h"
 #include "stdlib.h"
 #include "prototypes.h"
+#include "shadowlog.h"
 
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 void usage(void)
 {
@@ -20,7 +20,8 @@ int main(int argc, char *argv[])
        uid_t *uids;
 
        Prog = Basename (argv[0]);
-       shadow_logfd = stderr;
+       log_set_progname(Prog);
+       log_set_logfd(stderr);
        if (argc < 2) {
                usage();
        }
index f652cb638e56382777d8095519fde261ae19b7a5..2bda1473c1932d43ce8a1387aa3e1742597ceaa2 100644 (file)
@@ -3,9 +3,9 @@
 #include <stdlib.h>
 #include "subid.h"
 #include "prototypes.h"
+#include "shadowlog.h"
 
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 void usage(void)
 {
@@ -22,7 +22,8 @@ int main(int argc, char *argv[])
        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];
index 04bed83d6bbd95b08fb48b03354238ccbd5b1f28..8bbbe6bef93aea377b3cb125e571a3cfce828522 100644 (file)
 /*@-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
@@ -989,7 +989,8 @@ int main (int argc, char **argv)
         */
        bywho = getuid ();
        Prog = Basename (argv[0]);
-       shadow_logfd = stderr;
+       log_set_progname(Prog);
+       log_set_logfd(stderr);
 
        OPENLOG ("gpasswd");
        setbuf (stdout, NULL);
index d7f68b1a15e8ae4ce6cbbd8b5e159cd96098aab1..533761c803beb2cf4fb5b3784345bda7ffc9f2f9 100644 (file)
@@ -56,6 +56,7 @@
 #ifdef SHADOWGRP
 #include "sgroupio.h"
 #endif
+#include "shadowlog.h"
 
 /*
  * exit status values
@@ -72,7 +73,6 @@
  * Global variables
  */
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 static /*@null@*/char *group_name;
 static gid_t group_id;
@@ -599,7 +599,8 @@ int main (int argc, char **argv)
         * 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);
index 364cac8de42a4088d45a73f8621b5a581cdf8a6e..a4774e46394e0b2289418574435e3b6185f4545e 100644 (file)
 #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;
@@ -377,7 +377,8 @@ int main (int argc, char **argv)
         * 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);
index c2b25583675b5f26bd8787b1d531edd5faab2a7f..69f8a77d5ba0960f3be27f901207897d91259bf3 100644 (file)
@@ -47,6 +47,7 @@
 #ifdef SHADOWGRP
 #include "sgroupio.h"
 #endif
+#include "shadowlog.h"
 
 /* Exit Status Values */
 /*@-exitarg@*/
@@ -65,7 +66,6 @@
  * Global variables
  */
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 static char *adduser = NULL;
 static char *deluser = NULL;
@@ -596,7 +596,8 @@ int main (int argc, char **argv)
         * 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);
index acd6f350a2fc3225bbe02b32c6cf0d42902a209a..6d1a24793d0d5a806c513f0589e08d805d2a799a 100644 (file)
@@ -56,6 +56,7 @@
 #ifdef SHADOWGRP
 #include "sgroupio.h"
 #endif
+#include "shadowlog.h"
 /*
  * exit status values
  */
@@ -76,7 +77,6 @@
  * Global variables
  */
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 #ifdef SHADOWGRP
 static bool is_shadow_grp;
@@ -793,7 +793,8 @@ int main (int argc, char **argv)
         * 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);
index 3bfd48300707e875411c5a9004e9120c776959b1..70e3fcb23546c5182dbd0728480d40e608b75489 100644 (file)
 #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);
@@ -127,7 +127,8 @@ int main (int argc, char **argv)
         * 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) {
 
index 69bef036838c5618f3473f61815a0551e73754f1..c4387b7a23875ac2c52e81060cb3aa0ad3cdb14a 100644 (file)
@@ -45,6 +45,7 @@
 #include "nscd.h"
 #include "sssd.h"
 #include "prototypes.h"
+#include "shadowlog.h"
 
 #ifdef SHADOWGRP
 #include "sgroupio.h"
@@ -66,7 +67,6 @@
  * Global variables
  */
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 static const char *grp_file = GROUP_FILE;
 static bool use_system_grp_file = true;
@@ -841,7 +841,8 @@ int main (int argc, char **argv)
         * 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);
index aecafa404ad9ec415bd1fca82f8dcc94e0762b59..d3d0fb96759029bab22fb2d0266deeacd98ac014 100644 (file)
 #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;
@@ -147,7 +147,8 @@ int main (int argc, char **argv)
        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);
index d750e2bd630653c347e23a6cdd240219ba0e851b..b3a34ab884a6b5f9a054fa854c88477c56cc487a 100644 (file)
 #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;
@@ -146,7 +146,8 @@ int main (int argc, char **argv)
        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);
index 1b1803e18362cf38f926a5ce91d6b1ecca5a3574..b3a152d97aedaf7dbb415544c2d054fa388523f9 100644 (file)
@@ -50,6 +50,7 @@
 #include "getdef.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
+#include "shadowlog.h"
 
 /*
  * Needed for MkLinux DR1/2/2.1 - J.
@@ -62,7 +63,6 @@
  * 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;
@@ -318,7 +318,8 @@ int main (int argc, char **argv)
         * 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);
index 79517f8a0914c25d7b18db19ed4b67f851fe99ba..1623f29d4cdc245d9684e0efe40819d42e145f66 100644 (file)
@@ -53,6 +53,7 @@
 #include "pwauth.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
+#include "shadowlog.h"
 
 #ifdef USE_PAM
 #include "pam_defs.h"
@@ -83,7 +84,6 @@ static pam_handle_t *pamh = NULL;
  * Global variables
  */
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 static const char *hostname = "";
 static /*@null@*/ /*@only@*/char *username = NULL;
@@ -578,7 +578,8 @@ int main (int argc, char **argv)
 
        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);
index 02935a9137f8f88e013c8fe7f23260e082f35433..1f96a68e50eb4375d1dbeae2e6bad44c9df88240 100644 (file)
 #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")
@@ -188,7 +188,8 @@ int main (int argc, char **argv)
         * Start syslogging everything
         */
        Prog = Basename (argv[0]);
-       shadow_logfd = stderr;
+       log_set_progname(Prog);
+       log_set_logfd(stderr);
 
        OPENLOG ("logoutd");
 
index 96e6423276af898e96b6c560017566b3201f87c3..8975b725035a23f0df03273cb23952eed1b45bc2 100644 (file)
@@ -3,11 +3,11 @@
 #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)
 {
@@ -27,7 +27,8 @@ int main(int argc, char *argv[])
        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;
index 51a2eb440d4c02961605cd032c372c220e2ffeba..87581c433e17951720618c40e61f3d53e88ca75d 100644 (file)
 #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)
@@ -177,7 +177,8 @@ int main(int argc, char **argv)
        bool allow_setgroups = false;
 
        Prog = Basename (argv[0]);
-       shadow_logfd = stderr;
+       log_set_progname(Prog);
+       log_set_logfd(stderr);
 
        /*
         * The valid syntax are
index 566f1c899e2b1cda5751bb6bb8f0e0a43e84f784..d76bc90ada7727d596395d60dff3214168f33d57 100644 (file)
 #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;
@@ -445,7 +445,8 @@ int main (int argc, char **argv)
         * 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--;
index c9a92155c6e4e91e88d08dacc9a75b7879cb3d1e..d33e3e7e68133a574f59fcd68388a0931183180b 100644 (file)
 #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)
 {
@@ -107,7 +107,8 @@ int main(int argc, char **argv)
        int written;
 
        Prog = Basename (argv[0]);
-       shadow_logfd = stderr;
+       log_set_progname(Prog);
+       log_set_logfd(stderr);
 
        /*
         * The valid syntax are
index edbb401089beec7782f7b5859793e6195183d47e..db8dc95a015d09d0e28ed45f5b6f290ef809b76f 100644 (file)
 #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
@@ -1071,7 +1071,8 @@ int main (int argc, char **argv)
 #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);
index 8ec551255aea13fd235bfe539a7827d60b56cfd7..be217d31aa6abd0dacf736bfa3b5cc163c3cc794 100644 (file)
@@ -50,6 +50,7 @@
 #include "pwauth.h"
 #include "pwio.h"
 #include "shadowio.h"
+#include "shadowlog.h"
 
 /*
  * exit status values
@@ -66,7 +67,6 @@
  * 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 */
@@ -761,7 +761,8 @@ int main (int argc, char **argv)
         * 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);
index 4ce86af29d0aba0f8e3b35b12b7a9a028b1e9419..d79586bc4f2d44f1847c5c63f3f2528ce3c3326d 100644 (file)
@@ -52,6 +52,7 @@
 #ifdef WITH_TCB
 #include "tcbfuncs.h"
 #endif                         /* WITH_TCB */
+#include "shadowlog.h"
 
 /*
  * Exit codes
@@ -70,7 +71,6 @@
  * Global variables
  */
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 static bool use_system_pw_file = true;
 static bool use_system_spw_file = true;
@@ -857,7 +857,8 @@ int main (int argc, char **argv)
         * 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);
index 85ad9699e8dd78eac03e8866c7ea15934a5fe018..af6107fd9cf5af0404b61193f774386ea393be4b 100644 (file)
@@ -73,6 +73,7 @@
 #include "shadowio.h"
 #include "nscd.h"
 #include "sssd.h"
+#include "shadowlog.h"
 
 /*
  * exit status values
@@ -89,7 +90,6 @@
  * Global variables
  */
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 static bool spw_locked = false;
 static bool pw_locked = false;
@@ -177,7 +177,8 @@ int main (int argc, char **argv)
        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);
index a5ee999efd921bc4a2ffe1f84138255e8a828bac..c228befdff5f331f4558d2a8b6b5a3046acc3ace 100644 (file)
 #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;
@@ -138,7 +138,8 @@ int main (int argc, char **argv)
        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);
index 58882caf0fbbf9a4b83e0a56175b2c48414333f7..e7e3e967acd588661c0e1f5bb56eda3e36ef80d2 100644 (file)
--- a/src/su.c
+++ b/src/su.c
 #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;
@@ -734,7 +734,8 @@ static void save_caller_context (char **argv)
         * 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);
index a5a150c1aab7494982d9d1c4c858d4e90223fa8e..e438e3cbe2b726031d148d8d47d96ae78b659b47 100644 (file)
 #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];
@@ -107,7 +107,8 @@ static RETSIGTYPE catch_signals (unused int sig)
 #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);
index 3eec17787849d9c118fdd11265120a8b3d1f61fb..179e08984d174c5d1f87240626d0217da63658f7 100644 (file)
@@ -78,6 +78,7 @@
 #ifdef WITH_TCB
 #include "tcbfuncs.h"
 #endif
+#include "shadowlog.h"
 
 #ifndef SKEL_DIR
 #define SKEL_DIR "/etc/skel"
@@ -96,7 +97,6 @@
  * Global variables
  */
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 /*
  * These defaults are used if there is no defaults file.
@@ -2459,7 +2459,8 @@ int main (int argc, char **argv)
         * 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);
index 459b002180459fa3298ccdd946fe97c7c21ad316..ef63543757b5e332a2fb49ce2c15bc832bbb6223 100644 (file)
@@ -72,6 +72,7 @@
 #ifdef ENABLE_SUBIDS
 #include "subordinateio.h"
 #endif                         /* ENABLE_SUBIDS */
+#include "shadowlog.h"
 
 /*
  * exit status values
@@ -91,7 +92,6 @@
  * Global variables
  */
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 static char *user_name;
 static uid_t user_id;
@@ -1016,7 +1016,8 @@ int main (int argc, char **argv)
         * 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);
index 0a075565fe63e73c381af09f409cbab9c7e106e3..10f9ccfd3895b8b7232e3ce4d2d5058dd1e55f0e 100644 (file)
@@ -74,6 +74,7 @@
 #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;
@@ -2181,7 +2181,8 @@ int main (int argc, char **argv)
         * 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);
index 1a69ef285ce2964cac4510485baaf06def827441..9c94d6bbdbc73dbc54495a86326128618b500e12 100644 (file)
@@ -53,6 +53,7 @@
 #include <tcb.h>
 #include "tcbfuncs.h"
 #endif                         /* WITH_TCB */
+#include "shadowlog.h"
 
 #define MSG_WARN_EDIT_OTHER_FILE _( \
        "You have modified %s.\n"\
@@ -63,7 +64,6 @@
  * Global variables
  */
 const char *Prog;
-FILE *shadow_logfd = NULL;
 
 static const char *filename, *fileeditname;
 static bool filelocked = false;
@@ -485,7 +485,8 @@ int main (int argc, char **argv)
        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);