summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoris <joris@openbsd.org>2006-05-27 18:18:06 +0000
committerjoris <joris@openbsd.org>2006-05-27 18:18:06 +0000
commitb8b35aa37cdd185974f5ec5c7af0addb2c0fab13 (patch)
tree5901224bc309e8430b8e67bad34719819e3fe63d
parentSystem calls return -1 upon failure, so check for -1 (diff)
downloadwireguard-openbsd-b8b35aa37cdd185974f5ec5c7af0addb2c0fab13.tar.xz
wireguard-openbsd-b8b35aa37cdd185974f5ec5c7af0addb2c0fab13.zip
lets be nice and abort cvs when we find out there is
no CVSROOT directory where there is suppose to be one.
-rw-r--r--usr.bin/cvs/cvs.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c
index 8f4400467a6..183aa6a01b4 100644
--- a/usr.bin/cvs/cvs.c
+++ b/usr.bin/cvs/cvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.c,v 1.99 2006/05/27 18:04:46 joris Exp $ */
+/* $OpenBSD: cvs.c,v 1.100 2006/05/27 18:18:06 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -115,6 +115,7 @@ main(int argc, char **argv)
struct cvs_cmd *cmdp;
struct passwd *pw;
struct stat st;
+ char fpath[MAXPATHLEN];
tzset();
@@ -226,6 +227,21 @@ main(int argc, char **argv)
if (current_cvsroot->cr_method != CVS_METHOD_LOCAL)
fatal("remote setups are not supported yet");
+ i = snprintf(fpath, sizeof(fpath), "%s/%s", current_cvsroot->cr_dir,
+ CVS_PATH_ROOT);
+ if (stat(fpath, &st) == -1) {
+ if (errno == ENOENT)
+ fatal("'%s' does not seem to be a valid repository",
+ current_cvsroot->cr_dir);
+ else
+ fatal("%s: %s", current_cvsroot->cr_dir,
+ strerror(errno));
+ } else {
+ if (!S_ISDIR(st.st_mode))
+ fatal("'%s' is not a directory",
+ current_cvsroot->cr_dir);
+ }
+
cvs_parse_configfile();
umask(cvs_umask);