Return-Path: <ml-errors@fatcity.com>
Received: from ensim.rackshack.net (root@localhost)
 by orafaq.net (8.11.6/8.11.6) with ESMTP id h7T1kQK03784
 for <oracle-l@orafaq.net>; Thu, 28 Aug 2003 20:46:26 -0500
X-ClientAddr: 66.27.56.212
Received: from www3.fatcity.com (rrcs-west-66-27-56-212.biz.rr.com [66.27.56.212])
 by ensim.rackshack.net (8.11.6/8.11.6) with ESMTP id h7T1kN303776
 for <oracle-l@orafaq.net>; Thu, 28 Aug 2003 20:46:23 -0500
Received: (from root@localhost)
 by www3.fatcity.com (8.11.6/8.11.6) id h7SNFVR12080
 for oracle-l@orafaq.net; Thu, 28 Aug 2003 16:15:31 -0700
Received: by fatcity.com (05-Jun-2003/v1.0g-b73/bab) via fatcity.com id 005CDD11; Thu, 28 Aug 2003 16:14:26 -0800
Message-ID: <F001.005CDD11.20030828161426@fatcity.com>
Date: Thu, 28 Aug 2003 16:14:26 -0800
To: Multiple recipients of list ORACLE-L <ORACLE-L@fatcity.com>
X-Comment: Oracle RDBMS Community Forum
X-Sender: Tim Gorman <tim@sagelogix.com>
Sender: ml-errors@fatcity.com
Reply-To: ORACLE-L@fatcity.com
Errors-To: ML-ERRORS@fatcity.com
From: Tim Gorman <tim@sagelogix.com>
Subject: Re: How to keep "root" out?
Organization: Fat City Network Services, San Diego, California
X-ListServer: v1.0g, build 73; ListGuru (c) 1996-2003 Bruce A. Bergman
Precedence: bulk
Mime-Version: 1.0
Content-type: multipart/alternative; boundary="B_3144935545_5423111"
--B_3144935545_5423111
Content-type: text/plain; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable

Couldn't you just retrieve the column OSUSER from V$SESSION?

Perhaps something like the following:

> SQL> create or replace trigger osusertrg
>   2          after logon
>   3          on database
>   4  declare
>   5          v_osuser        varchar2(30);
>   6  begin
>   7          dbms_output.enable(20000);
>   8          select distinct decode(osuser, 'root', 'root', 'not root')
>   9          into    v_osuser
>  10          from    v$session
>  11          where   audsid =3D userenv('SESSIONID');
>  12          dbms_output.put_line('osuser is "'||v_osuser||'"');
>  13  end osusertrg;
>  14  /
>=20
> Trigger created.
>=20
> SQL> show errors
> No errors.
> SQL>=20
> SQL> connect scott/tiger
> Connected.
> SQL> variable buffer varchar2(100)
> SQL> variable status number
> SQL> exec dbms_output.get_line(:buffer, :status)
>=20
> PL/SQL procedure successfully completed.
>=20
> SQL> print buffer
>=20
> BUFFER
> -------------------------------------------------------------------------=
-----
> --
> osuser is "not root"

Be aware that when you are connected as SYS then all sessions have the same
AUDSID and USERENV(=8CSESSIONID=B9) values of 0...

Hope this helps...

-Tim



on 8/28/03 2:34 PM, Diego Cutrone at diegocutrone@yahoo.com.ar wrote:

