*/
for (i = j = 0; list[i] != NULL; i++) {
- if (strcmp (list[i], member) != 0) {
+ if (!streq(list[i], member)) {
j++;
}
}
*/
for (i = j = 0; list[i] != NULL; i++) {
- if (strcmp (list[i], member) != 0) {
+ if (!streq(list[i], member)) {
tmp[j] = list[i];
j++;
}
rounds = SHA_get_salt_rounds (arg);
SHA_salt_rounds_to_buf (result, rounds);
#endif /* USE_SHA_CRYPT */
- } else if (0 != strcmp (method, "DES")) {
+ } else if (!streq(method, "DES")) {
fprintf (log_get_logfd(),
_("Invalid ENCRYPT_METHOD value: '%s'.\n"
"Defaulting to DES.\n"),
unsigned long first = range->start;
unsigned long last = first + range->count - 1;
- if (0 != strcmp(range->owner, owner))
+ if (!streq(range->owner, owner))
continue;
if ((val >= first) && (val <= last))
/*
* We only do special handling for these two files
*/
- if ((0 != strcmp(db->filename, SUBUID_FILE)) && (0 != strcmp(db->filename, SUBGID_FILE)))
+ if (!streq(db->filename, SUBUID_FILE) && !streq(db->filename, SUBGID_FILE))
return NULL;
/*
last = first + range->count - 1;
/* Skip entries with a different owner */
- if (0 != strcmp (range->owner, owner)) {
+ if (!streq(range->owner, owner)) {
continue;
}
if (reuse) {
while ((r = commonio_next(db)) != NULL) {
// TODO account for username vs uid_t
- if (0 != strcmp(r->owner, range->owner))
+ if (!streq(r->owner, range->owner))
continue;
if (r->count >= range->count) {
range->count = r->count;
if (NULL == real_new_dir_rel) {
goto out_free;
}
- if ( (strcmp (real_new_dir, newdir) != 0)
+ if ( !streq(real_new_dir, newdir)
&& (symlink (real_new_dir_rel, newdir) != 0)) {
fprintf (shadow_logfd,
_("%s: Cannot create symbolic link %s: %s\n"),
}
if (cflg) {
- if ( (0 != strcmp (crypt_method, "DES"))
- && (0 != strcmp (crypt_method, "MD5"))
- && (0 != strcmp (crypt_method, "NONE"))
+ if ( !streq(crypt_method, "DES")
+ && !streq(crypt_method, "MD5")
+ && !streq(crypt_method, "NONE")
#ifdef USE_SHA_CRYPT
- && (0 != strcmp (crypt_method, "SHA256"))
- && (0 != strcmp (crypt_method, "SHA512"))
+ && !streq(crypt_method, "SHA256")
+ && !streq(crypt_method, "SHA512")
#endif /* USE_SHA_CRYPT */
#ifdef USE_BCRYPT
- && (0 != strcmp (crypt_method, "BCRYPT"))
+ && !streq(crypt_method, "BCRYPT")
#endif /* USE_BCRYPT */
#ifdef USE_YESCRYPT
- && (0 != strcmp (crypt_method, "YESCRYPT"))
+ && !streq(crypt_method, "YESCRYPT")
#endif /* USE_YESCRYPT */
) {
fprintf (stderr,
newpwd = cp;
if ( (!eflg)
&& ( (NULL == crypt_method)
- || (0 != strcmp (crypt_method, "NONE")))) {
+ || !streq(crypt_method, "NONE"))) {
void *arg = NULL;
const char *salt;
if (md5flg) {
newsg.sg_passwd = cp;
}
if ( (NULL == sg)
- || (strcmp (gr->gr_passwd, SHADOW_PASSWD_STRING) != 0))
+ || !streq(gr->gr_passwd, SHADOW_PASSWD_STRING))
#endif
{
newgr = *gr;
}
}
if ( (NULL == sg)
- || (strcmp (gr->gr_passwd, SHADOW_PASSWD_STRING) != 0))
+ || !streq(gr->gr_passwd, SHADOW_PASSWD_STRING))
#endif
{
if (gr_update (&newgr) == 0) {
}
if ( (NULL == sp)
- || (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) != 0)) {
+ || !streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
newpw = *pw;
newpw.pw_passwd = cp;
}
}
}
if ( (NULL == sp)
- || (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) != 0)) {
+ || !streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
if (pw_update (&newpw) == 0) {
fprintf (stderr,
_("%s: line %d: failed to prepare the new %s entry '%s'\n"),
if ( pflg
#ifdef SHADOWGRP
&& ( (!is_shadow_grp)
- || (strcmp (grent->gr_passwd, SHADOW_PASSWD_STRING) != 0))
+ || !streq(grent->gr_passwd, SHADOW_PASSWD_STRING))
#endif
) {
/* Update the password in group if there is no gshadow
continue;
}
- if (strcmp (grp->gr_name, ent->gr_name) != 0) {
+ if (!streq(grp->gr_name, ent->gr_name)) {
continue;
}
/* The group entry has a gshadow counterpart.
* Make sure no passwords are in group.
*/
- if (strcmp (grp->gr_passwd, SHADOW_PASSWD_STRING) != 0) {
+ if (!streq(grp->gr_passwd, SHADOW_PASSWD_STRING)) {
printf (_("group %s has an entry in %s, but its password field in %s is not set to 'x'\n"),
grp->gr_name, sgr_file, grp_file);
*errors += 1;
continue;
}
- if (strcmp (sgr->sg_name, ent->sg_name) != 0) {
+ if (!streq(sgr->sg_name, ent->sg_name)) {
continue;
}
#include <errno.h>
#include <fcntl.h>
+#include <getopt.h>
#include <grp.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <time.h>
#include <unistd.h>
-#include <getopt.h>
#include "attr.h"
-#include "nscd.h"
-#include "sssd.h"
-#include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "nscd.h"
+#include "prototypes.h"
+#include "string/strcmp/streq.h"
+
#ifdef SHADOWGRP
#include "groupio.h"
#include "sgroupio.h"
#include "shadowlog.h"
+#include "sssd.h"
+
+
/*
* Global variables
*/
if (NULL != sg) {
/* update existing shadow group entry */
sgent = *sg;
- if (strcmp (gr->gr_passwd, SHADOW_PASSWD_STRING) != 0)
+ if (!streq(gr->gr_passwd, SHADOW_PASSWD_STRING))
sgent.sg_passwd = gr->gr_passwd;
} else {
static char *empty = NULL;
look = gr->gr_mem;
while (*look && notfound)
- notfound = strcmp (*look++, name);
+ notfound = !streq(*look++, name);
return !notfound;
}
}
if (grp->gr_passwd[0] == '\0' ||
- strcmp (cpasswd, grp->gr_passwd) != 0) {
+ !streq(cpasswd, grp->gr_passwd)) {
#ifdef WITH_AUDIT
SNPRINTF(audit_buf, "authentication new-gid=%lu",
(unsigned long) grp->gr_gid);
* when the entry was created, so this user would have to have had
* the password set someplace else.
*/
- if (strcmp (pwd->pw_passwd, "x") != 0) {
+ if (!streq(pwd->pw_passwd, "x")) {
return update_passwd (pwd, password);
}
#else /* USE_PAM */
* The password will be updated later for all users using PAM.
*/
if ( (NULL != sp)
- || (strcmp (pwd->pw_passwd, "x") != 0)) {
+ || !streq(pwd->pw_passwd, "x")) {
return 0;
}
#endif /* USE_PAM */
#endif /* USE_SHA_CRYPT || USE_BCRYPT || USE_YESCRYPT */
if (cflg) {
- if ( (0 != strcmp (crypt_method, "DES"))
- && (0 != strcmp (crypt_method, "MD5"))
- && (0 != strcmp (crypt_method, "NONE"))
+ if ( !streq(crypt_method, "DES")
+ && !streq(crypt_method, "MD5")
+ && !streq(crypt_method, "NONE")
#ifdef USE_SHA_CRYPT
- && (0 != strcmp (crypt_method, "SHA256"))
- && (0 != strcmp (crypt_method, "SHA512"))
+ && !streq(crypt_method, "SHA256")
+ && !streq(crypt_method, "SHA512")
#endif /* USE_SHA_CRYPT */
#ifdef USE_BCRYPT
- && (0 != strcmp (crypt_method, "BCRYPT"))
+ && !streq(crypt_method, "BCRYPT")
#endif /* USE_BCRYPT */
#ifdef USE_YESCRYPT
- && (0 != strcmp (crypt_method, "YESCRYPT"))
+ && !streq(crypt_method, "YESCRYPT")
#endif /* USE_YESCRYPT */
) {
fprintf (stderr,
return -1;
}
- if (strcmp (cipher, crypt_passwd) != 0) {
+ if (!streq(cipher, crypt_passwd)) {
erase_pass (clear);
strzero (cipher);
SYSLOG ((LOG_WARN, "incorrect password for %s",
MEMZERO(pass);
return -1;
}
- if (warned && (strcmp (pass, cp) != 0)) {
+ if (warned && !streq(pass, cp)) {
warned = false;
}
ret = STRTCPY (pass, cp);
MEMZERO(pass);
return -1;
}
- if (strcmp (cp, pass) != 0) {
+ if (!streq(cp, pass)) {
erase_pass (cp);
(void) fputs (_("They don't match; try again.\n"), stderr);
} else {
case 'r':
/* -r repository (files|nis|nisplus) */
/* only "files" supported for now */
- if (strcmp (optarg, "files") != 0) {
+ if (!streq(optarg, "files")) {
fprintf (stderr,
_("%s: repository %s not supported\n"),
Prog, optarg);
#ident "$Id$"
#include <fcntl.h>
+#include <getopt.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
-#include <getopt.h>
+
#include "chkname.h"
#include "commonio.h"
#include "defines.h"
+#include "getdef.h"
+#include "nscd.h"
#include "prototypes.h"
#include "pwio.h"
#include "shadowio.h"
-#include "getdef.h"
-#include "nscd.h"
+#include "shadowlog.h"
#include "sssd.h"
+#include "string/strcmp/streq.h"
#ifdef WITH_TCB
#include "tcbfuncs.h"
#endif /* WITH_TCB */
-#include "shadowlog.h"
+
/*
* Exit codes
continue;
}
- if (strcmp (pwd->pw_name, ent->pw_name) != 0) {
+ if (!streq(pwd->pw_name, ent->pw_name)) {
continue;
}
/*
* Home directory does not exist, give a warning (unless intentional)
*/
- if (NULL == nonexistent || strcmp (pwd->pw_dir, nonexistent) != 0) {
+ if (NULL == nonexistent || !streq(pwd->pw_dir, nonexistent)) {
printf (_("user '%s': directory '%s' does not exist\n"),
pwd->pw_name, pwd->pw_dir);
*errors += 1;
* Make sure no passwords are in passwd.
*/
if ( !quiet
- && (strcmp (pwd->pw_passwd,
- SHADOW_PASSWD_STRING) != 0)) {
+ && !streq(pwd->pw_passwd, SHADOW_PASSWD_STRING)) {
printf (_("user %s has an entry in %s, but its password field in %s is not set to 'x'\n"),
pwd->pw_name, spw_dbname (), pw_dbname ());
*errors += 1;
continue;
}
- if (strcmp (spw->sp_namp, ent->sp_namp) != 0) {
+ if (!streq(spw->sp_namp, ent->sp_namp)) {
continue;
}
su_failure (caller_tty, 0 == pw->pw_uid);
}
tmp_name = item;
- if (strcmp (name, tmp_name) != 0) {
+ if (!streq(name, tmp_name)) {
SYSLOG ((LOG_INFO,
"Change user from '%s' to '%s' as requested by PAM",
name, tmp_name));
}
if ( '\0' != optarg[0]
&& '*' != optarg[0]
- && strcmp(optarg, "/sbin/nologin") != 0
+ && !streq(optarg, "/sbin/nologin")
&& ( stat(optarg, &st) != 0
|| S_ISDIR(st.st_mode)
|| access(optarg, X_OK) != 0)) {
* used for this account.
*/
if ( (!is_shadow_pwd)
- || (strcmp (pwent->pw_passwd, SHADOW_PASSWD_STRING) != 0)) {
+ || !streq(pwent->pw_passwd, SHADOW_PASSWD_STRING)) {
pwent->pw_passwd = new_pw_passwd (pwent->pw_passwd);
}
}
if ( '\0' != optarg[0]
&& '*' != optarg[0]
- && strcmp(optarg, "/sbin/nologin") != 0
+ && !streq(optarg, "/sbin/nologin")
&& ( stat(optarg, &st) != 0
|| S_ISDIR(st.st_mode)
|| access(optarg, X_OK) != 0)) {