#include <sys/stat.h>
#include <syslog.h>
+#include "string/strcmp/streq.h"
+
#define IMMEDIATE_CHANGE /* Expire newly created password, must be changed
* immediately upon next login */
#ifdef HAVE_GETUSERSHELL
setusershell ();
while ((sh = getusershell ()) != NULL)
- if (!strcmp (shell, sh))
+ if (streq(shell, sh))
ok = 1;
endusershell ();
#endif
#include <sys/types.h>
#include <sys/stat.h>
-#include "prototypes.h"
-#include "defines.h"
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
+#include "defines.h"
+#include "prototypes.h"
+#include "string/strcmp/streq.h"
+
+
static int chown_tree_at (int at_fd,
const char *path,
uid_t old_uid,
/*
* Skip the "." and ".." entries
*/
- if ( (strcmp (ent->d_name, ".") == 0)
- || (strcmp (ent->d_name, "..") == 0)) {
+ if ( streq(ent->d_name, ".")
+ || streq(ent->d_name, "..")) {
continue;
}
#include "sssd.h"
#include "string/memset/memzero.h"
#include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
if (NULL == spw_ptr->eptr) {
continue;
}
- if (strcmp (name, shadow->ops->getname (spw_ptr->eptr))
- == 0) {
+ if (streq(name, shadow->ops->getname(spw_ptr->eptr)))
break;
- }
}
if (NULL == spw_ptr) {
continue;
for (p = pos; NULL != p; p = p->next) {
ep = p->eptr;
if ( (NULL != ep)
- && (strcmp (db->ops->getname (ep), name) == 0)) {
+ && streq(db->ops->getname(ep), name)) {
break;
}
}
#include "defines.h"
#include "getdef.h"
#include "prototypes.h"
+#include "string/strcmp/streq.h"
#include "string/strcpy/strtcpy.h"
#include "string/strtok/stpsep.h"
STRTCPY(buf, cons);
pbuf = &buf[0];
while ((s = strtok (pbuf, ":")) != NULL) {
- if (strcmp (s, tty) == 0) {
+ if (streq(s, tty)) {
return true;
}
while (fgets (buf, sizeof (buf), fp) != NULL) {
stpsep(buf, "\n");
- if (strcmp (buf, tty) == 0) {
+ if (streq(buf, tty)) {
(void) fclose (fp);
return true;
}
#endif /* WITH_ATTR */
#include "shadowlog.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
static /*@null@*/const char *src_orig;
/*
* Skip the "." and ".." entries
*/
- if (strcmp(ent->d_name, ".") == 0 ||
- strcmp(ent->d_name, "..") == 0)
+ if (streq(ent->d_name, ".") ||
+ streq(ent->d_name, ".."))
{
continue;
}
#include "attr.h"
#include "getdate.h"
#include "string/strchr/stpspn.h"
+#include "string/strcmp/streq.h"
/* Some old versions of bison generate parsers that use bcopy.
if (isupper (*p))
*p = tolower (*p);
- if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
+ if (streq(buff, "am") || streq(buff, "a.m."))
{
yylval.Meridian = MERam;
return tMERIDIAN;
}
- if (strcmp (buff, "pm") == 0 || strcmp (buff, "p.m.") == 0)
+ if (streq(buff, "pm") || streq(buff, "p.m."))
{
yylval.Meridian = MERpm;
return tMERIDIAN;
return tp->type;
}
}
- else if (strcmp (buff, tp->name) == 0)
+ else if (streq(buff, tp->name))
{
yylval.Number = tp->value;
return tp->type;
}
for (tp = TimezoneTable; tp->name; tp++)
- if (strcmp (buff, tp->name) == 0)
+ if (streq(buff, tp->name))
{
yylval.Number = tp->value;
return tp->type;
}
- if (strcmp (buff, "dst") == 0)
+ if (streq(buff, "dst"))
return tDST;
for (tp = UnitsTable; tp->name; tp++)
- if (strcmp (buff, tp->name) == 0)
+ if (streq(buff, tp->name))
{
yylval.Number = tp->value;
return tp->type;
{
stpcpy(&buff[i], "");
for (tp = UnitsTable; tp->name; tp++)
- if (strcmp (buff, tp->name) == 0)
+ if (streq(buff, tp->name))
{
yylval.Number = tp->value;
return tp->type;
}
for (tp = OtherTable; tp->name; tp++)
- if (strcmp (buff, tp->name) == 0)
+ if (streq(buff, tp->name))
{
yylval.Number = tp->value;
return tp->type;
if (buff[1] == '\0' && isalpha (*buff))
{
for (tp = MilitaryTable; tp->name; tp++)
- if (strcmp (buff, tp->name) == 0)
+ if (streq(buff, tp->name))
{
yylval.Number = tp->value;
return tp->type;
stpcpy(p, "");
if (0 != i)
for (tp = TimezoneTable; NULL != tp->name; tp++)
- if (strcmp (buff, tp->name) == 0)
+ if (streq(buff, tp->name))
{
yylval.Number = tp->value;
return tp->type;
#include "string/sprintf/xasprintf.h"
#include "string/strchr/stpspn.h"
#include "string/strchr/strrspn.h"
+#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
*/
for (ptr = def_table; NULL != ptr->name; ptr++) {
- if (strcmp (ptr->name, name) == 0) {
+ if (streq(ptr->name, name)) {
return ptr;
}
}
*/
for (ptr = knowndef_table; NULL != ptr->name; ptr++) {
- if (strcmp (ptr->name, name) == 0) {
+ if (streq(ptr->name, name)) {
goto out;
}
}
#include "alloc/calloc.h"
#include "alloc/malloc.h"
-#include "prototypes.h"
-#include "defines.h"
#include "commonio.h"
+#include "defines.h"
#include "getdef.h"
#include "groupio.h"
+#include "prototypes.h"
+#include "string/strcmp/streq.h"
static /*@null@*/struct commonio_entry *merge_group_entries (
struct group *g2 = gr2->eptr;
if (NULL != g1 &&
NULL != g2 &&
- 0 == strcmp (g1->gr_name, g2->gr_name) &&
- 0 == strcmp (g1->gr_passwd, g2->gr_passwd) &&
+ streq(g1->gr_name, g2->gr_name) &&
+ streq(g1->gr_passwd, g2->gr_passwd) &&
g1->gr_gid == g2->gr_gid) {
/* Both group entries refer to the same
* group. It is a split group. Merge the
for (i=0; NULL != gptr2->gr_mem[i]; i++) {
char **pmember = gptr1->gr_mem;
while (NULL != *pmember) {
- if (0 == strcmp(*pmember, gptr2->gr_mem[i])) {
+ if (streq(*pmember, gptr2->gr_mem[i])) {
break;
}
pmember++;
for (i=0; NULL != gptr2->gr_mem[i]; i++) {
char **pmember = new_members;
while (NULL != *pmember) {
- if (0 == strcmp(*pmember, gptr2->gr_mem[i])) {
+ if (streq(*pmember, gptr2->gr_mem[i])) {
break;
}
pmember++;
#include "alloc/x/xrealloc.h"
#include "defines.h"
#include "prototypes.h"
+#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
setsgent ();
while ((sgrp = getsgent ()) != NULL) {
- if (strcmp (name, sgrp->sg_name) == 0) {
+ if (streq(name, sgrp->sg_name)) {
break;
}
}
#include "getdef.h"
#include "prototypes.h"
#include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
}
for (found = false; !found && (fgets (buf, sizeof buf, fp) == buf);) {
stpsep(buf, "\n");
- found = (strcmp (buf, pw->pw_shell) == 0) ||
- (strcmp (buf, pw->pw_name) == 0);
+ found = streq(buf, pw->pw_shell) ||
+ streq(buf, pw->pw_name);
}
(void) fclose (fp);
return found;
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
+#if HAVE_SYS_CAPABILITY_H
+#include <sys/prctl.h>
+#include <sys/capability.h>
+#endif
#include "alloc/calloc.h"
#include "alloc/x/xmalloc.h"
#include "atoi/a2i/a2u.h"
-#include "prototypes.h"
-#include "string/sprintf/stpeprintf.h"
#include "idmapping.h"
-#if HAVE_SYS_CAPABILITY_H
-#include <sys/prctl.h>
-#include <sys/capability.h>
-#endif
+#include "prototypes.h"
#include "shadowlog.h"
#include "sizeof.h"
+#include "string/sprintf/stpeprintf.h"
+#include "string/strcmp/streq.h"
struct map_range *
struct __user_cap_header_struct hdr = {_LINUX_CAPABILITY_VERSION_3, 0};
struct __user_cap_data_struct data[2] = {{0}};
- if (strcmp(map_file, "uid_map") == 0) {
+ if (streq(map_file, "uid_map")) {
cap = CAP_SETUID;
- } else if (strcmp(map_file, "gid_map") == 0) {
+ } else if (streq(map_file, "gid_map")) {
cap = CAP_SETGID;
} else {
fprintf(log_get_logfd(), _("%s: Invalid map file %s specified\n"), log_get_progname(), map_file);
#include "adds.h"
#include "defines.h"
#include "prototypes.h"
+#include "string/strcmp/streq.h"
#ident "$Id$"
* returns sp_lstchg==0 (must change password) instead of -1!
*/
if ( (0 == sp->sp_lstchg)
- && (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0)) {
+ && streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
return 1;
}
#include "atoi/str2i/str2u.h"
#include "string/memset/memzero.h"
#include "string/strchr/stpspn.h"
+#include "string/strcmp/streq.h"
#include "typetraits.h"
* being ignored if a limit type is not known to the system.
* Though, there will be complaining for unknown limit types.
*/
- if (strcmp (pp, "-") == 0) {
+ if (streq(pp, "-")) {
/* Remember to extend this, too, when adding new limits!
* Oh... but "unlimited" does not make sense for umask,
* or does it? (K-)
*/
if (sscanf (buf, "%s%[ACDFIKLMNOPRSTUacdfiklmnoprstu0-9 \t-]",
name, tempbuf) == 2) {
- if (strcmp (name, uname) == 0) {
+ if (streq(name, uname)) {
strcpy (limits, tempbuf);
break;
- } else if (strcmp (name, "*") == 0) {
+ } else if (streq(name, "*")) {
strcpy (deflimits, tempbuf);
} else if (name[0] == '@') {
/* If the user is in the group, the group
/* local, no need for xgetgrgid */
grp = getgrgid (info->pw_gid);
if ( (NULL != grp)
- && (strcmp (info->pw_name, grp->gr_name) == 0)) {
+ && streq(info->pw_name, grp->gr_name)) {
mode_t tmpmask;
tmpmask = umask (0777);
tmpmask = (tmpmask & ~070) | ((tmpmask >> 3) & 070);
#include "prototypes.h"
#include "defines.h"
#include "string/strchr/strchrcnt.h"
+#include "string/strcmp/streq.h"
#include "string/strdup/xstrdup.h"
*/
for (i = 0; list[i] != NULL; i++) {
- if (strcmp (list[i], member) == 0) {
+ if (streq(list[i], member)) {
return list;
}
}
assert (NULL != list);
while (NULL != *list) {
- if (strcmp (*list, member) == 0) {
+ if (streq(*list, member)) {
return true;
}
list++;
#include "shadowlog_internal.h"
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
-#include "string/strtok/stpsep.h"
#include "string/strchr/stpspn.h"
+#include "string/strcmp/streq.h"
+#include "string/strtok/stpsep.h"
#define NSSWITCH "/etc/nsswitch.conf"
// subid_nss has to be null here, but to ease reviews:
goto null_subid;
}
- if (strcmp(p, "files") == 0) {
+ if (streq(p, "files")) {
goto null_subid;
}
if (strlen(p) > 50) {
#include "getdef.h"
#include "string/memset/memzero.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strdup/xstrdup.h"
const char *msg = NULL;
char *oldmono, *newmono, *wrapped;
- if (strcmp (new, old) == 0) {
+ if (streq(new, old)) {
return _("no change");
}
if (palindrome (oldmono, newmono)) {
msg = _("a palindrome");
- } else if (strcmp (oldmono, newmono) == 0) {
+ } else if (streq(oldmono, newmono)) {
msg = _("case changes only");
} else if (similar (oldmono, newmono)) {
msg = _("too similar");
} else {
- if ( (strcmp (result, "MD5") == 0)
+ if ( streq(result, "MD5")
#ifdef USE_SHA_CRYPT
- || (strcmp (result, "SHA256") == 0)
- || (strcmp (result, "SHA512") == 0)
+ || streq(result, "SHA256")
+ || streq(result, "SHA512")
#endif
#ifdef USE_BCRYPT
- || (strcmp (result, "BCRYPT") == 0)
+ || streq(result, "BCRYPT")
#endif
#ifdef USE_YESCRYPT
- || (strcmp (result, "YESCRYPT") == 0)
+ || streq(result, "YESCRYPT")
#endif
) {
return NULL;
#include "defines.h"
#include "port.h"
#include "prototypes.h"
+#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
if (('\0' == *pattern) && ('\0' == *port)) {
return 0;
}
- if (strcmp(orig, "SU") == 0)
+ if (streq(orig, "SU"))
return 1;
return (*pattern == '*') ? 0 : 1;
continue;
for (ptu = port->pt_users; *ptu != NULL; ptu++) {
- if (strcmp(*ptu, user) == 0)
+ if (streq(*ptu, user))
goto end;
- if (strcmp(*ptu, "*") == 0)
+ if (streq(*ptu, "*"))
goto end;
}
}
#include "getdef.h"
#include "shadowlog.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
static char *passwd_db_file = NULL;
for (i = 0; i < argc; i++) {
val = NULL;
- if ( (strcmp (argv[i], "--prefix") == 0)
+ if ( streq(argv[i], "--prefix")
|| ((strncmp (argv[i], "--prefix=", 9) == 0)
&& (val = argv[i] + 9))
- || (strcmp (argv[i], short_opt) == 0)) {
+ || streq(argv[i], short_opt))
+ {
if (NULL != prefix) {
fprintf (log_get_logfd(),
_("%s: multiple --prefix options\n"),
exit (EXIT_FAILURE);
}
- if ( prefix[0] == '\0' || !strcmp(prefix, "/"))
+ if (prefix[0] == '\0' || streq(prefix, "/"))
return ""; /* if prefix is "/" then we ignore the flag option */
/* should we prevent symbolic link from being used as a prefix? */
if (!fg)
return NULL;
while ((grp = fgetgrent(fg)) != NULL) {
- if (!strcmp(name, grp->gr_name))
+ if (streq(name, grp->gr_name))
break;
}
fclose(fg);
if (!fg)
return NULL;
while ((pwd = fgetpwent(fg)) != NULL) {
- if (!strcmp(name, pwd->pw_name))
+ if (streq(name, pwd->pw_name))
break;
}
fclose(fg);
if (!fg)
return errno;
while ((ret = fgetpwent_r(fg, pwd, buf, buflen, result)) == 0) {
- if (!strcmp(name, pwd->pw_name))
+ if (streq(name, pwd->pw_name))
break;
}
fclose(fg);
if (!fg)
return NULL;
while ((sp = fgetspent(fg)) != NULL) {
- if (!strcmp(name, sp->sp_namp))
+ if (streq(name, sp->sp_namp))
break;
}
fclose(fg);
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
-#include "prototypes.h"
+
#include "defines.h"
+#include "prototypes.h"
+#include "string/strcmp/streq.h"
+
static int remove_tree_at (int at_fd, const char *path, bool remove_root)
{
/*
* Skip the "." and ".." entries
*/
- if (strcmp (ent->d_name, ".") == 0 ||
- strcmp (ent->d_name, "..") == 0) {
+ if (streq(ent->d_name, ".") ||
+ streq(ent->d_name, "..")) {
continue;
}
#ident "$Id$"
#include <stdio.h>
-#include <assert.h>
+
#include "defines.h"
-#include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "prototypes.h"
#include "shadowlog.h"
+#include "string/strcmp/streq.h"
+
+#include <assert.h>
+
static void change_root (const char* newroot);
for (i = 0; i < argc; i++) {
val = NULL;
- if ( (strcmp (argv[i], "--root") == 0)
+ if ( streq(argv[i], "--root")
|| ((strncmp (argv[i], "--root=", 7) == 0)
&& (val = argv[i] + 7))
- || (strcmp (argv[i], short_opt) == 0)) {
+ || streq(argv[i], short_opt)) {
if (NULL != newroot) {
fprintf (log_get_logfd(),
_("%s: multiple --root options\n"),
#include <string.h>
#include <strings.h>
-#include "prototypes.h"
#include "defines.h"
#include "getdef.h"
+#include "prototypes.h"
#include "shadowlog.h"
+#include "string/strcmp/streq.h"
+
#if (defined CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY && \
CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY)
}
}
- if (0 == strcmp (method, "MD5")) {
+ if (streq(method, "MD5")) {
MAGNUM(result, '1');
salt_len = MD5_CRYPT_SALT_SIZE;
rounds = 0;
#ifdef USE_BCRYPT
- } else if (0 == strcmp (method, "BCRYPT")) {
+ } else if (streq(method, "BCRYPT")) {
BCRYPTMAGNUM(result);
salt_len = BCRYPT_SALT_SIZE;
rounds = BCRYPT_get_salt_rounds (arg);
BCRYPT_salt_rounds_to_buf (result, rounds);
#endif /* USE_BCRYPT */
#ifdef USE_YESCRYPT
- } else if (0 == strcmp (method, "YESCRYPT")) {
+ } else if (streq(method, "YESCRYPT")) {
MAGNUM(result, 'y');
salt_len = YESCRYPT_SALT_SIZE;
rounds = YESCRYPT_get_salt_cost (arg);
YESCRYPT_salt_cost_to_buf (result, rounds);
#endif /* USE_YESCRYPT */
#ifdef USE_SHA_CRYPT
- } else if (0 == strcmp (method, "SHA256")) {
+ } else if (streq(method, "SHA256")) {
MAGNUM(result, '5');
salt_len = SHA_CRYPT_SALT_SIZE;
rounds = SHA_get_salt_rounds (arg);
SHA_salt_rounds_to_buf (result, rounds);
- } else if (0 == strcmp (method, "SHA512")) {
+ } else if (streq(method, "SHA512")) {
MAGNUM(result, '6');
salt_len = SHA_CRYPT_SALT_SIZE;
rounds = SHA_get_salt_rounds (arg);
#include "atoi/str2i/str2u.h"
#include "defines.h"
#include "prototypes.h"
+#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
setspent ();
while ((sp = getspent ()) != NULL) {
- if (strcmp (name, sp->sp_namp) == 0) {
+ if (streq(name, sp->sp_namp)) {
break;
}
}
#include "alloc/reallocf.h"
#include "atoi/str2i/str2u.h"
#include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
#define ID_SIZE 31
const struct subordinate_range *range;
commonio_rewind(db);
while ((range = commonio_next(db)) != NULL) {
- if (0 == strcmp(range->owner, owner))
+ if (streq(range->owner, owner))
return true;
}
return false;
* Range matches. Check if range owner is specified
* as numeric UID and if it matches.
*/
- if (0 == strcmp(range->owner, owner_uid_string)) {
+ if (streq(range->owner, owner_uid_string)) {
return range;
}
commonio_rewind(db);
while ((range = commonio_next(db)) != NULL) {
- if (0 == strcmp(range->owner, owner)) {
+ if (streq(range->owner, owner)) {
if (!append_range(&ranges, range, count++)) {
free(ranges);
ranges = NULL;
}
// Let's also compare with the ID
- if (have_owner_id == true && 0 == strcmp(range->owner, id)) {
+ if (have_owner_id == true && streq(range->owner, id)) {
if (!append_range(&ranges, range, count++)) {
free(ranges);
ranges = NULL;
#define _GNU_SOURCE
+#include <config.h>
+
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <tcb.h>
#include <unistd.h>
-#include "config.h"
-
#include "defines.h"
-#include "prototypes.h"
#include "fs/readlink/readlinknul.h"
#include "getdef.h"
-#include "shadowio.h"
+#include "prototypes.h"
#include "tcbfuncs.h"
+#include "shadowio.h"
#include "shadowlog_internal.h"
+#include "string/strcmp/streq.h"
#define SHADOWTCB_HASH_BY 1000
if (NULL == real_new_dir) {
goto out_free;
}
- if (strcmp (real_old_dir, real_new_dir) == 0) {
+ if (streq(real_old_dir, real_new_dir)) {
ret = SHADOWTCB_SUCCESS;
goto out_free;
}
#include "defines.h"
#include "getdef.h"
#include "prototypes.h"
+#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
stpsep(buf, "\n");
if ( (sscanf (buf, "%1023s %1023s", type, port) == 2)
- && (strcmp (line, port) == 0)) {
+ && streq(line, port)) {
break;
}
}
#endif /* ENABLE_SUBIDS */
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
#ifdef __linux__
if (READLINKNUL("/proc/self/ns/user", buf2) == -1)
return 0;
- if (strcmp(buf, buf2) == 0)
+ if (streq(buf, buf2))
return 0; /* same namespace */
return 1;
* This patch is applied by default in some RedHat
* kernels.
*/
- if ( (strcmp (tmp_d_name, ".") == 0)
- || (strcmp (tmp_d_name, "..") == 0)) {
+ if ( streq(tmp_d_name, ".")
+ || streq(tmp_d_name, "..")) {
continue;
}
if (*tmp_d_name == '.') {
#include "alloc/x/xcalloc.h"
#include "alloc/x/xmalloc.h"
#include "sizeof.h"
+#include "string/strcmp/streq.h"
#include "string/strcpy/strncpy.h"
#include "string/strcpy/strtcpy.h"
#include "string/strdup/xstrdup.h"
exit (EXIT_FAILURE);
}
- return strcmp (full_tty, tmptty) == 0;
+ return streq(full_tty, tmptty);
}
#ident "$Id$"
-#include <sys/types.h>
+#include <pwd.h>
#include <stdio.h>
-#include "prototypes.h"
+#include <sys/types.h>
+
#include "defines.h"
-#include <pwd.h>
+#include "prototypes.h"
+#include "string/strcmp/streq.h"
+
+
/*
* valid - compare encrypted passwords
*
if ( (NULL != ent->pw_name)
&& (NULL != encrypted)
- && (strcmp (encrypted, ent->pw_passwd) == 0)) {
+ && streq(encrypted, ent->pw_passwd)) {
return true;
} else {
return false;
#include "shadowlog.h"
#include "string/memset/memzero.h"
#include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strcpy/strtcpy.h"
#include "string/strdup/xstrdup.h"
#include "string/strftime.h"
change_field (buf, sizeof buf, _("Last Password Change (YYYY-MM-DD)"));
- if (strcmp (buf, "-1") == 0) {
+ if (streq(buf, "-1")) {
lstchgdate = -1;
} else {
lstchgdate = strtoday (buf);
change_field (buf, sizeof buf,
_("Account Expiration Date (YYYY-MM-DD)"));
- if (strcmp (buf, "-1") == 0) {
+ if (streq(buf, "-1")) {
expdate = -1;
} else {
expdate = strtoday (buf);
#include <sys/types.h>
#include <getopt.h>
+#include "chkname.h"
#include "defines.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
#include "getdef.h"
#include "nscd.h"
-#include "sssd.h"
#ifdef USE_PAM
#include "pam_defs.h"
#endif
#include "prototypes.h"
#include "pwauth.h"
#include "pwio.h"
-/*@-exitarg@*/
-#include "exitcodes.h"
#include "shadowlog.h"
+#include "sssd.h"
#include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strcpy/strtcpy.h"
#include "string/strdup/xstrdup.h"
-#include "chkname.h"
/*
cp = getdef_str ("CHFN_RESTRICT");
if (NULL == cp) {
cp = "";
- } else if (strcmp (cp, "yes") == 0) {
+ } else if (streq(cp, "yes")) {
cp = "rwh";
- } else if (strcmp (cp, "no") == 0) {
+ } else if (streq(cp, "no")) {
cp = "frwh";
}
/*@-exitarg@*/
#include "exitcodes.h"
#include "shadowlog.h"
+#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
usage (E_USAGE);
}
#if defined(USE_SHA_CRYPT)
- if ( ( ((0 == strcmp (crypt_method, "SHA256")) || (0 == strcmp (crypt_method, "SHA512")))
+ if ( ( (streq(crypt_method, "SHA256") || streq(crypt_method, "SHA512"))
&& (-1 == str2sl(&sha_rounds, optarg)))) {
bad_s = 1;
}
#endif /* USE_SHA_CRYPT */
#if defined(USE_BCRYPT)
- if (( (0 == strcmp (crypt_method, "BCRYPT"))
+ if (( streq(crypt_method, "BCRYPT")
&& (-1 == str2sl(&bcrypt_rounds, optarg)))) {
bad_s = 1;
}
#endif /* USE_BCRYPT */
#if defined(USE_YESCRYPT)
- if (( (0 == strcmp (crypt_method, "YESCRYPT"))
+ if (( streq(crypt_method, "YESCRYPT")
&& (-1 == str2sl(&yescrypt_cost, optarg)))) {
bad_s = 1;
}
#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
if (sflg) {
#if defined(USE_SHA_CRYPT)
- if ( (0 == strcmp (crypt_method, "SHA256"))
- || (0 == strcmp (crypt_method, "SHA512"))) {
+ if ( streq(crypt_method, "SHA256")
+ || streq(crypt_method, "SHA512")) {
arg = &sha_rounds;
}
#endif /* USE_SHA_CRYPT */
#if defined(USE_BCRYPT)
- if (0 == strcmp (crypt_method, "BCRYPT")) {
+ if (streq(crypt_method, "BCRYPT")) {
arg = &bcrypt_rounds;
}
#endif /* USE_BCRYPT */
#if defined(USE_YESCRYPT)
- if (0 == strcmp (crypt_method, "YESCRYPT")) {
+ if (streq(crypt_method, "YESCRYPT")) {
arg = &yescrypt_cost;
}
#endif /* USE_YESCRYPT */
sg = sgr_locate (name);
if ( (NULL == sg)
- && (strcmp (gr->gr_passwd,
- SHADOW_PASSWD_STRING) == 0)) {
+ && streq(gr->gr_passwd, SHADOW_PASSWD_STRING))
+ {
static char *empty = NULL;
/* If the password is set to 'x' in
* group, but there are no entries in
/*@-exitarg@*/
#include "exitcodes.h"
#include "shadowlog.h"
+#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
-#define IS_CRYPT_METHOD(str) ((crypt_method != NULL && strcmp(crypt_method, str) == 0) ? true : false)
+#define IS_CRYPT_METHOD(str) ((crypt_method != NULL && streq(crypt_method, str)) ? true : false)
/*
* Global variables
sp = spw_locate (name);
if ( (NULL == sp)
- && (strcmp (pw->pw_passwd,
- SHADOW_PASSWD_STRING) == 0)) {
+ && streq(pw->pw_passwd, SHADOW_PASSWD_STRING))
+ {
/* If the password is set to 'x' in
* passwd, but there are no entries in
* shadow, create one.
#include <stdio.h>
#include <sys/types.h>
+#include "chkname.h"
#include "defines.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
#include "getdef.h"
#include "nscd.h"
-#include "sssd.h"
#include "prototypes.h"
#include "pwauth.h"
#include "pwio.h"
#ifdef USE_PAM
#include "pam_defs.h"
#endif
-/*@-exitarg@*/
-#include "exitcodes.h"
#include "shadowlog.h"
+#include "sssd.h"
+#include "string/strcmp/streq.h"
#include "string/strcpy/strtcpy.h"
#include "string/strdup/xstrdup.h"
-#include "chkname.h"
#ifndef SHELLS_FILE
}
for (size_t i = 0; i < size; i++) {
- if (strcmp (keys[i], sh) == 0) {
+ if (streq(keys[i], sh)) {
found = true;
break;
}
char *cp;
setusershell ();
while ((cp = getusershell ())) {
- if (strcmp (cp, sh) == 0) {
+ if (streq(cp, sh)) {
found = true;
break;
}
continue;
}
- if (strcmp (buf, sh) == 0) {
+ if (streq(buf, sh)) {
found = true;
break;
}
#include <stdio.h>
#include "atoi/getnum.h"
-#include "subid.h"
-#include "stdlib.h"
#include "prototypes.h"
#include "shadowlog.h"
+#include "stdlib.h"
+#include "string/strcmp/streq.h"
+#include "subid.h"
static const char Prog[] = "get_subid_owners";
if (argc < 2) {
usage();
}
- if (argc == 3 && strcmp(argv[1], "-g") == 0) {
+ if (argc == 3 && streq(argv[1], "-g")) {
get_uid(argv[2], &u);
n = subid_get_gid_owners(u, &uids);
- } else if (argc == 2 && strcmp(argv[1], "-h") == 0) {
+ } else if (argc == 2 && streq(argv[1], "-h")) {
usage();
} else {
get_gid(argv[1], &u);
/* SPDX-License-Identifier: BSD-3-Clause */
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
-#include "subid.h"
+#include <string.h>
+
#include "prototypes.h"
#include "shadowlog.h"
+#include "string/strcmp/streq.h"
+#include "subid.h"
static const char Prog[] = "getsubids";
if (argc < 2)
usage();
owner = argv[1];
- if (argc == 3 && strcmp(argv[1], "-g") == 0) {
+ if (argc == 3 && streq(argv[1], "-g")) {
owner = argv[2];
count = subid_get_gid_ranges(owner, &ranges);
- } else if (argc == 2 && strcmp(argv[1], "-h") == 0) {
+ } else if (argc == 2 && streq(argv[1], "-h")) {
usage();
} else {
count = subid_get_uid_ranges(owner, &ranges);
#include "alloc/x/xmalloc.h"
#include "attr.h"
#include "defines.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
#include "groupio.h"
#include "nscd.h"
-#include "sssd.h"
#include "prototypes.h"
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
-/*@-exitarg@*/
-#include "exitcodes.h"
#include "shadowlog.h"
+#include "sssd.h"
#include "string/memset/memzero.h"
#include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strcpy/strtcpy.h"
#include "string/strdup/xstrdup.h"
exit (1);
}
- if (strcmp (pass, cp) == 0) {
+ if (streq(pass, cp)) {
erase_pass (cp);
break;
}
#include "alloc/x/xmalloc.h"
#include "defines.h"
-#include "prototypes.h"
#include "groupio.h"
+#include "prototypes.h"
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
#include "shadowlog.h"
+#include "string/strcmp/streq.h"
#include "string/strdup/xstrdup.h"
if ( (NULL != usr)
&& (NULL != grp)
- && (0 == strcmp (usr->pw_name, grp->gr_name))) {
+ && streq(usr->pw_name, grp->gr_name)) {
return xstrdup (usr->pw_name);
} else {
return NULL;
#include "chkname.h"
#include "defines.h"
#include "groupio.h"
-#include "pwio.h"
#include "nscd.h"
-#include "sssd.h"
#include "prototypes.h"
+#include "pwio.h"
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
#include "shadowlog.h"
+#include "sssd.h"
#include "string/sprintf/stpeprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strcpy/stpecpy.h"
#include "string/strdup/xstrdup.h"
sgrp = *osgrp;
new_sgent (&sgrp);
} else if ( pflg
- && (strcmp (grp.gr_passwd, SHADOW_PASSWD_STRING) == 0)) {
+ && streq(grp.gr_passwd, SHADOW_PASSWD_STRING)) {
static char *empty = NULL;
/* If there is a gshadow file with no entries for
* the group, but the group file indicates a
/*
* Make sure they are actually changing the name.
*/
- if (strcmp (group_name, group_newname) == 0) {
+ if (streq(group_name, group_newname)) {
nflg = 0;
return;
}
#include <pwd.h>
#include <stdio.h>
#include <getopt.h>
+
#include "chkname.h"
#include "commonio.h"
#include "defines.h"
#include "groupio.h"
#include "nscd.h"
-#include "sssd.h"
#include "prototypes.h"
#include "shadowlog.h"
+#include "sssd.h"
+#include "string/strcmp/streq.h"
#ifdef SHADOWGRP
#include "sgroupio.h"
for (pmem = members; NULL != *pmem; pmem++) {
for (other_pmem = other_members; NULL != *other_pmem; other_pmem++) {
- if (strcmp (*pmem, *other_pmem) == 0) {
+ if (streq(*pmem, *other_pmem)) {
break;
}
}
#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 "sssd.h"
+#include "string/strcmp/streq.h"
+
#ifdef SHADOWGRP
#include "groupio.h"
#include "sgroupio.h"
#include "shadowlog.h"
+
+
/*
* Global variables
*/
while ((gr = gr_next ()) != NULL) {
sg = sgr_locate (gr->gr_name);
if ( (NULL != sg)
- && (strcmp (gr->gr_passwd, SHADOW_PASSWD_STRING) == 0)) {
+ && streq(gr->gr_passwd, SHADOW_PASSWD_STRING)) {
/* add password to /etc/group */
grent = *gr;
grent.gr_passwd = sg->sg_passwd;
#include "attr.h"
#include "chkname.h"
#include "defines.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
#include "faillog.h"
#include "failure.h"
#include "getdef.h"
#include "prototypes.h"
#include "pwauth.h"
-/*@-exitarg@*/
-#include "exitcodes.h"
#include "shadowlog.h"
#include "string/memset/memzero.h"
#include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strcpy/strtcpy.h"
#include "string/strdup/xstrdup.h"
#include "string/strftime.h"
if (argv[arg][0] == '-' && strlen (argv[arg]) > 2) {
usage ();
}
- if (strcmp(argv[arg], "--") == 0) {
+ if (streq(argv[arg], "--")) {
break; /* stop checking on a "--" */
}
}
failed = true;
}
- if (strcmp (user_passwd, "") == 0) {
+ if (streq(user_passwd, "")) {
const char *prevent_no_auth = getdef_str("PREVENT_NO_AUTH");
if (prevent_no_auth == NULL) {
prevent_no_auth = "superuser";
}
- if (strcmp(prevent_no_auth, "yes") == 0) {
+ if (streq(prevent_no_auth, "yes")) {
failed = true;
} else if ((pwd->pw_uid == 0)
- && (strcmp(prevent_no_auth, "superuser") == 0)) {
+ && streq(prevent_no_auth, "superuser")) {
failed = true;
}
}
}
- if (strcmp (user_passwd, SHADOW_PASSWD_STRING) == 0) {
+ if (streq(user_passwd, SHADOW_PASSWD_STRING)) {
spwd = xgetspnam (username);
if (NULL != spwd) {
user_passwd = spwd->sp_pwdp;
#include "agetpass.h"
#include "alloc/x/xmalloc.h"
+#include "chkname.h"
#include "defines.h"
-#include "getdef.h"
-#include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "getdef.h"
+#include "prototypes.h"
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strdup/xstrdup.h"
-#include "chkname.h"
/*
* injecting arbitrary strings into our stderr/stdout, as this can
* be an exploit vector.
*/
- is_newgrp = (strcmp (Basename (argv[0]), "newgrp") == 0);
+ is_newgrp = streq(Basename (argv[0]), "newgrp");
Prog = is_newgrp ? "newgrp" : "sg";
log_set_progname(Prog);
* sg [-] groupid [[-c command]
*/
if ( (argc > 0)
- && ( (strcmp (argv[0], "-") == 0)
- || (strcmp (argv[0], "-l") == 0))) {
+ && ( streq(argv[0], "-")
+ || streq(argv[0], "-l"))) {
argc--;
argv++;
initflag = true;
* "sg group -c command" (as in the man page) or
* "sg group command" (as in the usage message).
*/
- if ((argc > 1) && (strcmp (argv[0], "-c") == 0)) {
+ if ((argc > 1) && streq(argv[0], "-c")) {
command = argv[1];
} else {
command = argv[0];
#include "pam_defs.h"
#endif /* USE_PAM */
#endif /* ACCT_TOOLS_SETUID */
-#include "prototypes.h"
+#include "chkname.h"
#include "defines.h"
#include "getdef.h"
#include "groupio.h"
#include "nscd.h"
-#include "sssd.h"
+#include "prototypes.h"
#include "pwio.h"
#include "sgroupio.h"
#include "shadowio.h"
#ifdef ENABLE_SUBIDS
#include "subordinateio.h"
#endif /* ENABLE_SUBIDS */
-#include "chkname.h"
#include "shadowlog.h"
+#include "sssd.h"
#include "string/sprintf/snprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strdup/xstrdup.h"
#include "string/strtok/stpsep.h"
if (NULL != crypt_method) {
#if defined(USE_SHA_CRYPT)
if (sflg) {
- if ( (0 == strcmp (crypt_method, "SHA256"))
- || (0 == strcmp (crypt_method, "SHA512"))) {
+ if ( streq(crypt_method, "SHA256")
+ || streq(crypt_method, "SHA512")) {
crypt_arg = &sha_rounds;
}
}
#endif /* USE_SHA_CRYPT */
#if defined(USE_BCRYPT)
if (sflg) {
- if (0 == strcmp (crypt_method, "BCRYPT")) {
+ if (streq(crypt_method, "BCRYPT")) {
crypt_arg = &bcrypt_rounds;
}
}
#endif /* USE_BCRYPT */
#if defined(USE_YESCRYPT)
if (sflg) {
- if (0 == strcmp (crypt_method, "YESCRYPT")) {
+ if (streq(crypt_method, "YESCRYPT")) {
crypt_arg = &yescrypt_cost;
}
}
#endif /* USE_YESCRYPT */
}
- if ((NULL != crypt_method) && (0 == strcmp(crypt_method, "NONE"))) {
+ if ((NULL != crypt_method) && streq(crypt_method, "NONE")) {
pwd->pw_passwd = (char *)password;
} else {
const char *salt = crypt_make_salt (crypt_method, crypt_arg);
if (NULL != crypt_method) {
#if defined(USE_SHA_CRYPT)
if (sflg) {
- if ( (0 == strcmp (crypt_method, "SHA256"))
- || (0 == strcmp (crypt_method, "SHA512"))) {
+ if (streq(crypt_method, "SHA256")
+ || streq(crypt_method, "SHA512"))
+ {
crypt_arg = &sha_rounds;
}
}
#endif /* USE_SHA_CRYPT */
#if defined(USE_BCRYPT)
if (sflg) {
- if (0 == strcmp (crypt_method, "BCRYPT")) {
+ if (streq(crypt_method, "BCRYPT")) {
crypt_arg = &bcrypt_rounds;
}
}
#endif /* USE_BCRYPT */
#if defined(USE_YESCRYPT)
if (sflg) {
- if (0 == strcmp (crypt_method, "YESCRYPT")) {
+ if (streq(crypt_method, "YESCRYPT")) {
crypt_arg = &yescrypt_cost;
}
}
if (NULL != sp) {
spent = *sp;
if ( (NULL != crypt_method)
- && (0 == strcmp(crypt_method, "NONE"))) {
+ && streq(crypt_method, "NONE"))
+ {
spent.sp_pwdp = (char *)password;
} else {
const char *salt = crypt_make_salt (crypt_method,
*/
spent.sp_namp = pwd->pw_name;
#ifndef USE_PAM
- if ((crypt_method != NULL) && (0 == strcmp(crypt_method, "NONE"))) {
+ if ((crypt_method != NULL) && streq(crypt_method, "NONE")) {
spent.sp_pwdp = (char *)password;
} else {
const char *salt = crypt_make_salt (crypt_method, crypt_arg);
usage (EXIT_FAILURE);
}
#if defined(USE_SHA_CRYPT)
- if ( ( ((0 == strcmp (crypt_method, "SHA256")) || (0 == strcmp (crypt_method, "SHA512")))
+ if ( ( (streq(crypt_method, "SHA256") || streq(crypt_method, "SHA512"))
&& (-1 == str2sl(&sha_rounds, optarg)))) {
bad_s = 1;
}
#endif /* USE_SHA_CRYPT */
#if defined(USE_BCRYPT)
- if (( (0 == strcmp (crypt_method, "BCRYPT"))
+ if (( streq(crypt_method, "BCRYPT")
&& (-1 == str2sl(&bcrypt_rounds, optarg)))) {
bad_s = 1;
}
#endif /* USE_BCRYPT */
#if defined(USE_YESCRYPT)
- if (( (0 == strcmp (crypt_method, "YESCRYPT"))
+ if (( streq(crypt_method, "YESCRYPT")
&& (-1 == str2sl(&yescrypt_cost, optarg)))) {
bad_s = 1;
}
#include "agetpass.h"
#include "atoi/a2i/a2s.h"
+#include "chkname.h"
#include "defines.h"
#include "getdef.h"
#include "nscd.h"
-#include "sssd.h"
#include "prototypes.h"
#include "pwauth.h"
#include "pwio.h"
#include "shadowio.h"
#include "shadowlog.h"
+#include "sssd.h"
#include "string/memset/memzero.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strcpy/strtcpy.h"
#include "string/strdup/xstrdup.h"
#include "time/day_to_str.h"
-#include "chkname.h"
/*
pass_max_len = getdef_num ("PASS_MAX_LEN", 8);
}
} else {
- if ( (strcmp (method, "MD5") == 0)
+ if ( streq(method, "MD5")
#ifdef USE_SHA_CRYPT
- || (strcmp (method, "SHA256") == 0)
- || (strcmp (method, "SHA512") == 0)
+ || streq(method, "SHA256")
+ || streq(method, "SHA512")
#endif /* USE_SHA_CRYPT */
#ifdef USE_BCRYPT
- || (strcmp (method, "BCRYPT") == 0)
+ || streq(method, "BCRYPT")
#endif /* USE_BCRYPT*/
#ifdef USE_YESCRYPT
- || (strcmp (method, "YESCRYPT") == 0)
+ || streq(method, "YESCRYPT")
#endif /* USE_YESCRYPT*/
) {
#include "defines.h"
#include "getdef.h"
+#include "nscd.h"
#include "prototypes.h"
#include "pwio.h"
-#include "shadowio.h"
-#include "nscd.h"
#include "sssd.h"
+#include "shadowio.h"
#include "shadowlog.h"
+#include "string/strcmp/streq.h"
+
/*
* exit status values
sp = spw_locate (pw->pw_name);
if (NULL != sp) {
/* do we need to update this entry? */
- if (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0) {
+ if (streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
continue;
}
/* update existing shadow entry */
#include <sys/types.h>
#include <unistd.h>
#include <getopt.h>
+
#include "defines.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
#include "getdef.h"
#include "nscd.h"
-#include "sssd.h"
#include "prototypes.h"
#include "pwio.h"
#include "shadowio.h"
-/*@-exitarg@*/
-#include "exitcodes.h"
#include "shadowlog.h"
+#include "sssd.h"
+#include "string/strcmp/streq.h"
+
/*
* Global variables
/*
* Update password if non-shadow is "x".
*/
- if (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0) {
+ if (streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
pwent.pw_passwd = spwd->sp_pwdp;
}
#include "alloc/x/xmalloc.h"
#include "attr.h"
#include "cast.h"
-#include "prototypes.h"
#include "defines.h"
-#include "pwauth.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
#include "getdef.h"
#ifdef USE_PAM
#include "pam_defs.h"
#endif /* USE_PAM */
-/*@-exitarg@*/
-#include "exitcodes.h"
+#include "pwauth.h"
+#include "prototypes.h"
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strcpy/strtcpy.h"
#include "string/strdup/xstrdup.h"
setusershell ();
while ((line = getusershell ()) != NULL) {
- if (('#' != *line) && (strcmp (line, shellname) == 0)) {
+ if (('#' != *line) && streq(line, shellname)) {
endusershell ();
return false;
}
return;
}
- if (strcmp (pw->pw_passwd, "") == 0) {
+ if (streq(pw->pw_passwd, "")) {
const char *prevent_no_auth = getdef_str("PREVENT_NO_AUTH");
if (prevent_no_auth == NULL) {
prevent_no_auth = "superuser";
}
- if (strcmp(prevent_no_auth, "yes") == 0) {
+ if (streq(prevent_no_auth, "yes")) {
fprintf(stderr, _("Password field is empty, this is forbidden for all accounts.\n"));
exit(1);
} else if ((pw->pw_uid == 0)
- && (strcmp(prevent_no_auth, "superuser") == 0)) {
+ && streq(prevent_no_auth, "superuser")) {
fprintf(stderr, _("Password field is empty, this is forbidden for super-user.\n"));
exit(1);
}
}
spwd = getspnam (name); /* !USE_PAM, no need for xgetspnam */
#ifdef SU_ACCESS
- if (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0) {
+ if (streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
if (NULL != spwd) {
password = spwd->sp_pwdp;
}
* -- chris
*/
password = pw->pw_passwd;
- if (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0) {
+ if (streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
const struct spwd *spwd = getspnam (caller_name);
if (NULL != spwd) {
password = spwd->sp_pwdp;
}
}
- if ((optind < argc) && (strcmp (argv[optind], "-") == 0)) {
+ if ((optind < argc) && streq(argv[optind], "-")) {
fakelogin = true;
optind++;
}
#include "prototypes.h"
#include "string/strchr/stpspn.h"
#include "string/strchr/strrspn.h"
+#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
continue;
if (!applies (actual_id, from_users))
continue;
- if (!strcmp (action, "DENY")) {
+ if (streq(action, "DENY")) {
SYSLOG ((su_to_root ? LOG_WARN : LOG_NOTICE,
"DENIED su from '%s' to '%s' (%s)\n",
actual_id, wanted_id, SUAUTHFILE));
stderr);
fclose (authfile_fd);
return DENY;
- } else if (!strcmp (action, "NOPASS")) {
+ } else if (streq(action, "NOPASS")) {
SYSLOG ((su_to_root ? LOG_NOTICE : LOG_INFO,
"NO password asked for su from '%s' to '%s' (%s)\n",
actual_id, wanted_id, SUAUTHFILE));
fputs (_("Password authentication bypassed.\n"),stderr);
fclose (authfile_fd);
return NOPWORD;
- } else if (!strcmp (action, "OWNPASS")) {
+ } else if (streq(action, "OWNPASS")) {
SYSLOG ((su_to_root ? LOG_NOTICE : LOG_INFO,
"su from '%s' to '%s': asking for user's own password (%s)\n",
actual_id, wanted_id, SUAUTHFILE));
for (tok = strtok (list, split); tok != NULL;
tok = strtok (NULL, split)) {
- if (!strcmp (tok, "ALL")) {
+ if (streq(tok, "ALL")) {
if (state != 0) {
SYSLOG ((LOG_ERR,
"%s, line %d: ALL in bad place\n",
return 0;
}
state = 1;
- } else if (!strcmp (tok, "EXCEPT")) {
+ } else if (streq(tok, "EXCEPT")) {
if (state != 1) {
SYSLOG ((LOG_ERR,
"%s, line %d: EXCEPT in bas place\n",
return 0;
}
state = 2;
- } else if (!strcmp (tok, "GROUP")) {
+ } else if (streq(tok, "GROUP")) {
if ((state != 0) && (state != 2)) {
SYSLOG ((LOG_ERR,
"%s, line %d: GROUP in bad place\n",
} else {
switch (state) {
case 0: /* No control words yet */
- if (!strcmp (tok, single))
+ if (streq(tok, single))
return 1;
break;
case 1: /* An all */
SUAUTHFILE, lines));
return 0;
case 2: /* All except */
- if (!strcmp (tok, single))
+ if (streq(tok, single))
return 0;
break;
case 3: /* Group */
#include "getdef.h"
#include "groupio.h"
#include "nscd.h"
-#include "sssd.h"
#include "prototypes.h"
#include "pwauth.h"
#include "pwio.h"
#include "tcbfuncs.h"
#endif
#include "shadowlog.h"
+#include "sssd.h"
#include "string/memset/memzero.h"
#include "string/sprintf/snprintf.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strdup/xstrdup.h"
#include "string/strtok/stpsep.h"
/*
* Primary GROUP identifier
*/
- if (strcmp(buf, DGROUP) == 0) {
+ if (streq(buf, DGROUP)) {
const struct group *grp = prefix_getgr_nam_gid (cp);
if (NULL == grp) {
fprintf (stderr,
ccp = cp;
- if (strcmp(buf, DGROUPS) == 0) {
+ if (streq(buf, DGROUPS)) {
if (get_groups (cp) != 0) {
fprintf (stderr,
_("%s: the '%s=' configuration in %s has an invalid group, ignoring the bad group\n"),
/*
* Default HOME filesystem
*/
- else if (strcmp(buf, DHOME) == 0) {
+ else if (streq(buf, DHOME)) {
def_home = xstrdup(ccp);
}
/*
* Default Login Shell command
*/
- else if (strcmp(buf, DSHELL) == 0) {
+ else if (streq(buf, DSHELL)) {
def_shell = xstrdup(ccp);
}
/*
* Default Password Inactive value
*/
- else if (strcmp(buf, DINACT) == 0) {
+ else if (streq(buf, DINACT)) {
if (a2sl(&def_inactive, ccp, NULL, 0, -1, LONG_MAX) == -1) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
/*
* Default account expiration date
*/
- else if (strcmp(buf, DEXPIRE) == 0) {
+ else if (streq(buf, DEXPIRE)) {
def_expire = xstrdup(ccp);
}
/*
* Default Skeleton information
*/
- else if (strcmp(buf, DSKEL) == 0) {
+ else if (streq(buf, DSKEL)) {
if ('\0' == *ccp)
ccp = SKEL_DIR;
/*
* Default Usr Skeleton information
*/
- else if (strcmp(buf, DUSRSKEL) == 0) {
+ else if (streq(buf, DUSRSKEL)) {
if ('\0' == *ccp)
ccp = USRSKELDIR;
/*
* Create by default user mail spool or not ?
*/
- else if (strcmp(buf, DCREATE_MAIL_SPOOL) == 0) {
+ else if (streq(buf, DCREATE_MAIL_SPOOL)) {
if (*ccp == '\0')
ccp = "no";
/*
* By default do we add the user to the lastlog and faillog databases ?
*/
- else if (strcmp(buf, DLOG_INIT) == 0) {
+ else if (streq(buf, DLOG_INIT)) {
if (*ccp == '\0')
ccp = def_log_init;
val = stpsep(buf, "=");
if (val == NULL) {
fprintf(ofp, "%s\n", buf);
- } else if (!out_group && strcmp(buf, DGROUP) == 0) {
+ } else if (!out_group && streq(buf, DGROUP)) {
fprintf(ofp, DGROUP "=%u\n", (unsigned int) def_group);
out_group = true;
- } else if (!out_groups && strcmp(buf, DGROUPS) == 0) {
+ } else if (!out_groups && streq(buf, DGROUPS)) {
fprintf(ofp, DGROUPS "=%s\n", def_groups);
out_groups = true;
- } else if (!out_home && strcmp(buf, DHOME) == 0) {
+ } else if (!out_home && streq(buf, DHOME)) {
fprintf(ofp, DHOME "=%s\n", def_home);
out_home = true;
- } else if (!out_inactive && strcmp(buf, DINACT) == 0) {
+ } else if (!out_inactive && streq(buf, DINACT)) {
fprintf(ofp, DINACT "=%ld\n", def_inactive);
out_inactive = true;
- } else if (!out_expire && strcmp(buf, DEXPIRE) == 0) {
+ } else if (!out_expire && streq(buf, DEXPIRE)) {
fprintf(ofp, DEXPIRE "=%s\n", def_expire);
out_expire = true;
- } else if (!out_shell && strcmp(buf, DSHELL) == 0) {
+ } else if (!out_shell && streq(buf, DSHELL)) {
fprintf(ofp, DSHELL "=%s\n", def_shell);
out_shell = true;
- } else if (!out_skel && strcmp(buf, DSKEL) == 0) {
+ } else if (!out_skel && streq(buf, DSKEL)) {
fprintf(ofp, DSKEL "=%s\n", def_template);
out_skel = true;
- } else if (!out_usrskel && strcmp(buf, DUSRSKEL) == 0) {
+ } else if (!out_usrskel && streq(buf, DUSRSKEL)) {
fprintf(ofp, DUSRSKEL "=%s\n", def_usrtemplate);
out_usrskel = true;
} else if (!out_create_mail_spool
- && strcmp(buf, DCREATE_MAIL_SPOOL) == 0)
+ && streq(buf, DCREATE_MAIL_SPOOL))
{
fprintf(ofp,
DCREATE_MAIL_SPOOL "=%s\n",
def_create_mail_spool);
out_create_mail_spool = true;
- } else if (!out_log_init && strcmp(buf, DLOG_INIT) == 0) {
+ } else if (!out_log_init && streq(buf, DLOG_INIT)) {
fprintf(ofp, DLOG_INIT "=%s\n", def_log_init);
out_log_init = true;
} else {
if (!lflg) {
/* If we are missing the flag lflg aka -l, check the defaults
* file to see if we need to disable it as a default*/
- if (strcmp (def_log_init, "no") == 0) {
+ if (streq(def_log_init, "no")) {
lflg = true;
}
}
#endif /* ENABLE_SUBIDS */
#include "shadowlog.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
#include "string/strdup/xstrdup.h"
*/
prefix_setpwent ();
while ((pwd = prefix_getpwent ()) != NULL) {
- if (strcmp (pwd->pw_name, user_name) == 0) {
+ if (streq(pwd->pw_name, user_name)) {
continue;
}
if (pwd->pw_gid == grp->gr_gid) {
*/
prefix_setpwent ();
while ((pwd = prefix_getpwent ())) {
- if (strcmp (pwd->pw_name, user_name) == 0) {
+ if (streq(pwd->pw_name, user_name)) {
continue;
}
if (path_prefix (user_home, pwd->pw_dir)) {
#include "groupio.h"
#include "must_be.h"
#include "nscd.h"
-#include "sssd.h"
#include "prototypes.h"
#include "pwauth.h"
#include "pwio.h"
#include "tcbfuncs.h"
#endif
#include "shadowlog.h"
+#include "sssd.h"
#include "string/memset/memzero.h"
#include "string/sprintf/xasprintf.h"
#include "string/strcmp/streq.h"
gflg = false;
}
if ( (NULL != user_newshell)
- && (strcmp (user_newshell, user_shell) == 0)) {
+ && streq(user_newshell, user_shell)) {
sflg = false;
}
- if (strcmp (user_newname, user_name) == 0) {
+ if (streq(user_newname, user_name)) {
lflg = false;
}
if (user_newinactive == user_inactive) {
eflg = false;
}
if ( (NULL != user_newhome)
- && (strcmp (user_newhome, user_home) == 0)) {
+ && streq(user_newhome, user_home)) {
dflg = false;
mflg = false;
}
if ( (NULL != user_newcomment)
- && (strcmp (user_newcomment, user_comment) == 0)) {
+ && streq(user_newcomment, user_comment)) {
cflg = false;
}
spent = *spwd;
new_spent (&spent);
} else if ( ( pflg
- && (strcmp (pwent.pw_passwd, SHADOW_PASSWD_STRING) == 0))
+ && streq(pwent.pw_passwd, SHADOW_PASSWD_STRING))
|| eflg || fflg) {
/* In some cases, we force the creation of a
* shadow entry:
#include "getdef.h"
#include "groupio.h"
#include "nscd.h"
-#include "sssd.h"
#include "prototypes.h"
#include "pwio.h"
#include "sgroupio.h"
#include "tcbfuncs.h"
#endif /* WITH_TCB */
#include "shadowlog.h"
+#include "sssd.h"
#include "string/sprintf/snprintf.h"
#include "string/sprintf/xasprintf.h"
+#include "string/strcmp/streq.h"
#define MSG_WARN_EDIT_OTHER_FILE _( \
bool editshadow = false;
bool do_vigr;
- do_vigr = (strcmp(Basename(argv[0]), "vigr") == 0);
+ do_vigr = streq(Basename(argv[0]), "vigr");
Prog = do_vigr ? "vigr" : "vipw";
log_set_progname(Prog);