diff options
author | 2005-05-24 03:06:16 +0000 | |
---|---|---|
committer | 2005-05-24 03:06:16 +0000 | |
commit | 60c5a2ee53486bf4ffc9d55d464dfeea1800d6a9 (patch) | |
tree | e6065750d98df4649e67574ab8a839a2d76abb44 | |
parent | typo (diff) | |
download | wireguard-openbsd-60c5a2ee53486bf4ffc9d55d464dfeea1800d6a9.tar.xz wireguard-openbsd-60c5a2ee53486bf4ffc9d55d464dfeea1800d6a9.zip |
create the target directory when we receive either of the
{Clear,Set}-{static-directory,sticky} responses
ok joris
-rw-r--r-- | usr.bin/cvs/resp.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/usr.bin/cvs/resp.c b/usr.bin/cvs/resp.c index 56f10ebd6f5..86199ddd4de 100644 --- a/usr.bin/cvs/resp.c +++ b/usr.bin/cvs/resp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resp.c,v 1.35 2005/05/20 19:58:03 xsa Exp $ */ +/* $OpenBSD: resp.c,v 1.36 2005/05/24 03:06:16 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -333,11 +333,22 @@ cvs_resp_statdir(struct cvsroot *root, int type, char *line) { int fd, len; char rpath[MAXPATHLEN], statpath[MAXPATHLEN]; + struct stat dst; /* remote directory line */ if (cvs_getln(root, rpath, sizeof(rpath)) < 0) return (-1); + STRIP_SLASH(line); + + /* if the directory doesn't exist, first create it */ + if ((stat(line, &dst) == -1) && (errno == ENOENT)) { + if (mkdir(line, 0755) == -1) { + cvs_log(LP_ERRNO, "failed to create %s", line); + return (-1); + } + } + len = snprintf(statpath, sizeof(statpath), "%s/%s", line, CVS_PATH_STATICENTRIES); if (len == -1 || len >= (int)sizeof(statpath)) { @@ -380,6 +391,7 @@ cvs_resp_sticky(struct cvsroot *root, int type, char *line) { char buf[MAXPATHLEN], subdir[MAXPATHLEN], *file; struct cvs_ent *ent; + struct stat dst; CVSFILE *cf, *sdir; CVSENTRIES *entf; @@ -389,6 +401,14 @@ cvs_resp_sticky(struct cvsroot *root, int type, char *line) STRIP_SLASH(line); + /* if the directory doesn't exist, first create it */ + if ((stat(line, &dst) == -1) && (errno == ENOENT)) { + if (mkdir(line, 0755) == -1) { + cvs_log(LP_ERRNO, "failed to create %s", line); + return (-1); + } + } + cvs_splitpath(line, subdir, sizeof(subdir), &file); sdir = cvs_file_find(cvs_files, subdir); if (sdir == NULL) { |