You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl-cvs@perl.apache.org by ri...@apache.org on 2001/08/10 16:06:42 UTC

cvs commit: embperl Changes.pod embperl.h epcmd.c epdat.h epmain.c

richter     01/08/10 07:06:42

  Modified:    .        Changes.pod embperl.h epcmd.c epdat.h epmain.c
  Log:
     - Added options optAddUserSessionToLinks, optAddStatusSessionToLinks
       and optNoSessionCookies to control how the session id is passed.
     - Added new hash %sdat which holds temporary sessins data.
  
  Revision  Changes    Path
  1.178     +5 -0      embperl/Changes.pod
  
  Index: Changes.pod
  ===================================================================
  RCS file: /home/cvs/embperl/Changes.pod,v
  retrieving revision 1.177
  retrieving revision 1.178
  diff -u -r1.177 -r1.178
  --- Changes.pod	2001/07/18 07:27:50	1.177
  +++ Changes.pod	2001/08/10 14:06:41	1.178
  @@ -14,6 +14,11 @@
      - Display correct Apache module name in Makefile.PL when
        requesting path for Apache module. Patch from James Lee.
      - New session handling using Apache::SessionX
  +   - Added options optAddUserSessionToLinks, optAddStatusSessionToLinks
  +     and optNoSessionCookies to control how the session id is passed.
  +   - Added new hash %sdat which holds temporary sessins data.
  +     
  +
   
   =head1 1.3.3 (RELEASE)   6. Juni 2001
   
  
  
  
  1.26      +5 -2      embperl/embperl.h
  
  Index: embperl.h
  ===================================================================
  RCS file: /home/cvs/embperl/embperl.h,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- embperl.h	2001/05/29 06:28:09	1.25
  +++ embperl.h	2001/08/10 14:06:42	1.26
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: embperl.h,v 1.25 2001/05/29 06:28:09 richter Exp $
  +#   $Id: embperl.h,v 1.26 2001/08/10 14:06:42 richter Exp $
   #
   ###################################################################################*/
   
  @@ -142,7 +142,10 @@
       optKeepSpaces	       = 0x100000,
       optOpenLogEarly            = 0x200000,
       optNoUncloseWarn	       = 0x400000,
  -    optDisableSelectScan       = 0x800000
  +    optDisableSelectScan       = 0x800000,
  +    optAddUserSessionToLinks   = 0x1000000,
  +    optAddStatusSessionToLinks = 0x2000000,
  +    optNoSessionCookies        = 0x4000000
       } ;
   
   /*
  
  
  
  1.44      +6 -7      embperl/epcmd.c
  
  Index: epcmd.c
  ===================================================================
  RCS file: /home/cvs/embperl/epcmd.c,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- epcmd.c	2001/07/20 05:29:01	1.43
  +++ epcmd.c	2001/08/10 14:06:42	1.44
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: epcmd.c,v 1.43 2001/07/20 05:29:01 richter Exp $
  +#   $Id: epcmd.c,v 1.44 2001/08/10 14:06:42 richter Exp $
   #
   ###################################################################################*/
   
  @@ -1127,10 +1127,10 @@
   		}
   	    oputs (r, pArgBuf) ;
   
  -	    /*
  -	    if (r -> bOptions & optAddSessionToLinks)
  +	    
  +	    if (r -> sSessionID)
                   {
  -                if (strchr(pArgBuf, '?')
  +                if (strchr(pArgBuf, '?'))
                       {
                       oputc(r, '&') ;
                       }
  @@ -1138,9 +1138,8 @@
                       {
                       oputc(r, '?') ;
                       }
  -                oputs (r, r -> pConf -> sCookieName) ;
  -                oputc(r, '=') ;
  -	    */
  +                oputs (r, r -> sSessionID) ;
  +                }
               
               
               r -> bEscInUrl = FALSE ;
  
  
  
  1.33      +3 -1      embperl/epdat.h
  
  Index: epdat.h
  ===================================================================
  RCS file: /home/cvs/embperl/epdat.h,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- epdat.h	2001/07/18 07:27:50	1.32
  +++ epdat.h	2001/08/10 14:06:42	1.33
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: epdat.h,v 1.32 2001/07/18 07:27:50 richter Exp $
  +#   $Id: epdat.h,v 1.33 2001/08/10 14:06:42 richter Exp $
   #
   ###################################################################################*/
   
  @@ -401,6 +401,8 @@
       int	    nInsideSub ;	/* Are we inside of a sub? */
       int	    bExit ;		/* We should exit the page */
       int	    nPathNdx ;		/* gives the index in the path where the current file is found */
  +
  +    char *  sSessionID ;        /* stores session name and id for status session data */
   #ifdef EP2
       bool    bEP1Compat ;	/* run in Embperl 1.x compatible mode */    
       tPhase  nPhase ;		/* which phase of the request we are in */
  
  
  
  1.109     +123 -81   embperl/epmain.c
  
  Index: epmain.c
  ===================================================================
  RCS file: /home/cvs/embperl/epmain.c,v
  retrieving revision 1.108
  retrieving revision 1.109
  diff -u -r1.108 -r1.109
  --- epmain.c	2001/07/18 07:27:50	1.108
  +++ epmain.c	2001/08/10 14:06:42	1.109
  @@ -10,7 +10,7 @@
   #   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   #   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   #
  -#   $Id: epmain.c,v 1.108 2001/07/18 07:27:50 richter Exp $
  +#   $Id: epmain.c,v 1.109 2001/08/10 14:06:42 richter Exp $
   #
   ###################################################################################*/
   
  @@ -2104,6 +2104,96 @@
   
   /* ---------------------------------------------------------------------------- */
   /*                                                                              */
  +/* Create Session cookie                                                        */
  +/*                                                                              */
  +/* ---------------------------------------------------------------------------- */
  +
  +
  +static SV * CreateSessionCookie (/*i/o*/ register req * r,
  +				 /*in*/  HV * pSessionHash,
  +				 /*in*/  char type,
  +                                 /*in*/  int  bReturnCookie)
  +    
  +    {
  +    SV **   ppSVID ;
  +    SV *    pSVID = NULL ;
  +    MAGIC * pMG ;
  +    char *  pUID = NULL ;
  +    char *  pInitialUID = NULL ;
  +    STRLEN  ulen = 0 ;
  +    STRLEN  ilen = 0 ;
  +    IV	    bModified ;
  +    SV *    pCookie = NULL ;
  +    STRLEN  ldummy ;
  +
  +    if (r -> nSessionMgnt)
  +	{			
  +	SV * pUserHashObj = NULL ;
  +	if ((pMG = mg_find((SV *)pSessionHash,'P')))
  +	    {
  +	    dSP;                            /* initialize stack pointer      */
  +	    int n ;
  +	    pUserHashObj = pMG -> mg_obj ;
  +
  +	    PUSHMARK(sp);                   /* remember the stack pointer    */
  +	    XPUSHs(pUserHashObj) ;            /* push pointer to obeject */
  +	    PUTBACK;
  +	    n = perl_call_method ("getids", G_ARRAY) ; /* call the function             */
  +	    SPAGAIN;
  +	    if (n > 2)
  +		{
  +		int  savewarn = dowarn ;
  +		dowarn = 0 ; /* no warnings here */
  +		bModified = POPi ;
  +		pSVID = POPs;
  +		pUID = SvPV (pSVID, ulen) ;
  +		pSVID = POPs;
  +		pInitialUID = SvPV (pSVID, ilen) ;
  +		dowarn = savewarn ;
  +		}
  +	    PUTBACK;
  +	    }
  +	
  +	if (r -> bDebug & dbgSession)  
  +	    lprintf (r, "[%d]SES:  Received Cookie ID: %s  New Cookie ID: %s  %s data is%s modified\n", r -> nPid, pInitialUID, pUID, type == 's'?"Status":"User", bModified?"":" NOT") ; 
  +
  +	if (ilen > 0 && (ulen == 0 || (!bModified && strcmp ("!DELETE", pInitialUID) == 0)))
  +	    { /* delete cookie */
  +            if (bReturnCookie)
  +                {                    
  +                pCookie = newSVpvf ("%s%s=; expires=Thu, 1-Jan-1970 00:00:01 GMT%s%s%s%s",  r -> pConf -> sCookieName, type == 's'?"s":"",
  +			    r -> pConf -> sCookieDomain[0]?"; domain=":""  , r -> pConf -> sCookieDomain, 
  +			    r -> pConf -> sCookiePath[0]?"; path=":""      , r -> pConf -> sCookiePath) ;
  +                }
  +
  +	    if (r -> bDebug & dbgSession)  
  +		lprintf (r, "[%d]SES:  Delete Cookie -> %s\n", r -> nPid, SvPV(pCookie, ldummy)) ;
  +	    }
  +	else if (ulen > 0 && 
  +		    ((bModified && (ilen == 0 || strcmp (pInitialUID, pUID) !=0)) ||
  +		     (r -> nSessionMgnt & 4)))
  +	    {
  +            if (bReturnCookie)
  +                {                    
  +	        pCookie = newSVpvf ("%s%s=%s%s%s%s%s%s%s",  r -> pConf -> sCookieName, type == 's'?"s":"", pUID,
  +			    r -> pConf -> sCookieDomain[0]?"; domain=":""  , r -> pConf -> sCookieDomain, 
  +			    r -> pConf -> sCookiePath[0]?"; path=":""      , r -> pConf -> sCookiePath, 
  +			    r -> pConf -> sCookieExpires[0]?"; expires=":"", r -> pConf -> sCookieExpires) ;
  +	        if (r -> bDebug & dbgSession)  
  +		    lprintf (r, "[%d]SES:  Send Cookie -> %s\n", r -> nPid, SvPV(pCookie, ldummy)) ; 
  +                }
  +            else
  +                {
  +                pCookie = newSVpvf ("%s%s=%s",  r -> pConf -> sCookieName, type == 's'?"s":"", pUID) ;
  +                }
  +	    }
  +	}
  +    return pCookie ;
  +    }
  +    
  +
  +/* ---------------------------------------------------------------------------- */
  +/*                                                                              */
   /* Setup Request                                                                */
   /*                                                                              */
   /* ---------------------------------------------------------------------------- */
  @@ -2335,6 +2425,8 @@
       if (r -> bDebug & dbgEarlyHttpHeader)
           r -> bOptions |= optEarlyHttpHeader ;
           
  +
  +
       if (r -> bDebug)
           {
           switch (r -> nIOType)
  @@ -2439,6 +2531,7 @@
   	sv_magic (pReqHV, NULL, '~', (char *)&pCurrReq, sizeof (pCurrReq)) ;
   	}
   
  +    _free (r, r -> sSessionID) ;
       r -> pNext = pReqFree ;
       pReqFree = r ;
       }
  @@ -2573,88 +2666,36 @@
           oBegin (r) ;
           }
   
  -    return ok ;
  -    }
  -
  -/* ---------------------------------------------------------------------------- */
  -/*                                                                              */
  -/* Create Session cookie                                                        */
  -/*                                                                              */
  -/* ---------------------------------------------------------------------------- */
  -
   
  -static SV * CreateSessionCookie (/*i/o*/ register req * r,
  -				 /*in*/  HV * pSessionHash,
  -				 /*in*/  char type)
  +    if ((r -> bOptions & optAddStatusSessionToLinks) && !r -> bSubReq)
  +        {
  +	SV * pCookie = CreateSessionCookie (r, r -> pStatusHash, 's', 0) ; 
  +        if (pCookie)
  +            {
  +            STRLEN l ;
  +            r -> sSessionID = _ep_strdup (r, SvPV (pCookie, l)) ;
  +            SvREFCNT_dev (pCookie) ;
  +            }
  +        }
       
  -    {
  -    SV **   ppSVID ;
  -    SV *    pSVID = NULL ;
  -    MAGIC * pMG ;
  -    char *  pUID = NULL ;
  -    char *  pInitialUID = NULL ;
  -    STRLEN  ulen = 0 ;
  -    STRLEN  ilen = 0 ;
  -    IV	    bModified ;
  -    SV *    pCookie = NULL ;
  -    STRLEN  ldummy ;
  -
  -    if (r -> nSessionMgnt)
  -	{			
  -	SV * pUserHashObj = NULL ;
  -	if ((pMG = mg_find((SV *)pSessionHash,'P')))
  -	    {
  -	    dSP;                            /* initialize stack pointer      */
  -	    int n ;
  -	    pUserHashObj = pMG -> mg_obj ;
  -
  -	    PUSHMARK(sp);                   /* remember the stack pointer    */
  -	    XPUSHs(pUserHashObj) ;            /* push pointer to obeject */
  -	    PUTBACK;
  -	    n = perl_call_method ("getids", G_ARRAY) ; /* call the function             */
  -	    SPAGAIN;
  -	    if (n > 2)
  -		{
  -		int  savewarn = dowarn ;
  -		dowarn = 0 ; /* no warnings here */
  -		bModified = POPi ;
  -		pSVID = POPs;
  -		pUID = SvPV (pSVID, ulen) ;
  -		pSVID = POPs;
  -		pInitialUID = SvPV (pSVID, ilen) ;
  -		dowarn = savewarn ;
  -		}
  -	    PUTBACK;
  -	    }
  -	
  -	if (r -> bDebug & dbgSession)  
  -	    lprintf (r, "[%d]SES:  Received Cookie ID: %s  New Cookie ID: %s  %s data is%s modified\n", r -> nPid, pInitialUID, pUID, type == 's'?"Status":"User", bModified?"":" NOT") ; 
  -
  -	if (ilen > 0 && (ulen == 0 || (!bModified && strcmp ("!DELETE", pInitialUID) == 0)))
  -	    { /* delete cookie */
  -	    pCookie = newSVpvf ("%s%s=; expires=Thu, 1-Jan-1970 00:00:01 GMT%s%s%s%s",  r -> pConf -> sCookieName, type == 's'?"s":"",
  -			r -> pConf -> sCookieDomain[0]?"; domain=":""  , r -> pConf -> sCookieDomain, 
  -			r -> pConf -> sCookiePath[0]?"; path=":""      , r -> pConf -> sCookiePath) ;
  +    if ((r -> bOptions & optAddUserSessionToLinks) && !r -> bSubReq)
  +        {
  +	SV * pCookie = CreateSessionCookie (r, r -> pStatusHash, 'u', 0) ; 
  +        if (pCookie)
  +            {
  +            STRLEN l ;
  +            if (r -> sSessionID)
  +                r -> sSessionID = _memstrcat (r, r -> sSessionID, "&", SvPV (pCookie, l)) ;
  +            else
  +                r -> sSessionID = _ep_strdup (r, SvPV (pCookie, l)) ;
  +            SvREFCNT_dev (pCookie) ;
  +            }
  +        }
   
  -	    if (r -> bDebug & dbgSession)  
  -		lprintf (r, "[%d]SES:  Delete Cookie -> %s\n", r -> nPid, SvPV(pCookie, ldummy)) ;
  -	    }
  -	else if (ulen > 0 && 
  -		    ((bModified && (ilen == 0 || strcmp (pInitialUID, pUID) !=0)) ||
  -		     (r -> nSessionMgnt & 4)))
  -	    {
  -	    pCookie = newSVpvf ("%s%s=%s%s%s%s%s%s%s",  r -> pConf -> sCookieName, type == 's'?"s":"", pUID,
  -			r -> pConf -> sCookieDomain[0]?"; domain=":""  , r -> pConf -> sCookieDomain, 
  -			r -> pConf -> sCookiePath[0]?"; path=":""      , r -> pConf -> sCookiePath, 
  -			r -> pConf -> sCookieExpires[0]?"; expires=":"", r -> pConf -> sCookieExpires) ;
  -	    if (r -> bDebug & dbgSession)  
  -		lprintf (r, "[%d]SES:  Send Cookie -> %s\n", r -> nPid, SvPV(pCookie, ldummy)) ; 
  -	    
  -	    }
  -	}
  -    return pCookie ;
  -    }
       
  +    
  +    return ok ;
  +    }
   
   /* ---------------------------------------------------------------------------- */
   /*                                                                              */
  @@ -2728,8 +2769,9 @@
           {  /* --- send http headers if not alreay done --- */
           if (!r -> bAppendToMainReq)
               {                    
  -	    pCookie = CreateSessionCookie (r, r -> pUserHash, 'u') ;
  -	    pCookie2 = CreateSessionCookie (r, r -> pStatusHash, 's') ;
  +            if (!(r -> bOptions & optNoSessionCookies))
  +                pCookie = CreateSessionCookie (r, r -> pUserHash, 'u', 1) ;
  +	    /* pCookie2 = CreateSessionCookie (r, r -> pStatusHash, 's') ; */
   		
   #ifdef APACHE
   	    if (r -> pApacheReq)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-cvs-help@perl.apache.org