Link to home
Start Free TrialLog in
Avatar of CSIA AN
CSIA ANFlag for Andorra

asked on

Issues when use LOG function from thread "http://www.experts-exchange.com/questions/28926237/send-ksh-history-to-syslogd-on-AIX.html"

Hi wmp,

We were asked to send to syslog all HSK history from users. This was the first thread we created:
https://www.experts-exchange.com/questions/28926237/send-ksh-history-to-syslogd-on-AIX.html

Then, we had some errors, that were fixed here:
https://www.experts-exchange.com/questions/28928201/log-not-found-on-some-commands.html

But, now we have found another issue on some commands, for examplewhen execute chfs to extend /FS filesystem, we got this:

(AIX):[root] / -> chfs -a size=+1M /FS
Usage: extendlv [-a IntraPolicy] [-e InterPolicy] [-m MapFile]
        [-s Strict] [-u UpperBound] LVname NumberOfLPs [PVname...]
Extends the size of a logical volume.

Open in new window


If I run debug KSH on the same command:
(AIX):[root] / -> ksh -vx chfs -a size=+1M /FS
. /tools/scripts/kshrc/kshrc.ksh
+ . /tools/scripts/kshrc/kshrc.ksh
+ typeset -xf log
+ trap log DEBUG
+ log
chfs "$@"+ chfs -a size=+1M /FS
Usage: extendlv [-a IntraPolicy] [-e InterPolicy] [-m MapFile]
        [-s Strict] [-u UpperBound] LVname NumberOfLPs [PVname...]
Extends the size of a logical volume.

Open in new window


Similar errors ocurs when execute shutdown command.

Remember, we have created this LOG function on /etc/profile and on every user's home directory .kshrc. I mean:
On /etc/profile we added at the end of file:
function log
{
        typeset -i stat=$?
        if [[ $LOGNAME = @(user1|user2) ]] ; then return; fi
        typeset x
        x=$(fc -ln -0)
        echo $x | grep -q "daemon.info" || logger -p daemon.info -t "SHELL: $LOGNAME $$" Status $stat PWD $PWD \'${x#       }\'
}
typeset -xf log
trap log DEBUG
export ENV=$HOME/.kshrc

Open in new window


And inside every /home/user/.kshrc, we added
(AIX):[root] / -> cat /home/israel/.kshrc
. /tools/scripts/kshrc/kshrc.ksh

Open in new window


When /tools/scripts/kshrc/kshrc.ksh has this code:
(AIX):[root] / -> cat /tools/scripts/kshrc/kshrc.ksh
function log
{
        typeset -i stat=$?
        if [[ $LOGNAME = @(user1|user2) ]] ; then return; fi
        typeset x
        x=$(fc -ln -0)
        echo $x | grep -q "daemon.info" || logger -p daemon.info -t "SHELL: $LOGNAME $$" Status $stat PWD $PWD \'${x#       }\'
}
typeset -xf log
trap log DEBUG

Open in new window


Can you help us to fix this new issue?

Thanks tons!
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

That's really strange! There's absolutely no visible reason why this "chfs "$@"+" should appear in front of the entered command.

Strange thing, too, that the "Usage" message would mention "extendlv" instead of "chfs"!

Did you set an alias for "chfs", or is it a script?
When I try to call chfs with the parameters you posted I get an "Usage" message from chfs, as expected.

What do you see in the syslog, by the way?
In the meantime I've been able to reproduce this issue. I don't see this "chfs "$@"+ " thing, but anyway.
It seems that our famous logging function would fail as soon as a script (extendlv) is called by a binary (chfs).

I don't have a real idea what's going on here.
I suspect that the cause is not in the logging function itself but rather due to the signal trapping.

I'll try to find out a bit more, but I'm not really optimistic that we can find a solution.

Let's see.
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CSIA AN

ASKER

Hi WMP,

Sorry the delay.  Now I see extendlv script is the cause of the error with RC 127. I think it should be similar with shutdown script.
But it's curious if you're not root user it works. Let me explain you. We have configured RBAC for admin users, to avoid use root user, and in this case chfs and extendlv works well.

See an example, run the same command using my user with RBAC role loaded:

():[israel] /home/israel -> ksh -vx chfs -a size=+1M /CORES
. /tools/scripts/kshrc/kshrc.ksh
+ . /tools/scripts/kshrc/kshrc.ksh
+ typeset -xf log
+ trap log DEBUG
+ log
chfs "$@"+ chfs -a size=+1M /CORES
Filesystem size changed to 524288

Open in new window


For now we're going to open a PMR with IBM to see if they can help us.

Thanks much!  Have a greate weekend!!
Oh dear, this makes it even more puzzling!

I'm really curious what IBM might say (if anything at all)!

Have a very nice weekend, too!

wmp
Avatar of CSIA AN

ASKER

Hi again,

I've been out of office last week. Let's open a PMR to see if there is any solution to our issue.
Avatar of CSIA AN

ASKER

Hi wmp,

Back again ;)

After a while IBM has said:

The issue is NOT related to the AIX commands,its due to the script of LOG function which actually
corrupting the $? value which has global scope.Please modify the script without corrupting $?.
I couldn't get what is wrong in the script though i suspect issue with back ticks "`".


So, there's no way to fix the issue with LOG function. IBM recommend to use auditbin to audit KSH commands.

Have a nice weekend!
Avatar of CSIA AN

ASKER

Thanks!