- move "Wflag" global from mtree.c to spec.c, and reinstate the functionality

of tv's previous code, which skips uname or gname parsing if -W is enabled.
- rename "lineno" to "mtree_lineno", to reduce possibility of name
  clashes in code that yanks in spec.c & misc.c (unlikely, but you never know)
This commit is contained in:
lukem 2001-11-03 12:51:40 +00:00
parent 33b90eebfd
commit c55aa0f9cb
4 changed files with 24 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.17 2001/10/25 14:47:39 lukem Exp $ */
/* $NetBSD: extern.h,v 1.18 2001/11/03 12:51:40 lukem Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -54,7 +54,7 @@ int verify(void);
extern int dflag, eflag, iflag, lflag, mflag, rflag, sflag, tflag, uflag;
extern int Wflag;
extern size_t lineno;
extern size_t mtree_lineno;
extern int crc_total, ftsoptions, keys;
extern char fullpath[];
extern slist_t includetags, excludetags;

View File

@ -1,4 +1,4 @@
/* $NetBSD: misc.c,v 1.18 2001/10/22 07:07:46 lukem Exp $ */
/* $NetBSD: misc.c,v 1.19 2001/11/03 12:51:41 lukem Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: misc.c,v 1.18 2001/10/22 07:07:46 lukem Exp $");
__RCSID("$NetBSD: misc.c,v 1.19 2001/11/03 12:51:41 lukem Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -153,9 +153,9 @@ mtree_err(const char *fmt, ...)
va_start(ap, fmt);
vwarnx(fmt, ap);
va_end(ap);
if (lineno)
if (mtree_lineno)
warnx("failed at line %lu of the specification",
(u_long) lineno);
(u_long) mtree_lineno);
exit(1);
/* NOTREACHED */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mtree.c,v 1.22 2001/10/25 14:47:39 lukem Exp $ */
/* $NetBSD: mtree.c,v 1.23 2001/11/03 12:51:41 lukem Exp $ */
/*-
* Copyright (c) 1989, 1990, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1990, 1993\n\
#if 0
static char sccsid[] = "@(#)mtree.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: mtree.c,v 1.22 2001/10/25 14:47:39 lukem Exp $");
__RCSID("$NetBSD: mtree.c,v 1.23 2001/11/03 12:51:41 lukem Exp $");
#endif
#endif /* not lint */
@ -62,7 +62,7 @@ __RCSID("$NetBSD: mtree.c,v 1.22 2001/10/25 14:47:39 lukem Exp $");
int ftsoptions = FTS_PHYSICAL;
int cflag, dflag, Dflag, eflag, iflag, lflag, mflag,
rflag, sflag, tflag, uflag, Uflag, Wflag;
rflag, sflag, tflag, uflag, Uflag;
char fullpath[MAXPATHLEN];
int main(int, char **);

View File

@ -1,4 +1,4 @@
/* $NetBSD: spec.c,v 1.38 2001/11/01 02:15:41 tv Exp $ */
/* $NetBSD: spec.c,v 1.39 2001/11/03 12:51:41 lukem Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -74,7 +74,7 @@
#if 0
static char sccsid[] = "@(#)spec.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: spec.c,v 1.38 2001/11/01 02:15:41 tv Exp $");
__RCSID("$NetBSD: spec.c,v 1.39 2001/11/03 12:51:41 lukem Exp $");
#endif
#endif /* not lint */
@ -97,7 +97,8 @@ __RCSID("$NetBSD: spec.c,v 1.38 2001/11/01 02:15:41 tv Exp $");
#include "extern.h"
#include "pack_dev.h"
size_t lineno; /* Current spec line number. */
size_t mtree_lineno; /* Current spec line number */
int Wflag; /* Don't "whack" permissions */
static dev_t parsedev(char *);
static void set(char *, NODE *);
@ -117,8 +118,8 @@ spec(FILE *fp)
tname = NULL;
tnamelen = 0;
memset(&ginfo, 0, sizeof(ginfo));
for (lineno = 0;
(buf = fparseln(fp, NULL, &lineno, NULL,
for (mtree_lineno = 0;
(buf = fparseln(fp, NULL, &mtree_lineno, NULL,
FPARSELN_UNESCCOMM | FPARSELN_UNESCCONT | FPARSELN_UNESCESC));
free(buf)) {
/* Skip leading whitespace. */
@ -130,7 +131,8 @@ spec(FILE *fp)
continue;
#ifdef DEBUG
(void)fprintf(stderr, "line %lu: {%s}\n", (u_long)lineno, p);
(void)fprintf(stderr, "line %lu: {%s}\n",
(u_long)mtree_lineno, p);
#endif
/* Grab file name, "$", "set", or "unset". */
next = buf;
@ -206,7 +208,7 @@ noparent: mtree_err("no parent node");
if ((centry = calloc(1, sizeof(NODE) + strlen(p))) == NULL)
mtree_err("%s", strerror(errno));
*centry = ginfo;
centry->lineno = lineno;
centry->lineno = mtree_lineno;
strcpy(centry->name, p);
#define MAGIC "?*["
if (strpbrk(p, MAGIC))
@ -395,8 +397,10 @@ set(char *t, NODE *ip)
mtree_err("invalid gid `%s'", val);
break;
case F_GNAME:
if (Wflag) /* don't parse if whacking */
break;
if (gid_from_group(val, &gid) == -1)
mtree_err("unknown group `%s'", val);
mtree_err("unknown group `%s'", val);
ip->st_gid = gid;
break;
case F_IGN:
@ -458,8 +462,10 @@ set(char *t, NODE *ip)
mtree_err("invalid uid `%s'", val);
break;
case F_UNAME:
if (Wflag) /* don't parse if whacking */
break;
if (uid_from_user(val, &uid) == -1)
mtree_err("unknown user `%s'", val);
mtree_err("unknown user `%s'", val);
ip->st_uid = uid;
break;
default: