Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Running fglrun as root  (Read 9288 times)
Jos? V.
Posts: 55


« on: May 07, 2019, 06:26:46 pm »

I'm having an issue while running fglrun as root.
The program tries connecting to the database and fails immediately.
The program I'm testing is the following:
Quote
main
    define  oUser           char(10)

    connect to 'db' user 'user' using 'pass'
    select @user into oUser from indica
    display "UTILIZADOR: ", oUser
end main

As root I get the following:
Quote
Program stopped at 'testeVersao.4gl', line number 4.
SQL statement error number -6366 (0).
Could not load database driver dbmdefault. Set FGLSQLDEBUG to get more details.

As a regular user this is my result:
Quote
UTILIZADOR: jcv

My question is why does this happen? is there a security block on fglrun that prevents it from being run as root?

I now it sounds weird running it as root, but the program we are developing makes some system administration and needs root to access some files.
Sebastien F.
Four Js
Posts: 509


« Reply #1 on: May 07, 2019, 06:35:33 pm »

Hello,

What is the database? Informix?

I suspect that your root user does not have all env settings (LD_LIBRARY_PATH) to load the database client library.

Compare env settings with root and your regular user "jcv" ...

Seb
Jos? V.
Posts: 55


« Reply #2 on: May 07, 2019, 06:39:45 pm »

Quote from: Sebastien F.
What is the database? Informix?

I suspect that your root user does not have all env settings (LD_LIBRARY_PATH) to load the database client library.

Compare env settings with root and your regular user "jcv" ...

Thanks for the quick reply Sebastien,
The database is informix.

I'm doing the following steps on my test to ensure the same environment:
1 - run the program as "jcv" -> OK
2 - do "su -" to ensure root keeps the env
3 - run the program as root.
Sebastien F.
Four Js
Posts: 509


« Reply #3 on: May 07, 2019, 06:47:49 pm »

I really suspect that your env is wrong.

Assuming this is Linux, in the root env, try:

ldd -r $FGLDIR/dbdrivers/dbmifx.so

and check if all Informix shared libs are resolved.

I tried to connect with a little program under root, and the Informix driver loads without problem when executing under root, but then I get an SQL error from the server because the root user has no privileges to connect to my db (as expected):

fglrun ifx.42m
Program stopped at 'ifx.4gl', line number 3.
SQL statement error number -387.
No connect permission.
SYSTEM error number -111.
ISAM error:  no record found.

I have really some doubts about executing programs as root ...

What version of Informix IDS is this?

You may at consider to create a database user with CREATE USER and connect as this user with CONNECT TO ... USER ... USING ...

Seb
Jos? V.
Posts: 55


« Reply #4 on: May 08, 2019, 01:14:59 pm »

Found the problem.
su logs in using the same env as the original user.
except if you "su" to root.
In this case the system takes precautionary security measures and blanks PATH and LIBPATH(aix version of LD_LIBRARY_PATH).
So the problem was that LIBPATH was in fact diferent from the expected.

Thank you for the help
Sebastien F.
Four Js
Posts: 509


« Reply #5 on: May 08, 2019, 06:08:22 pm »

Hello,

I am pleased to see that you have solved this issue.

Tip:
In such case, keep in mind that fglrun + the Informix ODI driver dbmifx act just like any other Informix ESQL/C program.
So if you want to isolate the test to Informix software and configuration only, write a little ESQL/C program, compile it with esql and see if it works.

Seb
Reuben B.
Four Js
Posts: 1047


« Reply #6 on: May 09, 2019, 01:42:13 am »

Another tip is to build into your programs a way of dumping or viewing the actual environment that is inherited by the fglrun process when it launches.

So something like ...

Code
  1. MAIN
  2.   ... as soon as possible typically as part of a library you call at start of each program
  3.   IF cmdline_arg("--dump-env") THEN
  4.      LET temp_filename = ...
  5.      LET cmd = "env | sort > ", temp_filename
  6.      RUN cmd WITHOUT WAITNG


GAS users will note that one of the first things in the uaproxy logs is a dump of the environment variables.

Reuben







Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines