version 1.1, 2004/07/13 22:02:40 |
version 1.2, 2004/07/27 12:01:58 |
|
|
|
|
#include <md5.h> |
#include <md5.h> |
#include <errno.h> |
#include <errno.h> |
|
#include <fcntl.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
|
|
fp = fopen(repo_path, "r"); |
fp = fopen(repo_path, "r"); |
if (fp == NULL) { |
if (fp == NULL) { |
cvs_log(LP_ERRNO, "failed to open `%s'", repo_path); |
|
return (-1); |
return (-1); |
} |
} |
|
|
|
|
dst[--dlen] = '\0'; |
dst[--dlen] = '\0'; |
|
|
(void)fclose(fp); |
(void)fclose(fp); |
|
|
return (0); |
return (0); |
} |
} |
|
|
|
|
int |
int |
cvs_strtomode(const char *str, mode_t *mode) |
cvs_strtomode(const char *str, mode_t *mode) |
{ |
{ |
int type; |
char type; |
mode_t m; |
mode_t m; |
char buf[32], ms[4], *sp, *ep; |
char buf[32], ms[4], *sp, *ep; |
|
|
|
|
for (sp = buf; ep != NULL; sp = ep + 1) { |
for (sp = buf; ep != NULL; sp = ep + 1) { |
ep = strchr(sp, ','); |
ep = strchr(sp, ','); |
if (ep != NULL) |
if (ep != NULL) |
*(ep++) = '\0'; |
*ep = '\0'; |
|
|
if (sscanf(sp, "%c=%3s", (char *)&type, ms) != 2) { |
if (sscanf(sp, "%c=%3s", &type, ms) != 2) { |
cvs_log(LP_WARN, "failed to scan mode string `%s'", sp); |
cvs_log(LP_WARN, "failed to scan mode string `%s'", sp); |
continue; |
continue; |
} |
} |
|
|
|
|
for (i = 0; i < argc; i++) |
for (i = 0; i < argc; i++) |
free(argv[i]); |
free(argv[i]); |
|
} |
|
|
|
|
|
/* |
|
* cvs_mkadmin() |
|
* |
|
* Create the CVS administrative files within the directory <cdir>. |
|
* Returns 0 on success, or -1 on failure. |
|
*/ |
|
|
|
int |
|
cvs_mkadmin(struct cvs_file *cdir, mode_t mode) |
|
{ |
|
char path[MAXPATHLEN]; |
|
FILE *fp; |
|
CVSENTRIES *ef; |
|
struct cvsroot *root; |
|
|
|
snprintf(path, sizeof(path), "%s/" CVS_PATH_CVSDIR, cdir->cf_path); |
|
if (mkdir(path, mode) == -1) { |
|
cvs_log(LP_ERRNO, "failed to create directory %s", path); |
|
return (-1); |
|
} |
|
|
|
ef = cvs_ent_open(cdir->cf_path, O_WRONLY); |
|
(void)cvs_ent_close(ef); |
|
|
|
snprintf(path, sizeof(path), "%s/" CVS_PATH_ROOTSPEC, cdir->cf_path); |
|
fp = fopen(path, "w"); |
|
if (fp == NULL) { |
|
cvs_log(LP_ERRNO, "failed to open %s", path); |
|
return (-1); |
|
} |
|
root = cdir->cf_ddat->cd_root; |
|
if (root->cr_user != NULL) { |
|
fprintf(fp, "%s", root->cr_user); |
|
if (root->cr_pass != NULL) |
|
fprintf(fp, ":%s", root->cr_pass); |
|
if (root->cr_host != NULL) |
|
putc('@', fp); |
|
} |
|
|
|
if (root->cr_host != NULL) { |
|
fprintf(fp, "%s", root->cr_host); |
|
if (root->cr_dir != NULL) |
|
putc(':', fp); |
|
} |
|
if (root->cr_dir) |
|
fprintf(fp, "%s", root->cr_dir); |
|
(void)fclose(fp); |
|
|
|
if (cdir->cf_ddat->cd_repo != NULL) { |
|
snprintf(path, sizeof(path), "%s/" CVS_PATH_REPOSITORY, |
|
cdir->cf_path); |
|
fp = fopen(path, "w"); |
|
if (fp == NULL) { |
|
cvs_log(LP_ERRNO, "failed to open %s", path); |
|
return (-1); |
|
} |
|
fprintf(fp, "%s", cdir->cf_ddat->cd_repo); |
|
(void)fclose(fp); |
|
} |
|
|
|
|
|
return (0); |
} |
} |