cvs-nserver-commits Mailing List for CVS with rewritten network layer (Page 3)
Brought to you by:
tyranny
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(41) |
Sep
(69) |
Oct
(12) |
Nov
(35) |
Dec
(43) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(12) |
Feb
(19) |
Mar
(55) |
Apr
(25) |
May
(69) |
Jun
(33) |
Jul
(3) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2003 |
Jan
|
Feb
|
Mar
|
Apr
(35) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Alexey M. <mo...@us...> - 2002-06-20 17:12:29
|
Update of /cvsroot/cvs-nserver/cvs-nserver/src In directory usw-pr-cvs1:/tmp/cvs-serv8102 Modified Files: Tag: NCLI-1-11-1 lsacl.c Log Message: lsacl now gives output that can be parsed w/ AI :-) Index: lsacl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/src/Attic/lsacl.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -d -r1.1.2.5 -r1.1.2.6 --- lsacl.c 23 Mar 2002 15:30:23 -0000 1.1.2.5 +++ lsacl.c 20 Jun 2002 17:12:22 -0000 1.1.2.6 @@ -21,216 +21,176 @@ #include "acl.h" #include "lsacl.h" #include "recurse.h" +#include "default-file-acl.h" +#include "stringbuf.h" #include <stdlib.h> static int local_only = 1; -static int deep = 0; -static size_t skip_prefix = 0; -static char *tagname = NULL; - +static int with_contents = 0; +static const char *branch = "trunk"; +static int error_counter = 0; +static int parent_list = 1; +static int all_branches = 0; +static struct stringbuf *outputbuf = NULL; static const char *const lsacl_usage[] = { - "Usage: %s %s subdirectories...\n", - "\t-R\tRecursively list ACLs.\n", + "Usage: %s %s [-l | -R] [-r rev] [-c] modules...\n", + "\t-l\tLocal directory only, not recursive\n", + "\t-R\tProcess directories recursively.\n", + "\t-r rev\tList Branch ACLs for the specified branch.\n", + "\t-c\tInclude listing of ACL for directory contents.\n", NULL }; -static struct stringbuf * -get_fulldir (char* relative_name) -{ - struct stringbuf *fulldir = new_stringbuf(current_parsed_root->directory); - if (!fulldir) - return NULL; - - catc_stringbuf(fulldir, '/'); - cat_stringbuf(fulldir, relative_name); - - return fulldir; -} +#define THIS_DIR_PREFIX "D/" +#define THIS_FILE_PREFIX "/" +#define THIS_ACL_PREFIX "\tD/" +#define PARENT_ACL_PREFIX "\tD/" +#define DEFAULT_FILE_ACL_PREFIX "\tDB/" +#define BRANCH_ACL_PREFIX "\tB/" +#define FIELD_SEPARATOR "//" +#define RECORD_SEPARATOR "\n" +#ifndef PATH_SEPARATOR +# define PATH_SEPARATOR "/" +#endif -static void -forbidden_in (struct stringbuf* line, char* what, struct stringbuf* dirname) -{ - int saved_len = line->len; - cat_stringbuf(line, what); - cat_stringbuf(line, " forbidden in "); - cat_stringbuf(line, dirname->buf); - catc_stringbuf(line, '\n'); - cvs_output(line->buf, line->len); - shrink_stringbuf(line, saved_len); -} +typedef const char* (*FORMACLFUNC)(int); -static void -forbidden (struct stringbuf* line, char* what) -{ - int saved_len = line->len; - cat_stringbuf(line, what); - cat_stringbuf(line, " forbidden\n"); - cvs_output(line->buf, line->len); - shrink_stringbuf(line, saved_len); +/* + FIXME: this procedure is UNIX file name convention oriented. + Probably porting to other systems will require significant rewriting + :-/ +*/ +static char *get_canon_dir(const char *const repos, const char *const dir) { + char *result = NULL; + char *dirp; + int i,j; + if (dir==NULL || repos == NULL) + return NULL; + dirp = xstrdup(repos + strlen(current_parsed_root->directory)); + if (dirp == NULL) + return NULL; + for(i=0;dirp[i]=='/';i++); + for(j = strlen(dirp) - 1; j >= i && dirp[j] == '/'; j--); + if (i > j) { + result = xstrdup("."); + goto err; + } + + if ((result = malloc(j-i+2))==NULL) + goto err; + strncpy(result, dirp + i, j-i + 1); + result[j-i+1] = '\0'; + err: + free(dirp); + return result; } -enum topdirs_what { TOPDIRS_DIRECTORY, TOPDIRS_FILE }; -static void -print_out_topdir_acls (DIR_ACL** topdir_acls, enum topdirs_what what, char* filename, struct stringbuf* line) +static int +print_user_acls(const USER_ACL *user_acl, FORMACLFUNC form_acl_string, + const char *const prefix, + const char *const fname, const char *const branch) { - if (topdir_acls) { - for (; *topdir_acls; topdir_acls++) { - DIR_ACL* topdir_acl = *topdir_acls; - USER_ACL* user_acl = topdir_acl->user_acls; - - while (user_acl) { - int saved_len = line->len; - if (filename) { - cat_stringbuf(line, filename); - catc_stringbuf(line, '/'); - } - - cat_stringbuf(line, user_acl->username); - catc_stringbuf(line, '/'); - cat_stringbuf(line, "parent/"); - switch (what) { - case TOPDIRS_DIRECTORY: - if ((user_acl->perm & dir_perm_access) != dir_perm_access) - forbidden_in(line, "access", topdir_acl->dirname); - - if ((user_acl->perm & dir_perm_modify) != dir_perm_modify) - forbidden_in(line, "modify", topdir_acl->dirname); - break; - - case TOPDIRS_FILE: - if ((user_acl->perm & branch_perm_checkin) != branch_perm_checkin) - forbidden_in(line, "checkin", topdir_acl->dirname); - - if ((user_acl->perm & branch_perm_checkout) != branch_perm_checkout) - forbidden_in(line, "checkout", topdir_acl->dirname); - - break; - } - - shrink_stringbuf(line, saved_len); - user_acl = user_acl->next; - } + stringbuf *ptr = outputbuf; + int is_ok = 1; + for(;user_acl; user_acl = user_acl->next) { + ptr = cat_stringbuf(ptr, prefix); + ptr = cat_stringbuf(ptr, user_acl->username); + ptr = cat_stringbuf(ptr,FIELD_SEPARATOR); + ptr = cat_stringbuf(ptr, form_acl_string(user_acl->perm)); + ptr = cat_stringbuf(ptr, FIELD_SEPARATOR); + if (branch != NULL) { + ptr = cat_stringbuf(ptr, branch); + ptr = cat_stringbuf(ptr, FIELD_SEPARATOR); + } + ptr = cat_stringbuf(ptr,fname); + ptr = cat_stringbuf(ptr,RECORD_SEPARATOR); + if (ptr == NULL) { + shrink_stringbuf(outputbuf,0); + is_ok = 0; + //break; + } else { + cvs_output(outputbuf->buf,0); + shrink_stringbuf(outputbuf,0); } } + return is_ok; } static int -print_out_acls_for_file(char* relative_name, char* filename, char* dirname, char* branch) +print_default_branch_acls (const struct DEFAULT_FILE_ACL *acl, + FORMACLFUNC form_acl_string, + const char * const prefix) { - int retval = 0; - char* xbranch = branch ? branch : "trunk"; - struct stringbuf* line = NULL; - struct stringbuf* fullname = NULL; - struct DIR_ACL* diracl; - struct BRANCH_ACL* branch_acl; - struct BRANCH_ACE* file_ace; - - diracl = get_dir_acl(dirname, xbranch); - if (!diracl) - error(errno, 0, "Error getting directory ACLs for %s\n", dirname); - - line = new_stringbuf("/"); - if (!line) - goto err; - - cat_stringbuf(line, filename); - catc_stringbuf(line, '/'); - - print_out_topdir_acls(diracl->top_dirs, TOPDIRS_FILE, NULL, line); - - branch_acl = get_branch_acl(diracl, xbranch); - file_ace = get_file_on_branch_ace(branch_acl, filename); - if (file_ace) { - struct USER_ACL* user_acl = file_ace->user_acls; - while (user_acl) { - int saved_len = line->len; - - cat_stringbuf(line, user_acl->username); - cat_stringbuf(line, "/here/"); - - if ((user_acl->perm & branch_perm_checkin) != branch_perm_checkin) - forbidden(line, "checkin"); - - if ((user_acl->perm & branch_perm_checkout) != branch_perm_checkout) - forbidden(line, "checkout"); - - shrink_stringbuf(line, saved_len); - - user_acl = user_acl->next; + stringbuf *ptr = outputbuf; + int is_ok = 1; + for(;acl; acl = acl->next) { + USER_ACL *user_acl = acl->user_acl; + if (strcmp(acl->branch, branch) != 0) + continue; + for(;user_acl; user_acl = user_acl->next) { + ptr = cat_stringbuf(ptr, prefix); + ptr = cat_stringbuf(ptr, user_acl->username); + ptr = cat_stringbuf(ptr,FIELD_SEPARATOR); + ptr = cat_stringbuf(ptr, form_acl_string(user_acl->perm)); + ptr = cat_stringbuf(ptr, FIELD_SEPARATOR); + ptr = cat_stringbuf(ptr, acl->branch); + ptr = cat_stringbuf(ptr, RECORD_SEPARATOR); + if (ptr == NULL) { + shrink_stringbuf(outputbuf, 0); + is_ok = 0; + //goto out; + } else { + cvs_output(outputbuf->buf,0); + shrink_stringbuf(outputbuf,0); + } } } - - retval = 1; - err: - free_stringbuf(line); - return retval; + out: + return is_ok; } static int -print_out_acls_for_dir(char* relative_name, char* branch) +plain_lsacl_dirproc (const char *dir, const DIR_ACL *dir_acl) { - int retval = 0; - int saved_len; - struct stringbuf* fulldir = NULL; - struct stringbuf* line = NULL; - DIR_ACL* dir_acl = NULL; - USER_ACL* user_acl; - - fulldir = get_fulldir(relative_name); - if (!fulldir) - goto out; - - line = new_stringbuf("DP/"); - if (!line) - goto out; - saved_len = line->len; - - if (fulldir->buf[fulldir->len - 1] == '/') - fulldir->buf[fulldir->len - 1] = '\0'; - - dir_acl = get_dir_acl(fulldir->buf, branch); - if (!dir_acl) - goto out; - - /* print out permissions denied in one of the top directories */ - print_out_topdir_acls(dir_acl->top_dirs, TOPDIRS_DIRECTORY, NULL, line); - - /* print out permissions denied in this directory */ - user_acl = dir_acl->user_acls; - while (user_acl) { - int saved_len = line->len; - cat_stringbuf(line, user_acl->username); - cat_stringbuf(line, "/here/"); - if ((user_acl->perm & dir_perm_access) != dir_perm_access) - forbidden(line, "access"); - - if ((user_acl->perm & dir_perm_modify) != dir_perm_modify) - forbidden(line, "modify"); + size_t rootlen = strlen(current_parsed_root->directory); + struct stringbuf *ptr = outputbuf; - shrink_stringbuf(line, saved_len); - user_acl = user_acl->next; + ptr = cat_stringbuf(ptr, THIS_DIR_PREFIX); + ptr = cat_stringbuf(ptr, dir); + ptr = cat_stringbuf(ptr, RECORD_SEPARATOR); + if (ptr == NULL) { + error(0,0,"Out of memory"); + shrink_stringbuf(outputbuf,0); + return 0; } + cvs_output(outputbuf->buf,0); + shrink_stringbuf(outputbuf,0); - retval = 1; - out: - free_stringbuf(fulldir); - free_stringbuf(line); - return retval; -} - - -static int -lsacl_fileproc (void *callerdat, struct file_info *finfo) -{ - print_out_acls_for_file(finfo->fullname, finfo->file, finfo->repository, tagname); - - return 0; + if (parent_list && dir_acl->top_dirs) { + DIR_ACL **topdir; + for(topdir = dir_acl->top_dirs; *topdir; topdir++) { + char *pdir = get_canon_dir((*topdir)->dirname->buf, (*topdir)->dirname->buf + rootlen); + if (pdir == NULL) { + error(0,0,"Out of memory"); + return 0; + } + print_user_acls((*topdir)->user_acls, dir_permissions_string, + PARENT_ACL_PREFIX, pdir, NULL); + free(pdir); + } + } + print_user_acls(dir_acl->user_acls, dir_permissions_string, + THIS_ACL_PREFIX,"",NULL); + print_default_branch_acls(dir_acl->default_file_acl, + branch_permissions_string, + DEFAULT_FILE_ACL_PREFIX); + return 1; } /* ARGSUSED */ @@ -242,37 +202,128 @@ char *update_dir; List *entries; { - /* Should we go this way? AM */ + DIR_ACL *dir_acl = NULL; + char *canon_dir = NULL; + dir_permission dir_perm = dir_perm_all; + int is_error = 0; + + if ((canon_dir = get_canon_dir(repository, update_dir))==NULL) { + error(0, 0, "Out of memory"); + error_counter++; + return R_SKIP_ALL; + } #ifdef SERVER_SUPPORT - int grant = grant_dir_permission(repository, dir, dir_perm_access, "list"); -#else - int grant = 1; + if ((dir_acl = get_dir_acl(repository,branch)) == NULL) { + error(0, errno, "Error getting directory ACL for '%s'", canon_dir); + is_error = 1; + goto err; + } + dir_perm = dir_permission_granted(dir_acl,CVS_Username,dir_perm_access); + if (!(dir_perm & dir_perm_access)) { + error(0,0,"ACL list permission denied for %s in '%s'", + CVS_Username, canon_dir); + is_error = 1; + goto err; + } #endif - if (deep > 0) { - cvs_output("D", 1); + is_error = !plain_lsacl_dirproc(canon_dir, dir_acl); + err: + destroy_dir_acl(dir_acl); + free(canon_dir); + if (is_error) { + error_counter++; + return R_SKIP_ALL; + } else { + return ((with_contents) ? R_PROCESS : R_SKIP_ALL); + } +} - if (!skip_prefix) - cvs_output("/",1); - - /* Is it really safe. I mean is 'update_dir' is always - * startdir + smth? - */ - cvs_output(update_dir + skip_prefix, 0); - if (!grant) - cvs_output("//locked",0); - cvs_output("\n", 1); +static int +plain_lsacl_fileproc(const char *const dir, struct file_info *finfo, + struct BRANCH_ACE *ace) +{ + size_t rootlen = strlen(current_parsed_root->directory); + struct stringbuf *ptr = outputbuf; + + ptr = cat_stringbuf(ptr, THIS_FILE_PREFIX); + ptr = cat_stringbuf(ptr, dir); + ptr = cat_stringbuf(ptr, PATH_SEPARATOR); + ptr = cat_stringbuf(ptr, finfo->file); + ptr = cat_stringbuf(ptr, RECORD_SEPARATOR); + if (ptr == NULL) { + error(0,0,"Out of memory"); + shrink_stringbuf(outputbuf,0); + return 0; } - deep++; - print_out_acls_for_dir(update_dir, tagname); + cvs_output(outputbuf->buf,0); + shrink_stringbuf(outputbuf,0); -#ifdef SERVER_SUPPORT - if (!grant) - return R_SKIP_ALL; -#endif - if (local_only && deep > 1) - return R_SKIP_ALL; - return R_PROCESS; + /* Print inherited ACLs */ + if (parent_list && ace->acl && ace->acl->dir_acl) { + if (ace->acl->dir_acl->top_dirs) { + DIR_ACL **topdir; + for(topdir = ace->acl->dir_acl->top_dirs; *topdir; topdir++) { + char *pdir = get_canon_dir((*topdir)->dirname->buf, (*topdir)->dirname->buf + rootlen); + if (pdir == NULL) { + error(0,0,"Out of memory"); + return 0; + } + print_user_acls((*topdir)->user_acls, dir_permissions_string, + PARENT_ACL_PREFIX, pdir, NULL); + free(pdir); + } + } + print_user_acls(ace->acl->dir_acl->user_acls, dir_permissions_string, + PARENT_ACL_PREFIX,dir,NULL); + print_default_branch_acls(ace->acl->dir_acl->default_file_acl, + branch_permissions_string, + DEFAULT_FILE_ACL_PREFIX); + } + print_user_acls(ace->user_acls, branch_permissions_string, + BRANCH_ACL_PREFIX,"",branch); + return 1; +} + +static int +lsacl_fileproc (void *callerdat, struct file_info *finfo) +{ + DIR_ACL *dir_acl = NULL; + BRANCH_ACL *branch_acl = NULL; + BRANCH_ACE *branch_ace = NULL; + char *canon_dir = NULL; + int is_error = 0; + + if ((canon_dir=get_canon_dir(finfo->repository,finfo->update_dir))==NULL) { + error(0, errno, "Out of memory"); + is_error = 1; + goto err; + } + if ((dir_acl = get_dir_acl(finfo->repository,branch)) == NULL) { + error(0, errno, + "Error getting directory ACL for '%s'", canon_dir); + is_error = 1; + goto err; + } + if ((branch_acl = get_branch_acl(dir_acl,branch))==NULL) { + error(0, errno, + "Error getting branch ACL for '%s'", canon_dir); + is_error = 1; + goto err; + } + if ((branch_ace = get_file_on_branch_ace(branch_acl,finfo->file))==NULL) { + error(0, errno, + "Error getting file ACE for '%s/%s'", canon_dir,finfo->file); + is_error = 1; + goto err; + } + is_error = !plain_lsacl_fileproc(canon_dir, finfo, branch_ace); + err: + free(canon_dir); + /* Place destroy_branch_acl and destroy_branch_ace when + appropriate function will be ready */ + destroy_dir_acl(dir_acl); + return ((is_error) ? 1 : 0); } static int @@ -280,31 +331,91 @@ char *mwhere, char *mfile, int shorten, int local, char *mname, char *msg) { + char *myargv[2]; int err = 0; int which = W_REPOS | W_ATTIC; - struct stringbuf* repository; + + struct stringbuf *repository = NULL; + struct stringbuf *rptr = NULL; - skip_prefix = (strcmp(".",argv[1])) ? strlen(argv[1]) : 0; + struct stringbuf *where; + struct stringbuf *wptr; + outputbuf = NULL; repository = new_stringbuf(current_parsed_root->directory); + rptr = catc_stringbuf(repository, '/'); + rptr = cat_stringbuf(rptr, argv[0]); + + where = new_stringbuf(argv[0]); + wptr = where; - if (CVS_CHDIR(repository->buf) < 0) { + if (rptr == NULL || wptr == NULL) { + error(0, 0, "Not enough memory for repository stringbuf"); err = 1; - goto out; + goto err; } + + + /* if mfile isn't null, we need to set up to do only part of the module */ + if (mfile != NULL) + { + + rptr = catc_stringbuf(rptr, '/'); + rptr = cat_stringbuf(rptr,mfile); + wptr = catc_stringbuf(wptr, '/'); + wptr = cat_stringbuf(wptr, mfile); + if (rptr == NULL || wptr == NULL) { + error(0, errno, "Not enough memory for repository stringbuf"); + err = 1; + goto err; + } - deep = 0; - local = 0; /* we always use recursion mode, 'cause we anyway need - subdirectores listing - */ - err = start_recursion (lsacl_fileproc, (FILESDONEPROC) NULL, lsacl_dirproc, - (DIRLEAVEPROC) NULL, (void *) NULL, - argc - 1, argv + 1, local, which, 0, 1, - "", 1); + if (!isdir(repository->buf)) { + /* Hmm... It's a file. we have to cut off its + * basename from repository... */ + size_t mflen; + char *sp = strrchr(mfile, '/'); + if (sp != NULL) + mfile = sp + 1; + mflen = strlen(mfile); + repository->buf[repository->len - mflen - 1] = '\0'; + repository->len -= (mflen + 1); + where->buf[where->len - mflen - 1] = '\0'; + where->len -= (mflen + 1); - out: - free_stringbuf(repository); - return err; + /* copied from patch.c w/o checking if this really way to + go :-) */ + myargv[0] = argv[0]; + myargv[1] = mfile; + argc = 2; + argv = myargv; + } + } + + /* cd to the starting repository */ + if ( CVS_CHDIR (repository->buf) < 0) { + error(0, errno, "Error changing working directory to %s", + repository->buf); + err = 1; + goto err; + } + outputbuf = new_stringbuf(""); + if (outputbuf == NULL) { + error(0, errno, "Not enough memory for output stringbuf"); + err = 1; + goto err; + } + + /* start the recursion processor */ + err = start_recursion (lsacl_fileproc,(FILESDONEPROC) NULL, + lsacl_dirproc, (DIRLEAVEPROC) NULL, + (void*)msg, argc - 1, argv + 1, local_only, + which, 0, 1, where->buf, 1); + err: + free_stringbuf(where); where = NULL; + free_stringbuf(repository); repository = NULL; + free_stringbuf(outputbuf); outputbuf = NULL; + return (err); } @@ -313,33 +424,31 @@ { int err = 0; int i; - - for (i = 0; i < argc; i++) { - err += lsacl_proc (argc + 1, argv - 1, (char *) NULL, - (char *) NULL, (char *) NULL, 0, local_only, (char *) NULL, - (char *) NULL); - } - return err; -} - -int -lsacl (int argc, char** argv) -{ int c; + DBM *db; + + argv++; /* skip 'cvs server' */ + /* argv++; */ /* Due to the bug of getopt(3) we don't need to + skip 'racl' */ + argc--; optind = 0; - while ((c = getopt (argc, argv, "Rr:")) != -1) + while ((c = getopt (argc, argv, "clRr:")) != -1) { switch (c) { case 'R': local_only = 0; break; - + case 'l': + local_only = 1; + break; + case 'c': + with_contents = 1; + break; case 'r': - tagname = xstrdup(optarg); + branch = xstrdup(optarg); break; - default: usage(lsacl_usage); break; @@ -349,32 +458,55 @@ argc -= optind; argv += optind; + if (argc < 1 || !(*argv[0])) usage (lsacl_usage); - -#ifdef CLIENT_SUPPORT - if (current_parsed_root->isremote) { - int i; + error_counter = 0; + db = open_module (); + for (i = 0; i < argc; i++) + err += do_module (db, argv[i], MISC, (char *) NULL, lsacl_proc, + (char *) NULL, 0, local_only, 0, 0, (char*) NULL); + close_module (db); + return err + error_counter; +} - start_server(); +#ifdef CLIENT_SUPPORT +static int client_side_lsacl(int argc, char **argv) { + int i; + start_server(); - ign_setup(); + ign_setup(); - if (!local_only) - send_to_server ("Argument -R\012", 0); + if (!supported_request ("lsacl")) + error (1, 0, "server does not support lsacl"); - if (tagname != NULL) - option_with_arg ("-r", tagname); + for (i = 0; i < argc; i++) { + send_arg(argv[i]); + } - for (i = 0; i < argc; i++) - send_arg (argv[i]); + send_to_server ("lsacl\012", 0); - send_to_server("lsacl\012", 0); + return get_responses_and_close(); +} +#endif - return get_responses_and_close(); - } -#endif /* CLIENT_SUPPORT */ +int +lsacl (int argc, char** argv) +{ + if (argc == -1) + usage(lsacl_usage); + +#ifdef SERVER_SUPPORT + if (server_active) + return server_side_lsacl(argc, argv); +#endif - return server_side_lsacl(argc, argv); +#ifdef CLIENT_SUPPORT + if (current_parsed_root->isremote) + return client_side_lsacl(argc, argv); +#endif + return 0; } + + |
From: Alexey M. <mo...@us...> - 2002-06-20 16:53:57
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv2518 Modified Files: Tag: NCLI-1-11-1 branch-acl.c Log Message: After long and hot discussion w/ Alex falling back to direct permissions manipulations :-) Index: branch-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/branch-acl.c,v retrieving revision 1.1.2.20 retrieving revision 1.1.2.21 diff -u -d -r1.1.2.20 -r1.1.2.21 --- branch-acl.c 20 Jun 2002 15:55:43 -0000 1.1.2.20 +++ branch-acl.c 20 Jun 2002 16:53:53 -0000 1.1.2.21 @@ -229,32 +229,20 @@ return perm; } -static const char *BRANCH_PERM_NONE_STRING = "none"; -static const char *BRANCH_PERM_CHECKOUT_STRING = "checkout"; -static const char *BRANCH_PERM_CHECKOUT_ALIAS = "co"; -static const char *BRANCH_PERM_CHECKIN_STRING = "checkin"; -static const char *BRANCH_PERM_CHECKIN_ALIAS = "ci"; -static const char *BRANCH_PERM_CHECKOUTIN_STRING = "checkout,checkin"; -static const char *BRANCH_PERM_INVALID_STRING = "invalid"; - int parse_branch_permissions (char *perm_str) { size_t len; branch_permission res = branch_perm_none; - if (strcmp(perm_str, BRANCH_PERM_NONE_STRING) == 0) + if (strcmp(perm_str, "none") == 0) return branch_perm_none; - if (strncmp(perm_str, BRANCH_PERM_CHECKOUT_STRING, - (len = strlen(BRANCH_PERM_CHECKOUT_STRING))) == 0 || - strncmp(perm_str, BRANCH_PERM_CHECKOUT_ALIAS, - (len = strlen(BRANCH_PERM_CHECKOUT_ALIAS)))==0) + if (strncmp(perm_str, "checkout", (len = strlen("checkout"))) == 0 || + strncmp(perm_str, "co", (len = strlen("co")))==0) res |= branch_perm_checkout; - else if (strncmp(perm_str, BRANCH_PERM_CHECKIN_STRING, - (len = strlen(BRANCH_PERM_CHECKIN_STRING))) == 0 || - strncmp(perm_str, BRANCH_PERM_CHECKIN_ALIAS, - (len = strlen(BRANCH_PERM_CHECKIN_ALIAS)))==0) + else if (strncmp(perm_str, "checkin", (len = strlen("checkin"))) == 0 || + strncmp(perm_str, "ci", (len = strlen("ci")))==0) res |= branch_perm_checkin; else return branch_perm_invalid; @@ -268,12 +256,10 @@ perm_str++; if ((!(res & branch_perm_checkout)) && - (strcmp(perm_str, BRANCH_PERM_CHECKOUT_STRING) == 0 || - strcmp(perm_str, BRANCH_PERM_CHECKOUT_ALIAS)==0)) + (strcmp(perm_str, "checkout") == 0 || strcmp(perm_str, "co")==0)) res |= branch_perm_checkout; else if ((!(res & branch_perm_checkin)) && - (strcmp(perm_str, BRANCH_PERM_CHECKIN_STRING) == 0 || - strcmp(perm_str, BRANCH_PERM_CHECKIN_ALIAS)==0)) + (strcmp(perm_str, "checkin") == 0 || strcmp(perm_str, "ci")==0)) res |= branch_perm_checkin; else return branch_perm_invalid; @@ -285,17 +271,17 @@ branch_permissions_string (int perm) { if (perm == branch_perm_none) - return BRANCH_PERM_NONE_STRING; + return "none"; if (perm == branch_perm_checkin) - return BRANCH_PERM_CHECKIN_STRING; + return "checkin"; if (perm == branch_perm_checkout) - return BRANCH_PERM_CHECKOUT_STRING; + return "checkout"; if (perm == (branch_perm_checkin | branch_perm_checkout)) - return BRANCH_PERM_CHECKOUTIN_STRING; + return "checkout,checkin"; - return BRANCH_PERM_INVALID_STRING; + return "invalid"; } |
From: Alexey M. <mo...@us...> - 2002-06-20 15:55:51
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv18317 Modified Files: Tag: NCLI-1-11-1 branch-acl.c Log Message: File permission aliases ('ci','co') are understood now Index: branch-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/branch-acl.c,v retrieving revision 1.1.2.19 retrieving revision 1.1.2.20 diff -u -d -r1.1.2.19 -r1.1.2.20 --- branch-acl.c 13 Jun 2002 09:20:44 -0000 1.1.2.19 +++ branch-acl.c 20 Jun 2002 15:55:43 -0000 1.1.2.20 @@ -229,43 +229,73 @@ return perm; } +static const char *BRANCH_PERM_NONE_STRING = "none"; +static const char *BRANCH_PERM_CHECKOUT_STRING = "checkout"; +static const char *BRANCH_PERM_CHECKOUT_ALIAS = "co"; +static const char *BRANCH_PERM_CHECKIN_STRING = "checkin"; +static const char *BRANCH_PERM_CHECKIN_ALIAS = "ci"; +static const char *BRANCH_PERM_CHECKOUTIN_STRING = "checkout,checkin"; +static const char *BRANCH_PERM_INVALID_STRING = "invalid"; + int parse_branch_permissions (char *perm_str) { + size_t len; + branch_permission res = branch_perm_none; - if (strcmp(perm_str, "checkin") == 0) - return branch_perm_checkin; - - if (strcmp(perm_str, "checkout") == 0) - return branch_perm_checkout; - - if (strcmp(perm_str, "checkin,checkout") == 0) - return branch_perm_checkin | branch_perm_checkout; + if (strcmp(perm_str, BRANCH_PERM_NONE_STRING) == 0) + return branch_perm_none; + + if (strncmp(perm_str, BRANCH_PERM_CHECKOUT_STRING, + (len = strlen(BRANCH_PERM_CHECKOUT_STRING))) == 0 || + strncmp(perm_str, BRANCH_PERM_CHECKOUT_ALIAS, + (len = strlen(BRANCH_PERM_CHECKOUT_ALIAS)))==0) + res |= branch_perm_checkout; + else if (strncmp(perm_str, BRANCH_PERM_CHECKIN_STRING, + (len = strlen(BRANCH_PERM_CHECKIN_STRING))) == 0 || + strncmp(perm_str, BRANCH_PERM_CHECKIN_ALIAS, + (len = strlen(BRANCH_PERM_CHECKIN_ALIAS)))==0) + res |= branch_perm_checkin; + else + return branch_perm_invalid; - if (strcmp(perm_str, "checkout,checkin") == 0) - return branch_perm_checkin | branch_perm_checkout; + perm_str += len; - if (strcmp(perm_str, "none") == 0) - return branch_perm_none; + if (*perm_str == '\0') + return res; + if (*perm_str != ',') + return branch_perm_invalid; + perm_str++; - return branch_perm_invalid; + if ((!(res & branch_perm_checkout)) && + (strcmp(perm_str, BRANCH_PERM_CHECKOUT_STRING) == 0 || + strcmp(perm_str, BRANCH_PERM_CHECKOUT_ALIAS)==0)) + res |= branch_perm_checkout; + else if ((!(res & branch_perm_checkin)) && + (strcmp(perm_str, BRANCH_PERM_CHECKIN_STRING) == 0 || + strcmp(perm_str, BRANCH_PERM_CHECKIN_ALIAS)==0)) + res |= branch_perm_checkin; + else + return branch_perm_invalid; + + return res; } const char * branch_permissions_string (int perm) { if (perm == branch_perm_none) - return "none"; + return BRANCH_PERM_NONE_STRING; if (perm == branch_perm_checkin) - return "checkin"; + return BRANCH_PERM_CHECKIN_STRING; if (perm == branch_perm_checkout) - return "checkout"; + return BRANCH_PERM_CHECKOUT_STRING; if (perm == (branch_perm_checkin | branch_perm_checkout)) - return "checkin,checkout"; + return BRANCH_PERM_CHECKOUTIN_STRING; - return "invalid"; + return BRANCH_PERM_INVALID_STRING; } |
From: Alexey M. <mo...@us...> - 2002-06-19 07:34:56
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv1726 Modified Files: Tag: NCLI-1-11-1 dir-acl.c Log Message: BUGFIX: it seems I fixed the 'doubling DIR_ACL bug in add_dir_acl_topdirs BUGFIX: and basic tests are Ok, but more accurate and formal testing required Index: dir-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.c,v retrieving revision 1.1.2.25 retrieving revision 1.1.2.26 diff -u -d -r1.1.2.25 -r1.1.2.26 --- dir-acl.c 13 Jun 2002 13:44:33 -0000 1.1.2.25 +++ dir-acl.c 19 Jun 2002 07:34:43 -0000 1.1.2.26 @@ -130,14 +130,14 @@ } static struct DIR_ACL *create_and_load_dir_acl (const char *dir); -static struct DIR_ACL *add_dir_acl_topdirs (char *dir, struct DIR_ACL *the_dir_acl); +static struct DIR_ACL *add_dir_acl_topdirs (const char * const dir, + struct DIR_ACL *the_dir_acl); struct DIR_ACL * get_dir_acl (const char *dir, const char *branch) { struct DIR_ACL *dir_acl = NULL; - char *dir_copy = NULL; size_t tldlen = strlen(current_toplevel_directory); size_t dirlen = strlen(dir); @@ -146,37 +146,22 @@ current_toplevel_directory itself, its length is less than length of the current_toplevel_directory because of trailing slash. Handle this case sui generis.... - */ + */ if (!(((tldlen == (dirlen+1)) && (current_toplevel_directory[tldlen-1] == '/') && (strncmp(dir,current_toplevel_directory,dirlen) == 0)) || (strncmp(dir, current_toplevel_directory,tldlen) == 0))) { /* error(0,0,"Trying to access Dir ACL in '%s' outside of '%s'", dir,current_toplevel_directory); */ - goto out; + return NULL; } dir_acl = create_and_load_dir_acl(dir); - if (!dir_acl) - goto err; - - /* add_dir_acl_topdirs() will modify its first argument */ - dir_copy = strdup(dir); - if (dir_copy == NULL) - goto err; - - if (!add_dir_acl_topdirs(dir_copy, dir_acl)) - goto err; - - out: - free(dir_copy); - + if (dir_acl == NULL || add_dir_acl_topdirs(dir,dir_acl)==NULL) { + destroy_dir_acl(dir_acl); + dir_acl = NULL; + } return dir_acl; - - err: - destroy_dir_acl(dir_acl); - dir_acl = NULL; - goto out; } @@ -228,41 +213,64 @@ */ static struct DIR_ACL * -add_dir_acl_topdirs (char *dir, struct DIR_ACL *the_dir_acl) +add_dir_acl_topdirs (const char * const dir, struct DIR_ACL *the_dir_acl) { - int toplevel_len = strlen(current_toplevel_directory); - char *last_component; - - /* FIXME: somehow the parent directory gets added twice. It is - harmless, but needs investigation */ - - last_component = strrchr(dir + toplevel_len, '/'); - if (last_component == NULL) { - /* we are processing the top dir */ - struct DIR_ACL *topdir_acl = create_and_load_dir_acl(dir); - if (!topdir_acl) - return NULL; - - if (!add_dir_to_path(the_dir_acl, topdir_acl)) - return NULL; - - } else { - /* we need to strip the last component and try to get its top dir */ - struct DIR_ACL *this_dir_acl; - *last_component = '\0'; - this_dir_acl = create_and_load_dir_acl(dir); - if (!this_dir_acl) - return NULL; - - if (!add_dir_to_path(the_dir_acl, this_dir_acl)) - return NULL; + size_t tldlen = strlen(current_toplevel_directory); + size_t dirlen = strlen(dir); + char *dircopy; + char *dirp; + char *ptr; + int is_error = 0; + + if ((dirlen + 1 == tldlen || dirlen == tldlen) && + strncmp(dir,current_toplevel_directory,dirlen)==0) { + /* The special case, it's a top level directory itself */ + return the_dir_acl; + } + + if (tldlen > dirlen || + strncmp(dir,current_toplevel_directory, tldlen)!=0) { + /* The bad invocation, the directory asked is not a + subdir inside current_toplevel_directory + */ + /* error(0,0,"Directory '%s' is outside of '%s'", + dir,current_toplevel_directory); */ + return NULL; + } - if (!add_dir_acl_topdirs(dir, the_dir_acl)) - return NULL; + dircopy = strdup(dir); + if (dircopy == NULL) { + /* error(0,0,"Out of memory"); */ + return NULL; + } + + if (dircopy[dirlen-1]=='/') + dircopy[dirlen-1]='\0'; - *last_component = '/'; + dirp = dircopy + tldlen - 1; + + while((ptr = strchr(dirp,'/'))!= NULL) { + DIR_ACL *topdir_acl = NULL; + *ptr = '\0'; + topdir_acl = create_and_load_dir_acl(dircopy); + if (topdir_acl == NULL) { + is_error = 1; + break; + } + if (!add_dir_to_path(the_dir_acl, topdir_acl)) { + destroy_dir_acl(topdir_acl); + is_error = 1; + break; + } + *ptr = '/'; + dirp = ptr + 1; } - return the_dir_acl; + /* We don't to process the last component as its already + * processed */ + + free(dircopy); + + return ((is_error) ? NULL : the_dir_acl); } @@ -560,12 +568,10 @@ USER_ACE* ace; enum DIR_PERM eff_perm = dir_perm_all; int user_was_mentioned_in_acl = 0; - if (dir_acl->top_dirs) { for (top_dirs = dir_acl->top_dirs; *top_dirs; top_dirs++) { struct DIR_ACL* parent_acl = *top_dirs; USER_ACE* ace; - /* restrict current parent permissions */ ace = get_user_ace(parent_acl->user_acls, username); if (ace != NULL) { |
From: Alexey M. <mo...@us...> - 2002-06-13 13:44:42
|
Update of /cvsroot/cvs-nserver/cvs-nserver/src In directory usw-pr-cvs1:/tmp/cvs-serv18537/src Modified Files: Tag: NCLI-1-11-1 racl.c Log Message: Dir/Branch management (old semantics) implemented for racl subcommand Index: racl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/src/Attic/racl.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -d -r1.1.2.5 -r1.1.2.6 --- racl.c 25 May 2002 20:57:03 -0000 1.1.2.5 +++ racl.c 13 Jun 2002 13:44:33 -0000 1.1.2.6 @@ -9,7 +9,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - Copyright (c) Alexey Mahotkin <al...@hs...> 2001 + Copyright (c) Alexey Mahotkin <al...@hs...> 2001-2002 + Alexey Morozov <mo...@no...>, + Novosoft, Inc, 2002 "cvs racl" subcommand manages ACL directly to repository @@ -21,16 +23,21 @@ #include "acl.h" #include "acl-admins.h" +#include "default-file-acl.h" #include "module-acl.h" #include "repository.h" +#include "audit-log.h" +#include "recurse.h" +#ifdef HAVE_ERRNO_H #include <errno.h> +#endif #include <stdlib.h> static const char *const racl_usage[] = { - "Usage: cvs racl [-r BRANCH] [grant|revoke] USER PERMISSION modules...\n", + "Usage: cvs racl [-r BRANCH] [-t] [grant|revoke] USER PERMISSION modules...\n", "\tPERMISSION could be one of those:\n", "\t\ttag\t\tAllow creating tags\n", "\t\ttag:PREFIX\tAllow tags whose names start with PREFIX\n", @@ -39,27 +46,371 @@ NULL }; +static const char *branch = "trunk"; + + #ifdef SERVER_SUPPORT static void +tag_module_racl(int argc, char **argv, char *username, + char *prefix, int isgrant, int isbranch) +{ + struct REPOSITORY *repos; + + repos = get_repository(current_parsed_root->directory); + + while (*argv) { + char *module = *argv; + struct MODULE_ACL *mod_acl = get_module_acl(repos, module); + + if (isgrant) { + if (!grant_module_tagging(mod_acl, username, prefix)) + error(1, errno, "Error granting tag permission to %s for %s", + username, module); + } else { + if (!revoke_module_tagging(mod_acl, username, prefix)) + error(1, errno, "Error revoking tag permission to %s for %s", + username, module); + } + argv++; + argc--; + } + + if (!save_module_acl(repos)) + error(1, errno, "Error saving module ACLS: %s", strerror(errno)); + free_repository(repos); +} + +static dir_permission dir_perm = dir_perm_invalid; +static branch_permission branch_perm = branch_perm_invalid; +static int is_set_default_file_acl = 0; +static int error_counter = 0; + +static Dtype +access_dirproc (username, dir, repository, update_dir, entries) + void *username; + char *dir; + char *repository; + char *update_dir; + List *entries; +{ + DIR_ACL *dir_acl = NULL; + + if ((dir_acl = get_dir_acl(repository, branch))==NULL) { + error(0, errno, "Error getting Dir ACL for %s", repository); + error_counter++; + return R_PROCESS; + }; + + if (is_set_default_file_acl) { + /* BUG BUG BUG... We shouldn't check if resulting permission + * is exactly requested permission + */ + if ((set_default_file_acl(dir_acl, branch, (char*)username, branch_perm) != branch_perm)) { + error(0, 0, "Error setting default file permission '%s' for '%s' on directory %s", + branch_permissions_string(branch_perm), (char*)username, update_dir); + error_counter++; + goto out; + } + error(0, 0, "Setting default file permissions '%s' for '%s' on directory %s\n", + branch_permissions_string(branch_perm),(char*)username, update_dir); + } + else { + /* Just in case we was asked to change only file permissions */ + if (dir_perm == dir_perm_invalid) + goto out; + + /* BUG BUG BUG (the same as above. I should consult Alex */ + if (set_dir_ace(dir_acl, username, dir_perm) != dir_perm) { + error(0, 0, "Error setting '%s' permissions for '%s' on directory %s", + dir_permissions_string(dir_perm), (char*)username, update_dir); + error_counter++; + goto out; + } + error(0, 0, "Setting '%s' permissions for '%s' on directory %s\n", + dir_permissions_string(dir_perm), (char*)username, update_dir); + } + if (store_dir_acl(dir_acl) != 0) { + error(0, 0, "Error storing permissions on directory %s", update_dir); + goto out; + } + + /* log this operation */ + if (audit_log_active()) { + if (!start_audit_log_line("racl")) { + error(1, 0, "Out of memory"); + } + append_audit_log_line("grant"); + if (is_set_default_file_acl) { + append_audit_log_line("default-file"); + append_audit_log_line(branch_permissions_string(branch_perm)); + } else { + append_audit_log_line("dir"); + append_audit_log_line(dir_permissions_string(dir_perm)); + } + append_audit_log_line(update_dir); + append_audit_log_line((char*)username); + append_audit_log_line(branch); + log_audit_event(); + } + out: + destroy_dir_acl(dir_acl); + return R_PROCESS; +} + + +static int +access_fileproc (void *username, struct file_info *finfo) +{ + struct DIR_ACL *dir_acl = NULL; + struct BRANCH_ACL *branch_acl = NULL; + struct BRANCH_ACE *branch_ace = NULL; + int err = 0; + + dir_acl = get_dir_acl(finfo->repository, "trunk"); + if (dir_acl == NULL) { + error(0, errno, + "Error getting directory ACL for %s", finfo->update_dir); + return 1; + } + + branch_acl = get_branch_acl(dir_acl, branch); + if (branch_acl == NULL) { + error(0, errno, "Error getting branch ACL for %s", finfo->update_dir); + err = 1; + goto err; + } + + branch_ace = get_file_on_branch_ace(branch_acl, finfo->file); + if (branch_ace == NULL) { + error(0, errno, "Error getting file ACE for %s",finfo->fullname); + err = 1; + goto err; + } + + set_branch_ace(branch_ace, (char*)username, branch_perm); + + if (!store_branch_acls(dir_acl)) { + error(0, errno, "Error storing branch ACLs for %s",finfo->update_dir); + err = 1; + goto err; + } + + /* log this operation */ + if (audit_log_active()) { + if (!start_audit_log_line("racl")) { + error(1, 0, "Out of memory"); + /* It's senseless 'cause error called this way terminates cvs + * but in case we'll eventually make a proper lib... + */ + err = 1; + goto err; + } + append_audit_log_line("grant"); + append_audit_log_line("branch"); + append_audit_log_line(branch_permissions_string(branch_perm)); + append_audit_log_line(finfo->update_dir); + append_audit_log_line(finfo->file); + append_audit_log_line((char*)username); + append_audit_log_line(branch); + log_audit_event(); + } + + error(0, 0, "Setting '%s' permissions for '%s' on file %s\n", + branch_permissions_string(branch_perm), (char*)username, + finfo->fullname); + err: + destroy_dir_acl(dir_acl); + return err; +} + +static int +access_proc (argc, argv, xwhere, mwhere, mfile, shorten, local, mname, username) + int argc; + char **argv; + char *xwhere; + char *mwhere; + char *mfile; + int shorten; + int local; + char *mname; + char *username; +{ + char *myargv[2]; + int err = 0; + int which = W_REPOS | W_ATTIC; + +/* char *repository; */ +/* char *where; */ + + struct stringbuf *repository = NULL; + struct stringbuf *rptr = NULL; + + struct stringbuf *where; + struct stringbuf *wptr; + + FILEPROC fileproc; + DIRENTPROC dirproc; + + repository = new_stringbuf(current_parsed_root->directory); + rptr = catc_stringbuf(repository, '/'); + rptr = cat_stringbuf(rptr, argv[0]); + + where = new_stringbuf(argv[0]); + wptr = where; + + if (rptr == NULL || wptr == NULL) { + error(0, 0, "Not enough memory for repository stringbuf"); + err = 1; + goto err; + } + + + /* if mfile isn't null, we need to set up to do only part of the module */ + if (mfile != NULL) + { + + rptr = catc_stringbuf(rptr, '/'); + rptr = cat_stringbuf(rptr,mfile); + wptr = catc_stringbuf(wptr, '/'); + wptr = cat_stringbuf(wptr, mfile); + if (rptr == NULL || wptr == NULL) { + error(0, errno, "Not enough memory for repository stringbuf"); + err = 1; + goto err; + } + + if (!isdir(repository->buf)) { + /* Hmm... It's a file. we have to cut off its + * basename from repository... */ + size_t mflen; + char *sp = strrchr(mfile, '/'); + if (sp != NULL) + mfile = sp + 1; + mflen = strlen(mfile); + repository->buf[repository->len - mflen - 1] = '\0'; + repository->len -= (mflen + 1); + where->buf[where->len - mflen - 1] = '\0'; + where->len -= (mflen + 1); + + /* copied from patch.c w/o checking if this really way to + go :-) */ + myargv[0] = argv[0]; + myargv[1] = mfile; + argc = 2; + argv = myargv; + } + } + + /* cd to the starting repository */ + if ( CVS_CHDIR (repository->buf) < 0) { + error(0, errno, "Error changing working directory to %s", + repository->buf); + err = 1; + goto err; + } + + dirproc = (dir_perm != dir_perm_invalid || is_set_default_file_acl) ? + access_dirproc : NULL; + fileproc = (branch_perm != branch_perm_invalid && !is_set_default_file_acl) ? + access_fileproc : NULL; + + /* start the recursion processor */ + err = start_recursion (fileproc, (FILESDONEPROC) NULL, dirproc, + (DIRLEAVEPROC) NULL, (void*)username, + argc - 1, argv + 1, local, which, 0, 1, + where->buf, 1); + err: + free_stringbuf(where); where = NULL; + free_stringbuf(repository); repository = NULL; + return (err); +} + +static int +access_module_racl (int argc, char **argv, char *username, int local) +{ + DBM *db; + int err = 0; + int i; + db = open_module (); + for (i = 0; i < argc; i++) + err += do_module (db, argv[i], MISC, (char *) username, access_proc, + (char *) NULL, 0, local, 0, 0, (char*) NULL); + close_module (db); + return err + error_counter; +} + +static branch_permission +dir_branch_perm_translate(dir_permission dir_perm) { + if (dir_perm == dir_perm_invalid) + return branch_perm_invalid; + else if (dir_perm == dir_perm_none) + return branch_perm_none; + else if (dir_perm == dir_perm_all) + return branch_perm_all; + else { + branch_permission bp = branch_perm_none; + if (dir_perm & dir_perm_access) + bp |= branch_perm_checkout; + if (dir_perm & dir_perm_modify) + bp |= branch_perm_checkin; + return bp; + } +} +#endif /* SERVER_SUPPORT */ + + +#ifdef SERVER_SUPPORT +static int server_side_racl (int argc, char **argv) { - struct REPOSITORY *repos; char *subcommand; char *username; char *perm; char *prefix = ""; - int grant = 0; - + int grant = 0; + int istranslate = 0; + int local = 1; + int c; + if (!is_acl_admin(CVS_Username)) error(1, 0, "%s is not allowed to manage ACLs", CVS_Username); argv++; /* skip 'cvs server' */ - argv++; /* skip 'racl' */ - - repos = get_repository(current_parsed_root->directory); + /* argv++; */ /* Due to the bug of getopt(3) we don't need to + skip 'racl' */ + argc--; + + optind = 0; + while ((c = getopt(argc, argv, "tr:")) != -1) { + switch (c) { + case 'r': + branch = xstrdup(optarg); + break; + case 't': + istranslate = 1; + break; + default: + error(1, 0, "invalid option -%c\n", c); + usage(racl_usage); + break; + } + } + /* Hmm... Either I'm don't understand completely the [GNU] getopt(3) + logic or it's set to at least 1 even if no options were passed. + This check is made in case there're different getopts... + Thus we skip racl subcommand, see comments above... + */ + if (optind == 0) + optind ++; + argc -= optind; + argv += optind; + + /* It's not necessary to check argc at this point */ subcommand = *argv++; + argc--; + if (!subcommand) usage(racl_usage); @@ -71,39 +422,44 @@ usage(racl_usage); username = *argv++; - if (!username) + argc--; + if (!username || !username[0]) usage(racl_usage); perm = *argv++; + argc--; if (!perm) usage(racl_usage); if (strncmp(perm, "tag", strlen("tag")) == 0) { - prefix = perm + strlen("tag") + 1; + const size_t TAG_LEN = strlen("tag"); + if (perm[TAG_LEN] == ':') + prefix = perm + TAG_LEN + 1; /* PREFIX was specified */ + else if (perm[TAG_LEN] == '\0') + prefix = perm + TAG_LEN; /* No PREFIX specified */ + else + goto err; + tag_module_racl(argc,argv,username,prefix,grant,0); + return 0; + } else if (strncmp(perm, "branch", strlen("branch")) == 0) { + error(1, 0, "Branch permissions isn't implemented yet"); + return 1; + } else if ((dir_perm = parse_dir_permissions(perm)) != dir_perm_invalid) { + if (istranslate) + branch_perm = dir_branch_perm_translate(dir_perm); + return access_module_racl(argc,argv,username,local); } else { - error(1, 0, "Unknown permission: '%s'", perm); - } - - while (*argv) { - char *module = *argv; - struct MODULE_ACL *mod_acl = get_module_acl(repos, module); - - if (grant) { - if (!grant_module_tagging(mod_acl, username, prefix)) - error(1, errno, "Error granting tag permission to %s for %s", - username, module); - } else { - if (!revoke_module_tagging(mod_acl, username, prefix)) - error(1, errno, "Error revoking tag permission to %s for %s", - username, module); - } - argv++; + size_t deflen = strlen(DEFAULT_FILE_ACL_PREFIX); + if (strncmp(perm, DEFAULT_FILE_ACL_PREFIX, deflen)==0) { + is_set_default_file_acl = 1; + perm += deflen; + } + if ((branch_perm = parse_branch_permissions(perm)) != branch_perm_invalid) + return access_module_racl(argc,argv,username,local); } - - if (!save_module_acl(repos)) - error(1, errno, "Error saving module ACLS: %s", strerror(errno)); - - free_repository(repos); + err: + error(1, 0, "Unknown permission: '%s'", perm); + return 1; } #endif @@ -134,7 +490,7 @@ #ifdef SERVER_SUPPORT if (server_active) - server_side_racl(argc, argv); + return server_side_racl(argc, argv); #endif #ifdef CLIENT_SUPPORT @@ -144,3 +500,4 @@ return 0; } + |
From: Alexey M. <mo...@us...> - 2002-06-13 13:44:38
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv18537/acl Modified Files: Tag: NCLI-1-11-1 default-file-acl.h dir-acl.c Log Message: Dir/Branch management (old semantics) implemented for racl subcommand Index: default-file-acl.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/default-file-acl.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -d -r1.1.2.2 -r1.1.2.3 --- default-file-acl.h 13 Jun 2002 09:20:44 -0000 1.1.2.2 +++ default-file-acl.h 13 Jun 2002 13:44:33 -0000 1.1.2.3 @@ -38,6 +38,8 @@ #include "dir-acl.h" +#define DEFAULT_FILE_ACL_PREFIX "default:" + int store_default_file_acl (FILE *acl_file, struct DEFAULT_FILE_ACL *dfacl); int set_default_file_acl (struct DIR_ACL *dir_acl,const char *branch, const char *username, int perm); Index: dir-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.c,v retrieving revision 1.1.2.24 retrieving revision 1.1.2.25 diff -u -d -r1.1.2.24 -r1.1.2.25 --- dir-acl.c 13 Jun 2002 09:20:44 -0000 1.1.2.24 +++ dir-acl.c 13 Jun 2002 13:44:33 -0000 1.1.2.25 @@ -138,10 +138,23 @@ { struct DIR_ACL *dir_acl = NULL; char *dir_copy = NULL; + size_t tldlen = strlen(current_toplevel_directory); + size_t dirlen = strlen(dir); - /* check that requested directory derives from top-level directory */ - if (strncmp(dir, current_toplevel_directory, strlen(current_toplevel_directory)) != 0) + /* check that requested directory derives from top-level directory + There's one special case for this check: if dir requested is + current_toplevel_directory itself, its length is less than + length of the current_toplevel_directory because of trailing + slash. Handle this case sui generis.... + */ + if (!(((tldlen == (dirlen+1)) + && (current_toplevel_directory[tldlen-1] == '/') + && (strncmp(dir,current_toplevel_directory,dirlen) == 0)) + || (strncmp(dir, current_toplevel_directory,tldlen) == 0))) { + /* error(0,0,"Trying to access Dir ACL in '%s' outside of '%s'", + dir,current_toplevel_directory); */ goto out; + } dir_acl = create_and_load_dir_acl(dir); if (!dir_acl) |
From: Alexey M. <mo...@us...> - 2002-06-13 13:43:01
|
Update of /cvsroot/cvs-nserver/cvs-nserver/src In directory usw-pr-cvs1:/tmp/cvs-serv17477 Modified Files: Tag: NCLI-1-11-1 ls.c lsmodules.c Log Message: Code cleanups and small bugfixes for lsmodules.c Index: ls.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/src/Attic/ls.c,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -u -d -r1.1.2.13 -r1.1.2.14 --- ls.c 4 Jun 2002 08:02:44 -0000 1.1.2.13 +++ ls.c 13 Jun 2002 13:42:49 -0000 1.1.2.14 @@ -10,6 +10,8 @@ General Public License for more details. Copyright (c) Alexey Mahotkin <al...@hs...> 2001 + Alexey Morozov <mo...@no...>, + Novosoft, Inc. 2002 "ls" subcommand gives a listing of specified directory in repository @@ -20,8 +22,6 @@ #include "ls.h" -#include "stringbuf.h" - #include "cvs.h" #include "acl.h" #include "recurse.h" @@ -45,7 +45,6 @@ static int deep = 0; static struct DIR_ACL *dir_acl = NULL; - /* ARGSUSED */ static Dtype ls_dirproc (callerdat, dir, repository, update_dir, entries) @@ -77,21 +76,7 @@ cvs_output("D/", 2); cvs_output(update_dir,0); cvs_output("//",2); - if (perm == dir_perm_none) { - cvs_output("none",0); - } else { - int need_comma = 0; - if (perm & dir_perm_access) { - cvs_output("access",0); - need_comma = 1; - } - if (perm & dir_perm_modify) { - if (need_comma) - cvs_output(",modify",0); - else - cvs_output("modify",0); - } - } + cvs_output(dir_permissions_string(perm),0); cvs_output("\n", 1); #ifdef SERVER_SUPPORT @@ -116,7 +101,6 @@ return 0; } - int ls_fileproc (void *callerdat, struct file_info *finfo) { @@ -128,7 +112,6 @@ struct BRANCH_ACL *branch_acl; struct BRANCH_ACE *branch_ace; char timestamp[32]; - int ts_len; int single_file; char *xbranch = (tagname) ? tagname : "trunk"; int perm; @@ -136,8 +119,11 @@ #ifdef SERVER_SUPPORT if (dir_acl == NULL) { - if ((dir_acl = get_dir_acl(finfo->repository,xbranch)) == NULL) - error(1, 0, "Error getting directory ACL for %s: %s", finfo->repository, strerror(errno)); + if ((dir_acl = get_dir_acl(finfo->repository,xbranch)) == NULL) { + error(0, errno, + "Error getting directory ACL for %s", finfo->repository); + return 1; + } single_file = 1; } #endif @@ -185,22 +171,7 @@ perm = branch_perm_all; #endif - if (perm == branch_perm_none) { - cvs_output("none",0); - } else { - int need_comma = 0; - if (perm & branch_perm_checkout) { - cvs_output("checkout",0); - need_comma = 1; - } - if (perm & branch_perm_checkin) { - if (need_comma) - cvs_output(",checkin",0); - else - cvs_output("checkin",0); - } - } - + cvs_output(branch_permissions_string(perm),0); cvs_output("/",1); @@ -228,7 +199,6 @@ server_side_ls (int argc, char **argv) { int err = 0; - int i; err += ls_proc (argc , argv, (char *) NULL, (char *) NULL, (char *) NULL, 0, (char *) NULL,(char *) NULL); Index: lsmodules.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/src/Attic/lsmodules.c,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -d -r1.1.2.7 -r1.1.2.8 --- lsmodules.c 4 Jun 2002 08:02:44 -0000 1.1.2.7 +++ lsmodules.c 13 Jun 2002 13:42:49 -0000 1.1.2.8 @@ -8,7 +8,6 @@ #include "acl.h" #include "cvs.h" #include "lsmodules.h" -#include "stringbuf.h" #include "recurse.h" static const char *const lsmodules_usage[] = @@ -34,29 +33,15 @@ static void lsmodules_print(const char *module, int perm) { -#if 1 - cvs_output("D/", 2); -#endif if (mod_list != ALL_MOD_LIST && perm == dir_perm_none) return; +#if 1 + cvs_output("D/", 2); +#endif cvs_output(module,0); cvs_output("//",2); - if (perm == dir_perm_none) { - cvs_output("none",0); - } else { - int need_comma = 0; - if (perm & dir_perm_access) { - cvs_output("access",0); - need_comma = 1; - } - if (perm & dir_perm_modify) { - if (need_comma) - cvs_output(",modify",0); - else - cvs_output("modify",0); - } - } + cvs_output(dir_permissions_string(perm), 0); cvs_output("\n", 1); } @@ -74,8 +59,10 @@ int perm; char *xbranch = (tagname) ? tagname : "trunk"; struct DIR_ACL *dir_acl = NULL; - if ((dir_acl = get_dir_acl(repository,xbranch)) == NULL) - error(1, 0, "Error getting directory ACL for %s: %s", repository, strerror(errno)); + if ((dir_acl = get_dir_acl(repository,xbranch)) == NULL) { + error(0, errno, "Error getting directory ACL for %s", repository); + return R_SKIP_ALL; + } perm = dir_permission_granted(dir_acl,CVS_Username,dir_perm_all); #else int perm = dir_perm_all; @@ -86,8 +73,7 @@ /* prevent unprivileged user from checking if a particular * directory even exists */ - error(1, 0, "could not read RCS file for %s",update_dir); - /* just in case */ + error(0, 0, "could not read RCS file for %s",update_dir); return R_SKIP_ALL; } deep++; @@ -110,18 +96,34 @@ char *msg; { struct DIR_ACL *dir_acl = NULL; + char fullpath[PATH_MAX + 1]; char *xbranch = (tagname) ? tagname : "trunk"; int perm; - + int err = 0; /* The module can be either regular or alias. In either case - * argv[0] is directory name related to the current directory (hopefully, - * repository. So first we retrieve its DIRACL and check if it allows us - * to go further (has dir_perm_access) */ + * argv[0] is directory name related to the current directory + * (hopefully, repository). So first we retrieve its DIRACL and + * check if it allows us to go further (has dir_perm_access) */ - if ((dir_acl = get_dir_acl(argv[0],xbranch)) == NULL) - error(1, 0, "Error getting directory ACL for %s/%s: %s", - current_parsed_root->directory, argv[0], strerror(errno)); + if ((strlen(current_parsed_root->directory) + strlen(argv[0]) + 2) > PATH_MAX) { + error(0, 0, "Repository path %s/%s exceeds PATH_MAX", + current_parsed_root->directory, argv[0]); + return 1; + } + + strcpy(fullpath, current_parsed_root->directory); + strcat(fullpath, "/"); + strcat(fullpath, argv[0]); + + /* Unfortunately libcvsacl requires absolute dir names... I don't + know why Alex decided so... */ + if ((dir_acl = get_dir_acl(fullpath,xbranch)) == NULL) { + error(0, errno, "Error getting directory ACL for %s", fullpath); + return 1; + } + perm = dir_permission_granted(dir_acl,CVS_Username,dir_perm_all); + if (! (perm & dir_perm_access)) return 0; if (argc == 1) { @@ -131,7 +133,6 @@ module_dir_perm |= perm; return 0; } - if (mwhere != NULL) { int i; /* Hmm looks like a regular module, not alias. @@ -141,41 +142,58 @@ * and then check every item ACLs */ struct stat stbuf; char curdir[PATH_MAX+1]; - if (getcwd(curdir,PATH_MAX)==NULL) - error(1, 0, "unable to get current directory: %s", - strerror(errno)); - if (CVS_CHDIR(argv[0])!=0) - error(1, 0, "unable to change working directory to %s/%s: %s", - current_parsed_root->directory, argv[0], strerror(errno)); + if (getcwd(curdir,PATH_MAX)==NULL) { + error(0, errno, "Error getting current directory"); + return 1; + } + if (CVS_CHDIR(fullpath)!=0) { + CVS_CHDIR(curdir); + error(0, errno, + "Error changing working directory to %s", fullpath); + return 1; + } for(i=1;i<argc;i++) { - if (CVS_STAT(argv[i],&stbuf)==-1) - continue; /* some elements may refer to non-existing objects */ - if (S_ISDIR(stbuf.st_mode)) { + if (CVS_STAT(argv[i],&stbuf)!=-1 && S_ISDIR(stbuf.st_mode)) { struct DIR_ACL *sd_acl; - if ((sd_acl = get_dir_acl(argv[i],xbranch)) == NULL) - error(1, 0, "unable to get DIR ACL for %s/%s/%s: %s", - current_parsed_root->directory, - argv[0],argv[i],strerror(errno)); - module_dir_perm |= dir_permission_granted(sd_acl,CVS_Username, - dir_perm_all); + char itempath[PATH_MAX + 1]; + if ((strlen(fullpath) + strlen(argv[i]) + 1) > PATH_MAX) { + error(0, 0, "Path %s/%s exceeds PATH_MAX", fullpath, argv[i]); + err++; + continue; + } + strcpy(itempath, fullpath); + strcat(itempath, "/"); + strcat(itempath, argv[i]); + if ((sd_acl = get_dir_acl(itempath,xbranch)) == NULL) { + error(0, errno, "Error getting Dir ACL for %s", itempath); + err++; + continue; + } + module_dir_perm |= + dir_permission_granted(sd_acl,CVS_Username,dir_perm_all); /* should we somehow cleanup sd_acl structure?? */ } else { - /* Well, the file is a specific part of the module. So + /* Well, argv[i] either not or it's not a dir. + * We consider this case as a file case. So * if a user can checkout it, it means she has access * to the module. If she can checkin the file, she's * able to modify the module */ struct BRANCH_ACL *branch_acl; struct BRANCH_ACE *branch_ace; - if ((branch_acl = get_branch_acl(dir_acl,xbranch)) == NULL) - error(1, 0, "Error getting branch ACL for %s/%s: %s", - current_parsed_root->directory, argv[0], - strerror(errno)); + if ((branch_acl = get_branch_acl(dir_acl,xbranch)) == NULL) { + error(0, errno, "Error getting Branch ACL for %s", + fullpath); + err++; + continue; + } - if ((branch_ace = get_file_on_branch_ace(branch_acl, argv[i])) == NULL) - error(1, 0, "Error getting file ACE for %s/%s/%s: %s", - current_parsed_root->directory,argv[0], argv[i], - strerror(errno)); + if ((branch_ace = get_file_on_branch_ace(branch_acl, argv[i])) == NULL) { + error(0, errno, "Error getting File ACE for %s/%s", + fullpath, argv[i]); + err++; + continue; + } perm = branch_permission_granted(branch_ace, CVS_Username, branch_perm_all); if (perm & branch_perm_checkout) @@ -184,19 +202,23 @@ module_dir_perm |= dir_perm_modify; } } + CVS_CHDIR(curdir); } else if (argc > 1 && argv[1] && *argv[1]) { /* Well, it's an alias. if argv[1] presents it's a file * (not dir) inside argv[0] */ struct BRANCH_ACL *branch_acl; struct BRANCH_ACE *branch_ace; - if ((branch_acl = get_branch_acl(dir_acl,xbranch)) == NULL) - error(1, 0, "Error getting branch ACL for %s/%s: %s", - current_parsed_root->directory, argv[0], strerror(errno)); - - if ((branch_ace = get_file_on_branch_ace(branch_acl, argv[1])) == NULL) - error(1, 0, "Error getting file ACE for %s/%s/%s: %s", - current_parsed_root->directory,argv[0], argv[1], - strerror(errno)); + if ((branch_acl = get_branch_acl(dir_acl,xbranch)) == NULL) { + error(0, errno, "Error getting branch ACL for %s", fullpath); + return 1; + } + + if ((branch_ace = get_file_on_branch_ace(branch_acl, argv[1])) == NULL) { + error(0, errno, "Error getting file ACE for %s/%s", + fullpath, argv[1]); + return 1; + } + perm = branch_permission_granted(branch_ace, CVS_Username, branch_perm_all); if (perm & branch_perm_checkout) @@ -204,7 +226,7 @@ if (perm & branch_perm_checkin) module_dir_perm |= dir_perm_modify; } - return 0; + return err; } extern int ls_fileproc(void *callerdat, struct file_info *finfo); @@ -216,8 +238,11 @@ const int argc = 1; const int which = W_REPOS | W_ATTIC; deep = 0; - if (CVS_CHDIR(current_parsed_root->directory) < 0) + if (CVS_CHDIR(current_parsed_root->directory) < 0) { + error(0, errno, "Error changing working directory to %s", + current_parsed_root->directory); return 1; + } return start_recursion (ls_fileproc, (FILESDONEPROC) NULL, lsmodules_dirproc, (DIRLEAVEPROC) NULL, (void *) NULL, argc , argv, 0, which, 0, 1,"", 1); @@ -238,8 +263,10 @@ * only one opened instance of the DB. But this may change in future * releases so be careful... */ #if 0 - if (!(db1 = open_module ())) - error (1, 0, "failed to open the modules file"); + if (!(db1 = open_module ())) { + error (0, errno, "failed to open the modules file"); + return 1; + } #else # define db1 db #endif |
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv11573 Modified Files: Tag: NCLI-1-11-1 branch-acl.c branch-acl.h check_acl_admins.c check_branch_acl.c check_module_acl.c check_repository.c check_stringbuf.c check_user_acl.c check_user_groups.c cvsgroup-internal.h cvsgroup.c cvsgroup.h default-file-acl.c default-file-acl.h dir-acl.c dir-acl.h user-acl.c user-acl.h Log Message: Headers inclusion/function declaration cleanups. Nothing significant. Index: branch-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/branch-acl.c,v retrieving revision 1.1.2.18 retrieving revision 1.1.2.19 diff -u -d -r1.1.2.18 -r1.1.2.19 --- branch-acl.c 9 Jun 2002 14:25:23 -0000 1.1.2.18 +++ branch-acl.c 13 Jun 2002 09:20:44 -0000 1.1.2.19 @@ -46,7 +46,7 @@ BRANCH_ACL * -find_branch_acl (DIR_ACL *dir_acl, char *branch) +find_branch_acl (DIR_ACL *dir_acl, const char *branch) { struct BRANCH_ACL *current = dir_acl->branch_acls; @@ -61,7 +61,7 @@ } BRANCH_ACL * -get_branch_acl (DIR_ACL *dir_acl, char *branch) +get_branch_acl (DIR_ACL *dir_acl, const char *branch) { struct BRANCH_ACL *result; @@ -77,7 +77,7 @@ BRANCH_ACL * -create_branch_acl (DIR_ACL *dir_acl, char *branch) +create_branch_acl (DIR_ACL *dir_acl, const char *branch) { struct BRANCH_ACL *branch_acl; Index: branch-acl.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/branch-acl.h,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -d -r1.1.2.10 -r1.1.2.11 --- branch-acl.h 9 Jun 2002 14:25:23 -0000 1.1.2.10 +++ branch-acl.h 13 Jun 2002 09:20:44 -0000 1.1.2.11 @@ -55,9 +55,9 @@ typedef int branch_permission; -BRANCH_ACL *create_branch_acl (DIR_ACL *dir_acl, char *branch); -BRANCH_ACL *find_branch_acl (DIR_ACL *dir_acl, char *branch); -BRANCH_ACL *get_branch_acl (DIR_ACL *dir_acl, char *branch); +BRANCH_ACL *create_branch_acl (DIR_ACL *dir_acl, const char *branch); +BRANCH_ACL *find_branch_acl (DIR_ACL *dir_acl, const char *branch); +BRANCH_ACL *get_branch_acl (DIR_ACL *dir_acl, const char *branch); BRANCH_ACE *get_file_on_branch_ace (BRANCH_ACL *branch_acl, char *file); Index: check_acl_admins.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_acl_admins.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- check_acl_admins.c 30 Sep 2001 19:40:04 -0000 1.1.2.1 +++ check_acl_admins.c 13 Jun 2002 09:20:44 -0000 1.1.2.2 @@ -1,8 +1,11 @@ - +#include "config.h" #include "acl-admins.h" #include <assert.h> +#ifdef HAVE_ERRNO_H #include <errno.h> +#endif +#include <stdlib.h> int main (void) { Index: check_branch_acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_branch_acl.c,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -u -d -r1.1.2.13 -r1.1.2.14 --- check_branch_acl.c 7 Jun 2002 13:18:36 -0000 1.1.2.13 +++ check_branch_acl.c 13 Jun 2002 09:20:44 -0000 1.1.2.14 @@ -16,6 +16,7 @@ */ #include "branch-acl.h" +#include "default-file-acl.h" #include "check_acl.h" #include "dir-acl.h" Index: check_module_acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_module_acl.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -d -r1.1.2.2 -r1.1.2.3 --- check_module_acl.c 21 Nov 2001 22:51:17 -0000 1.1.2.2 +++ check_module_acl.c 13 Jun 2002 09:20:44 -0000 1.1.2.3 @@ -14,11 +14,14 @@ Test-suite for module-level Access Control Lists */ - +#include "config.h" #include "module-acl.h" #include <assert.h> #include <stdlib.h> +#ifdef HAVE_STRING_H +#include <string.h> +#endif static void Index: check_repository.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_repository.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- check_repository.c 13 Nov 2001 23:26:34 -0000 1.1.2.1 +++ check_repository.c 13 Jun 2002 09:20:44 -0000 1.1.2.2 @@ -14,11 +14,14 @@ Test-suite for ACL-related repository handling */ - +#include "config.h" #include "repository.h" #include <assert.h> #include <stdlib.h> +#ifdef HAVE_STRING_H +#include <string.h> +#endif int main (void) Index: check_stringbuf.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_stringbuf.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -d -r1.1.2.5 -r1.1.2.6 --- check_stringbuf.c 9 May 2002 15:09:11 -0000 1.1.2.5 +++ check_stringbuf.c 13 Jun 2002 09:20:44 -0000 1.1.2.6 @@ -15,11 +15,14 @@ */ - +#include "config.h" #include "stringbuf.h" #include <assert.h> #include <stdlib.h> +#ifdef HAVE_STRING_H +#include <string.h> +#endif static void test_NULL_stringbuf (void) Index: check_user_acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_user_acl.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -d -r1.1.2.2 -r1.1.2.3 --- check_user_acl.c 8 Sep 2001 23:04:36 -0000 1.1.2.2 +++ check_user_acl.c 13 Jun 2002 09:20:44 -0000 1.1.2.3 @@ -1,8 +1,11 @@ - +#include "config.h" #include "user-acl.h" #include <assert.h> #include <stdlib.h> +#ifdef HAVE_STRING_H +#include <string.h> +#endif int main (void) Index: check_user_groups.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_user_groups.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -d -r1.1.2.2 -r1.1.2.3 --- check_user_groups.c 14 Apr 2002 18:36:29 -0000 1.1.2.2 +++ check_user_groups.c 13 Jun 2002 09:20:44 -0000 1.1.2.3 @@ -1,9 +1,16 @@ +#include "config.h" #include "cvsgroup.h" #include "cvsgroup-internal.h" #include <assert.h> +#ifdef HAVE_ERRNO_H #include <errno.h> +#endif #include <stdio.h> +#ifdef HAVE_STRING_H +#include <string.h> +#endif +#include <stdlib.h> static void check_creating_groups (void) Index: cvsgroup-internal.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/cvsgroup-internal.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- cvsgroup-internal.h 29 Sep 2001 23:50:32 -0000 1.1.2.1 +++ cvsgroup-internal.h 13 Jun 2002 09:20:44 -0000 1.1.2.2 @@ -10,17 +10,17 @@ int users_count; }; -int internal_add_user_to_group (char *username, struct cvsgroup *cvsgroup); -int add_user_to_group (char *username, char *groupname); +int internal_add_user_to_group (const char *username, struct cvsgroup *cvsgroup); +int add_user_to_group (const char *username, const char *groupname); -int internal_user_in_group (char *username, struct cvsgroup *cvsgroup); +int internal_user_in_group (const char *username, struct cvsgroup *cvsgroup); -struct cvsgroup *create_cvsgroup (char *groupname); +struct cvsgroup *create_cvsgroup (const char *groupname); void free_cvsgroup (struct cvsgroup *group); -struct cvsgroup *get_cvsgroup (char *groupname); +struct cvsgroup *get_cvsgroup (const char *groupname); void clear_groups(void); Index: cvsgroup.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/cvsgroup.c,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -d -r1.1.2.3 -r1.1.2.4 --- cvsgroup.c 14 Apr 2002 18:36:29 -0000 1.1.2.3 +++ cvsgroup.c 13 Jun 2002 09:20:44 -0000 1.1.2.4 @@ -21,7 +21,7 @@ static struct group_elem *first_group_elem = NULL; struct cvsgroup * -get_cvsgroup (char *group) +get_cvsgroup (const char *group) { struct group_elem *current = first_group_elem; @@ -35,7 +35,7 @@ } struct cvsgroup * -create_cvsgroup (char *group) +create_cvsgroup (const char *group) { struct cvsgroup *result; struct group_elem *group_elem; @@ -97,7 +97,7 @@ int -add_user_to_group (char *username, char *group) +add_user_to_group (const char *username, const char *group) { struct cvsgroup *cvsgroup; @@ -117,7 +117,7 @@ #define ALLOC_DELTA 8 int -internal_add_user_to_group (char *username, struct cvsgroup *cvsgroup) +internal_add_user_to_group (const char *username, struct cvsgroup *cvsgroup) { char **new_users; char *username_copy; @@ -248,7 +248,7 @@ int -internal_user_in_group (char *username, struct cvsgroup *cvsgroup) +internal_user_in_group (const char *username, struct cvsgroup *cvsgroup) { char **users; if (cvsgroup->users == NULL) @@ -264,7 +264,7 @@ int -user_in_group (char *username, char *group) +user_in_group (const char *username, const char *group) { struct cvsgroup *cvsgroup; Index: cvsgroup.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/cvsgroup.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- cvsgroup.h 29 Sep 2001 23:50:32 -0000 1.1.2.1 +++ cvsgroup.h 13 Jun 2002 09:20:44 -0000 1.1.2.2 @@ -4,6 +4,6 @@ int read_cvsgroup_file (char *filename); -int user_in_group (char *username, char *groupname); +int user_in_group (const char *username, const char *groupname); #endif /* CVSGROUP_H */ Index: default-file-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/default-file-acl.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- default-file-acl.c 9 Jun 2002 12:07:53 -0000 1.1.2.1 +++ default-file-acl.c 13 Jun 2002 09:20:44 -0000 1.1.2.2 @@ -41,7 +41,7 @@ static struct DEFAULT_FILE_ACL * -get_default_file_acl (struct DIR_ACL *dir_acl, char *branch) +get_default_file_acl (struct DIR_ACL *dir_acl, const char *branch) { struct DEFAULT_FILE_ACL *current = dir_acl->default_file_acl; @@ -56,7 +56,7 @@ } struct USER_ACL * -get_default_file_user_acl (struct DIR_ACL *dir_acl, char *branch) +get_default_file_user_acl (struct DIR_ACL *dir_acl, const char *branch) { struct DEFAULT_FILE_ACL *dfa = get_default_file_acl(dir_acl, branch); if (dfa == NULL) @@ -66,7 +66,7 @@ } int -set_default_file_acl (struct DIR_ACL *dir_acl, char *branch, char *username, int perm) +set_default_file_acl (struct DIR_ACL *dir_acl, const char *branch, const char *username, int perm) { struct DEFAULT_FILE_ACL *dfa; struct USER_ACL *new_acls; Index: default-file-acl.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/default-file-acl.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- default-file-acl.h 9 Jun 2002 12:07:53 -0000 1.1.2.1 +++ default-file-acl.h 13 Jun 2002 09:20:44 -0000 1.1.2.2 @@ -40,9 +40,9 @@ int store_default_file_acl (FILE *acl_file, struct DEFAULT_FILE_ACL *dfacl); -int set_default_file_acl (struct DIR_ACL *dir_acl, char *branch, char *username, int perm); +int set_default_file_acl (struct DIR_ACL *dir_acl,const char *branch, const char *username, int perm); -struct USER_ACL *get_default_file_user_acl(struct DIR_ACL *dir_acl, char *branch); +struct USER_ACL *get_default_file_user_acl(struct DIR_ACL *dir_acl, const char *branch); #endif /* DEFAULT_FILE_ACL_H__ */ Index: dir-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.c,v retrieving revision 1.1.2.23 retrieving revision 1.1.2.24 diff -u -d -r1.1.2.23 -r1.1.2.24 --- dir-acl.c 9 Jun 2002 12:07:53 -0000 1.1.2.23 +++ dir-acl.c 13 Jun 2002 09:20:44 -0000 1.1.2.24 @@ -129,12 +129,12 @@ return current_default_dir_perm; } -static struct DIR_ACL *create_and_load_dir_acl (char *dir); +static struct DIR_ACL *create_and_load_dir_acl (const char *dir); static struct DIR_ACL *add_dir_acl_topdirs (char *dir, struct DIR_ACL *the_dir_acl); struct DIR_ACL * -get_dir_acl (char *dir, char *branch) +get_dir_acl (const char *dir, const char *branch) { struct DIR_ACL *dir_acl = NULL; char *dir_copy = NULL; @@ -268,7 +268,7 @@ */ static struct DIR_ACL* -create_dir_acl (char* dir) +create_dir_acl (const char* dir) { struct DIR_ACL* dir_acl = calloc(1, sizeof(struct DIR_ACL)); if (dir_acl == NULL) @@ -324,7 +324,7 @@ */ static struct DIR_ACL * -create_and_load_dir_acl (char *dir) +create_and_load_dir_acl (const char *dir) { FILE *acl = NULL; struct DIR_ACL *dir_acl = NULL; Index: dir-acl.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.h,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -u -d -r1.1.2.13 -r1.1.2.14 --- dir-acl.h 9 Jun 2002 12:07:53 -0000 1.1.2.13 +++ dir-acl.h 13 Jun 2002 09:20:44 -0000 1.1.2.14 @@ -104,7 +104,7 @@ void set_default_dir_perm (enum DIR_PERM new_perm); enum DIR_PERM get_default_dir_perm (void); -struct DIR_ACL *get_dir_acl(char *dir, char *branch); +struct DIR_ACL *get_dir_acl(const char *dir, const char *branch); void destroy_dir_acl (struct DIR_ACL* dir_acl); Index: user-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/user-acl.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -d -r1.1.2.5 -r1.1.2.6 --- user-acl.c 9 Jun 2002 11:41:50 -0000 1.1.2.5 +++ user-acl.c 13 Jun 2002 09:20:44 -0000 1.1.2.6 @@ -51,7 +51,7 @@ USER_ACE * -get_user_ace (USER_ACL *acls, char *username) +get_user_ace (USER_ACL *acls, const char *username) { USER_ACL *acl = acls; @@ -69,7 +69,7 @@ } USER_ACL * -set_user_ace (USER_ACL *acls, char *username, int perm) +set_user_ace (USER_ACL *acls, const char *username, int perm) { USER_ACL *acl = acls; Index: user-acl.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/user-acl.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -d -r1.1.2.2 -r1.1.2.3 --- user-acl.h 9 Jun 2002 11:41:50 -0000 1.1.2.2 +++ user-acl.h 13 Jun 2002 09:20:44 -0000 1.1.2.3 @@ -31,8 +31,8 @@ void free_user_acls (USER_ACL* acls); -USER_ACL * set_user_ace(USER_ACL *acls, char *username, int perm); +USER_ACL * set_user_ace(USER_ACL *acls, const char *username, int perm); -USER_ACE * get_user_ace (USER_ACL *acls, char *username); +USER_ACE * get_user_ace (USER_ACL *acls, const char *username); #endif /* USER_ACL_H */ |
From: Alexey M. <ty...@us...> - 2002-06-09 16:02:47
|
Update of /cvsroot/cvs-nserver/cvs-nserver/src In directory usw-pr-cvs1:/tmp/cvs-serv7513 Modified Files: Tag: NCLI-1-11-1 acl.c Log Message: Update Index: acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/src/Attic/acl.c,v retrieving revision 1.1.2.16 retrieving revision 1.1.2.17 diff -u -d -r1.1.2.16 -r1.1.2.17 --- acl.c 30 May 2002 21:19:07 -0000 1.1.2.16 +++ acl.c 9 Jun 2002 16:02:44 -0000 1.1.2.17 @@ -25,6 +25,7 @@ #include "acl-admins.h" #include "branch-acl.h" +#include "default-file-acl.h" #include "dir-acl.h" #include "stringbuf.h" @@ -303,7 +304,7 @@ if (perm == dir_perm_invalid) error(1, 0, "Invalid directory permissions '%s'", perm_string); - if (set_dir_ace(dir_acl, username, perm) != perm) + if (set_dir_ace(dir_acl, branch, username, perm) != perm) error(1, 0, "Error setting %s permissions on directory %s", perm_string, relative_name); |
From: Alexey M. <mo...@us...> - 2002-06-09 14:41:09
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv21463 Modified Files: Tag: NCLI-1-11-1 check_default_file_acl.c check_persistent_acl.c Log Message: Includes are done more accurately. Shouldn't affect any 'reasonable' build environment though ;-) Index: check_default_file_acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_default_file_acl.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -d -r1.1.2.5 -r1.1.2.6 --- check_default_file_acl.c 9 Jun 2002 12:07:53 -0000 1.1.2.5 +++ check_default_file_acl.c 9 Jun 2002 14:41:06 -0000 1.1.2.6 @@ -6,7 +6,12 @@ #include <assert.h> #include <stdio.h> +#ifdef HAVE_STDLIB_H #include <stdlib.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif static void check_default_file_acl_internals (void) Index: check_persistent_acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_persistent_acl.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -d -r1.1.2.5 -r1.1.2.6 --- check_persistent_acl.c 25 Nov 2001 20:00:00 -0000 1.1.2.5 +++ check_persistent_acl.c 9 Jun 2002 14:41:06 -0000 1.1.2.6 @@ -23,7 +23,12 @@ #include <assert.h> #include <stdio.h> +#ifdef HAVE_STDLIB_H #include <stdlib.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif static void check_single_persistent_file_acl (void) |
From: Alexey M. <mo...@us...> - 2002-06-09 14:25:39
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv17452 Modified Files: Tag: NCLI-1-11-1 branch-acl.c branch-acl.h Log Message: /home/alex/tmp/cvsfrmDvE Index: branch-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/branch-acl.c,v retrieving revision 1.1.2.17 retrieving revision 1.1.2.18 diff -u -d -r1.1.2.17 -r1.1.2.18 --- branch-acl.c 9 Jun 2002 12:07:53 -0000 1.1.2.17 +++ branch-acl.c 9 Jun 2002 14:25:23 -0000 1.1.2.18 @@ -251,7 +251,7 @@ return branch_perm_invalid; } -char * +const char * branch_permissions_string (int perm) { if (perm == branch_perm_none) Index: branch-acl.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/branch-acl.h,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -d -r1.1.2.9 -r1.1.2.10 --- branch-acl.h 25 Nov 2001 20:00:00 -0000 1.1.2.9 +++ branch-acl.h 9 Jun 2002 14:25:23 -0000 1.1.2.10 @@ -69,7 +69,7 @@ int parse_branch_permissions (char *perm_str); -char *branch_permissions_string (int perm); +const char *branch_permissions_string (int perm); int internal_read_branch_acl_file (char *filename, char *on_branch, struct BRANCH_ACE *bacl); |
From: Alexey M. <ty...@us...> - 2002-06-09 12:07:58
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv17003 Modified Files: Tag: NCLI-1-11-1 Makefile.am Makefile.in branch-acl.c check_default_file_acl.c dir-acl.c dir-acl.h Added Files: Tag: NCLI-1-11-1 default-file-acl.c default-file-acl.h Log Message: Move default file ACL functionality to default-file-acl.[ch] --- NEW FILE: default-file-acl.c --- /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Copyright (c) Alexey Mahotkin <al...@hs...> 2002 */ #include <config.h> #include <stdio.h> #include <string.h> #include "branch-acl.h" #include "default-file-acl.h" #include "dir-acl.h" int store_default_file_acl (FILE *acl_file, struct DEFAULT_FILE_ACL *dfacl) { while (dfacl != NULL) { struct USER_ACL *user_acl = dfacl->user_acl; while (user_acl != NULL) { fprintf(acl_file, "D%s\t%s\t%s\n", dfacl->branch, user_acl->username, branch_permissions_string(user_acl->perm)); user_acl = user_acl->next; } dfacl = dfacl->next; } return 0; } static struct DEFAULT_FILE_ACL * get_default_file_acl (struct DIR_ACL *dir_acl, char *branch) { struct DEFAULT_FILE_ACL *current = dir_acl->default_file_acl; while (current != NULL) { if (strcmp(current->branch, branch) == 0) return current; current = current->next; } return NULL; } struct USER_ACL * get_default_file_user_acl (struct DIR_ACL *dir_acl, char *branch) { struct DEFAULT_FILE_ACL *dfa = get_default_file_acl(dir_acl, branch); if (dfa == NULL) return NULL; return dfa->user_acl; } int set_default_file_acl (struct DIR_ACL *dir_acl, char *branch, char *username, int perm) { struct DEFAULT_FILE_ACL *dfa; struct USER_ACL *new_acls; dfa = get_default_file_acl(dir_acl, branch); if (dfa == NULL) { dfa = calloc(1, sizeof(struct DEFAULT_FILE_ACL)); if (dfa == NULL) return 0; dfa->branch = strdup(branch); if (dfa->branch == NULL) { free(dfa); return 0; } dfa->next = dir_acl->default_file_acl; dir_acl->default_file_acl = dfa; } new_acls = set_user_ace(dfa->user_acl, username, perm); if (new_acls == NULL) return 0; dfa->user_acl = new_acls; return perm; } --- NEW FILE: default-file-acl.h --- /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Copyright (c) Alexey Mahotkin <al...@hs...> 2002 */ /*! \file default-file-acl.h Default file ACL interface. */ #ifndef DEFAULT_FILE_ACL_H__ #define DEFAULT_FILE_ACL_H__ 1 #include "user-acl.h" #include <stdio.h> /*! \struct DEFAULT_FILE_ACL \brief Default file access control list for a branch */ struct DEFAULT_FILE_ACL { char *branch; struct USER_ACL *user_acl; struct DEFAULT_FILE_ACL *next; }; #include "dir-acl.h" int store_default_file_acl (FILE *acl_file, struct DEFAULT_FILE_ACL *dfacl); int set_default_file_acl (struct DIR_ACL *dir_acl, char *branch, char *username, int perm); struct USER_ACL *get_default_file_user_acl(struct DIR_ACL *dir_acl, char *branch); #endif /* DEFAULT_FILE_ACL_H__ */ Index: Makefile.am =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/Makefile.am,v retrieving revision 1.1.2.14 retrieving revision 1.1.2.15 diff -u -d -r1.1.2.14 -r1.1.2.15 --- Makefile.am 19 Jan 2002 15:22:36 -0000 1.1.2.14 +++ Makefile.am 9 Jun 2002 12:07:53 -0000 1.1.2.15 @@ -23,6 +23,7 @@ acl-admins.h acl-admins.c \ branch-acl.h branch-acl.c \ cvsgroup.h cvsgroup-internal.h cvsgroup.c \ + default-file-acl.h default-file-acl.c \ dir-acl.h dir-acl.c \ module-acl.h module-acl.c \ repository.h repository.c \ Index: Makefile.in =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/Makefile.in,v retrieving revision 1.1.2.16 retrieving revision 1.1.2.17 diff -u -d -r1.1.2.16 -r1.1.2.17 --- Makefile.in 9 Feb 2002 20:03:17 -0000 1.1.2.16 +++ Makefile.in 9 Jun 2002 12:07:53 -0000 1.1.2.17 @@ -116,6 +116,7 @@ acl-admins.h acl-admins.c \ branch-acl.h branch-acl.c \ cvsgroup.h cvsgroup-internal.h cvsgroup.c \ + default-file-acl.h default-file-acl.c \ dir-acl.h dir-acl.c \ module-acl.h module-acl.c \ repository.h repository.c \ @@ -168,7 +169,8 @@ libcvsacl_a_AR = $(AR) cru libcvsacl_a_LIBADD = am_libcvsacl_a_OBJECTS = acl-admins$U.$(OBJEXT) branch-acl$U.$(OBJEXT) \ - cvsgroup$U.$(OBJEXT) dir-acl$U.$(OBJEXT) module-acl$U.$(OBJEXT) \ + cvsgroup$U.$(OBJEXT) default-file-acl$U.$(OBJEXT) \ + dir-acl$U.$(OBJEXT) module-acl$U.$(OBJEXT) \ repository$U.$(OBJEXT) stringbuf$U.$(OBJEXT) \ user-acl$U.$(OBJEXT) libcvsacl_a_OBJECTS = $(am_libcvsacl_a_OBJECTS) @@ -239,9 +241,11 @@ @AMDEP_TRUE@ $(DEPDIR)/check_traversing$U.Po \ @AMDEP_TRUE@ $(DEPDIR)/check_user_acl$U.Po \ @AMDEP_TRUE@ $(DEPDIR)/check_user_groups$U.Po \ -@AMDEP_TRUE@ $(DEPDIR)/cvsgroup$U.Po $(DEPDIR)/dir-acl$U.Po \ -@AMDEP_TRUE@ $(DEPDIR)/module-acl$U.Po $(DEPDIR)/repository$U.Po \ -@AMDEP_TRUE@ $(DEPDIR)/stringbuf$U.Po $(DEPDIR)/user-acl$U.Po +@AMDEP_TRUE@ $(DEPDIR)/cvsgroup$U.Po \ +@AMDEP_TRUE@ $(DEPDIR)/default-file-acl$U.Po \ +@AMDEP_TRUE@ $(DEPDIR)/dir-acl$U.Po $(DEPDIR)/module-acl$U.Po \ +@AMDEP_TRUE@ $(DEPDIR)/repository$U.Po $(DEPDIR)/stringbuf$U.Po \ +@AMDEP_TRUE@ $(DEPDIR)/user-acl$U.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) @@ -340,6 +344,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/check_user_acl$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/check_user_groups$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/cvsgroup$U.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/default-file-acl$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/dir-acl$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/module-acl$U.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/repository$U.Po@am__quote@ @@ -391,6 +396,8 @@ $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/check_user_groups.c; then echo $(srcdir)/check_user_groups.c; else echo check_user_groups.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > check_user_groups_.c || rm -f check_user_groups_.c cvsgroup_.c: cvsgroup.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/cvsgroup.c; then echo $(srcdir)/cvsgroup.c; else echo cvsgroup.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > cvsgroup_.c || rm -f cvsgroup_.c +default-file-acl_.c: default-file-acl.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/default-file-acl.c; then echo $(srcdir)/default-file-acl.c; else echo default-file-acl.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > default-file-acl_.c || rm -f default-file-acl_.c dir-acl_.c: dir-acl.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/dir-acl.c; then echo $(srcdir)/dir-acl.c; else echo dir-acl.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > dir-acl_.c || rm -f dir-acl_.c module-acl_.c: module-acl.c $(ANSI2KNR) @@ -407,9 +414,10 @@ check_module_acl_.$(OBJEXT) check_persistent_acl_.$(OBJEXT) \ check_repository_.$(OBJEXT) check_stringbuf_.$(OBJEXT) \ check_traversing_.$(OBJEXT) check_user_acl_.$(OBJEXT) \ -check_user_groups_.$(OBJEXT) cvsgroup_.$(OBJEXT) dir-acl_.$(OBJEXT) \ -module-acl_.$(OBJEXT) repository_.$(OBJEXT) stringbuf_.$(OBJEXT) \ -user-acl_.$(OBJEXT) : $(ANSI2KNR) +check_user_groups_.$(OBJEXT) cvsgroup_.$(OBJEXT) \ +default-file-acl_.$(OBJEXT) dir-acl_.$(OBJEXT) module-acl_.$(OBJEXT) \ +repository_.$(OBJEXT) stringbuf_.$(OBJEXT) user-acl_.$(OBJEXT) : \ +$(ANSI2KNR) uninstall-info-am: tags: TAGS Index: branch-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/branch-acl.c,v retrieving revision 1.1.2.16 retrieving revision 1.1.2.17 diff -u -d -r1.1.2.16 -r1.1.2.17 --- branch-acl.c 7 Jun 2002 13:18:35 -0000 1.1.2.16 +++ branch-acl.c 9 Jun 2002 12:07:53 -0000 1.1.2.17 @@ -20,6 +20,7 @@ #include "config.h" #include "branch-acl.h" +#include "default-file-acl.h" #include <assert.h> #include <errno.h> Index: check_default_file_acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_default_file_acl.c,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -d -r1.1.2.4 -r1.1.2.5 --- check_default_file_acl.c 27 Nov 2001 00:24:46 -0000 1.1.2.4 +++ check_default_file_acl.c 9 Jun 2002 12:07:53 -0000 1.1.2.5 @@ -1,5 +1,6 @@ #include "check_acl.h" +#include "default-file-acl.h" #include "dir-acl.h" #include "branch-acl.h" Index: dir-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.c,v retrieving revision 1.1.2.22 retrieving revision 1.1.2.23 diff -u -d -r1.1.2.22 -r1.1.2.23 --- dir-acl.c 9 Jun 2002 11:42:55 -0000 1.1.2.22 +++ dir-acl.c 9 Jun 2002 12:07:53 -0000 1.1.2.23 @@ -54,6 +54,7 @@ #include "dir-acl.h" #include "branch-acl.h" +#include "default-file-acl.h" #include "user-acl.h" /* Is there a better solution ?? */ @@ -431,6 +432,7 @@ *p = '\0'; \ p++; +/* FIXME: move this to branch-acl.c */ int load_branch_acls (struct DIR_ACL *dir_acl) { @@ -663,25 +665,6 @@ return retval; } -static int -internal_store_default_file_acl (FILE *acl_file, struct DIR_ACL *dir_acl) -{ - struct DEFAULT_FILE_ACL *dfa = dir_acl->default_file_acl; - - while (dfa != NULL) { - struct USER_ACL *user_acl = dfa->user_acl; - while (user_acl != NULL) { - fprintf(acl_file, "D%s\t%s\t%s\n", dfa->branch, - user_acl->username, branch_permissions_string(user_acl->perm)); - - user_acl = user_acl->next; - } - dfa = dfa->next; - } - - return 0; -} - int store_dir_acl (struct DIR_ACL *dir_acl) { @@ -714,7 +697,7 @@ if (internal_store_dir_acl(fd, dir_acl) != 0) goto out; - if (internal_store_default_file_acl(acl_file, dir_acl) != 0) + if (store_default_file_acl(acl_file, dir_acl->default_file_acl) != 0) goto out; if (fclose(acl_file) == EOF) @@ -798,62 +781,4 @@ free_stringbuf(tmpfilename); free_stringbuf(filename); return retval; -} - - -static struct DEFAULT_FILE_ACL * -get_default_file_acl (struct DIR_ACL *dir_acl, char *branch) -{ - struct DEFAULT_FILE_ACL *current = dir_acl->default_file_acl; - - while (current != NULL) { - if (strcmp(current->branch, branch) == 0) - return current; - - current = current->next; - } - - return NULL; -} - -struct USER_ACL * -get_default_file_user_acl (struct DIR_ACL *dir_acl, char *branch) -{ - struct DEFAULT_FILE_ACL *dfa = get_default_file_acl(dir_acl, branch); - if (dfa == NULL) - return NULL; - - return dfa->user_acl; -} - -int -set_default_file_acl (struct DIR_ACL *dir_acl, char *branch, char *username, int perm) -{ - struct DEFAULT_FILE_ACL *dfa; - struct USER_ACL *new_acls; - - dfa = get_default_file_acl(dir_acl, branch); - if (dfa == NULL) { - dfa = calloc(1, sizeof(struct DEFAULT_FILE_ACL)); - if (dfa == NULL) - return 0; - - dfa->branch = strdup(branch); - if (dfa->branch == NULL) { - free(dfa); - return 0; - } - - dfa->next = dir_acl->default_file_acl; - - dir_acl->default_file_acl = dfa; - } - - new_acls = set_user_ace(dfa->user_acl, username, perm); - if (new_acls == NULL) - return 0; - - dfa->user_acl = new_acls; - - return perm; } Index: dir-acl.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.h,v retrieving revision 1.1.2.12 retrieving revision 1.1.2.13 diff -u -d -r1.1.2.12 -r1.1.2.13 --- dir-acl.h 9 Jun 2002 11:42:55 -0000 1.1.2.12 +++ dir-acl.h 9 Jun 2002 12:07:53 -0000 1.1.2.13 @@ -9,9 +9,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - Copyright (c) Alexey Mahotkin <al...@hs...> 2001 - - Per-directory ACL implementation + Copyright (c) Alexey Mahotkin <al...@hs...> 2001-2002 */ @@ -25,16 +23,6 @@ #include "stringbuf.h" -/*! \struct DEFAULT_FILE_ACL - \brief Default file access control list for a branch -*/ - -struct DEFAULT_FILE_ACL { - char *branch; - struct USER_ACL *user_acl; - struct DEFAULT_FILE_ACL *next; -}; - /*! \struct DIR_ACL \brief Access control list for a particular directory. @@ -42,6 +30,8 @@ struct BRANCH_ACL; +struct DEFAULT_FILE_ACL; + struct DIR_ACL { /*! \var dirname @@ -130,9 +120,5 @@ int dir_permission_granted (struct DIR_ACL *dir_acl, char *username, int perm); int store_dir_acl (struct DIR_ACL *dir_acl); - -int set_default_file_acl (struct DIR_ACL *dir_acl, char *branch, char *username, int perm); - -struct USER_ACL *get_default_file_user_acl(struct DIR_ACL *dir_acl, char *branch); #endif /* DIR_ACL_H */ |
From: Alexey M. <ty...@us...> - 2002-06-09 11:42:57
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv12159 Modified Files: Tag: NCLI-1-11-1 dir-acl.c dir-acl.h Log Message: Rename internal_get_dir_acl() to add_dir_acl_topdirs(); refactor; plug memory leaks; better error handling; document Index: dir-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.c,v retrieving revision 1.1.2.21 retrieving revision 1.1.2.22 diff -u -d -r1.1.2.21 -r1.1.2.22 --- dir-acl.c 9 Jun 2002 00:36:49 -0000 1.1.2.21 +++ dir-acl.c 9 Jun 2002 11:42:55 -0000 1.1.2.22 @@ -128,9 +128,8 @@ return current_default_dir_perm; } -static DIR_ACL *create_and_load_dir_acl (char *dir); -static DIR_ACL *internal_get_dir_acl (char *dir, char *branch, - struct DIR_ACL *the_dir_acl); +static struct DIR_ACL *create_and_load_dir_acl (char *dir); +static struct DIR_ACL *add_dir_acl_topdirs (char *dir, struct DIR_ACL *the_dir_acl); struct DIR_ACL * @@ -143,15 +142,16 @@ if (strncmp(dir, current_toplevel_directory, strlen(current_toplevel_directory)) != 0) goto out; - dir_copy = strdup(dir); - if (dir_copy == NULL) - goto err; - dir_acl = create_and_load_dir_acl(dir); if (!dir_acl) goto err; - if (!internal_get_dir_acl(dir_copy, branch, dir_acl)) + /* add_dir_acl_topdirs() will modify its first argument */ + dir_copy = strdup(dir); + if (dir_copy == NULL) + goto err; + + if (!add_dir_acl_topdirs(dir_copy, dir_acl)) goto err; out: @@ -195,15 +195,30 @@ } -static DIR_ACL * -internal_get_dir_acl (char *dir, char *branch, struct DIR_ACL *the_dir_acl) +/*! \fn struct DIR_ACL* add_dir_acl_topdirs (char* dir, struct DIR_ACL* the_dir_acl) + + \brief Adds parent directories of specified directory to \c the_dir_acl->top_dirs + + \param dir Full path to the directory that corresponds to \c + the_dir_acl. This argument will be modified inplace, so it should be + temporary \c strdup()'ed copy. + + \param the_dir_acl \c "struct DIR_ACL", whose \c top_dirs field will + be filled with DIR_ACL's for parent directories. + + \retval the_dir_acl if all was Ok. + + \retval NULL if memory allocation failed or \c + create_and_load_dir_acl() returned error. + +*/ + +static struct DIR_ACL * +add_dir_acl_topdirs (char *dir, struct DIR_ACL *the_dir_acl) { int toplevel_len = strlen(current_toplevel_directory); char *last_component; - if (the_dir_acl == NULL) - return NULL; - /* FIXME: somehow the parent directory gets added twice. It is harmless, but needs investigation */ @@ -211,17 +226,25 @@ if (last_component == NULL) { /* we are processing the top dir */ struct DIR_ACL *topdir_acl = create_and_load_dir_acl(dir); + if (!topdir_acl) + return NULL; - add_dir_to_path(the_dir_acl, topdir_acl); + if (!add_dir_to_path(the_dir_acl, topdir_acl)) + return NULL; } else { /* we need to strip the last component and try to get its top dir */ struct DIR_ACL *this_dir_acl; *last_component = '\0'; this_dir_acl = create_and_load_dir_acl(dir); - add_dir_to_path(the_dir_acl, this_dir_acl); + if (!this_dir_acl) + return NULL; - internal_get_dir_acl(dir, branch, the_dir_acl); + if (!add_dir_to_path(the_dir_acl, this_dir_acl)) + return NULL; + + if (!add_dir_acl_topdirs(dir, the_dir_acl)) + return NULL; *last_component = '/'; } @@ -264,10 +287,16 @@ void destroy_dir_acl (struct DIR_ACL* dir_acl) { + int i; + if (!dir_acl) return; free_stringbuf(dir_acl->dirname); + free_user_acls(dir_acl->user_acls); + for (i = 0; i < dir_acl->top_dirs_count; i++) { + destroy_dir_acl(dir_acl->top_dirs[i]); + } free(dir_acl->top_dirs); free(dir_acl); } @@ -278,7 +307,7 @@ /*! \fn struct DIR_ACL* create_and_load_dir_acl (char* dir) - \brief Creates struct DIR_ACL for specified directory and loads its + \brief Creates \c "struct DIR_ACL" for specified directory and loads its access control list. \param dir Full path to a directory @@ -288,8 +317,8 @@ \retval NULL if: - memory allocation failed; - specified directory does not exist (\c errno is set to \c ENOENT); - - too long line in the DIRACL file (\c errno is set to \c E2BIG); - - invalid line format in the DIRACL file (\c errno is set to \c EINVAL); + - too long line in the \c DIRACL file (\c errno is set to \c E2BIG); + - invalid line format in the \c DIRACL file (\c errno is set to \c EINVAL); */ @@ -597,7 +626,7 @@ static int -internal_store_dir_acl (int fd, DIR_ACL *dir_acl) +internal_store_dir_acl (int fd, struct DIR_ACL *dir_acl) { int retval = -1; struct stringbuf *line = NULL; @@ -635,7 +664,7 @@ } static int -internal_store_default_file_acl (FILE *acl_file, DIR_ACL *dir_acl) +internal_store_default_file_acl (FILE *acl_file, struct DIR_ACL *dir_acl) { struct DEFAULT_FILE_ACL *dfa = dir_acl->default_file_acl; @@ -773,7 +802,7 @@ static struct DEFAULT_FILE_ACL * -get_default_file_acl (DIR_ACL *dir_acl, char *branch) +get_default_file_acl (struct DIR_ACL *dir_acl, char *branch) { struct DEFAULT_FILE_ACL *current = dir_acl->default_file_acl; @@ -788,7 +817,7 @@ } struct USER_ACL * -get_default_file_user_acl (DIR_ACL *dir_acl, char *branch) +get_default_file_user_acl (struct DIR_ACL *dir_acl, char *branch) { struct DEFAULT_FILE_ACL *dfa = get_default_file_acl(dir_acl, branch); if (dfa == NULL) @@ -798,7 +827,7 @@ } int -set_default_file_acl (DIR_ACL *dir_acl, char *branch, char *username, int perm) +set_default_file_acl (struct DIR_ACL *dir_acl, char *branch, char *username, int perm) { struct DEFAULT_FILE_ACL *dfa; struct USER_ACL *new_acls; Index: dir-acl.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.h,v retrieving revision 1.1.2.11 retrieving revision 1.1.2.12 diff -u -d -r1.1.2.11 -r1.1.2.12 --- dir-acl.h 9 Jun 2002 00:36:49 -0000 1.1.2.11 +++ dir-acl.h 9 Jun 2002 11:42:55 -0000 1.1.2.12 @@ -97,6 +97,8 @@ int branch_acls_loaded; }; +typedef struct DIR_ACL DIR_ACL; + enum DIR_PERM { dir_perm_none = 0x00, dir_perm_access = 0x01, @@ -105,8 +107,6 @@ dir_perm_all = dir_perm_access | dir_perm_modify }; -typedef struct DIR_ACL DIR_ACL; - typedef int dir_permission; void set_toplevel_directory(char *toplevel_dir); @@ -131,8 +131,8 @@ int store_dir_acl (struct DIR_ACL *dir_acl); -int set_default_file_acl (DIR_ACL *dir_acl, char *branch, char *username, int perm); +int set_default_file_acl (struct DIR_ACL *dir_acl, char *branch, char *username, int perm); -struct USER_ACL *get_default_file_user_acl(DIR_ACL *dir_acl, char *branch); +struct USER_ACL *get_default_file_user_acl(struct DIR_ACL *dir_acl, char *branch); #endif /* DIR_ACL_H */ |
From: Alexey M. <ty...@us...> - 2002-06-09 11:41:59
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv12035 Modified Files: Tag: NCLI-1-11-1 user-acl.c user-acl.h Log Message: Allow freeing struct USER_ACL Index: user-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/user-acl.c,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -d -r1.1.2.4 -r1.1.2.5 --- user-acl.c 29 Sep 2001 23:50:32 -0000 1.1.2.4 +++ user-acl.c 9 Jun 2002 11:41:50 -0000 1.1.2.5 @@ -25,6 +25,31 @@ #include <stdlib.h> #include <string.h> +static void +free_user_ace (USER_ACE* ace) +{ + if (!ace) + return; + + free(ace->username); + free(ace); +} + +void +free_user_acls (USER_ACL* acls) +{ + USER_ACL* current = acls; + + while (current) { + USER_ACL* next = current->next; + + free_user_ace(current); + + current = next; + } +} + + USER_ACE * get_user_ace (USER_ACL *acls, char *username) { Index: user-acl.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/user-acl.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- user-acl.h 29 Aug 2001 17:28:11 -0000 1.1.2.1 +++ user-acl.h 9 Jun 2002 11:41:50 -0000 1.1.2.2 @@ -29,10 +29,10 @@ typedef struct USER_ACL USER_ACE; -USER_ACL * -set_user_ace(USER_ACL *acls, char *username, int perm); +void free_user_acls (USER_ACL* acls); -USER_ACE * -get_user_ace (USER_ACL *acls, char *username); +USER_ACL * set_user_ace(USER_ACL *acls, char *username, int perm); + +USER_ACE * get_user_ace (USER_ACL *acls, char *username); #endif /* USER_ACL_H */ |
From: Alexey M. <ty...@us...> - 2002-06-09 00:36:55
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv5678 Modified Files: Tag: NCLI-1-11-1 check_dir_acl.c dir-acl.c dir-acl.h Log Message: Refactor; plug memory leaks; fix error handling Index: check_dir_acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_dir_acl.c,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -d -r1.1.2.9 -r1.1.2.10 --- check_dir_acl.c 7 Jun 2002 13:18:36 -0000 1.1.2.9 +++ check_dir_acl.c 9 Jun 2002 00:36:49 -0000 1.1.2.10 @@ -64,6 +64,8 @@ topdir_acl = get_dir_acl("./nosuchdir", "trunk"); assert(topdir_acl == NULL); assert(errno == ENOENT); + + destroy_dir_acl(topdir_acl); } @@ -87,6 +89,8 @@ /* set default dir permissions back to all */ set_default_dir_perm(dir_perm_all); + + destroy_dir_acl(topdir_acl); } static void @@ -116,6 +120,8 @@ set_default_dir_perm(dir_perm_all); assert(dir_permission_granted(topdir_acl, "mike", dir_perm_access)); assert(dir_permission_granted(topdir_acl, "mike", dir_perm_modify)); + + destroy_dir_acl(topdir_acl); } static void @@ -133,6 +139,7 @@ perror("Storing dir ACL"); exit(1); } + destroy_dir_acl(topdir_acl); topdir_acl = get_dir_acl("./test-acl", "trunk"); assert(topdir_acl); @@ -163,12 +170,14 @@ perror("Storing dir ACL"); exit(1); } + destroy_dir_acl(topdir_acl); topdir_acl = get_dir_acl("./test-acl", "trunk"); assert(topdir_acl); assert(!dir_permission_granted(topdir_acl, "bob", dir_perm_access)); assert(!dir_permission_granted(topdir_acl, "bob", dir_perm_modify)); + destroy_dir_acl(topdir_acl); } int Index: dir-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.c,v retrieving revision 1.1.2.20 retrieving revision 1.1.2.21 diff -u -d -r1.1.2.20 -r1.1.2.21 --- dir-acl.c 9 Jun 2002 00:12:39 -0000 1.1.2.20 +++ dir-acl.c 9 Jun 2002 00:36:49 -0000 1.1.2.21 @@ -132,19 +132,37 @@ static DIR_ACL *internal_get_dir_acl (char *dir, char *branch, struct DIR_ACL *the_dir_acl); -DIR_ACL * + +struct DIR_ACL * get_dir_acl (char *dir, char *branch) { - struct DIR_ACL *dir_acl = create_and_load_dir_acl(dir); - char *dir_copy = strdup(dir); + struct DIR_ACL *dir_acl = NULL; + char *dir_copy = NULL; + + /* check that requested directory derives from top-level directory */ + if (strncmp(dir, current_toplevel_directory, strlen(current_toplevel_directory)) != 0) + goto out; + + dir_copy = strdup(dir); if (dir_copy == NULL) - return NULL; + goto err; - internal_get_dir_acl(dir_copy, branch, dir_acl); + dir_acl = create_and_load_dir_acl(dir); + if (!dir_acl) + goto err; + if (!internal_get_dir_acl(dir_copy, branch, dir_acl)) + goto err; + + out: free(dir_copy); return dir_acl; + + err: + destroy_dir_acl(dir_acl); + dir_acl = NULL; + goto out; } @@ -183,10 +201,6 @@ int toplevel_len = strlen(current_toplevel_directory); char *last_component; - /* check that requested directory derives from top-level directory */ - if (strncmp(dir, current_toplevel_directory, toplevel_len) != 0) - return NULL; - if (the_dir_acl == NULL) return NULL; @@ -237,22 +251,24 @@ return NULL; dir_acl->dirname = new_stringbuf(dir); - if (dir_acl->dirname == NULL) { - free(dir_acl); - return NULL; - } + if (!dir_acl->dirname) + goto err; return dir_acl; + err: + destroy_dir_acl(dir_acl); + return NULL; } -static void +void destroy_dir_acl (struct DIR_ACL* dir_acl) { if (!dir_acl) return; free_stringbuf(dir_acl->dirname); + free(dir_acl->top_dirs); free(dir_acl); } @@ -680,6 +696,7 @@ retval = 0; out: + free_stringbuf(filename); free_stringbuf(tmpfilename); return retval; Index: dir-acl.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.h,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -d -r1.1.2.10 -r1.1.2.11 --- dir-acl.h 8 Jun 2002 23:30:01 -0000 1.1.2.10 +++ dir-acl.h 9 Jun 2002 00:36:49 -0000 1.1.2.11 @@ -114,7 +114,9 @@ void set_default_dir_perm (enum DIR_PERM new_perm); enum DIR_PERM get_default_dir_perm (void); -DIR_ACL *get_dir_acl(char *dir, char *branch); +struct DIR_ACL *get_dir_acl(char *dir, char *branch); +void destroy_dir_acl (struct DIR_ACL* dir_acl); + int load_branch_acls(struct DIR_ACL *dir_acl); int store_branch_acls (struct DIR_ACL *dir_acl); |
From: Alexey M. <ty...@us...> - 2002-06-09 00:17:03
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv2512 Modified Files: Tag: NCLI-1-11-1 Doxyfile Log Message: Extract static functions too Index: Doxyfile =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/Doxyfile,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- Doxyfile 8 Jun 2002 23:30:32 -0000 1.1.2.1 +++ Doxyfile 9 Jun 2002 00:16:58 -0000 1.1.2.2 @@ -57,7 +57,7 @@ # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. -EXTRACT_STATIC = NO +EXTRACT_STATIC = YES # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. |
From: Alexey M. <ty...@us...> - 2002-06-09 00:12:41
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv1826 Modified Files: Tag: NCLI-1-11-1 dir-acl.c Log Message: Refactor, document, and fix create_and_load_dir_acl(), create_dir_acl(), and destroy_dir_acl() Index: dir-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.c,v retrieving revision 1.1.2.19 retrieving revision 1.1.2.20 diff -u -d -r1.1.2.19 -r1.1.2.20 --- dir-acl.c 8 Jun 2002 23:30:00 -0000 1.1.2.19 +++ dir-acl.c 9 Jun 2002 00:12:39 -0000 1.1.2.20 @@ -9,9 +9,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - Copyright (c) Alexey Mahotkin <al...@hs...> 2001 - - Per-directory ACL implementation + Copyright (c) Alexey Mahotkin <al...@hs...> 2001-2002 */ @@ -20,32 +18,32 @@ \brief Directory-level ACL implementation. - Directory-level permissions are kept in the DIRACL file in each + Directory-level permissions are kept in the \c DIRACL file in each subdirectory where at list one ACE (access control list entry) exists. - DIRACL file is a plain text file. Each line starts with a single + \c DIRACL file is a plain text file. Each line starts with a single letter, indicating type of this line. There are currently two types of lines: - - "/" line contains directory-level access control entry; + - \c "/" line contains directory-level access control entry; - - "D" line contains default file access control entry; + - \c "D" line contains default file access control entry; The initial letter is followed by several tab-separated fields. Directory-level ACE lines contain the following fields: - - name of the branch (or "<trunk>"); + - name of the branch (or \c "trunk"); - name of the user to whom this ACE is applied; - directory permission string; - Directory permission strings contain either single word "none", + Directory permission strings contain either single word \c "none", meaning no permission, or a sequence of one or more comma-separated - words "access" or "modify" with obvious meaning (see the + words \c "access" or \c "modify" with obvious meaning (see the Administrator's Guide for more details). */ @@ -90,14 +88,16 @@ static char *current_toplevel_directory = "./"; /*! \fn void set_toplevel_directory (char* toplevel_directory); + \brief Sets the toplevel directory (most often this is a path to repository) + \param toplevel_directory Path to toplevel directory. ACLs are handled only for directories within this toplevel - directory. The get_dir_acl() function will return NULL if asked + directory. The get_dir_acl() function will return \c NULL if asked about directory which is not within toplevel directory. - Initial value is "./". + Initial value is \c "./". */ @@ -128,14 +128,14 @@ return current_default_dir_perm; } -static DIR_ACL *create_and_load_dir_acl (char *dir, char *branch); +static DIR_ACL *create_and_load_dir_acl (char *dir); static DIR_ACL *internal_get_dir_acl (char *dir, char *branch, struct DIR_ACL *the_dir_acl); DIR_ACL * get_dir_acl (char *dir, char *branch) { - struct DIR_ACL *dir_acl = create_and_load_dir_acl(dir, branch); + struct DIR_ACL *dir_acl = create_and_load_dir_acl(dir); char *dir_copy = strdup(dir); if (dir_copy == NULL) return NULL; @@ -196,7 +196,7 @@ last_component = strrchr(dir + toplevel_len, '/'); if (last_component == NULL) { /* we are processing the top dir */ - struct DIR_ACL *topdir_acl = create_and_load_dir_acl(dir, branch); + struct DIR_ACL *topdir_acl = create_and_load_dir_acl(dir); add_dir_to_path(the_dir_acl, topdir_acl); @@ -204,7 +204,7 @@ /* we need to strip the last component and try to get its top dir */ struct DIR_ACL *this_dir_acl; *last_component = '\0'; - this_dir_acl = create_and_load_dir_acl(dir, branch); + this_dir_acl = create_and_load_dir_acl(dir); add_dir_to_path(the_dir_acl, this_dir_acl); internal_get_dir_acl(dir, branch, the_dir_acl); @@ -215,24 +215,24 @@ } +/*! \fn struct DIR_ACL* create_dir_acl (char* dir) -#define MAX_LINE_SIZE 128 + \brief Creates empty struct DIR_ACL for the specified directory. -static DIR_ACL * -create_and_load_dir_acl (char *dir, char *branch) -{ - FILE *acl; - struct DIR_ACL *dir_acl; - struct stat stat_buf; - struct stringbuf *filename; - char buf[MAX_LINE_SIZE]; + \param dir Full path do directory - errno = 0; + \retval "struct DIR_ACL*" containing empty ACL for this directory - if (stat(dir, &stat_buf) == -1) - return NULL; + \retval NULL if memory allocation failed. - dir_acl = (DIR_ACL *) calloc(1, sizeof(struct DIR_ACL)); + \internal + + */ + +static struct DIR_ACL* +create_dir_acl (char* dir) +{ + struct DIR_ACL* dir_acl = calloc(1, sizeof(struct DIR_ACL)); if (dir_acl == NULL) return NULL; @@ -242,16 +242,73 @@ return NULL; } + return dir_acl; +} + + +static void +destroy_dir_acl (struct DIR_ACL* dir_acl) +{ + if (!dir_acl) + return; + + free_stringbuf(dir_acl->dirname); + free(dir_acl); +} + + + +#define MAX_LINE_SIZE 128 + +/*! \fn struct DIR_ACL* create_and_load_dir_acl (char* dir) + + \brief Creates struct DIR_ACL for specified directory and loads its + access control list. + + \param dir Full path to a directory + + \retval "struct DIR_ACL*" containing ACL for this directory + + \retval NULL if: + - memory allocation failed; + - specified directory does not exist (\c errno is set to \c ENOENT); + - too long line in the DIRACL file (\c errno is set to \c E2BIG); + - invalid line format in the DIRACL file (\c errno is set to \c EINVAL); + + */ + +static struct DIR_ACL * +create_and_load_dir_acl (char *dir) +{ + FILE *acl = NULL; + struct DIR_ACL *dir_acl = NULL; + struct stat stat_buf; + struct stringbuf *filename = NULL; + char buf[MAX_LINE_SIZE]; + + errno = 0; + + if (stat(dir, &stat_buf) == -1) + goto err; + + dir_acl = create_dir_acl(dir); + if (!dir_acl) + goto err; + filename = dup_stringbuf(dir_acl->dirname); - if (filename == NULL) { - free(dir_acl); - return NULL; - } - cat_stringbuf(filename, "/DIRACL"); + if (!filename) + goto err; + if (!cat_stringbuf(filename, "/DIRACL")) + goto err; + /* DIRACL file could be missing */ acl = fopen(filename->buf, "r"); - if (acl == NULL) - goto out; + if (acl == NULL) { + if (errno == ENOENT) + goto out; + else + goto err; + } while (fgets(buf, MAX_LINE_SIZE, acl) != NULL) { int len = strlen(buf); @@ -261,11 +318,17 @@ char *username; char *perm_string; - if (buf[len - 1] != '\n') + /* too long line */ + if (buf[len - 1] != '\n') { + errno = E2BIG; goto err; + } buf[len - 1] = '\0'; initial_char = *p++; + /* ignore unknown initial line types */ + /* FIXME: those lines are not preserved when older server + rewrites DIRACL file */ if ((initial_char != '/') && (initial_char != 'D')) continue; @@ -273,7 +336,7 @@ while (*p && (*p != '\t')) p++; if (!*p) - goto err; + goto inval; *p++ = '\0'; username = p; @@ -281,7 +344,7 @@ while (*p && (*p != '\t')) p++; if (!*p) - goto err; + goto inval; *p++ = '\0'; perm_string = p; @@ -290,7 +353,7 @@ p++; if (*p) - goto err; + goto inval; if (initial_char == '/') set_dir_ace(dir_acl, username, parse_dir_permissions(perm_string)); @@ -298,16 +361,19 @@ set_default_file_acl(dir_acl, branch, username, parse_branch_permissions(perm_string)); } - fclose(acl); - out: - return dir_acl; - - err: free_stringbuf(filename); if (acl != NULL) fclose(acl); - return NULL; + return dir_acl; + + inval: + errno = EINVAL; + + err: + destroy_dir_acl(dir_acl); + dir_acl = NULL; + goto out; } @@ -535,6 +601,7 @@ cat_stringbuf(line, dir_permissions_string(user_acl->perm)); catc_stringbuf(line, '\n'); + /* FIXME: change to fprintf() */ if (write(fd, line->buf, line->len) != line->len) goto out; |
From: Alexey M. <ty...@us...> - 2002-06-08 23:30:35
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv27177 Added Files: Tag: NCLI-1-11-1 Doxyfile Log Message: Doxygen configuration file --- NEW FILE: Doxyfile --- # Doxyfile 1.2.12 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Brazilian, Chinese, Croatian, Czech, Danish, Dutch, Finnish, French, # German, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, # Portuguese, Romanian, Russian, Slovak, Slovene, Spanish and Swedish. OUTPUT_LANGUAGE = English # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these class will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. It is allowed to use relative paths in the argument list. STRIP_FROM_PATH = # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower case letters. If set to YES upper case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # users are adviced to set this option to NO. CASE_SENSE_NAMES = YES # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explict @brief command for a brief description. JAVADOC_AUTOBRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # reimplements. INHERIT_DOCS = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consist of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. # For instance some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. WARN_FORMAT = # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank file matching one of the following patterns are included: # *.c *.cc *.cxx *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp # *.h++ *.idl FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. EXCLUDE_PATTERNS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command <filter> <input-file>, where <filter> # is the value of the INPUT_FILTER tag, and <input-file> is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. INPUT_FILTER = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse. FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the Html help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript and frames is required (for instance Mozilla, Netscape 4.0+, # or Internet explorer 4.0+). Note that for large projects the tree generation # can take a very long time. In such cases it is better to disable this feature. # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = YES # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimised for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assigments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_XML = NO #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_PREDEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line and do not end with a semicolon. Such function macros are typically # used for boiler-plate code, and will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::addtions related to external references #--------------------------------------------------------------------------- # The TAGFILES tag can be used to specify one or more tagfiles. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or # super classes. Setting the tag to NO turns the diagrams off. Note that this # option is superceded by the HAVE_DOT option below. This is only a fallback. It is # recommended to install and use dot, since it yield more powerful graphs. CLASS_DIAGRAMS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found on the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_WIDTH = 1024 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_HEIGHT = 1024 # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermedate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::addtions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO # The CGI_NAME tag should be the name of the CGI script that # starts the search engine (doxysearch) with the correct parameters. # A script with this name will be generated by doxygen. CGI_NAME = # The CGI_URL tag should be the absolute URL to the directory where the # cgi binaries are located. See the documentation of your http daemon for # details. CGI_URL = # The DOC_URL tag should be the absolute URL to the directory where the # documentation is located. If left blank the absolute path to the # documentation, with file:// prepended to it, will be used. DOC_URL = # The DOC_ABSPATH tag should be the absolute path to the directory where the # documentation is located. If left blank the directory on the local machine # will be used. DOC_ABSPATH = # The BIN_ABSPATH tag must point to the directory where the doxysearch binary # is installed. BIN_ABSPATH = # The EXT_DOC_PATHS tag can be used to specify one or more paths to # documentation generated for other projects. This allows doxysearch to search # the documentation for these projects as well. EXT_DOC_PATHS = |
From: Alexey M. <ty...@us...> - 2002-06-08 23:30:07
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv27049 Modified Files: Tag: NCLI-1-11-1 dir-acl.c dir-acl.h Log Message: Initial doxygen documentation Index: dir-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.c,v retrieving revision 1.1.2.18 retrieving revision 1.1.2.19 diff -u -d -r1.1.2.18 -r1.1.2.19 --- dir-acl.c 7 Jun 2002 13:18:36 -0000 1.1.2.18 +++ dir-acl.c 8 Jun 2002 23:30:00 -0000 1.1.2.19 @@ -15,9 +15,44 @@ */ + +/*! \file dir-acl.c + + \brief Directory-level ACL implementation. + + Directory-level permissions are kept in the DIRACL file in each + subdirectory where at list one ACE (access control list entry) + exists. + + DIRACL file is a plain text file. Each line starts with a single + letter, indicating type of this line. There are currently two types + of lines: + + - "/" line contains directory-level access control entry; + + - "D" line contains default file access control entry; + + The initial letter is followed by several tab-separated fields. + + Directory-level ACE lines contain the following fields: + + - name of the branch (or "<trunk>"); + + - name of the user to whom this ACE is applied; + + - directory permission string; + + + Directory permission strings contain either single word "none", + meaning no permission, or a sequence of one or more comma-separated + words "access" or "modify" with obvious meaning (see the + Administrator's Guide for more details). + +*/ + #define _BSD_SOURCE 1 -#include "config.h" +#include <config.h> #include "dir-acl.h" #include "branch-acl.h" @@ -52,18 +87,30 @@ #include <io.h> #endif -static char *toplevel_directory = "./"; +static char *current_toplevel_directory = "./"; + +/*! \fn void set_toplevel_directory (char* toplevel_directory); + \brief Sets the toplevel directory (most often this is a path to repository) + \param toplevel_directory Path to toplevel directory. + + ACLs are handled only for directories within this toplevel + directory. The get_dir_acl() function will return NULL if asked + about directory which is not within toplevel directory. + + Initial value is "./". + + */ void -set_toplevel_directory (char *new_tl_dir) +set_toplevel_directory (char *toplevel_directory) { - if (new_tl_dir == NULL) + if (toplevel_directory == NULL) return; - if (new_tl_dir[strlen(new_tl_dir) - 1] != '/') + if (toplevel_directory[strlen(toplevel_directory) - 1] != '/') return; - toplevel_directory = new_tl_dir; + current_toplevel_directory = toplevel_directory; } @@ -133,11 +180,11 @@ static DIR_ACL * internal_get_dir_acl (char *dir, char *branch, struct DIR_ACL *the_dir_acl) { - int toplevel_len = strlen(toplevel_directory); + int toplevel_len = strlen(current_toplevel_directory); char *last_component; /* check that requested directory derives from top-level directory */ - if (strncmp(dir, toplevel_directory, toplevel_len) != 0) + if (strncmp(dir, current_toplevel_directory, toplevel_len) != 0) return NULL; if (the_dir_acl == NULL) Index: dir-acl.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.h,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -d -r1.1.2.9 -r1.1.2.10 --- dir-acl.h 7 Jun 2002 13:18:36 -0000 1.1.2.9 +++ dir-acl.h 8 Jun 2002 23:30:01 -0000 1.1.2.10 @@ -18,9 +18,16 @@ #ifndef DIR_ACL_H #define DIR_ACL_H 1 +/*! \file dir-acl.h + \brief Directory-level ACL interface + +*/ + #include "stringbuf.h" -struct BRANCH_ACL; +/*! \struct DEFAULT_FILE_ACL + \brief Default file access control list for a branch +*/ struct DEFAULT_FILE_ACL { char *branch; @@ -28,14 +35,65 @@ struct DEFAULT_FILE_ACL *next; }; +/*! \struct DIR_ACL + \brief Access control list for a particular directory. + + */ + +struct BRANCH_ACL; + struct DIR_ACL { + /*! \var dirname + + \brief Full path to a directory + */ stringbuf *dirname; + + /*! \var user_acls + + \brief List of access control entries + + \todo FIXME: Currently directory-level permissions do not take + branches into account. + + */ struct USER_ACL *user_acls; + + /*! \var default_file_acl + + \brief Default file access control list + */ struct DEFAULT_FILE_ACL *default_file_acl; + + /*! \var top_dirs + + \brief List of DIR_ACL for all the parent directories of this + directory, up to toplevel directory. + */ + struct DIR_ACL **top_dirs; - struct BRANCH_ACL *branch_acls; + /*! \var top_dirs_count + + \brief Number of elements in top_dirs + */ int top_dirs_count; + + /*! \var top_dirs_allocated + + \brief Number of elements allocated for top_dirs + */ int top_dirs_allocated; + + /*! \var branch_acls + + \brief File-level access control list. + */ + struct BRANCH_ACL *branch_acls; + + /*! \var branch_acls_loaded + + \brief True if file-level ACL is loaded. + */ int branch_acls_loaded; }; |
From: Alexey M. <mo...@us...> - 2002-06-07 13:18:42
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv28091 Modified Files: Tag: NCLI-1-11-1 branch-acl.c check_branch_acl.c check_dir_acl.c dir-acl.c dir-acl.h Log Message: BUGFIX: fixed bug in incorrect branch acl handling Several declaration/header inclusion cleanups... Index: branch-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/branch-acl.c,v retrieving revision 1.1.2.15 retrieving revision 1.1.2.16 diff -u -d -r1.1.2.15 -r1.1.2.16 --- branch-acl.c 27 Nov 2001 00:24:46 -0000 1.1.2.15 +++ branch-acl.c 7 Jun 2002 13:18:35 -0000 1.1.2.16 @@ -23,12 +23,22 @@ #include <assert.h> #include <errno.h> +#ifdef HAVE_FCNTL_H #include <fcntl.h> +#endif #include <stdio.h> +#ifdef HAVE_STDLIB_H #include <stdlib.h> +#endif +#ifdef HAVE_STRING_H #include <string.h> +#endif +#ifdef HAVE_SYS_STAT_H #include <sys/stat.h> +#endif +#ifdef HAVE_SYS_TYPES_H #include <sys/types.h> +#endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif @@ -160,7 +170,8 @@ /* no list of users, use permissions on trunk, and then default permissions for directory */ - if (branch_ace->user_acls == NULL) { + if (branch_ace->user_acls == NULL || + (ace = get_user_ace(branch_ace->user_acls, username))==NULL) { struct BRANCH_ACL *branch_acl = branch_ace->acl; struct DIR_ACL *dir_acl = branch_acl->dir_acl; @@ -181,12 +192,6 @@ return default_branch_perm & perm; return ace->perm & perm; } - - ace = get_user_ace(branch_ace->user_acls, username); - - if (ace == NULL) - return branch_perm_none; - return ace->perm & perm; } Index: check_branch_acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_branch_acl.c,v retrieving revision 1.1.2.12 retrieving revision 1.1.2.13 diff -u -d -r1.1.2.12 -r1.1.2.13 --- check_branch_acl.c 27 Nov 2001 00:24:46 -0000 1.1.2.12 +++ check_branch_acl.c 7 Jun 2002 13:18:36 -0000 1.1.2.13 @@ -20,9 +20,16 @@ #include "dir-acl.h" #include <assert.h> +#ifdef HAVE_ERRNO_H #include <errno.h> +#endif #include <stdio.h> +#ifdef HAVE_STDLIB_H #include <stdlib.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif void Index: check_dir_acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_dir_acl.c,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -d -r1.1.2.8 -r1.1.2.9 --- check_dir_acl.c 31 Mar 2002 18:23:44 -0000 1.1.2.8 +++ check_dir_acl.c 7 Jun 2002 13:18:36 -0000 1.1.2.9 @@ -23,10 +23,19 @@ #include "user-acl.h" #include <assert.h> +#ifdef HAVE_ERRNO_H #include <errno.h> +#endif +#ifdef HAVE_STDLIB_H #include <stdlib.h> +#endif #include <stdio.h> +#ifdef HAVE_STRING_H +#include <string.h> +#endif +#ifdef HAVE_SYS_STAT_H #include <sys/stat.h> +#endif static void Index: dir-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.c,v retrieving revision 1.1.2.17 retrieving revision 1.1.2.18 diff -u -d -r1.1.2.17 -r1.1.2.18 --- dir-acl.c 20 Apr 2002 15:26:50 -0000 1.1.2.17 +++ dir-acl.c 7 Jun 2002 13:18:36 -0000 1.1.2.18 @@ -26,15 +26,25 @@ /* Is there a better solution ?? */ #include "system.h" +#ifdef HAVE_ERRNO_H #include <errno.h> +#endif +#ifdef HAVE_FCNTL_H #include <fcntl.h> +#endif #include <stdio.h> +#ifdef HAVE_STDLIB_H #include <stdlib.h> +#endif #ifdef HAVE_STRING_H #include <string.h> #endif +#ifdef HAVE_SYS_STAT_H #include <sys/stat.h> +#endif +#ifdef HAVE_SYS_TYPES_H #include <sys/types.h> +#endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif @@ -438,7 +448,7 @@ return dir_perm_invalid; } -char * +const char * dir_permissions_string (int perm) { if (perm == dir_perm_none) Index: dir-acl.h =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/dir-acl.h,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -d -r1.1.2.8 -r1.1.2.9 --- dir-acl.h 30 Mar 2002 16:08:09 -0000 1.1.2.8 +++ dir-acl.h 7 Jun 2002 13:18:36 -0000 1.1.2.9 @@ -63,7 +63,7 @@ int parse_dir_permissions(char *perm_string); -char *dir_permissions_string(int perm); +const char *dir_permissions_string(int perm); int set_dir_ace (struct DIR_ACL *dir_acl, char *username, int perm); |
From: Alexey M. <mo...@us...> - 2002-06-04 08:02:55
|
Update of /cvsroot/cvs-nserver/cvs-nserver/src In directory usw-pr-cvs1:/tmp/cvs-serv522 Modified Files: Tag: NCLI-1-11-1 ls.c lsmodules.c Log Message: lsmodules now displays files in root directory of the repository (using file listing procededure from ls.c). output format slightly changed and follows ls output format Index: ls.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/src/Attic/ls.c,v retrieving revision 1.1.2.12 retrieving revision 1.1.2.13 diff -u -d -r1.1.2.12 -r1.1.2.13 --- ls.c 3 May 2002 07:42:15 -0000 1.1.2.12 +++ ls.c 4 Jun 2002 08:02:44 -0000 1.1.2.13 @@ -117,7 +117,7 @@ } -static int +int ls_fileproc (void *callerdat, struct file_info *finfo) { char *rev; @@ -130,13 +130,12 @@ char timestamp[32]; int ts_len; int single_file; - char *xbranch; + char *xbranch = (tagname) ? tagname : "trunk"; int perm; Vers_TS *ts; #ifdef SERVER_SUPPORT if (dir_acl == NULL) { - xbranch = (tagname) ? tagname : "trunk"; if ((dir_acl = get_dir_acl(finfo->repository,xbranch)) == NULL) error(1, 0, "Error getting directory ACL for %s: %s", finfo->repository, strerror(errno)); single_file = 1; Index: lsmodules.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/src/Attic/lsmodules.c,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -d -r1.1.2.6 -r1.1.2.7 --- lsmodules.c 30 May 2002 13:54:46 -0000 1.1.2.6 +++ lsmodules.c 4 Jun 2002 08:02:44 -0000 1.1.2.7 @@ -34,7 +34,7 @@ static void lsmodules_print(const char *module, int perm) { -#if 0 +#if 1 cvs_output("D/", 2); #endif if (mod_list != ALL_MOD_LIST && perm == dir_perm_none) @@ -207,6 +207,7 @@ return 0; } +extern int ls_fileproc(void *callerdat, struct file_info *finfo); static int lsmodules_real(void) @@ -217,7 +218,7 @@ deep = 0; if (CVS_CHDIR(current_parsed_root->directory) < 0) return 1; - return start_recursion ((FILEPROC) NULL, (FILESDONEPROC) NULL, + return start_recursion (ls_fileproc, (FILESDONEPROC) NULL, lsmodules_dirproc, (DIRLEAVEPROC) NULL, (void *) NULL, argc , argv, 0, which, 0, 1,"", 1); } |
From: Alexey M. <mo...@us...> - 2002-06-03 12:15:38
|
Update of /cvsroot/cvs-nserver/cvsview In directory usw-pr-cvs1:/tmp/cvs-serv26023 Log Message: Initial cvsview commit as a separate cvs-nserver module Status: Vendor Tag: nsft Release Tags: start No conflicts created by this import ***** Bogus filespec: - Imported sources |
From: Alexey M. <mo...@us...> - 2002-06-03 12:07:08
|
Update of /cvsroot/cvs-nserver/cvs-nserver/perl In directory usw-pr-cvs1:/tmp/cvs-serv22993 Removed Files: Tag: NCLI-1-11-1 Compat.pm README Log Message: perl files will go into another place --- Compat.pm DELETED --- --- README DELETED --- |
From: Alexey M. <ty...@us...> - 2002-05-31 07:20:21
|
Update of /cvsroot/cvs-nserver/cvs-nserver/src In directory usw-pr-cvs1:/tmp/cvs-serv1805 Modified Files: Tag: NCLI-1-11-1 server.c Log Message: Fixed yet another memory reallocation error; all hail valgrind Index: server.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/src/server.c,v retrieving revision 1.1.1.7.2.1.2.12 retrieving revision 1.1.1.7.2.1.2.13 diff -u -d -r1.1.1.7.2.1.2.12 -r1.1.1.7.2.1.2.13 --- server.c 31 May 2002 06:30:18 -0000 1.1.1.7.2.1.2.12 +++ server.c 31 May 2002 07:20:16 -0000 1.1.1.7.2.1.2.13 @@ -2098,9 +2098,9 @@ return 0; } -static int argument_count; -static char **argument_vector; -static int argument_vector_size; +static int argument_count = 0; +static char **argument_vector = NULL; +static int argument_vector_size = 0; static void serve_argument (arg) @@ -2109,18 +2109,20 @@ char *p; if (error_pending()) return; - - if (argument_vector_size <= argument_count + 1) + +#define ALLOCATE_DELTA 10 + + /* reallocate if needed */ + if (argument_count + 1 >= argument_vector_size) { - argument_vector_size *= 2; - argument_vector = - (char **) realloc ((char *)argument_vector, - argument_vector_size * sizeof (char *)); + argument_vector = realloc ((char *)argument_vector, + (argument_vector_size + ALLOCATE_DELTA) * sizeof (char *)); if (argument_vector == NULL) { pending_error = ENOMEM; return; } + argument_vector_size += ALLOCATE_DELTA; } p = malloc (strlen (arg) + 1); if (p == NULL) |
From: Alexey M. <ty...@us...> - 2002-05-31 06:30:21
|
Update of /cvsroot/cvs-nserver/cvs-nserver/src In directory usw-pr-cvs1:/tmp/cvs-serv5201 Modified Files: Tag: NCLI-1-11-1 lstags.c main.c server.c Log Message: Split 'cvs lstags' to 'cvs lsbranches' and 'cvs lsalltags' Index: lstags.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/src/Attic/lstags.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- lstags.c 9 May 2002 18:12:50 -0000 1.1.2.1 +++ lstags.c 31 May 2002 06:30:18 -0000 1.1.2.2 @@ -12,6 +12,18 @@ int retval = 1; struct stringbuf* filename; FILE* nval_tags; + int send_tags = 0; + int send_branches = 0; + + if (strcmp(command_name, "lstags") == 0) { + send_tags = 1; + } else if (strcmp(command_name, "lsbranches") == 0) { + send_branches = 1; + } else if (strcmp(command_name, "lsalltags") == 0) { + send_branches = 1; + send_tags = 1; + } else + error(1, 0, "Internal error: unknown lstags-style command '%s'", command_name); filename = new_stringbuf(current_parsed_root->directory); if (!filename) @@ -29,7 +41,10 @@ } else { char buf[BUFSIZ]; while (fgets(buf, sizeof(buf), nval_tags)) { - cvs_output(buf, 0); + if ((send_tags && (buf[0] == 'T')) || + (send_branches && (buf[0] == 'B'))) { + cvs_output(buf, 0); + } } if (fclose(nval_tags) == EOF) { error(1, errno, "Error closing %s: %s", filename->buf, strerror(errno)); @@ -55,10 +70,11 @@ if (current_parsed_root->isremote) { start_server(); - if (!supported_request ("lstags")) + if (!supported_request (command_name)) error (1, 0, "server does not support tags listing"); - send_to_server("lstags\012", 0); + send_to_server(command_name, 0); + send_to_server("\012", 0); return get_responses_and_close(); } Index: main.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/src/main.c,v retrieving revision 1.1.1.6.2.4.2.17 retrieving revision 1.1.1.6.2.4.2.18 diff -u -d -r1.1.1.6.2.4.2.17 -r1.1.1.6.2.4.2.18 --- main.c 25 May 2002 15:54:41 -0000 1.1.1.6.2.4.2.17 +++ main.c 31 May 2002 06:30:18 -0000 1.1.1.6.2.4.2.18 @@ -148,6 +148,8 @@ { "lsacl", NULL, NULL, lsacl, 0 }, { "lsmodules",NULL, NULL, lsmodules, 0 }, { "lstags", NULL, NULL, lstags, 0 }, + { "lsbranches", NULL, NULL, lstags, 0 }, + { "lsalltags", NULL, NULL, lstags, 0 }, { "log", "lo", NULL, cvslog, CVS_CMD_USES_WORK_DIR }, #ifdef AUTH_CLIENT_SUPPORT { "login", "logon", "lgn", login, 0 }, @@ -249,6 +251,9 @@ " logout Removes entry in .cvspass for remote repository\n", #endif /* AUTH_CLIENT_SUPPORT */ " ls Lists files and directories in repository\n", + " lstags List tags in repository\n", + " lsbranches List branches in repository\n", + " lsalltags List both tags and branches in repository\n", #if (defined(AUTH_SERVER_SUPPORT) || defined (HAVE_GSSAPI)) && defined(SERVER_SUPPORT) " pserver Password server mode\n", #endif Index: server.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/src/server.c,v retrieving revision 1.1.1.7.2.1.2.11 retrieving revision 1.1.1.7.2.1.2.12 diff -u -d -r1.1.1.7.2.1.2.11 -r1.1.1.7.2.1.2.12 --- server.c 25 May 2002 15:54:41 -0000 1.1.1.7.2.1.2.11 +++ server.c 31 May 2002 06:30:18 -0000 1.1.1.7.2.1.2.12 @@ -3629,6 +3629,8 @@ SERVE(lsacl) SERVE(lsmodules) SERVE(lstags) + SERVE_R(lsalltags, lstags) + SERVE_R(lsbranches, lstags) SERVE(passwd) SERVE(racl) SERVE_R(rannotate, annotate) @@ -4670,6 +4672,8 @@ REQ_LINE("lsacl", serve_lsacl, 0), REQ_LINE("lsmodules", serve_lsmodules, 0), REQ_LINE("lstags", serve_lstags, 0), + REQ_LINE("lsalltags", serve_lsalltags, 0), + REQ_LINE("lsbranches", serve_lsbranches, 0), REQ_LINE(NULL, NULL, 0) #undef REQ_LINE |