예제 #1
0
VOID
r_p_let()
{
    i4			tok_type;
    DB_DATA_VALUE	exp_type;
    i4			state = WANT_VAR;
    char		*name;
    ITEM		item;
    DB_DATA_VALUE	*dbdv;
    LET			*let;
    i4			status;
    DB_DATA_VALUE	*con;

    while ((tok_type = r_g_eskip()) != TK_ENDSTRING)
    {
        switch(state)
        {
        case WANT_VAR:
            if ((tok_type == TK_ALPHA) ||
                    ((tok_type == TK_QUOTE) && (St_xns_given)))
            {
                name = r_g_ident(FALSE);
                _VOID_ IIUGdlm_ChkdlmBEobject(name,name,FALSE);
                status = r_p_tparam(name, FALSE, &item, &exp_type);
            }

            if (((tok_type != TK_ALPHA) && (tok_type != TK_QUOTE)) ||
                    ((tok_type == TK_QUOTE) && (!St_xns_given)) ||
                    (status == NO_EXP))
            {
                r_error(0x3C, NONFATAL, Cact_tname, Cact_attribute,
                        Cact_command, Cact_rtext, NULL);
                return;
            }

            dbdv = &(item.item_val.i_v_par->par_value);
            state = WANT_COLON;
            break;

        case WANT_COLON:
            if (tok_type == TK_COLON)
            {
                Tokchar++;
                state = WANT_EQUAL;
                break;
            }
        /* fall through */

        case WANT_EQUAL:
            if (tok_type != TK_EQUALS)
            {
                r_error(0x3C, NONFATAL, Cact_tname, Cact_attribute,
                        Cact_command, Cact_rtext, NULL);
                return;
            }

            Tokchar++;
            state = WANT_EXPR;
            break;

        case WANT_EXPR:
            status = r_g_expr(&item, &exp_type);
            switch (status)
            {
            case NO_EXP:
                r_error(0x3E, NONFATAL, Cact_tname, Cact_attribute, Tokchar,
                        Cact_command, Cact_rtext, NULL);
                return;

            case BAD_EXP:
                return;

            case GOOD_EXP:
                if (exp_type.db_datatype == DB_BOO_TYPE)
                {
                    IIUGerr(E_RW003D_r_p_let_No_boolean,UG_ERR_FATAL,0);
                }
                break;

            case NULL_EXP:
                if (!AFE_NULLABLE_MACRO(dbdv->db_datatype))
                {
                    r_error(0x41, NONFATAL, Cact_tname, Cact_attribute,
                            Cact_command, Cact_rtext, NULL);
                    return;
                }

                item.item_type = I_CON;
                con = (DB_DATA_VALUE *) MEreqmem(0,sizeof(DB_DATA_VALUE),TRUE,
                                                 (STATUS *) NULL);
                item.item_val.i_v_con = con;
                con->db_datatype = dbdv->db_datatype;
                con->db_length = dbdv->db_length;
                con->db_prec = dbdv->db_prec;
                con->db_data = (PTR) MEreqmem(0,con->db_length,TRUE,
                                              (STATUS *) NULL);
                adc_getempty(Adf_scb, con);
                break;
            }

            Cact_tcmd->tcmd_code = P_LET;
            let = (LET *) MEreqmem(0,sizeof(LET),TRUE,(STATUS *) NULL);
            Cact_tcmd->tcmd_val.t_v_let = let;
            let->let_left = dbdv;
            MEcopy((PTR)&item, (u_i2)sizeof(ITEM), (PTR)&(let->let_right));

            return;
        }
    }
}
예제 #2
0
파일: psyuser.c 프로젝트: saqibjamil/Ingres
/*{
** Name: psy_auser - Alter user
**
**  INTERNAL PSF call format: status = psy_auser(&psy_cb, sess_cb);
**
** Description:
**	This procedure alters an iiuser tuple.  If the
**	user does not exist, the statement is aborted.
**	If the user does exist, the associated
**	iiuser tuple is replaced.
**	This procedure is called for SQL language only.
**
** Inputs:
**      psy_cb
**	    .psy_usrq			user list
**	sess_cb				Pointer to session control block
**					(Can be NULL)
**
** Outputs:
**      psy_cb
**	    .psy_error			Filled in if error happens
**	Returns:
**	    E_DB_OK			Function completed normally.
**	    E_DB_WARN			Function completed with warning(s);
**	    E_DB_ERROR			Function failed; non-catastrophic error
**	    E_DB_SEVERE			Function failed; catastrophic error
**	Exceptions:
**	    none
**
** Side Effects:
**	    Replaces tuples in iiuser.
**
** History:
**	04-sep-89 (ralph)
**          written
**      16-jan-90 (ralph)
**          add support for user passwords
**	12-mar-90 (andre)
**	    set rdr_2types_mask to 0.
**      22-may-90 (teg)
**          init rdr_instr to RDF_NO_INSTR
**	08-aug-90 (ralph)
**	    add support for oldpassword (as in ALTER USER OLDPASSWORD = '******')
**	12-apr-95 (forky01)
**	    Apply default privs when only privs specified to allow backward
**	    compatibility to fix Secure 2.0 code.
**	28-jul-2003 (gupsh01)
**	    Added check for case when noprivileges have been added and
**	    nodefault_privileges is not specified, with a profile in alter
**	    user statement. 
*/
DB_STATUS
psy_auser(
	PSY_CB             *psy_cb,
	PSS_SESBLK	   *sess_cb)
{
    DB_STATUS		status, stat;
    RDF_CB		rdf_cb;
    i4		err_code;
    register RDR_RB	*rdf_rb = &rdf_cb.rdf_rb;
    struct
    {
	DU_USER	    ustuple;
	DU_USER	    ustuple2;
    }			usparam;
    register DU_USER	*ustup  = &usparam.ustuple;
    register DU_USER	*ustup2 = &usparam.ustuple2;
    PSY_USR		*psy_usr;
    bool                encrypt;
    bool                encrypt2;
    SCF_CB              scf_cb;
    SCF_CB              scf_cb2;
    DB_DATA_VALUE	db_data;
    DB_DATE	        dateval;

    /* This code is called for SQL only */

    /*
    ** Fill in the part of RDF request block that will be constant.
    */
    pst_rdfcb_init(&rdf_cb, sess_cb);
    rdf_rb->rdr_update_op   = RDR_REPLACE;
    rdf_rb->rdr_status	    = DB_SQL;
    rdf_rb->rdr_types_mask  = RDR_USER;
    rdf_rb->rdr_qrytuple    = (PTR) ustup;
    rdf_rb->rdr_qtuple_count = 1;

    ustup->du_gid	= 0;
    ustup->du_mid	= 0;
    ustup->du_flagsmask  = 0;

    /* User profile */
    if(psy_cb->psy_usflag& PSY_USRPROFILE)
    {
	    MECOPY_CONST_MACRO((PTR)&psy_cb->psy_usprofile, 
		sizeof(psy_cb->psy_usprofile), 
	    	(PTR)&ustup->du_profile);
	   
	    ustup->du_flagsmask|= DU_UHASPROFILE;
    }
    else
    {
	MEfill(sizeof(ustup->du_profile),
	       (u_char)' ',
	       (PTR)&ustup->du_profile);
    }

    if ((psy_cb->psy_usflag& PSY_USRPROFILE) &&
	(psy_cb->psy_usflag& PSY_USRPRIVS) &&
	(psy_cb->psy_usflag& PSY_UNOPRIVS) &&
        !(psy_cb->psy_usflag & PSY_UNODEFPRIV))
    {
  	/* If alter user has PSY_UNOPRIVS specified and
  	** we have provided a profile for this user
  	** but we have not set the nodefault_privileges
  	** specified, We should return an error. profile
  	** may have default_privileges, which will be
  	** inherited by the user with noprivileges.
  	*/
  	  err_code = E_US1968_6504_UNOPRIV_WDEFAULT;
  	  (VOID) psf_error( E_US1968_6504_UNOPRIV_WDEFAULT, 0L,
  	     PSF_USERERR, &err_code, &psy_cb->psy_error, 0);
  	  status = E_DB_ERROR;

	  return(status);
    }

    if(psy_cb->psy_usflag& PSY_USRDEFPRIV)
    {
	ustup->du_defpriv = psy_cb->psy_usdefprivs;
	ustup->du_flagsmask|= DU_UDEFPRIV;
	/* Add default=all indicator */
	if(psy_cb->psy_usflag & PSY_USRDEFALL)
		ustup->du_flagsmask|=DU_UDEFALL;

	/* set value of nodefault_privileges flag */
	if (psy_cb->psy_usflag & PSY_UNODEFPRIV)
	  ustup->du_flagsmask|= DU_UNODEFPRIV;
    }
    else
    {
	/*
	** If no default specified use all privileges
	*/
	if (psy_cb->psy_usflag & PSY_USRPRIVS)
		ustup->du_defpriv = (i4)psy_cb->psy_usprivs;
	else
		ustup->du_defpriv = 0;
    }

    /*
    ** Expiration date, may be empty
    */
    if(psy_cb->psy_usflag& PSY_USREXPDATE)
    {
	/*
	** Date already formatted earlier
	*/
	MECOPY_CONST_MACRO((PTR)&psy_cb->psy_date, sizeof(DB_DATE), 
			(PTR)&ustup->du_expdate);
	ustup->du_flagsmask|= DU_UEXPDATE;
    }
    else
    {
	/*
	** Initialize to the empty date
	*/
	db_data.db_datatype  = DB_DTE_TYPE;
	db_data.db_prec	 = 0;
	db_data.db_length    = DB_DTE_LEN;
	db_data.db_data	 = (PTR)&ustup->du_expdate;
	status = adc_getempty(sess_cb->pss_adfcb, &db_data);
	if(status)
		return status;
    }
    /*
    ** Check if adding, deleting, or setting privileges
    */
    ustup->du_status = (i4) psy_cb->psy_usprivs;

	
    if (psy_cb->psy_usflag & PSY_USRAPRIVS)
	ustup->du_flagsmask |=  DU_UAPRIV;
    else if (psy_cb->psy_usflag & PSY_USRDPRIVS)
	ustup->du_flagsmask |=  DU_UDPRIV;
    else if (psy_cb->psy_usflag & PSY_USRPRIVS)
	ustup->du_flagsmask |=  DU_UPRIV;
    else
	ustup->du_status = 0;
    /*
    ** Check if updating security audit options
    */
    if (psy_cb->psy_usflag & PSY_USRSECAUDIT)
    {
	if(psy_cb->psy_ussecaudit & PSY_USAU_ALL_EVENTS)
		ustup->du_flagsmask |= DU_UALLEVENTS;
	else
		ustup->du_flagsmask |= DU_UDEFEVENTS;
	if (psy_cb->psy_ussecaudit & PSY_USAU_QRYTEXT)
		ustup->du_flagsmask |= DU_UQRYTEXT;
	else
		ustup->du_flagsmask |= DU_UNOQRYTEXT;
    }

    if (psy_cb->psy_usflag & PSY_USRDEFGRP)
    {
	MEcopy((PTR)&psy_cb->psy_usgroup,
	       sizeof(ustup->du_group),
	       (PTR)&ustup->du_group);
	ustup->du_flagsmask|= DU_UGROUP;
    }
    else
    {
	MEfill(sizeof(ustup->du_group),
	       (u_char)' ',
	       (PTR)&ustup->du_group);
    }

    encrypt = (STskipblank((char *)&psy_cb->psy_apass,
                           (i4)sizeof(psy_cb->psy_apass))
                            != NULL);
    if (encrypt)
    {
        scf_cb.scf_length       = sizeof (SCF_CB);
        scf_cb.scf_type		= SCF_CB_TYPE;
        scf_cb.scf_facility     = DB_PSF_ID;
        scf_cb.scf_session      = sess_cb->pss_sessid;
        scf_cb.scf_nbr_union.scf_xpasskey =
            (PTR)&ustup->du_name;
        scf_cb.scf_ptr_union.scf_xpassword =
            (PTR)&ustup->du_pass;
        scf_cb.scf_len_union.scf_xpwdlen =
             sizeof(ustup->du_pass);
    }
    else
        STRUCT_ASSIGN_MACRO(psy_cb->psy_apass, ustup->du_pass);

    if (psy_cb->psy_usflag & PSY_USRPASS)
    {
	ustup->du_flagsmask|= DU_UPASS;
        if (psy_cb->psy_usflag & PSY_USREXTPASS)
	     ustup->du_flagsmask |= DU_UEXTPASS;
    }
    else
    {
	MEfill(sizeof(ustup->du_pass),
	       (u_char)' ',
	       (PTR)&ustup->du_pass);
    }

    encrypt2 = (STskipblank((char *)&psy_cb->psy_bpass,
                           (i4)sizeof(psy_cb->psy_bpass))
                            != NULL);
    if (encrypt2)
    {
        scf_cb2.scf_length      = sizeof (SCF_CB);
        scf_cb2.scf_type	= SCF_CB_TYPE;
        scf_cb2.scf_facility    = DB_PSF_ID;
        scf_cb2.scf_session     = sess_cb->pss_sessid;
        scf_cb2.scf_nbr_union.scf_xpasskey =
            (PTR)&ustup->du_name;
        scf_cb2.scf_ptr_union.scf_xpassword =
            (PTR)&ustup2->du_pass;
        scf_cb2.scf_len_union.scf_xpwdlen =
             sizeof(ustup2->du_pass);
    }
    else
        STRUCT_ASSIGN_MACRO(psy_cb->psy_bpass, ustup2->du_pass);

    if (psy_cb->psy_usflag & PSY_USROLDPASS)
	ustup->du_flagsmask|= DU_UOLDPASS;
    else
    {
	MEfill(sizeof(ustup2->du_pass),
	       (u_char)' ',
	       (PTR)&ustup2->du_pass);
    }

    status = E_DB_OK;

    for (psy_usr  = (PSY_USR *)  psy_cb->psy_usrq.q_next;
	 psy_usr != (PSY_USR *) &psy_cb->psy_usrq;
	 psy_usr  = (PSY_USR *)  psy_usr->queue.q_next
	)
    {
	/* STRUCT_ASSIGN_MACRO(psy_usr->psy_usrnm,
			       ustup->du_name); */
	MEcopy((PTR)&psy_usr->psy_usrnm,
	       sizeof(ustup->du_name),
	       (PTR)&ustup->du_name);

	/* Encrypt the password if nonblank and not already hex value */

        if (encrypt)
        {
            STRUCT_ASSIGN_MACRO(psy_cb->psy_apass, ustup->du_pass);
	    if(!(psy_cb->psy_usflag & PSY_HEXPASS))
	    {
		status = scf_call(SCU_XENCODE, &scf_cb);
		if (status != E_DB_OK)
		{
		    err_code = scf_cb.scf_error.err_code;
		    (VOID) psf_error(E_PS0D43_XENCODE_ERROR, 0L,
			PSF_INTERR, &err_code, &psy_cb->psy_error, 0);
		    status = (status > E_DB_SEVERE) ? status : E_DB_SEVERE;
		    return(status);
		}
            }
        }

        if (encrypt2)
        {
            STRUCT_ASSIGN_MACRO(psy_cb->psy_bpass, ustup2->du_pass);
            status = scf_call(SCU_XENCODE, &scf_cb2);
            if (status != E_DB_OK)
            {
                err_code = scf_cb2.scf_error.err_code;
                (VOID) psf_error(E_PS0D43_XENCODE_ERROR, 0L,
                                PSF_INTERR, &err_code, &psy_cb->psy_error, 0);
                status = (status > E_DB_SEVERE) ? status : E_DB_SEVERE;
                return(status);
            }
        }

	stat = rdf_call(RDF_UPDATE, (PTR) &rdf_cb);
	status = (stat > status) ? stat : status;

	if (DB_FAILURE_MACRO(stat))
	    break;
    }

    if (DB_FAILURE_MACRO(status))
	(VOID) psf_rdf_error(RDF_UPDATE, &rdf_cb.rdf_error, 
	    &psy_cb->psy_error);

    return    (status);
} 
예제 #3
0
DB_STATUS
adu_dbconst(
ADF_CB		    *adf_scb,
ADK_MAP		    *kmap,
DB_DATA_VALUE       *rdv)
{
    ADK_CONST_BLK	*k = adf_scb->adf_constants;
    bool		kcalced = FALSE;
    PTR			kptr = NULL;
    DB_ERROR		err;
    ADF_DBMSINFO	*dbi  = kmap->adk_dbi;
    i4			kbit  = kmap->adk_kbit;
    DB_STATUS		db_stat;
    bool		datetimetype = FALSE;
    DB_DT_ID		date_dt;
    u_i4		val;
    /* Beware that some of the dbmsinfo functions care not about
    ** caller lengths and will update the DBV regardless so
    ** we arrange to get the constants written directy and if
    ** need be, we conver on return. */
    DB_DATA_VALUE tmp_rdv = *rdv;
    i8 tmp_buf[1024/sizeof(i8)]; /* Make temporary aligned */

    switch (kbit)	    /* look for datetime constants */
    {
    case ADK_CURR_DATE:		/* _current_date */
	datetimetype = TRUE;
	date_dt = DB_ADTE_TYPE;
	break;

    case ADK_CURR_TIME:		/* _current_time */
	datetimetype = TRUE;
	date_dt = DB_TMW_TYPE;
	break;

    case ADK_CURR_TSTMP:	/* _current_timestamp */
	datetimetype = TRUE;
	date_dt = DB_TSW_TYPE;
	break;

    case ADK_LOCAL_TIME:	/* _local_time*/
	datetimetype = TRUE;
	date_dt = DB_TME_TYPE;
	break;

    case ADK_LOCAL_TSTMP:	/* _local_timestamp */
	datetimetype = TRUE;
	date_dt = DB_TSTMP_TYPE;
	break;
    }

    if (k != NULL)
    {
	switch (kbit)	    /* switch on known query constants */
	{
	  case ADK_BINTIM:	/* _bintim */
	    tmp_rdv.db_data = (PTR) &k->adk_bintim;
	    tmp_rdv.db_length = sizeof(k->adk_bintim);
	    break;

	  case ADK_CPU_MS:	/* _cpu_ms */
	    tmp_rdv.db_data = (PTR) &k->adk_cpu_ms;
	    tmp_rdv.db_length = sizeof(k->adk_cpu_ms);
	    break;

	  case ADK_ET_SEC:	/* _et_sec */
	    tmp_rdv.db_data = (PTR) &k->adk_et_sec;
	    tmp_rdv.db_length = sizeof(k->adk_et_sec);
	    break;

	  case ADK_DIO_CNT:	/* _dio_cnt */
	    tmp_rdv.db_data = (PTR) &k->adk_dio_cnt;
	    tmp_rdv.db_length = sizeof(k->adk_dio_cnt);
	    break;

	  case ADK_BIO_CNT:	/* _bio_cnt */
	    tmp_rdv.db_data = (PTR) &k->adk_bio_cnt;
	    tmp_rdv.db_length = sizeof(k->adk_bio_cnt);
	    break;

	  case ADK_PFAULT_CNT:	/* _pfault_cnt */
	    tmp_rdv.db_data = (PTR) &k->adk_pfault_cnt;
	    tmp_rdv.db_length = sizeof(k->adk_pfault_cnt);
	    break;

	  case ADK_CURR_DATE:	/* _current_date */
	    tmp_rdv.db_data = (PTR) &k->adk_curr_date;
	    tmp_rdv.db_length = sizeof(k->adk_curr_date);
	    break;

	  case ADK_CURR_TIME:	/* _current_time */
	    tmp_rdv.db_data = (PTR) &k->adk_curr_time;
	    tmp_rdv.db_length = sizeof(k->adk_curr_time);
	    break;

	  case ADK_CURR_TSTMP:	/* _current_timestamp */
	    tmp_rdv.db_data = (PTR) &k->adk_curr_tstmp;
	    tmp_rdv.db_length = sizeof(k->adk_curr_tstmp);
	    break;

	  case ADK_LOCAL_TIME:	/* _local_time*/
	    tmp_rdv.db_data = (PTR) &k->adk_local_time;
	    tmp_rdv.db_length = sizeof(k->adk_local_time);
	    break;

	  case ADK_LOCAL_TSTMP:	/* _local_timestamp */
	    tmp_rdv.db_data = (PTR) &k->adk_local_tstmp;
	    tmp_rdv.db_length = sizeof(k->adk_local_tstmp);
	    break;

	  default:
	    return (adu_error (adf_scb, E_AD9998_INTERNAL_ERROR,
		2, 0, "dbmsinfo kbit"));
	}
	
	if (k->adk_set_mask & kbit) /* Has this value been calculated yet? */
	    kcalced = TRUE;
    }
    else
	tmp_rdv.db_data = (PTR)tmp_buf;


    if (!kcalced)
    {
	/* Must calculate value from scratch */

	if (datetimetype)
	{
	    AD_NEWDTNTRNL       dn;
	    struct timevect     tv;
	    DB_STATUS           db_stat;
	    i4			sec_time_zone;
	    HRSYSTIME		hrsystime;

	    TMhrnow(&hrsystime);

	    MEfill ((u_i2) sizeof(i4)*10, NULLCHAR, (PTR) &tv);

	    adu_cvtime((i4) hrsystime.tv_sec, (i4)hrsystime.tv_nsec, &tv);

	    MEfill((u_i2) sizeof(AD_NEWDTNTRNL), NULLCHAR, (PTR) &dn);
	    /* Interpret the time vector */
	    dn.dn_year    = (i2)tv.tm_year + 1900;
	    dn.dn_month   = (i2)tv.tm_mon + 1;
	    dn.dn_day     = tv.tm_mday;
	    dn.dn_seconds = tv.tm_hour * 3600 + tv.tm_min * 60 + tv.tm_sec;
	    dn.dn_nsecond = tv.tm_nsec;
	    dn.dn_dttype  = date_dt;

	    sec_time_zone = TMtz_search(adf_scb->adf_tzcb, TM_TIMETYPE_GMT,
				 (i4) hrsystime.tv_sec);

	    AD_TZ_SETNEW(&dn, sec_time_zone);

	    dn.dn_status = AD_DN_ABSOLUTE;
	    switch (date_dt)
	    {
	    case DB_ADTE_TYPE:	/* _current_date */
		dn.dn_seconds = 0;
		dn.dn_nsecond = 0;
		dn.dn_status2 |= AD_DN2_ADTE_TZ;
		dn.dn_status |= AD_DN_YEARSPEC|AD_DN_MONTHSPEC|AD_DN_DAYSPEC;
		break;

	    case DB_TME_TYPE:	/* _local_time*/
		dn.dn_status2 |= AD_DN2_TZ_OFF_LCL;
		/*FALLTHROUGH*/
	    case DB_TMW_TYPE:	/* _current_time */
		dn.dn_status |= AD_DN_TIMESPEC;
		dn.dn_status2 |= AD_DN2_NO_DATE;
		break;

	    case DB_TSTMP_TYPE:	/* _local_timestamp */
		dn.dn_status2 |= AD_DN2_TZ_OFF_LCL;
		/*FALLTHROUGH*/
	    case DB_TSW_TYPE:	/* _current_timestamp */
		dn.dn_status |= AD_DN_YEARSPEC|AD_DN_MONTHSPEC|AD_DN_DAYSPEC;
		dn.dn_status |= AD_DN_TIMESPEC;
		break;
	    }

	    /* Convert straight into constant data area */
	    if (db_stat = adu_7from_dtntrnl (adf_scb, &tmp_rdv, &dn))
		return (db_stat);
	}
	else if (dbi == NULL  ||  dbi->dbi_func == NULL)
	{
	    /* If no function ptr in dbmsinfo array, set default value */
	    if (db_stat = adc_getempty(adf_scb, &tmp_rdv))
		return (db_stat);
	}
	else
	{
	    /* Get the value from the proper dbmsinfo function */

	    /*
	    ** NOTE: If the dbmsinfo routines ever change the size of
	    ** of the returned object, it will be assumed that the length
	    ** will match the adk_* buffer length. If not, there will
	    ** be a risk of uninitialised data slipping in.
	    */
	    if (db_stat = (*dbi->dbi_func)(dbi, NULL, &tmp_rdv, &err))
		return (db_stat);
	}

	/* We now have the calculated result written directly to the
	** constant buffers if they exist or to the tmp_buf.
	** Either way, we don't need to write the constant again, we just
	** need to convert out to the return buffer/dbv.
	*/

	/* Don't forget to set the `already calculated' bit */
	if (k)
	    k->adk_set_mask |= kbit;
    }

    /* We have the value requested, so just set result and return */
    if (rdv->db_datatype == DB_INT_TYPE)
    {	/* Currently, all query constants are uints or dates */
	u_i8 val;
	switch (tmp_rdv.db_length)
	{
	case 8:
	    val = (u_i8)*(u_i8*)tmp_rdv.db_data;
	    break;
	case 4:
	    val = (u_i8)*(u_i4*)tmp_rdv.db_data;
	    break;
	case 2:
	    val = (u_i8)*(u_i2*)tmp_rdv.db_data;
	    break;
	case 1:
	    val = (u_i8)*(u_i1*)tmp_rdv.db_data;
	    break;
	}
	switch (rdv->db_length)
	{
	case 8:
	    I8ASSIGN_MACRO(val, *(u_i8 *)rdv->db_data);
	    break;
	case 4:
	    {
		u_i4 val4 = (u_i4)val;
		I4ASSIGN_MACRO(val4, *(u_i4 *)rdv->db_data);
	    }
	    break;
	case 2:
	    {
		u_i2 val2 = (u_i2)val;
		I2ASSIGN_MACRO(val2, *(i2*)rdv->db_data);
	    }
	    break;
	case 1:
	    *(u_i1 *)rdv->db_data = (u_i1)val;
	    break;
	default:
	    return (adu_error (adf_scb, E_AD9998_INTERNAL_ERROR,
		2, 0, "dbmsinfo isz"));
	}
    }
    else if (tmp_rdv.db_length != rdv->db_length)
    {
	return (adu_error (adf_scb, E_AD9998_INTERNAL_ERROR,
		2, 0, "dbmsinfo len"));
    }
    else
    {
	MEcopy(tmp_rdv.db_data, rdv->db_length, rdv->db_data);
    }
    return (E_DB_OK);
}
예제 #4
0
파일: psyuser.c 프로젝트: saqibjamil/Ingres
/*{
** Name: psy_aprofile - Alter profile
**
** Description:
**	This procedure alters an iiprofile tuple.  If the
**	user does not exist, the statement is aborted.
**	If the user does exist, the associated
**	iiprofile tuple is replaced.
**	This procedure is called for SQL language only.
**
** Inputs:
**      psy_cb
**	    .psy_usrq			user list
**	sess_cb				Pointer to session control block
**					(Can be NULL)
**
** Outputs:
**      psy_cb
**	    .psy_error			Filled in if error happens
**	Returns:
**	    E_DB_OK			Function completed normally.
**	    E_DB_WARN			Function completed with warning(s);
**	    E_DB_ERROR			Function failed; non-catastrophic error
**	    E_DB_SEVERE			Function failed; catastrophic error
**	Exceptions:
**	    none
**
** Side Effects:
**	    Replaces tuples in iiuser.
**
** History:
**	27-aug-93 (robf)
**          Written
*/
static DB_STATUS
psy_aprofile(
	PSY_CB             *psy_cb,
	PSS_SESBLK	   *sess_cb)
{
    DB_STATUS		status, stat;
    RDF_CB		rdf_cb;
    i4		err_code;
    register RDR_RB	*rdf_rb = &rdf_cb.rdf_rb;
    struct
    {
	DU_PROFILE	    protuple;
	DU_PROFILE	    protuple2;
    }			usparam;
    register DU_PROFILE	*protup  = &usparam.protuple;
    register DU_PROFILE	*protup2 = &usparam.protuple2;
    PSY_USR		*psy_usr;
    SCF_CB              scf_cb;
    SCF_CB              scf_cb2;
    DB_DATA_VALUE	db_data;
    DB_DATE	        dateval;

    FUNC_EXTERN DB_STATUS rdf_call();
    FUNC_EXTERN DB_STATUS scf_call();

    /* This code is called for SQL only */

    /*
    ** Fill in the part of RDF request block that will be constant.
    */
    pst_rdfcb_init(&rdf_cb, sess_cb);
    rdf_rb->rdr_update_op   = RDR_REPLACE;
    rdf_rb->rdr_status	    = DB_SQL;
    rdf_rb->rdr_2types_mask = RDR2_PROFILE;
    rdf_rb->rdr_qrytuple    = (PTR) protup;
    rdf_rb->rdr_qtuple_count = 1;

    protup->du_flagsmask  = 0;

    if(psy_cb->psy_usflag& PSY_USRDEFPRIV)
    {
	protup->du_defpriv = psy_cb->psy_usdefprivs;
	protup->du_flagsmask|= DU_UDEFPRIV;
	/* Add default=all indicator */
	if(psy_cb->psy_usflag & PSY_USRDEFALL)
		protup->du_flagsmask|=DU_UDEFALL;

	/* if user has specified nodefault_privileges we
	** store this flag to negotiate the final status
	** of default privileges.
	*/
	if (psy_cb->psy_usflag & PSY_UNODEFPRIV)
  	  protup->du_flagsmask|= DU_UNODEFPRIV;
    }
    else
	protup->du_defpriv = 0;

    /*
    ** Expiration date, may be empty
    */
    if(psy_cb->psy_usflag& PSY_USREXPDATE)
    {
	/*
	** Date already formatted earlier
	*/
	MECOPY_CONST_MACRO((PTR)&psy_cb->psy_date, sizeof(DB_DATE), 
			(PTR)&protup->du_expdate);
	protup->du_flagsmask|= DU_UEXPDATE;
    }
    else
    {
	/*
	** Initialize to the empty date
	*/
	db_data.db_datatype  = DB_DTE_TYPE;
	db_data.db_prec	 = 0;
	db_data.db_length    = DB_DTE_LEN;
	db_data.db_data	 = (PTR)&protup->du_expdate;
	status = adc_getempty(sess_cb->pss_adfcb, &db_data);
	if(status)
		return status;
    }
    /*
    ** Check if adding, deleting, or setting privileges
    */
    protup->du_status = (i4) psy_cb->psy_usprivs;
    if (psy_cb->psy_usflag & PSY_USRAPRIVS)
	protup->du_flagsmask |=  DU_UAPRIV;
    else if (psy_cb->psy_usflag & PSY_USRDPRIVS)
	protup->du_flagsmask |=  DU_UDPRIV;
    else if (psy_cb->psy_usflag & PSY_USRPRIVS)
	protup->du_flagsmask |=  DU_UPRIV;
    else
	protup->du_status = 0;
    /*
    ** Check if updating security audit options
    */
    if (psy_cb->psy_usflag & PSY_USRSECAUDIT)
    {
	if(psy_cb->psy_ussecaudit & PSY_USAU_ALL_EVENTS)
		protup->du_flagsmask |= DU_UALLEVENTS;
	else
		protup->du_flagsmask |= DU_UDEFEVENTS;
	if (psy_cb->psy_ussecaudit & PSY_USAU_QRYTEXT)
		protup->du_flagsmask |= DU_UQRYTEXT;
	else
		protup->du_flagsmask |= DU_UNOQRYTEXT;
    }

    if (psy_cb->psy_usflag & PSY_USRDEFGRP)
    {
	MEcopy((PTR)&psy_cb->psy_usgroup,
	       sizeof(protup->du_group),
	       (PTR)&protup->du_group);
	protup->du_flagsmask|= DU_UGROUP;
    }
    else
    {
	MEfill(sizeof(protup->du_group),
	       (u_char)' ',
	       (PTR)&protup->du_group);
    }



    status = E_DB_OK;

    for (psy_usr  = (PSY_USR *)  psy_cb->psy_usrq.q_next;
	 psy_usr != (PSY_USR *) &psy_cb->psy_usrq;
	 psy_usr  = (PSY_USR *)  psy_usr->queue.q_next
	)
    {
	/* STRUCT_ASSIGN_MACRO(psy_usr->psy_usrnm,
			       protup->du_name); */
	MEcopy((PTR)&psy_usr->psy_usrnm,
	       sizeof(protup->du_name),
	       (PTR)&protup->du_name);

	stat = rdf_call(RDF_UPDATE, (PTR)&rdf_cb);
	status = (stat > status) ? stat : status;

	if (DB_FAILURE_MACRO(stat))
	    break;
    }

    if (DB_FAILURE_MACRO(status))
	(VOID) psf_rdf_error(RDF_UPDATE, &rdf_cb.rdf_error, 
	    &psy_cb->psy_error);

    return    (status);
}