=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/init.c,v retrieving revision 1.20 retrieving revision 1.21 diff -c -r1.20 -r1.21 *** src/usr.bin/cvs/init.c 2006/01/02 08:11:56 1.20 --- src/usr.bin/cvs/init.c 2006/01/08 18:02:06 1.21 *************** *** 1,4 **** ! /* $OpenBSD: init.c,v 1.20 2006/01/02 08:11:56 xsa Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: init.c,v 1.21 2006/01/08 18:02:06 xsa Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. *************** *** 57,63 **** }; static int cvs_init_pre_exec(struct cvsroot *); ! static int cvs_init_create_files(struct cvsroot *); struct cvs_cmd cvs_cmd_init = { CVS_OP_INIT, CVS_REQ_INIT, "init", --- 57,63 ---- }; static int cvs_init_pre_exec(struct cvsroot *); ! static void cvs_init_create_files(struct cvsroot *); struct cvs_cmd cvs_cmd_init = { CVS_OP_INIT, CVS_REQ_INIT, "init", *************** *** 85,94 **** static int cvs_init_pre_exec(struct cvsroot *root) { ! if (root->cr_method == CVS_METHOD_LOCAL) { ! if (cvs_init_create_files(root) < 0) ! return (CVS_EX_FILE); ! } return (0); } --- 85,92 ---- static int cvs_init_pre_exec(struct cvsroot *root) { ! if (root->cr_method == CVS_METHOD_LOCAL) ! cvs_init_create_files(root); return (0); } *************** *** 101,107 **** * Returns 0 on success, -1 on failure. * */ ! static int cvs_init_create_files(struct cvsroot *root) { size_t len; --- 99,105 ---- * Returns 0 on success, -1 on failure. * */ ! static void cvs_init_create_files(struct cvsroot *root) { size_t len; *************** *** 115,123 **** if (mkdir(root->cr_dir, 0777) == -1) { if (!(errno == EEXIST || (errno == EACCES && (stat(root->cr_dir, &st) == 0) && S_ISDIR(st.st_mode)))) { ! cvs_log(LP_ERRNO, "cannot make directory %s", ! root->cr_dir); ! return (CVS_EX_FILE); } } --- 113,120 ---- if (mkdir(root->cr_dir, 0777) == -1) { if (!(errno == EEXIST || (errno == EACCES && (stat(root->cr_dir, &st) == 0) && S_ISDIR(st.st_mode)))) { ! fatal("cvs_init_create_files: mkdir: %s: %s", ! root->cr_dir, strerror(errno)); } } *************** *** 126,163 **** len = cvs_path_cat(root->cr_dir, cvsroot_files[i].cf_path, path, sizeof(path)); if (len >= sizeof(path)) ! return (-1); if (cvsroot_files[i].cf_type == CFT_DIR) { if (mkdir(path, cvsroot_files[i].cf_mode) == -1) { if (!(errno == EEXIST || (errno == EACCES && (stat(path, &st) == 0) && S_ISDIR(st.st_mode)))) { ! cvs_log(LP_ERRNO, ! "cannot make directory %s", path); ! return (CVS_EX_FILE); } } } else if (cvsroot_files[i].cf_type == CFT_FILE) { fd = open(path, O_WRONLY|O_CREAT|O_EXCL, cvsroot_files[i].cf_mode); ! if (fd == -1) { ! cvs_log(LP_ERRNO, "failed to create `%s'", ! path); ! return (CVS_EX_FILE); ! } (void)close(fd); strlcat(path, RCS_FILE_EXT, sizeof(path)); rfp = rcs_open(path, RCS_WRITE|RCS_CREATE, 0640); ! if (rfp == NULL) { ! return (CVS_EX_DATA); ! } rcs_close(rfp); } } - - return (0); } --- 123,154 ---- len = cvs_path_cat(root->cr_dir, cvsroot_files[i].cf_path, path, sizeof(path)); if (len >= sizeof(path)) ! fatal("cvs_init_create_files: path truncation"); if (cvsroot_files[i].cf_type == CFT_DIR) { if (mkdir(path, cvsroot_files[i].cf_mode) == -1) { if (!(errno == EEXIST || (errno == EACCES && (stat(path, &st) == 0) && S_ISDIR(st.st_mode)))) { ! fatal("cvs_init_create_files: mkdir: " ! "%s: %s", path, strerror(errno)); } } } else if (cvsroot_files[i].cf_type == CFT_FILE) { fd = open(path, O_WRONLY|O_CREAT|O_EXCL, cvsroot_files[i].cf_mode); ! if (fd == -1) ! fatal("cvs_init_create_file: open failed: %s", ! strerror(errno)); (void)close(fd); strlcat(path, RCS_FILE_EXT, sizeof(path)); rfp = rcs_open(path, RCS_WRITE|RCS_CREATE, 0640); ! if (rfp == NULL) ! return; rcs_close(rfp); } } }