Re: [exim] pgsql login allowing mysterious sending

Top Page
Delete this message
Reply to this message
Author: Chris Wilson
Date:  
To: Mark Adams
CC: Exim users list, Chris Wilson
Subject: Re: [exim] pgsql login allowing mysterious sending
Hi Mark,

> This is fn_mail_user_get_active_smtp:
>
> CREATE FUNCTION fn_mail_user_get_active_smtp(character varying) RETURNS
> SETOF users
>    LANGUAGE plpgsql
>    AS $_$

>
> DECLARE
>
>    in_email       ALIAS for $1;
>    usercheck      users%ROWTYPE;

>
> BEGIN
>
>        SELECT INTO usercheck
>                *
>        FROM
>            users
>        WHERE
>            userid || '@' || domain  = lower(in_email)
>            AND
>            status IN (1,2)
>            AND
>            b_isadmin IS FALSE
>        ORDER BY
>            userid;

>
>        RETURN NEXT usercheck;
> END;$_$;


Do you have a race condition on the usercheck table where two login
attempts are happening simultaneously? How do rows get deleted from this
table? Why don't you use a plain simple SELECT() instead to avoid both
problems?

Cheers, Chris.
-- 
_ ___ __     _
  / __/ / ,__(_)_  | Chris Wilson <0000 at qwirx.com> - Cambs UK |
/ (_/ ,\/ _/ /_ \ | Security/C/C++/Java/Perl/SQL/HTML Developer |
\ _/_/_/_//_/___/ | We are GNU-free your mind-and your software |