1

On a RedHat 6 server, a third party application requires to be root to run and needs access to sqlplus. I have a running database, I can run sqlplus as user 'oracle'. When logged in as user root, 'sqlplus usr/pwd@dbname' works as expected. The trouble is that this agent needs to run sqlplus with no parameters and it always returns ORA-12546: TNS:permission denied.

I've read a dozen times that enabling root to launch Oracle is a security issue but I really have no other choice.

Running Oracle 11.2.0.1.0.

Any help will be much appreciated as I've googled for 2 days with no success.

4
  • You haven't said what you've tried so this could get repetitive. Presumably you have the environment variables (ORACLE_HOME, TNS_ADMIN, ORACLE_SID...) set up properly, or I think you'd see different errors. Are you using the full Oracle install, and is there anything odd about the permissions in your ORACLE_HOME? I would suggest you have a separate installation of the instant client for root to use to keep as much separation as possible - is that feasible? Commented Feb 19, 2014 at 11:09
  • I have the exact same environment variable for root than for the oracle user. Yes, its a standard Enterprise Oracle installation. I checked the file permissions and ownership with another server that runs as expected but couldn't find a difference and so I suspect it's related to a configuration somewhere. Unfortunately, installing a separate client for root is not possible in this context. I feel this is a problem with the listener configuration, much more than the database. Thanks for your investigations, so far. Commented Feb 19, 2014 at 12:22
  • Yes, I'm just launching sqlplus and rely on ORACLE_SID. I've not configured any wallet, maybe is there a default config? The system that works right is using Oracle 11.1.0.6 rather than 11.2.0.1 on the other one. TWO_TASK is not set on either systems. Couldn't find any difference comparing dirs on both systems. I haven't told it yet but from user root, 'tnsping dbname' answers correctly! I'm puzzled! Commented Feb 19, 2014 at 13:10
  • The only way I know for this to happen - for remote connections to work (tnsping dbname and connecting @dname) but for local connections to get that error is through permissions; specifically when $ORACLE_HOME/bin/oracle isn't world-executable. But that's one of the first things Google suggests, and you've sad the permissions match a working server. Can you confirm that specific flag though? And is root in the dba group on the working server? Commented Feb 19, 2014 at 15:00

1 Answer 1

1

From the documentation, ORA_12546 is:

ORA-12546: TNS:permission denied
Cause: User has insufficient privileges to perform the requested operation. Action: Acquire necessary privileges and try again.

Which isn't entirely helpful, but various forum and blog posts (way too many to link to, Googling for the error shows a lot of similar advice) mention permissions on a particular part of the installation, $ORACLE_HOME/bin/oracle, which is a crucial and central part of most of the services.

Normally the permissions on that file would be -rws-r-s--x, with the file owned by oracle:dba, and this error can occur when the word-writable flag - the final x in that pattern - is not set. Anyone in the dba group will still be able to execute it, but those outside will not.

Your listener seems to be fine as you can connect remotely, by specifying @dbname in the connect string. The listener runs as oracle (usually, could be grid with HA, RAC or ASM) so it is in the dba group and can happily hand-off connections to an instance of the oracle executable.

When you connect without going via the listener, you have to be able to execute that file yourself. It appears that root cannot execute it (or possibly some other file, but this is usually the culprit, apparently), which implies the world-writable bit is indeed not set.

As far as I can see you have three options:

  • set the world-writable bit, with chmod o+x $ORACLE_HOME/bin/oracle; but that opens up the permissions for everyone, and presumably they've been restricted for a reason;
  • add root to the dba group, via usermod or in the /etc/group; which potentially weakens security as well;
  • use SQL*Net even when you don't specify @dbname in the connect string, by adding export TWO_TASK=dbname to the root environment.

You said you don't have this problem on another server, and that the file permissions are the same; in which case root might be in the dba group on that box. But I think the third option seems the simplest and safest. There is a fourth option I suppose, to install a separate instant client, but you'd have to set TWO_TASK anyway and go over SQL*Net, and you've already ruled that out.

I won't dwell on whether it's a good idea to run sqlplus (or indeed the application that needs it) as root, but will just mention that you'd could potentially have a script or function called sqlplus that switches to a less privileged account via su to run the real executable, and that might be transparent to the application. Unless you switch to the oracle account though, which is also not a good idea, you'd have the same permission issue and options.

Sign up to request clarification or add additional context in comments.

3 Comments

This is what I call a very clear explanation. I first tried the TWO_TASK setting and it now works perfectly. By the way, I wanted to check the permissions on oracle bin and they are well -rws-r-s--x. Anyway, thanks a lot for your help! My reputation isn't high enough to award you with a point, or I would give it gratefully.
@PierreVn - glad that works; possibly a directory in the path that makes up $ORACLE_HOME/bin has permissions 750 (drwx-rx---), but not sure if you get exactly that error. Also possible there is an access control list. All a bit irrelevant as TWO_TASK works, but always interesting to know what is wrong, not just how to work around it.
I think I deserve a pair of swipes: I did check the permissions on sub-directories except /home/oracle (Oracle installed underneath), which was 700! I chmod-ed it to 755, removed the TWO_TASK in the shell session, tried sqlplus again and guess what: it also works. Shame on me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.