lib/, src/: Use stpsep() instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
39da15614e
commit
d91b22cc2f
+2
-1
@@ -36,6 +36,7 @@
|
||||
#include "shadowlog_internal.h"
|
||||
#include "sssd.h"
|
||||
#include "string/sprintf/snprintf.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
@@ -659,7 +660,7 @@ int commonio_open (struct commonio_db *db, int mode)
|
||||
goto cleanup_buf;
|
||||
}
|
||||
}
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
stpsep(buf, "\n");
|
||||
|
||||
line = strdup (buf);
|
||||
if (NULL == line) {
|
||||
|
||||
+2
-3
@@ -17,8 +17,7 @@
|
||||
#include "getdef.h"
|
||||
#include "prototypes.h"
|
||||
#include "string/strcpy/strtcpy.h"
|
||||
|
||||
#ident "$Id$"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -76,7 +75,7 @@ static bool is_listed (const char *cfgin, const char *tty, bool def)
|
||||
*/
|
||||
|
||||
while (fgets (buf, sizeof (buf), fp) != NULL) {
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
stpsep(buf, "\n");
|
||||
if (strcmp (buf, tty) == 0) {
|
||||
(void) fclose (fp);
|
||||
return true;
|
||||
|
||||
+2
-4
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "string/strchr/strrspn.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -80,11 +81,8 @@ void change_field (char *buf, size_t maxsize, const char *prompt)
|
||||
return;
|
||||
}
|
||||
|
||||
cp = strchr (newf, '\n');
|
||||
if (NULL == cp) {
|
||||
if (stpsep(newf, "\n") == NULL)
|
||||
return;
|
||||
}
|
||||
stpcpy(cp, "");
|
||||
|
||||
if ('\0' != newf[0]) {
|
||||
/*
|
||||
|
||||
+4
-5
@@ -29,9 +29,9 @@
|
||||
#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"
|
||||
|
||||
|
||||
/*
|
||||
@@ -569,13 +569,12 @@ static void def_load (void)
|
||||
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.
|
||||
|
||||
+5
-3
@@ -20,8 +20,10 @@
|
||||
#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;
|
||||
@@ -91,7 +93,7 @@ void endsgent (void)
|
||||
}
|
||||
|
||||
strcpy (sgrbuf, string);
|
||||
stpcpy(strchrnul(sgrbuf, '\n'), "");
|
||||
stpsep(sgrbuf, "\n");
|
||||
|
||||
/*
|
||||
* There should be exactly 4 colon separated fields. Find
|
||||
@@ -172,7 +174,7 @@ void endsgent (void)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
stpsep(buf, "\n");
|
||||
return (sgetsgent (buf));
|
||||
}
|
||||
return NULL;
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@
|
||||
#include "getdef.h"
|
||||
#include "prototypes.h"
|
||||
#include "string/sprintf/snprintf.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -72,7 +73,7 @@ bool hushed (const char *username)
|
||||
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);
|
||||
}
|
||||
|
||||
+6
-7
@@ -16,10 +16,12 @@
|
||||
#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)
|
||||
{
|
||||
@@ -83,11 +85,8 @@ void login_prompt (char *name, int namesize)
|
||||
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.
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@
|
||||
#include "defines.h"
|
||||
#include "port.h"
|
||||
#include "prototypes.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
static FILE *ports;
|
||||
@@ -142,7 +143,7 @@ next:
|
||||
if ('#' == buf[0])
|
||||
goto next;
|
||||
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
stpsep(buf, "\n");
|
||||
|
||||
field = buf;
|
||||
|
||||
|
||||
+6
-12
@@ -28,6 +28,7 @@
|
||||
#include "shadowlog.h"
|
||||
#include "string/sprintf/xasprintf.h"
|
||||
#include "string/strdup/xstrdup.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
#ifndef USE_PAM
|
||||
@@ -52,11 +53,8 @@ static void read_env_file (const char *filename)
|
||||
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 */
|
||||
@@ -71,15 +69,11 @@ static void read_env_file (const char *filename)
|
||||
* (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)
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@
|
||||
#include "atoi/getnum.h"
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
#define NFIELDS 4
|
||||
@@ -83,7 +84,7 @@ struct group *sgetgrent (const char *buf)
|
||||
}
|
||||
}
|
||||
strcpy (grpbuf, buf);
|
||||
stpcpy(strchrnul(grpbuf, '\n'), "");
|
||||
stpsep(grpbuf, "\n");
|
||||
|
||||
for (cp = grpbuf, i = 0; (i < NFIELDS) && (NULL != cp); i++)
|
||||
grpfields[i] = strsep(&cp, ":");
|
||||
|
||||
+3
-2
@@ -21,9 +21,10 @@
|
||||
|
||||
#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
|
||||
@@ -54,7 +55,7 @@ sgetspent(const char *string)
|
||||
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
|
||||
|
||||
+3
-2
@@ -22,6 +22,7 @@
|
||||
#include "atoi/str2i.h"
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
static FILE *shadow;
|
||||
@@ -77,7 +78,7 @@ static struct spwd *my_sgetspent (const char *string)
|
||||
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
|
||||
@@ -202,7 +203,7 @@ struct spwd *fgetspent (FILE * fp)
|
||||
|
||||
if (fgets (buf, sizeof buf, fp) != NULL)
|
||||
{
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
stpsep(buf, "\n");
|
||||
return my_sgetspent (buf);
|
||||
}
|
||||
return 0;
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
#include "prototypes.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -49,7 +50,7 @@ void ttytype (const char *line)
|
||||
continue;
|
||||
}
|
||||
|
||||
stpcpy(strchrnul(buf, '\n'), "");
|
||||
stpsep(buf, "\n");
|
||||
|
||||
if ( (sscanf (buf, "%1023s %1023s", type, port) == 2)
|
||||
&& (strcmp (line, port) == 0)) {
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
|
||||
#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
|
||||
@@ -42,7 +45,7 @@
|
||||
|
||||
strcpy (tzbuf, def_tz);
|
||||
} else {
|
||||
stpcpy(strchrnul(tzbuf, '\n'), "");
|
||||
stpsep(tzbuf, "\n");
|
||||
}
|
||||
|
||||
if (NULL != fp) {
|
||||
|
||||
+4
-9
@@ -34,6 +34,7 @@
|
||||
/*@-exitarg@*/
|
||||
#include "exitcodes.h"
|
||||
#include "shadowlog.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -460,10 +461,7 @@ int main (int argc, char **argv)
|
||||
*/
|
||||
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++;
|
||||
@@ -480,11 +478,8 @@ int main (int argc, char **argv)
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
+4
-9
@@ -31,6 +31,7 @@
|
||||
/*@-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)
|
||||
@@ -501,12 +502,8 @@ int main (int argc, char **argv)
|
||||
*/
|
||||
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');
|
||||
@@ -533,10 +530,8 @@ int main (int argc, char **argv)
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
+3
-4
@@ -33,11 +33,12 @@
|
||||
#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"
|
||||
|
||||
|
||||
/*
|
||||
@@ -423,15 +424,13 @@ static void process_flags (int argc, char **argv)
|
||||
* 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);
|
||||
}
|
||||
|
||||
+6
-6
@@ -58,6 +58,8 @@
|
||||
|
||||
#include "sizeof.h"
|
||||
#include "string/strchr/strrspn.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
#if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 64)
|
||||
#undef MAXHOSTNAMELEN
|
||||
@@ -213,18 +215,16 @@ static bool user_match (const char *tok, const char *string)
|
||||
#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));
|
||||
|
||||
+2
-4
@@ -54,6 +54,7 @@
|
||||
#include "shadowlog.h"
|
||||
#include "string/sprintf/snprintf.h"
|
||||
#include "string/strdup/xstrdup.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -1101,14 +1102,11 @@ int main (int argc, char **argv)
|
||||
*/
|
||||
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.
|
||||
|
||||
+4
-8
@@ -68,6 +68,7 @@
|
||||
#include "string/sprintf/snprintf.h"
|
||||
#include "string/sprintf/xasprintf.h"
|
||||
#include "string/strdup/xstrdup.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
#ifndef SKEL_DIR
|
||||
@@ -361,7 +362,7 @@ static void get_defaults (void)
|
||||
* 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) {
|
||||
@@ -603,10 +604,7 @@ static int set_defaults (void)
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
@@ -1350,15 +1348,13 @@ static void process_flags (int argc, char **argv)
|
||||
* 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user