diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-01-10 10:05:41 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-01-10 10:05:41 +0000 |
commit | 93f38e798dbadd8cdba2df89a71474ae338ab7e5 (patch) | |
tree | fc436e20062b01797034d8ba4cb7bb900ca01b8a | |
parent | b6be805f5238bfe5b48e07d480f05445ce8a6c3f (diff) |
Simply the use of cmdp and cvs_command by zapping cvs_command and working
solely with cmdp. This remedies some reliability issues with invalid
commands supplied and also fixes a GNU cvs style incompatibility with
release command.
> Based on patch from Igor Zinovik
-rw-r--r-- | usr.bin/cvs/client.c | 4 | ||||
-rw-r--r-- | usr.bin/cvs/cmd.c | 3 | ||||
-rw-r--r-- | usr.bin/cvs/cvs.c | 17 | ||||
-rw-r--r-- | usr.bin/cvs/cvs.h | 4 | ||||
-rw-r--r-- | usr.bin/cvs/log.c | 22 | ||||
-rw-r--r-- | usr.bin/cvs/release.c | 4 |
6 files changed, 19 insertions, 35 deletions
diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index 8157ed60dc8..74a6a77f39b 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.86 2008/01/10 09:48:51 tobias Exp $ */ +/* $OpenBSD: client.c,v 1.87 2008/01/10 10:05:40 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -1008,7 +1008,7 @@ cvs_client_initlog(void) s++; switch (*s) { case 'c': - if (strlcpy(fpath, cvs_command, sizeof(fpath)) >= + if (strlcpy(fpath, cmdp->cmd_name, sizeof(fpath)) >= sizeof(fpath)) fatal("cvs_client_initlog: truncation"); break; diff --git a/usr.bin/cvs/cmd.c b/usr.bin/cvs/cmd.c index 92cf2dcf4e2..e1dd327a233 100644 --- a/usr.bin/cvs/cmd.c +++ b/usr.bin/cvs/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.63 2007/09/25 10:56:04 chl Exp $ */ +/* $OpenBSD: cmd.c,v 1.64 2008/01/10 10:05:40 tobias Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -66,7 +66,6 @@ struct cvs_cmd * cvs_findcmd(const char *cmd) { int i, j; - struct cvs_cmd *cmdp; cmdp = NULL; diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c index f948fb9569c..db9458eea48 100644 --- a/usr.bin/cvs/cvs.c +++ b/usr.bin/cvs/cvs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.c,v 1.139 2007/10/07 18:14:09 chl Exp $ */ +/* $OpenBSD: cvs.c,v 1.140 2008/01/10 10:05:40 tobias Exp $ */ /* * Copyright (c) 2006, 2007 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -59,7 +59,6 @@ int cvs_server_active = 0; char *cvs_tagname = NULL; char *cvs_defargs; /* default global arguments from .cvsrc */ -char *cvs_command; /* name of the command we are running */ char *cvs_rootstr; char *cvs_rsh = CVS_RSH_DEFAULT; char *cvs_editor = CVS_EDITOR_DEFAULT; @@ -68,6 +67,7 @@ char *cvs_msg = NULL; char *cvs_tmpdir = CVS_TMPDIR_DEFAULT; struct cvsroot *current_cvsroot = NULL; +struct cvs_cmd *cmdp; /* struct of command we are running */ int cvs_getopt(int, char **); __dead void usage(void); @@ -128,7 +128,6 @@ main(int argc, char **argv) { char *envstr, *cmd_argv[CVS_CMD_MAXARG], **targv; int i, ret, cmd_argc; - struct cvs_cmd *cmdp; struct passwd *pw; struct stat st; char fpath[MAXPATHLEN]; @@ -172,8 +171,6 @@ main(int argc, char **argv) if (argc == 0) usage(); - cvs_command = argv[0]; - /* * check the tmp dir, either specified through * the environment variable TMPDIR, or via @@ -184,9 +181,9 @@ main(int argc, char **argv) else if (!S_ISDIR(st.st_mode)) fatal("`%s' is not valid temporary directory", cvs_tmpdir); - cmdp = cvs_findcmd(cvs_command); + cmdp = cvs_findcmd(argv[0]); if (cmdp == NULL) { - fprintf(stderr, "Unknown command: `%s'\n\n", cvs_command); + fprintf(stderr, "Unknown command: `%s'\n\n", argv[0]); fprintf(stderr, "CVS commands are:\n"); for (i = 0; cvs_cdt[i] != NULL; i++) fprintf(stderr, "\t%-16s%s\n", @@ -396,7 +393,7 @@ cvs_read_rcfile(void) char rcpath[MAXPATHLEN], *buf, *lbuf, *lp, *p; int cmd_parsed, cvs_parsed, i, linenum; size_t len, pos; - struct cvs_cmd *cmdp, *tcmdp; + struct cvs_cmd *tcmdp; FILE *fp; linenum = 0; @@ -415,10 +412,6 @@ cvs_read_rcfile(void) return; } - cmdp = cvs_findcmd(cvs_command); - if (cmdp == NULL) - fatal("unknown command `%s'", cvs_command); - cmd_parsed = cvs_parsed = 0; lbuf = NULL; while ((buf = fgetln(fp, &len)) != NULL) { diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h index ea8168528d3..e8e4ede6ea7 100644 --- a/usr.bin/cvs/cvs.h +++ b/usr.bin/cvs/cvs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.h,v 1.147 2007/09/23 11:19:24 joris Exp $ */ +/* $OpenBSD: cvs.h,v 1.148 2008/01/10 10:05:40 tobias Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -289,7 +289,6 @@ extern volatile sig_atomic_t sig_received; extern volatile sig_atomic_t cvs_quit; extern struct cvsroot *current_cvsroot; extern char *cvs_tagname; -extern char *cvs_command; extern char *cvs_editor; extern char *cvs_homedir; extern char *cvs_msg; @@ -314,6 +313,7 @@ extern int cvs_error; extern int cvs_server_active; extern int reset_stickies; +extern struct cvs_cmd *cmdp; extern struct cvs_cmd *cvs_cdt[]; extern struct cvs_cmd cvs_cmd_add; diff --git a/usr.bin/cvs/log.c b/usr.bin/cvs/log.c index c46093c6a7c..294c098d196 100644 --- a/usr.bin/cvs/log.c +++ b/usr.bin/cvs/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.41 2007/09/07 23:59:01 tobias Exp $ */ +/* $OpenBSD: log.c,v 1.42 2008/01/10 10:05:40 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -61,7 +61,6 @@ cvs_vlog(u_int level, const char *fmt, va_list vap) { int ecp; FILE *out; - struct cvs_cmd *cmdp; if (cvs_trace != 1 && level == LP_TRACE) return; @@ -96,19 +95,12 @@ cvs_vlog(u_int level, const char *fmt, va_list vap) (void)fputs("-> ", out); } else if (level != LP_RCS) { (void)fputs(__progname, out); - if (cvs_command != NULL) { - /* - * always use the command name in error messages, - * not aliases - */ - cmdp = cvs_findcmd(cvs_command); - putc(' ', out); - if (level == LP_ABORT) - (void)fprintf(out, - "[%s aborted]", cmdp->cmd_name); - else - (void)fputs(cmdp->cmd_name, out); - } + putc(' ', out); + if (level == LP_ABORT) + (void)fprintf(out, + "[%s aborted]", cmdp->cmd_name); + else + (void)fputs(cmdp->cmd_name, out); (void)fputs(": ", out); } diff --git a/usr.bin/cvs/release.c b/usr.bin/cvs/release.c index 69f17983526..9b1c76fabd8 100644 --- a/usr.bin/cvs/release.c +++ b/usr.bin/cvs/release.c @@ -1,4 +1,4 @@ -/* $OpenBSD: release.c,v 1.36 2007/09/25 10:56:04 chl Exp $ */ +/* $OpenBSD: release.c,v 1.37 2008/01/10 10:05:40 tobias Exp $ */ /*- * Copyright (c) 2005-2007 Xavier Santolaria <xsa@openbsd.org> * @@ -155,7 +155,7 @@ cvs_release_local(struct cvs_file *cf) if (cvs_yesno() == -1) { (void)fprintf(stderr, - "** `%s' aborted by user choice.\n", cvs_command); + "** `%s' aborted by user choice.\n", cmdp->cmd_name); /* change back to original working dir */ cvs_chdir(wdir, 0); |