>=20
> I don't know if this will work.
> But I'd write an external procedure (a shell) that
> checks the OS userid that's logging into the
> database...
> (may be "who am i", it works even with "su")
>=20
> -------------------
> bash-2.04# id
> uid=3D0(root) gid=3D0(root) groups=3D0(root),48(apache)
> bash-2.04# su - oracle
> oracle::/home/oracle> who am i
> costos!root     pts/1    Aug 28 16:45
> oracle::/home/oracle>
> -------------------
>=20
> I'd put this code in the logon trigger.....
> I'm not sure if this will work with "internal" user...
>=20
> Greetings=20
> Diego Cutrone
>=20
>=20
>=20
>=20
>> Just for grins, I'll ask this question... Is there
> any >way to keep the Unix "root" user from logging
> into the >database (i.e. connect internal or / as
> sysdba)? >Currently using 8.1.7.4 on Solaris 8 here.
>>=20
>> We have a couple people in our Unix admin group that
> vfeel the need to "help" by writing their own DB
>> monitoring scripts. Of course, they don't know what
>> t>hey're talking about. They do not have formal
> logins >for the database, but since they are root
> users they >are connecting via "connect internal".
> This is not >only counterproductive but actually a
> potential >security issue--just because someone has
> root doesn't >necessarily entitle them to see the data
> in the >database. What if it is a payroll database?
>>=20
>> So, I'm curious, is there any way to prevent access
>> via "connect internal" or "/ as sysdba"?
>>=20
>> Thanks in advance.
>=20
> W
>=20
> ------------
> Internet GRATIS es Yahoo! Conexi=F3n
> 4004-1010 desde Buenos Aires. Usuario: yahoo; contrase=F1a: yahoo
> M=E1s ciudades: http://conexion.yahoo.com.ar


--B_3144935545_5423111
Content-type: text/html; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable

