* src/gpasswd.c: New functions: check_perms(), get_group(),
change_passwd(), check_flags(). Split out of main() to simplify main().
* src/gpasswd.c: Avoid implicit brackets.
+ * src/gpasswd.c: Avoid assignment in comparisons.
2007-12-27 Nicolas François <nicolas.francois@centraliens.net>
size_t len;
for (start = users; start && *start; start = end) {
- if ((end = strchr (start, ','))) {
+ end = strchr (start, ',');
+ if (NULL != end) {
len = end - start;
end++;
} else {
#endif
exit (1);
}
-#ifdef SHADOWGRP
+#ifdef SHADOWGRP
if (is_shadowgrp && (sgr_lock () == 0)) {
fprintf (stderr, _("%s: can't get shadow lock\n"), Prog);
SYSLOG ((LOG_WARN, "failed to get lock for /etc/gshadow"));
#endif
exit (1);
}
-#ifdef SHADOWGRP
+#ifdef SHADOWGRP
if (is_shadowgrp && (sgr_open (O_RDWR) == 0)) {
fprintf (stderr, _("%s: can't open shadow file\n"), Prog);
SYSLOG ((LOG_WARN, "cannot open /etc/gshadow"));
#endif
exit (1);
}
-#ifdef SHADOWGRP
+#ifdef SHADOWGRP
if (is_shadowgrp && (sgr_close () == 0)) {
fprintf (stderr, _("%s: can't re-write shadow file\n"), Prog);
SYSLOG ((LOG_WARN, "cannot re-write /etc/gshadow"));
exit (1);
}
- if (!(tmpgr = gr_locate (group))) {
+ tmpgr = gr_locate (group);
+ if (NULL == tmpgr) {
fprintf (stderr, _("unknown group: %s\n"), group);
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
#endif
exit (1);
}
- if ((tmpsg = sgr_locate (group))) {
+ tmpsg = sgr_locate (group);
+ if (NULL != tmpsg) {
*sg = *tmpsg;
sg->sg_name = xstrdup (tmpsg->sg_name);
sg->sg_passwd = xstrdup (tmpsg->sg_passwd);
printf (_("Changing the password for group %s\n"), group);
for (retries = 0; retries < RETRIES; retries++) {
- if (!(cp = getpass (_("New Password: ")))) {
+ cp = getpass (_("New Password: "));
+ if (NULL == cp) {
exit (1);
}
STRFCPY (pass, cp);
strzero (cp);
- if (!(cp = getpass (_("Re-enter new password: ")))) {
+ cp = getpass (_("Re-enter new password: "));
+ if (NULL == cp) {
exit (1);
}