GridSite Grid Security for the Web
Web platforms for Grids

Welcome page : Documentation : Download : License

gridsite.h

Go to the documentation of this file.
00001 /*
00002    Copyright (c) 2002-5, Andrew McNab, University of Manchester
00003    All rights reserved.
00004 
00005    Redistribution and use in source and binary forms, with or
00006    without modification, are permitted provided that the following
00007    conditions are met:
00008 
00009      o Redistributions of source code must retain the above
00010        copyright notice, this list of conditions and the following
00011        disclaimer. 
00012      o Redistributions in binary form must reproduce the above
00013        copyright notice, this list of conditions and the following
00014        disclaimer in the documentation and/or other materials
00015        provided with the distribution. 
00016 
00017    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
00018    CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
00019    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00020    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
00022    BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00024    TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00025    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00026    ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00027    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00028    OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029    POSSIBILITY OF SUCH DAMAGE.
00030 */
00031 
00032 /*---------------------------------------------------------------*
00033  * For more about GridSite: http://www.gridsite.org/             *
00034  *---------------------------------------------------------------*/
00035 
00036 #ifndef HEADER_SSL_H
00037 #include <openssl/ssl.h>
00038 #endif
00039 
00040 #ifndef HEADER_CRYPTO_H
00041 #include <openssl/crypto.h>
00042 #endif
00043 
00044 #ifndef FALSE
00045 #define FALSE (0)
00046 #endif
00047 #ifndef TRUE
00048 #define TRUE (!FALSE)
00049 #endif
00050 
00052 #define GRST_RET_OK             0
00053 
00055 #define GRST_RET_FAILED         1000
00056 
00058 #define GRST_RET_CERT_NOT_FOUND 1001
00059 
00061 #define GRST_RET_BAD_SIGNATURE  1002
00062 
00064 #define GRST_RET_NO_SUCH_FILE   1003
00065 
00066 typedef struct { char                      *name;
00067                  char                      *value;
00068                  void                      *next;  } GRSTgaclNamevalue;
00069 
00070 typedef struct { char                      *type;
00071                  int                        delegation;
00072                  GRSTgaclNamevalue         *firstname;
00073                  void                      *next;      } GRSTgaclCred;
00074  
00075 typedef int                GRSTgaclAction;
00076 typedef unsigned int       GRSTgaclPerm;
00077  
00078 typedef struct { GRSTgaclCred   *firstcred;
00079                  GRSTgaclPerm    allowed;
00080                  GRSTgaclPerm    denied;
00081                  void           *next;    } GRSTgaclEntry;
00082  
00083 typedef struct { GRSTgaclEntry *firstentry; } GRSTgaclAcl;
00084  
00085 typedef struct { GRSTgaclCred *firstcred; 
00086                  char         *dnlists;   } GRSTgaclUser;
00087 
00088 #define GRST_PERM_NONE   0
00089 #define GRST_PERM_READ   1
00090 #define GRST_PERM_EXEC   2
00091 #define GRST_PERM_LIST   4
00092 #define GRST_PERM_WRITE  8
00093 #define GRST_PERM_ADMIN 16
00094 #define GRST_PERM_ALL   31
00095 
00096 /* DO NOT USE PermIsNone!! */
00097 #define GRSTgaclPermIsNone(perm)    (perm == 0)
00098 
00099 #define GRSTgaclPermHasNone(perm)    (perm == 0)
00100 #define GRSTgaclPermHasRead(perm)  ((perm & GRST_PERM_READ ) != 0)
00101 #define GRSTgaclPermHasExec(perm)  ((perm & GRST_PERM_EXEC ) != 0)
00102 #define GRSTgaclPermHasList(perm)  ((perm & GRST_PERM_LIST ) != 0)
00103 #define GRSTgaclPermHasWrite(perm) ((perm & GRST_PERM_WRITE) != 0)
00104 #define GRSTgaclPermHasAdmin(perm) ((perm & GRST_PERM_ADMIN) != 0)
00105 
00106 #define GRST_ACTION_ALLOW 0
00107 #define GRST_ACTION_DENY  1
00108 
00109 #define GRST_HIST_PREFIX  ".grsthist"
00110 #define GRST_ACL_FILE     ".gacl"
00111 #define GRST_DN_LISTS     "/etc/grid-security/dn-lists"
00112 #define GRST_RECURS_LIMIT 9
00113 
00114 #define GRST_PROXYCERTINFO_OID  "1.3.6.1.4.1.3536.1.222"
00115 #define GRST_VOMS_OID           "1.3.6.1.4.1.8005.100.100.5"
00116 #define GRST_VOMS_DIR           "/etc/grid-security/vomsdir"
00117 
00118 #define GRST_ASN1_MAXCOORDLEN   50
00119 #define GRST_ASN1_MAXTAGS       500
00120 
00121 struct GRSTasn1TagList { char treecoords[GRST_ASN1_MAXCOORDLEN+1];
00122                          int  start;
00123                          int  headerlength;
00124                          int  length;
00125                          int  tag; } ;
00126 
00127 #define GRST_HTTP_PORT          777
00128 #define GRST_HTTPS_PORT         488
00129 #define GRST_HTCP_PORT          777
00130                          
00131 #define GRSThtcpNOPop 0
00132 #define GRSThtcpTSTop 1
00133 
00134 typedef struct { unsigned char length_msb;
00135                  unsigned char length_lsb;
00136                  char text[1]; } GRSThtcpCountstr;
00137 
00138 #define GRSThtcpCountstrLen(string) (256*((string)->length_msb) + (string)->length_lsb)
00139 
00140 typedef struct { unsigned char total_length_msb;
00141                  unsigned char total_length_lsb;
00142                  unsigned char version_msb;
00143                  unsigned char version_lsb;
00144                  unsigned char data_length_msb;
00145                  unsigned char data_length_lsb;
00146                  unsigned int  response : 4;
00147                  unsigned int  opcode   : 4;
00148                  unsigned int  rr       : 1;                 
00149                  unsigned int  f1       : 1;
00150                  unsigned int  reserved : 6;
00151                  unsigned int  trans_id;        /* must be 4 bytes */
00152                  GRSThtcpCountstr *method;
00153                  GRSThtcpCountstr *uri;
00154                  GRSThtcpCountstr *version;
00155                  GRSThtcpCountstr *req_hdrs;
00156                  GRSThtcpCountstr *resp_hdrs;
00157                  GRSThtcpCountstr *entity_hdrs;
00158                  GRSThtcpCountstr *cache_hdrs;   } GRSThtcpMessage;
00159 
00160 int GRSTgaclInit(void);
00161 
00162 /* #define GACLnewCred(x)               GRSTgaclCredNew((x)) */
00163 GRSTgaclCred  *GRSTgaclCredNew(char *);
00164 
00165 /* #define GACLaddToCred(x,y,z) GRSTgaclCredAddValue((x),(y),(z)) */
00166 int        GRSTgaclCredAddValue(GRSTgaclCred *, char *, char *);
00167 
00168 #define GRSTgaclCredSetDelegation(cred, level) ((cred)->delegation = (level))
00169 #define GRSTgaclCredGetDelegation(cred) ((cred)->delegation)
00170 
00171 /* #define GACLfreeCred(x)              GRSTgaclCredFree((x)) */
00172 int        GRSTgaclCredFree(GRSTgaclCred *);
00173 
00174 /*  #define GACLaddCred(x,y)    GRSTgaclEntryAddCred((x),(y)) */
00175 int        GRSTgaclEntryAddCred(GRSTgaclEntry *, GRSTgaclCred *);
00176 
00177 /*  #define GACLdelCred(x,y)    GRSTgaclEntryDelCred((x),(y)) */
00178 int        GRSTgaclEntryDelCred(GRSTgaclEntry *, GRSTgaclCred *);
00179 
00180 /*  #define GACLprintCred(x,y)  GRSTgaclCredPrint((x),(y)) */
00181 int        GRSTgaclCredCredPrint(GRSTgaclCred *, FILE *);
00182 
00183 
00184 /*  #define GACLnewEntry(x)             GRSTgaclEntryNew((x)) */
00185 GRSTgaclEntry *GRSTgaclEntryNew(void);
00186 
00187 /*  #define GACLfreeEntry(x)    GRSTgaclEntryFree((x)) */
00188 int        GRSTgaclEntryFree(GRSTgaclEntry *);
00189 
00190 /*  #define GACLaddEntry(x,y)   GRSTgaclAclAddEntry((x),(y)) */
00191 int        GRSTgaclAclAddEntry(GRSTgaclAcl *, GRSTgaclEntry *);
00192 
00193 /*  #define GACLprintEntry(x,y) GRSTgaclEntryPrint((x),(y)) */
00194 int        GRSTgaclEntryPrint(GRSTgaclEntry *, FILE *);
00195 
00196 
00197 /*  #define GACLprintPerm(x,y)  GRSTgaclPermPrint((x),(y)) */
00198 int        GRSTgaclPermPrint(GRSTgaclPerm, FILE *);
00199 
00200 /*  #define GACLallowPerm(x,y)  GRSTgaclEntryAllowPerm((x),(y)) */
00201 int        GRSTgaclEntryAllowPerm(GRSTgaclEntry *, GRSTgaclPerm);
00202 
00203 /*  #define GACLunallowPerm(x,y)        GRSTgaclEntryUnallowPerm((x),(y)) */
00204 int        GRSTgaclEntryUnallowPerm(GRSTgaclEntry *, GRSTgaclPerm);
00205 
00206 /*  #define GACLdenyPerm(x,y)   GRSTgaclEntryDenyPerm((x),(y)) */
00207 int        GRSTgaclEntryDenyPerm(GRSTgaclEntry *, GRSTgaclPerm);
00208 
00209 /*  #define GACLundenyPerm(x,y) GRSTgaclEntryUndenyPerm((x),(y)) */
00210 int        GRSTgaclEntryUndenyPerm(GRSTgaclEntry *, GRSTgaclPerm);
00211 
00212 /*  #define GACLpermToChar(x)   GRSTgaclPermToChar((x)) */
00213 char      *GRSTgaclPermToChar(GRSTgaclPerm);
00214 
00215 /*  #define GACLcharToPerm(x)   GRSTgaclPermFromChar((x)) */
00216 GRSTgaclPerm   GRSTgaclPermFromChar(char *);
00217 
00218 /*  #define GACLnewAcl(x)               GRSTgaclAclNew((x)) */
00219 GRSTgaclAcl   *GRSTgaclAclNew(void);
00220 
00221 /*  #define GACLfreeAcl(x)              GRSTgaclAclFree((x)) */
00222 int        GRSTgaclAclFree(GRSTgaclAcl *);
00223 
00224 /*  #define GACLprintAcl(x,y)   GRSTgaclAclPrint((x),(y)) */
00225 int        GRSTgaclAclPrint(GRSTgaclAcl *, FILE *);
00226 
00227 /*  #define GACLsaveAcl(x,y)    GRSTgaclAclSave((y),(x)) */
00228 int        GRSTgaclAclSave(GRSTgaclAcl *, char *);
00229 
00230 /*  #define GACLloadAcl(x)              GRSTgaclFileLoadAcl((x)) */
00231 GRSTgaclAcl   *GRSTgaclAclLoadFile(char *);
00232 
00233 /*  #define GACLfindAclForFile(x)       GRSTgaclFileFindAclname((x)) */
00234 char      *GRSTgaclFileFindAclname(char *);
00235 
00236 /*  #define GACLloadAclForFile(x)       GRSTgaclFileLoadAcl((x)) */
00237 GRSTgaclAcl   *GRSTgaclAclLoadforFile(char *);
00238 
00239 /*  #define GACLisAclFile(x)    GRSTgaclFileIsAcl((x)) */
00240 int        GRSTgaclFileIsAcl(char *);
00241 
00242 
00243 /*  #define GACLnewUser(x)              GRSTgaclUserNew((x)) */
00244 GRSTgaclUser *GRSTgaclUserNew(GRSTgaclCred *);
00245 
00246 /*  #define GACLfreeUser(x)             GRSTgaclUserFree((x)) */
00247 int       GRSTgaclUserFree(GRSTgaclUser *);
00248 
00249 /*  #define GACLuserAddCred(x,y)        GRSTgaclUserAddCred((x),(y)) */
00250 int       GRSTgaclUserAddCred(GRSTgaclUser *, GRSTgaclCred *);
00251 
00252 /*  #define GACLuserHasCred(x,y)        GRSTgaclUserHasCred((x),(y)) */
00253 int       GRSTgaclUserHasCred(GRSTgaclUser *, GRSTgaclCred *);
00254 
00255 int       GRSTgaclUserSetDNlists(GRSTgaclUser *, char *);
00256 
00257 /*  #define GACLuserFindCredType(x,y) GRSTgaclUserFindCredtype((x),(y)) */
00258 GRSTgaclCred *GRSTgaclUserFindCredtype(GRSTgaclUser *, char *);
00259 
00260 /*  #define GACLtestDnList(x,y) GRSTgaclDNlistHasUser((x),(y)) */
00261 int GRSTgaclDNlistHasUser(char *, GRSTgaclUser *);
00262 
00263 /*  #define GACLtestUserAcl(x,y)        GRSTgaclAclTestUser((x),(y)) */
00264 GRSTgaclPerm   GRSTgaclAclTestUser(GRSTgaclAcl *, GRSTgaclUser *);
00265 
00266 /*  #define GACLtestExclAcl(x,y)        GRSTgaclAclTestexclUser((x),(y)) */
00267 GRSTgaclPerm   GRSTgaclAclTestexclUser(GRSTgaclAcl *, GRSTgaclUser *);
00268 
00269 char      *GRSThttpUrlDecode(char *);
00270 
00271 /*  #define GACLurlEncode(x)    GRSThttpUrlEncode((x)) */
00272 char      *GRSThttpUrlEncode(char *);
00273 
00274 /*  #define GACLmildUrlEncode(x)        GRSThttpMildUrlEncode((x)) */
00275 char      *GRSThttpUrlMildencode(char *);
00276 
00277 int GRSTx509NameCmp(char *, char *);
00278 
00279 int GRSTx509KnownCriticalExts(X509 *);
00280 
00281 int GRSTx509IsCA(X509 *);
00282 int GRSTx509CheckChain(int *, X509_STORE_CTX *);
00283 int GRSTx509VerifyCallback(int, X509_STORE_CTX *);
00284 
00285 int GRSTx509GetVomsCreds(int *, int, size_t, char *, X509 *, STACK_OF(X509) *, char *);
00286 GRSTgaclCred *GRSTx509CompactToCred(char *);
00287 int GRSTx509CompactCreds(int *, int, size_t, char *, STACK_OF(X509) *, char *, X509 *);
00288 char *GRSTx509CachedProxyFind(char *, char *, char *);
00289 char *GRSTx509FindProxyFileName(void);
00290 int GRSTx509MakeProxyCert(char **, FILE *, char *, char *, char *, int);
00291 char *GRSTx509CachedProxyKeyFind(char *, char *, char *);
00292 int GRSTx509ProxyDestroy(char *, char *, char *);
00293 int GRSTx509ProxyGetTimes(char *, char *, char *, time_t *, time_t *);
00294 int GRSTx509MakeProxyRequest(char **, char *, char *, char *);
00295 int GRSTx509StringToChain(STACK_OF(X509) **, char *);
00296 char *GRSTx509MakeDelegationID(void);
00297 char *GRSTx509MakeProxyFileName(char *, STACK_OF(X509) *);
00298 int GRSTx509CacheProxy(char *, char *, char *, char *);
00299 
00300 #define GRST_HEADFILE   "gridsitehead.txt"
00301 #define GRST_FOOTFILE   "gridsitefoot.txt"
00302 #define GRST_ADMIN_FILE "gridsite-admin.cgi"
00303 
00304 typedef struct { char *text;
00305                  void *next; } GRSThttpCharsList;
00306 
00307 typedef struct { size_t             size;
00308                  GRSThttpCharsList *first;
00309                  GRSThttpCharsList *last;  } GRSThttpBody;
00310 
00311 void  GRSThttpBodyInit(GRSThttpBody *); 
00312 void  GRSThttpPrintf(GRSThttpBody *, char *, ...);
00313 int   GRSThttpCopy(GRSThttpBody *, char *);
00314 void  GRSThttpWriteOut(GRSThttpBody *);
00315 int   GRSThttpPrintHeaderFooter(GRSThttpBody *, char *, char *);
00316 char *GRSThttpGetCGI(char *);
00317 
00318 time_t GRSTasn1TimeToTimeT(char *, size_t);
00319 int    GRSTasn1SearchTaglist(struct GRSTasn1TagList taglist[], int, char *);
00320 int    GRSTasn1ParseDump(BIO *, unsigned char *, long,
00321                          struct GRSTasn1TagList taglist[], int, int *);
00322 int    GRSTasn1GetX509Name(char *, int, char *, char *,
00323                            struct GRSTasn1TagList taglist[], int);
00324 
00325 int    GRSThtcpNOPrequestMake(char **, int *, unsigned int);
00326 int    GRSThtcpNOPresponseMake(char **, int *, unsigned int);
00327 int    GRSThtcpTSTrequestMake(char **, int *, unsigned int, char *, char *, char *);
00328 int    GRSThtcpTSTresponseMake(char **, int *, unsigned int, char *, char *, char *);
00329 int    GRSThtcpMessageParse(GRSThtcpMessage *, char *, int);

Generated on Fri Feb 16 11:51:15 2007 by  doxygen 1.3.9.1


Last modified Fri 16 February 2007 . View page history
Switch to HTTPS . Print View . Built with GridSite 1.4.3
Funded by:   GridPP   STFC   JISC   University of Manchester