diff --git a/ChangeLog b/ChangeLog index d72f60bc..b1cdb280 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-09-06 Nicolas François + + * src/newgrp.c, src/userdel.c, src/grpck.c, src/gpasswd.c, + src/newusers.c, src/pwconv.c, src/chpasswd.c, src/logoutd.c, + src/chfn.c, src/groupmems.c, src/usermod.c, src/pwunconv.c, + src/expiry.c, src/groupdel.c, src/chgpasswd.c, src/useradd.c, + src/su.c, src/groupmod.c, src/passwd.c, src/pwck.c, + src/groupadd.c, src/chage.c, src/login.c, src/grpconv.c, + src/groups.c, src/grpunconv.c, src/chsh.c: Prog is now global (not + static to the file) so that it can be used by the helper functions + of libmisc. + * lib/prototypes.h: Added extern char *Prog. + * libmisc/find_new_gid.c, libmisc/find_new_uid.c: Indicate the + program name with the warning. + 2008-09-05 Nicolas François * configure.in: Check if AUDIT_ADD_USER, AUDIT_DEL_USER, diff --git a/lib/prototypes.h b/lib/prototypes.h index a5adedc1..569df12f 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -57,6 +57,8 @@ #include "defines.h" #include "commonio.h" +extern char *Prog; + /* addgrps.c */ extern int add_groups (const char *); extern void add_cons_grps (void); diff --git a/libmisc/find_new_gid.c b/libmisc/find_new_gid.c index c1f7f0a9..7225ce30 100644 --- a/libmisc/find_new_gid.c +++ b/libmisc/find_new_gid.c @@ -110,7 +110,8 @@ int find_new_gid (bool sys_group, gid_t *gid, gid_t const *preferred_gid) } } if (group_id == gid_max) { - fputs (_("Can't get unique GID (no more available GIDs)\n"), stderr); + fprintf (stderr, _("%s: Can't get unique GID (no more available GIDs)\n"), Prog); + SYSLOG ((LOG_WARN, "no more available GID on the system")); return -1; } } diff --git a/libmisc/find_new_uid.c b/libmisc/find_new_uid.c index 7a90420c..835b2794 100644 --- a/libmisc/find_new_uid.c +++ b/libmisc/find_new_uid.c @@ -111,7 +111,8 @@ int find_new_uid (bool sys_user, uid_t *uid, uid_t const *preferred_uid) } } if (user_id == uid_max) { - fputs (_("Can't get unique UID (no more available UIDs)\n"), stderr); + fprintf (stderr, _("Prog: Can't get unique UID (no more available UIDs)\n"), Prog); + SYSLOG ((LOG_WARN, "no more available UID on the system")); return -1; } } diff --git a/src/chage.c b/src/chage.c index 269c7efe..43fa925c 100644 --- a/src/chage.c +++ b/src/chage.c @@ -58,7 +58,7 @@ /* * Global variables */ -static char *Prog; +char *Prog; static bool dflg = false, /* set last password change date */ diff --git a/src/chfn.c b/src/chfn.c index ae4185a5..9f0f60c0 100644 --- a/src/chfn.c +++ b/src/chfn.c @@ -56,7 +56,7 @@ /* * Global variables. */ -static char *Prog; +char *Prog; static char fullnm[BUFSIZ]; static char roomno[BUFSIZ]; static char workph[BUFSIZ]; diff --git a/src/chgpasswd.c b/src/chgpasswd.c index e0e2fcf6..9262d19b 100644 --- a/src/chgpasswd.c +++ b/src/chgpasswd.c @@ -53,7 +53,7 @@ /* * Global variables */ -static char *Prog; +char *Prog; static bool cflg = false; static bool eflg = false; static bool md5flg = false; diff --git a/src/chpasswd.c b/src/chpasswd.c index 422eb790..723bdfcc 100644 --- a/src/chpasswd.c +++ b/src/chpasswd.c @@ -51,7 +51,7 @@ /* * Global variables */ -static char *Prog; +char *Prog; static bool cflg = false; static bool eflg = false; static bool md5flg = false; diff --git a/src/chsh.c b/src/chsh.c index 7fc8f59a..7b64017f 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -59,7 +59,7 @@ /* * Global variables */ -static char *Prog; /* Program name */ +char *Prog; /* Program name */ static bool amroot; /* Real UID is root */ static char loginsh[BUFSIZ]; /* Name of new login shell */ /* command line options */ diff --git a/src/expiry.c b/src/expiry.c index f12a434c..32bb508e 100644 --- a/src/expiry.c +++ b/src/expiry.c @@ -40,6 +40,10 @@ #include #include "defines.h" #include "prototypes.h" + +/* Global variables */ +char *Prog; + /* local function prototypes */ static RETSIGTYPE catch_signals (int); static void usage (void); @@ -70,9 +74,9 @@ static void usage (void) int main (int argc, char **argv) { struct passwd *pwd; - struct spwd *spwd; - char *Prog = Basename (argv[0]); + + Prog = Basename (argv[0]); sanitize_env (); diff --git a/src/gpasswd.c b/src/gpasswd.c index cb12fe9b..02f367e1 100644 --- a/src/gpasswd.c +++ b/src/gpasswd.c @@ -54,7 +54,7 @@ * Global variables */ /* The name of this command, as it is invoked */ -static char *Prog; +char *Prog; #ifdef SHADOWGRP /* Indicate if shadow groups are enabled on the system diff --git a/src/groupadd.c b/src/groupadd.c index ff66293a..d509ee70 100644 --- a/src/groupadd.c +++ b/src/groupadd.c @@ -68,13 +68,13 @@ /* * Global variables */ +char *Prog; + static char *group_name; static gid_t group_id; static char *group_passwd; static char *empty_list = NULL; -static char *Prog; - static bool oflg = false; /* permit non-unique group ID to be specified with -g */ static bool gflg = false; /* ID value for the new group */ static bool fflg = false; /* if group already exists, do nothing and exit(0) */ diff --git a/src/groupdel.c b/src/groupdel.c index 311a8102..792450e0 100644 --- a/src/groupdel.c +++ b/src/groupdel.c @@ -53,8 +53,9 @@ /* * Global variables */ +char *Prog; + static char *group_name; -static char *Prog; static gid_t group_id = -1; #ifdef SHADOWGRP diff --git a/src/groupmems.c b/src/groupmems.c index f8557839..e5ce73d0 100644 --- a/src/groupmems.c +++ b/src/groupmems.c @@ -64,13 +64,14 @@ /* * Global variables */ +char *Prog; + static char *adduser = NULL; static char *deluser = NULL; static char *thisgroup = NULL; static bool purge = false; static bool list = false; static int exclusive = 0; -static char *Prog; static bool gr_locked = false; #ifdef SHADOWGRP /* Indicate if shadow groups are enabled on the system diff --git a/src/groupmod.c b/src/groupmod.c index 9ea85291..3d536dbf 100644 --- a/src/groupmod.c +++ b/src/groupmod.c @@ -66,6 +66,8 @@ /* * Global variables */ +char *Prog; + #ifdef SHADOWGRP static bool is_shadow_grp; static bool sgr_locked = false; @@ -78,8 +80,6 @@ static char *group_passwd; static gid_t group_id; static gid_t group_newid; -static char *Prog; - static bool oflg = false, /* permit non-unique group ID to be specified with -g */ gflg = false, /* new ID value for the group */ diff --git a/src/groups.c b/src/groups.c index cbb7fc11..4a153644 100644 --- a/src/groups.c +++ b/src/groups.c @@ -42,7 +42,7 @@ /* * Global variables */ -static char *Prog; +char *Prog; /* local function prototypes */ static void print_groups (const char *member); diff --git a/src/grpck.c b/src/grpck.c index ecbeb39c..877d2b3d 100644 --- a/src/grpck.c +++ b/src/grpck.c @@ -64,7 +64,8 @@ /* * Global variables */ -static char *Prog; +char *Prog; + static const char *grp_file = GROUP_FILE; static bool use_system_grp_file = true; diff --git a/src/grpconv.c b/src/grpconv.c index f1efeb37..18aa2659 100644 --- a/src/grpconv.c +++ b/src/grpconv.c @@ -53,9 +53,10 @@ /* * Global variables */ +char *Prog; + static bool gr_locked = false; static bool sgr_locked = false; -static char *Prog; /* local function prototypes */ static void fail_exit (int status); diff --git a/src/grpunconv.c b/src/grpunconv.c index 3b706368..f7235295 100644 --- a/src/grpunconv.c +++ b/src/grpunconv.c @@ -54,9 +54,10 @@ /* * Global variables */ +char *Prog; + static bool gr_locked = false; static bool sgr_locked = false; -static char *Prog; /* local function prototypes */ static void fail_exit (int status); diff --git a/src/login.c b/src/login.c index f2f6346e..73f6e066 100644 --- a/src/login.c +++ b/src/login.c @@ -105,8 +105,8 @@ static bool preauth_flag = false; /* * Global variables. */ +char *Prog; -static char *Prog; static bool amroot; static int timeout; diff --git a/src/logoutd.c b/src/logoutd.c index 078109f4..5679d127 100644 --- a/src/logoutd.c +++ b/src/logoutd.c @@ -43,7 +43,7 @@ /* * Global variables */ -static char *Prog; +char *Prog; #ifndef DEFAULT_HUP_MESG #define DEFAULT_HUP_MESG _("login time exceeded\n\n") diff --git a/src/newgrp.c b/src/newgrp.c index 82c05789..ab0621fe 100644 --- a/src/newgrp.c +++ b/src/newgrp.c @@ -45,6 +45,8 @@ /* * Global variables */ +char *Prog; + extern char **newenvp; extern char **environ; @@ -53,7 +55,6 @@ static int ngroups; static GETGROUPS_T *grouplist; #endif -static char *Prog; static bool is_newgrp; #ifdef WITH_AUDIT diff --git a/src/newusers.c b/src/newusers.c index ce700f0a..45099690 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -65,7 +65,8 @@ /* * Global variables */ -static char *Prog; +char *Prog; + static bool cflg = false; static bool rflg = false; /* create a system account */ static bool sflg = false; diff --git a/src/passwd.c b/src/passwd.c index e67beb9a..31adc48d 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -68,9 +68,10 @@ /* * Global variables */ +char *Prog; /* Program name */ + static char *name; /* The name of user whose password is being changed */ static char *myname; /* The current user's name */ -static char *Prog; /* Program name */ static bool amroot; /* The caller's real UID was 0 */ static bool diff --git a/src/pwck.c b/src/pwck.c index 9d5a0c01..5b1704cf 100644 --- a/src/pwck.c +++ b/src/pwck.c @@ -63,8 +63,8 @@ /* * Global variables */ +char *Prog; -static char *Prog; static const char *pwd_file = PASSWD_FILE; static bool use_system_pw_file = true; static const char *spw_file = SHADOW_FILE; diff --git a/src/pwconv.c b/src/pwconv.c index 475c92ae..262343d3 100644 --- a/src/pwconv.c +++ b/src/pwconv.c @@ -83,7 +83,8 @@ /* * Global variables */ -static char *Prog; +char *Prog; + static bool spw_locked = false; static bool pw_locked = false; diff --git a/src/pwunconv.c b/src/pwunconv.c index c0f49be3..5825f9df 100644 --- a/src/pwunconv.c +++ b/src/pwunconv.c @@ -47,7 +47,8 @@ /* * Global variables */ -static char *Prog; +char *Prog; + static bool spw_locked = false; static bool pw_locked = false; diff --git a/src/su.c b/src/su.c index 7a16dbff..084e33b1 100644 --- a/src/su.c +++ b/src/su.c @@ -75,6 +75,8 @@ /* * Global variables */ +char *Prog; + /* not needed by sulog.c anymore */ static char name[BUFSIZ]; static char oldname[BUFSIZ]; @@ -87,7 +89,6 @@ static pam_handle_t *pamh = NULL; static bool caught = false; #endif -static char *Prog; extern struct passwd pwent; /* diff --git a/src/useradd.c b/src/useradd.c index 993f7635..e3efcb7e 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -79,6 +79,8 @@ /* * Global variables */ +char *Prog; + /* * These defaults are used if there is no defaults file. */ @@ -119,8 +121,6 @@ static char **user_groups; /* NULL-terminated list */ static long sys_ngroups; static bool do_grp_update = false; /* group files need to be updated */ -static char *Prog; - static bool bflg = false, /* new default root of home directory */ cflg = false, /* comment (GECOS) field for new account */ diff --git a/src/userdel.c b/src/userdel.c index f9a1a09c..3a8862db 100644 --- a/src/userdel.c +++ b/src/userdel.c @@ -68,11 +68,16 @@ #define E_USER_BUSY 8 /* user currently logged in */ #define E_GRP_UPDATE 10 /* can't update group file */ #define E_HOMEDIR 12 /* can't remove home directory */ + +/* + * Global variables + */ +char *Prog; + static char *user_name; static uid_t user_id; static char *user_home; -static char *Prog; static bool fflg = false; static bool rflg = false; diff --git a/src/usermod.c b/src/usermod.c index e3aeb56c..ca1a7688 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -82,6 +82,8 @@ /* * Global variables */ +char *Prog; + static char *user_name; static char *user_newname; static char *user_pass; @@ -102,8 +104,6 @@ static long user_newinactive; static long sys_ngroups; static char **user_groups; /* NULL-terminated list */ -static char *Prog; - static bool aflg = false, /* append to existing secondary group set */ cflg = false, /* new comment (GECOS) field */