[Cvs-nserver-commits] CVS: cvs-nserver/acl default-file-acl.c,NONE,1.1.2.1 default-file-acl.h,NONE,1
Brought to you by:
tyranny
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 */ |