<HTML>
<HEAD>
<TITLE>Re: How to keep &quot;root&quot; out?</TITLE>
</HEAD>
<BODY>
<FONT FACE=3D"Arial">Couldn't you just retrieve the column OSUSER from V$SESS=
ION?<BR>
<BR>
Perhaps something like the following:<BR>
<BR>
</FONT><BLOCKQUOTE><FONT FACE=3D"Courier">SQL&gt; create or replace trigger o=
susertrg<BR>
&nbsp;&nbsp;2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;after l=
ogon<BR>
&nbsp;&nbsp;3 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;on data=
base<BR>
&nbsp;&nbsp;4 &nbsp;declare<BR>
&nbsp;&nbsp;5 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v_osuse=
r &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;varchar2(30);<BR>
&nbsp;&nbsp;6 &nbsp;begin<BR>
&nbsp;&nbsp;7 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dbms_ou=
tput.enable(20000);<BR>
&nbsp;&nbsp;8 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select =
distinct decode(osuser, 'root', 'root', 'not root')<BR>
&nbsp;&nbsp;9 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;into &n=
bsp;&nbsp;&nbsp;v_osuser<BR>
&nbsp;10 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from &nbsp;&=
nbsp;&nbsp;v$session<BR>
&nbsp;11 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;where &nbsp;=
&nbsp;audsid =3D userenv('SESSIONID');<BR>
&nbsp;12 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dbms_output.=
put_line('osuser is &quot;'||v_osuser||'&quot;');<BR>
&nbsp;13 &nbsp;end osusertrg;<BR>
&nbsp;14 &nbsp;/<BR>
<BR>
Trigger created.<BR>
<BR>
SQL&gt; show errors<BR>
No errors.<BR>
SQL&gt; <BR>
SQL&gt; connect scott/tiger<BR>
Connected.<BR>
SQL&gt; variable buffer varchar2(100)<BR>
SQL&gt; variable status number<BR>
SQL&gt; exec dbms_output.get_line(:buffer, :status)<BR>
<BR>
PL/SQL procedure successfully completed.<BR>
<BR>
SQL&gt; print buffer<BR>
<BR>
BUFFER<BR>
---------------------------------------------------------------------------=
-----<BR>
osuser is &quot;not root&quot;<BR>
</FONT></BLOCKQUOTE><FONT FACE=3D"Arial"><BR>
Be aware that when you are connected as SYS then all sessions have the same=
 AUDSID and USERENV(&#8216;SESSIONID&#8217;) values of 0...<BR>
<BR>
Hope this helps...<BR>
<BR>
-Tim<BR>
<BR>
<BR>
<BR>
on 8/28/03 2:34 PM, Diego Cutrone at diegocutrone@yahoo.com.ar wrote:<BR>
<BR>
<FONT COLOR=3D"#000098">&gt; <BR>
&gt; I don't know if this will work.<BR>
&gt; But I'd write an external procedure (a shell) that<BR>
&gt; checks the OS userid that's logging into the<BR>
&gt; database...<BR>
&gt; (may be &quot;who am i&quot;, it works even with &quot;su&quot;)<BR>
&gt; <BR>
&gt; -------------------<BR>
&gt; bash-2.04# id<BR>
&gt; uid=3D0(root) gid=3D0(root) groups=3D0(root),48(apache)<BR>
&gt; bash-2.04# su - oracle<BR>
&gt; oracle::/home/oracle&gt; who am i<BR>
&gt; costos!root &nbsp;&nbsp;&nbsp;&nbsp;pts/1 &nbsp;&nbsp;&nbsp;Aug 28 16:=
45<BR>
&gt; oracle::/home/oracle&gt;<BR>
&gt; -------------------<BR>
&gt; <BR>
&gt; I'd put this code in the logon trigger.....<BR>
&gt; I'm not sure if this will work with &quot;internal&quot; user...<BR>
&gt; <BR>
&gt; Greetings <BR>
&gt; Diego Cutrone<BR>
&gt; <BR>
&gt; <BR>
&gt; <BR>
&gt; <BR>
</FONT><FONT COLOR=3D"#006600">&gt;&gt; Just for grins, I'll ask this questio=
n... Is there<BR>
</FONT><FONT COLOR=3D"#000098">&gt; any &gt;way to keep the Unix &quot;root&q=
uot; user from logging<BR>
&gt; into the &gt;database (i.e. connect internal or / as<BR>
&gt; sysdba)? &gt;Currently using 8.1.7.4 on Solaris 8 here.<BR>
</FONT><FONT COLOR=3D"#006600">&gt;&gt; <BR>
&gt;&gt; We have a couple people in our Unix admin group that<BR>
</FONT><FONT COLOR=3D"#000098">&gt; vfeel the need to &quot;help&quot; by wri=
ting their own DB<BR>
</FONT><FONT COLOR=3D"#006600">&gt;&gt; monitoring scripts. Of course, they d=
on't know what<BR>
&gt;&gt; t&gt;hey're talking about. They do not have formal<BR>
</FONT><FONT COLOR=3D"#000098">&gt; logins &gt;for the database, but since th=
ey are root<BR>
&gt; users they &gt;are connecting via &quot;connect internal&quot;.<BR>
&gt; This is not &gt;only counterproductive but actually a<BR>
&gt; potential &gt;security issue--just because someone has<BR>
&gt; root doesn't &gt;necessarily entitle them to see the data<BR>
&gt; in the &gt;database. What if it is a payroll database?<BR>
</FONT><FONT COLOR=3D"#006600">&gt;&gt; <BR>
&gt;&gt; So, I'm curious, is there any way to prevent access<BR>
&gt;&gt; via &quot;connect internal&quot; or &quot;/ as sysdba&quot;?<BR>
&gt;&gt; <BR>
&gt;&gt; Thanks in advance.<BR>
</FONT><FONT COLOR=3D"#000098">&gt; <BR>
&gt; W<BR>
&gt; <BR>
&gt; ------------<BR>
&gt; Internet GRATIS es Yahoo! Conexi&oacute;n<BR>
&gt; 4004-1010 desde Buenos Aires. Usuario: yahoo; contrase&ntilde;a: yahoo=
<BR>
&gt; M&aacute;s ciudades: http://conexion.yahoo.com.ar<BR>
</FONT></FONT>
</BODY>
</HTML>


--B_3144935545_5423111--

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Tim Gorman
  INET: tim@sagelogix.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

