#include "shadowlog_internal.h"
#include "sssd.h"
#include "string/sprintf/snprintf.h"
+#include "string/strtok/stpsep.h"
/* local function prototypes */
goto cleanup_buf;
}
}
- stpcpy(strchrnul(buf, '\n'), "");
+ stpsep(buf, "\n");
line = strdup (buf);
if (NULL == line) {
#include "getdef.h"
#include "prototypes.h"
#include "string/strcpy/strtcpy.h"
-
-#ident "$Id$"
+#include "string/strtok/stpsep.h"
/*
*/
while (fgets (buf, sizeof (buf), fp) != NULL) {
- stpcpy(strchrnul(buf, '\n'), "");
+ stpsep(buf, "\n");
if (strcmp (buf, tty) == 0) {
(void) fclose (fp);
return true;
#include "prototypes.h"
#include "string/strchr/strrspn.h"
+#include "string/strtok/stpsep.h"
/*
return;
}
- cp = strchr (newf, '\n');
- if (NULL == cp) {
+ if (stpsep(newf, "\n") == NULL)
return;
- }
- stpcpy(cp, "");
if ('\0' != newf[0]) {
/*
#include "prototypes.h"
#include "shadowlog_internal.h"
#include "string/sprintf/xasprintf.h"
-#include "string/strchr/stpcspn.h"
#include "string/strchr/stpspn.h"
#include "string/strchr/strrspn.h"
+#include "string/strtok/stpsep.h"
/*
if (*name == '\0' || *name == '#')
continue; /* comment or empty */
- s = stpcspn(name, " \t"); /* end of field */
- if (*s == '\0')
+ s = stpsep(name, " \t"); /* next field */
+ if (s == NULL)
continue; /* only 1 field?? */
- stpcpy(s++, "");
value = stpspn(s, " \"\t"); /* next nonwhite */
- stpcpy(strchrnul(value, '"'), "");
+ stpsep(value, "\"");
/*
* Store the value in def_table.
#include "alloc/malloc.h"
#include "alloc/realloc.h"
#include "alloc/x/xrealloc.h"
-#include "prototypes.h"
#include "defines.h"
+#include "prototypes.h"
+#include "string/strtok/stpsep.h"
+
static /*@null@*/FILE *shadow;
static /*@null@*//*@only@*/char **members = NULL;
}
strcpy (sgrbuf, string);
- stpcpy(strchrnul(sgrbuf, '\n'), "");
+ stpsep(sgrbuf, "\n");
/*
* There should be exactly 4 colon separated fields. Find
return NULL;
}
}
- stpcpy(strchrnul(buf, '\n'), "");
+ stpsep(buf, "\n");
return (sgetsgent (buf));
}
return NULL;
#include "getdef.h"
#include "prototypes.h"
#include "string/sprintf/snprintf.h"
+#include "string/strtok/stpsep.h"
/*
return false;
}
for (found = false; !found && (fgets (buf, sizeof buf, fp) == buf);) {
- stpcpy(strchrnul(buf, '\n'), "");
+ stpsep(buf, "\n");
found = (strcmp (buf, pw->pw_shell) == 0) ||
(strcmp (buf, pw->pw_name) == 0);
}
#include <signal.h>
#include "attr.h"
-#include "memzero.h"
-#include "prototypes.h"
#include "defines.h"
#include "getdef.h"
+#include "memzero.h"
+#include "prototypes.h"
+#include "string/strtok/stpsep.h"
+
static void login_exit (MAYBE_UNUSED int sig)
{
exit (EXIT_FAILURE);
}
- cp = strchr (buf, '\n');
- if (NULL == cp) {
- exit (EXIT_FAILURE);
- }
- stpcpy(cp, ""); /* remove \n [ must be there ] */
+ if (stpsep(buf, "\n") == NULL)
+ exit(EXIT_FAILURE);
/*
* Skip leading whitespace. This makes " username" work right.
#include "defines.h"
#include "port.h"
#include "prototypes.h"
+#include "string/strtok/stpsep.h"
static FILE *ports;
if ('#' == buf[0])
goto next;
- stpcpy(strchrnul(buf, '\n'), "");
+ stpsep(buf, "\n");
field = buf;
#include "shadowlog.h"
#include "string/sprintf/xasprintf.h"
#include "string/strdup/xstrdup.h"
+#include "string/strtok/stpsep.h"
#ifndef USE_PAM
return;
}
while (fgets (buf, (int)(sizeof buf), fp) == buf) {
- cp = strrchr (buf, '\n');
- if (NULL == cp) {
+ if (stpsep(buf, "\n") == NULL)
break;
- }
- stpcpy(cp, "");
cp = buf;
/* ignore whitespace and comments */
* (for example, the "export NAME" shell commands)
*/
name = cp;
- while (('\0' != *cp) && !isspace (*cp) && ('=' != *cp)) {
- cp++;
- }
- if ('=' != *cp) {
+ val = stpsep(cp, "=");
+ if (val == NULL)
+ continue;
+ if (strpbrk(name, " \t") != NULL)
continue;
- }
- /* NUL-terminate the name */
- stpcpy(cp++, "");
- val = cp;
#if 0 /* XXX untested, and needs rewrite with fewer goto's :-) */
/*
(state, char_type) -> (state, action)
#include "atoi/getnum.h"
#include "defines.h"
#include "prototypes.h"
+#include "string/strtok/stpsep.h"
#define NFIELDS 4
}
}
strcpy (grpbuf, buf);
- stpcpy(strchrnul(grpbuf, '\n'), "");
+ stpsep(grpbuf, "\n");
for (cp = grpbuf, i = 0; (i < NFIELDS) && (NULL != cp); i++)
grpfields[i] = strsep(&cp, ":");
#include "atoi/a2i.h"
#include "atoi/str2i.h"
+#include "defines.h"
#include "prototypes.h"
#include "shadowlog_internal.h"
-#include "defines.h"
+#include "string/strtok/stpsep.h"
#define FIELDS 9
return NULL; /* fail if too long */
}
strcpy (spwbuf, string);
- stpcpy(strchrnul(spwbuf, '\n'), "");
+ stpsep(spwbuf, "\n");
/*
* Tokenize the string into colon separated fields. Allow up to
#include "atoi/str2i.h"
#include "defines.h"
#include "prototypes.h"
+#include "string/strtok/stpsep.h"
static FILE *shadow;
if (strlen (string) >= sizeof spwbuf)
return 0;
strcpy (spwbuf, string);
- stpcpy(strchrnul(spwbuf, '\n'), "");
+ stpsep(spwbuf, "\n");
/*
* Tokenize the string into colon separated fields. Allow up to
if (fgets (buf, sizeof buf, fp) != NULL)
{
- stpcpy(strchrnul(buf, '\n'), "");
+ stpsep(buf, "\n");
return my_sgetspent (buf);
}
return 0;
#include "defines.h"
#include "getdef.h"
#include "prototypes.h"
+#include "string/strtok/stpsep.h"
/*
continue;
}
- stpcpy(strchrnul(buf, '\n'), "");
+ stpsep(buf, "\n");
if ( (sscanf (buf, "%1023s %1023s", type, port) == 2)
&& (strcmp (line, port) == 0)) {
#include <stdio.h>
#include <string.h>
+
#include "defines.h"
-#include "prototypes.h"
#include "getdef.h"
+#include "prototypes.h"
+#include "string/strtok/stpsep.h"
+
/*
* tz - return local timezone name
strcpy (tzbuf, def_tz);
} else {
- stpcpy(strchrnul(tzbuf, '\n'), "");
+ stpsep(tzbuf, "\n");
}
if (NULL != fp) {
/*@-exitarg@*/
#include "exitcodes.h"
#include "shadowlog.h"
+#include "string/strtok/stpsep.h"
/*
*/
while (fgets (buf, (int) sizeof buf, stdin) != NULL) {
line++;
- cp = strrchr (buf, '\n');
- if (NULL != cp) {
- stpcpy(cp, "");
- } else {
+ if (stpsep(buf, "\n") == NULL) {
fprintf (stderr, _("%s: line %d: line too long\n"),
Prog, line);
errors++;
*/
name = buf;
- cp = strchr (name, ':');
- if (NULL != cp) {
- stpcpy(cp, "");
- cp++;
- } else {
+ cp = stpsep(name, ":");
+ if (cp == NULL) {
fprintf (stderr,
_("%s: line %d: missing new password\n"),
Prog, line);
/*@-exitarg@*/
#include "exitcodes.h"
#include "shadowlog.h"
+#include "string/strtok/stpsep.h"
#define IS_CRYPT_METHOD(str) ((crypt_method != NULL && strcmp(crypt_method, str) == 0) ? true : false)
*/
while (fgets (buf, sizeof buf, stdin) != NULL) {
line++;
- cp = strrchr (buf, '\n');
- if (NULL != cp) {
- stpcpy(cp, "");
- } else {
+ if (stpsep(buf, "\n") == NULL) {
if (feof (stdin) == 0) {
-
// Drop all remaining characters on this line.
while (fgets (buf, sizeof buf, stdin) != NULL) {
cp = strchr (buf, '\n');
*/
name = buf;
- cp = strchr (name, ':');
- if (NULL != cp) {
- stpcpy(cp++, "");
- } else {
+ cp = stpsep(name, ":");
+ if (cp == NULL) {
fprintf (stderr,
_("%s: line %d: missing new password\n"),
Prog, line);
#include "nscd.h"
#include "sssd.h"
#include "prototypes.h"
+#include "run_part.h"
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
#include "shadowlog.h"
-#include "run_part.h"
+#include "string/strtok/stpsep.h"
/*
* example: -K GID_MIN=100 -K GID_MAX=499
* note: -K GID_MIN=10,GID_MAX=499 doesn't work yet
*/
- cp = strchr (optarg, '=');
+ cp = stpsep(optarg, "=");
if (NULL == cp) {
fprintf (stderr,
_("%s: -K requires KEY=VALUE\n"),
Prog);
exit (E_BAD_ARG);
}
- /* terminate name, point to value */
- stpcpy(cp++, "");
if (putdef_str (optarg, cp, NULL) < 0) {
exit (E_BAD_ARG);
}
#include "sizeof.h"
#include "string/strchr/strrspn.h"
+#include "string/strtok/stpsep.h"
+
#if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 64)
#undef MAXHOSTNAMELEN
#ifdef PRIMARY_GROUP_MATCH
struct passwd *userinf;
#endif
- char *at;
+ char *host;
/*
* If a token has the magic value "ALL" the match always succeeds.
* Otherwise, return true if the token fully matches the username, or if
* the token is a group that contains the username.
*/
- at = strchr (tok + 1, '@');
- if (NULL != at) { /* split user@host pattern */
- stpcpy(at, "");
- return ( user_match (tok, string)
- && from_match (at + 1, myhostname ()));
+ host = stpsep(tok + 1, "@"); /* split user@host pattern */
+ if (host != NULL) {
+ return user_match(tok, string) && from_match(host, myhostname());
#if HAVE_INNETGR
} else if (tok[0] == '@') { /* netgroup */
return (netgroup_match (tok + 1, NULL, string));
#include "shadowlog.h"
#include "string/sprintf/snprintf.h"
#include "string/strdup/xstrdup.h"
+#include "string/strtok/stpsep.h"
/*
*/
while (fgets (buf, sizeof buf, stdin) != NULL) {
line++;
- cp = strrchr (buf, '\n');
- if (cp == NULL && feof (stdin) == 0) {
+ if (stpsep(buf, "\n") == NULL && feof(stdin) == 0) {
fprintf (stderr, _("%s: line %d: line too long\n"),
Prog, line);
fail_exit (EXIT_FAILURE);
}
- if (cp != NULL)
- stpcpy(cp, "");
/*
* Break the string into fields and screw around with them.
#include "string/sprintf/snprintf.h"
#include "string/sprintf/xasprintf.h"
#include "string/strdup/xstrdup.h"
+#include "string/strtok/stpsep.h"
#ifndef SKEL_DIR
* values are used, everything else can be ignored.
*/
while (fgets (buf, sizeof buf, fp) == buf) {
- stpcpy(strchrnul(buf, '\n'), "");
+ stpsep(buf, "\n");
cp = strchr (buf, '=');
if (NULL == cp) {
}
while (fgets (buf, sizeof buf, ifp) == buf) {
- cp = strrchr (buf, '\n');
- if (NULL != cp) {
- stpcpy(cp, "");
- } else {
+ if (stpsep(buf, "\n") == NULL) {
/* A line which does not end with \n is only valid
* at the end of the file.
*/
* example: -K UID_MIN=100 -K UID_MAX=499
* note: -K UID_MIN=10,UID_MAX=499 doesn't work yet
*/
- cp = strchr (optarg, '=');
+ cp = stpsep(optarg, "=");
if (NULL == cp) {
fprintf (stderr,
_("%s: -K requires KEY=VALUE\n"),
Prog);
exit (E_BAD_ARG);
}
- /* terminate name, point to value */
- stpcpy(cp++, "");
if (putdef_str (optarg, cp, NULL) < 0) {
exit (E_BAD_ARG);
}