+2007-12-31 Nicolas François <nicolas.francois@centraliens.net>
+
+ * src/newusers.c: Compilation fix for PAM support (pamh needs to be
+ global since the function split).
+ * src/chpasswd.c: Likewise.
+ * src/chgpasswd.c: Likewise.
+ * src/chpasswd.c: Avoid implicit conversions to booleans.
+
2007-12-31 Nicolas François <nicolas.francois@centraliens.net>
* src/chage.c: Fix typo: s/maximim/maximum/
static int is_shadow_grp;
#endif
+#ifdef USE_PAM
+static pam_handle_t *pamh = NULL;
+#endif
+
/* local function prototypes */
static void usage (void);
static void process_flags (int argc, char **argv);
static void check_perms (void)
{
#ifdef USE_PAM
- pam_handle_t *pamh = NULL;
int retval = PAM_SUCCESS;
-
struct passwd *pampw;
+
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
if (pampw == NULL) {
retval = PAM_USER_UNKNOWN;
static int is_shadow_pwd;
+#ifdef USE_PAM
+static pam_handle_t *pamh = NULL;
+#endif
+
/* local function prototypes */
static void usage (void);
static void process_flags (int argc, char **argv);
*
* It will not return if an error is encountered.
*/
-static void check_flags ()
+static void check_flags (void)
{
if (sflg && !cflg) {
fprintf (stderr,
static void check_perms (void)
{
#ifdef USE_PAM
- pam_handle_t *pamh = NULL;
int retval = PAM_SUCCESS;
struct passwd *pampw;
* Lock the password file and open it for reading and writing. This
* will bring all of the entries into memory where they may be updated.
*/
- if (!pw_lock ()) {
+ if (pw_lock () == 0) {
fprintf (stderr, _("%s: can't lock password file\n"), Prog);
exit (1);
}
- if (!pw_open (O_RDWR)) {
+ if (pw_open (O_RDWR) == 0) {
fprintf (stderr, _("%s: can't open password file\n"), Prog);
pw_unlock ();
exit (1);
/* Do the same for the shadowed database, if it exist */
if (is_shadow_pwd) {
- if (!spw_lock ()) {
+ if (spw_lock () == 0) {
fprintf (stderr, _("%s: can't lock shadow file\n"),
Prog);
pw_unlock ();
exit (1);
}
- if (!spw_open (O_RDWR)) {
+ if (spw_open (O_RDWR) == 0) {
fprintf (stderr, _("%s: can't open shadow file\n"),
Prog);
pw_unlock ();
static void close_files (void)
{
if (is_shadow_pwd) {
- if (!spw_close ()) {
+ if (spw_close () == 0) {
fprintf (stderr,
_("%s: error updating shadow file\n"), Prog);
pw_unlock ();
spw_unlock ();
}
- if (!pw_close ()) {
+ if (pw_close () == 0) {
fprintf (stderr, _("%s: error updating password file\n"), Prog);
exit (1);
}
pw_unlock ();
-
}
int main (int argc, char **argv)
* already exist.
*/
pw = pw_locate (name);
- if (!pw) {
+ if (NULL == pw) {
fprintf (stderr,
_("%s: line %d: unknown user %s\n"), Prog,
line, name);
* user's password file entry and the last password change
* date is set to the current date.
*/
- if (sp) {
+ if (NULL != sp) {
newsp = *sp;
newsp.sp_pwdp = cp;
newsp.sp_lstchg = now;
* be written to the password file later, after all the
* other entries have been updated as well.
*/
- if (sp) {
+ if (NULL != sp) {
ok = spw_update (&newsp);
} else {
ok = pw_update (&newpw);
static int is_shadow_grp;
#endif
+#ifdef USE_PAM
+static pam_handle_t *pamh = NULL;
+#endif
+
/* local function prototypes */
static void usage (void);
static int add_group (const char *, const char *, gid_t *);
static void check_perms (void)
{
#ifdef USE_PAM
- pam_handle_t *pamh = NULL;
int retval = PAM_SUCCESS;
struct passwd *pampw;