ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General IBM MQ Support » Help on security exit testing

Post new topic  Reply to topic
 Help on security exit testing « View previous topic :: View next topic » 
Author Message
WBI_user
PostPosted: Mon Jun 19, 2006 6:28 am    Post subject: Help on security exit testing Reply with quote

Partisan

Joined: 07 Aug 2001
Posts: 386

I was given a channel security exit to implement on a Linux server Qmgr. But it does not seem to work properly. Looking at the source code, I can see printf statements sending output to stdout and stderr. But I don't see the output anywhere. If I can see the outout, I may be able to tell where is the failure. The program is wrtten in C and the programmer is on vacation for a couple of weeks.
Any idea how I can see those outputs when the exit is implemented on Linux without havng to modify the source code. Where does stdout and stderr go when the exit program runs under the MCA ?
If source code modification is required, I'll try. I am not a C programmer, but if someone can show me what to add or change, I probably can handle the editing and recompiling.
Back to top
View user's profile Send private message
Mr Butcher
PostPosted: Mon Jun 19, 2006 6:40 am    Post subject: Reply with quote

Padawan

Joined: 23 May 2005
Posts: 1716

maybe home directory of the mqm userid (or the userid that runs the mca)? (just a guess, i do not know)
_________________
Regards, Butcher
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Jun 19, 2006 6:43 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I suspect that stdout and stderr will only show up if you enable MQ tracing, and then in the trace file.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mvic
PostPosted: Mon Jun 19, 2006 7:29 am    Post subject: Re: Help on security exit testing Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

WBI_user wrote:
Where does stdout and stderr go when the exit program runs under the MCA ?

Almost certainly they are closed, as is normal with a "server" process designed to run unattached from a console.

Instead of writing to stdout and stderr, code the exit to open a named file for output (use fopen) and write directly to the file (use fwrite).
Back to top
View user's profile Send private message
WBI_user
PostPosted: Mon Jun 19, 2006 8:32 am    Post subject: Reply with quote

Partisan

Joined: 07 Aug 2001
Posts: 386

Try to run with MQTRACE turned on. I can see that the Exit get invoked. But output are not shown in the exit.
I have tried to use frepon to send the stdout to a file. But printf output are not send there either. I'll try to use fwrite instead. But I donot want to spend too much time modifying the program as my job is administrator.
Back to top
View user's profile Send private message
mvic
PostPosted: Mon Jun 19, 2006 8:50 am    Post subject: Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

WBI_user wrote:
I'll try to use fwrite instead.

Actually it might be quicker/easier to use fprintf, not fwrite. fprintf looks much more like printf. The following (untested) sequence of calls might work:

Code:
FILE * fp;
char * thestring = "abc";
int theinteger = 1;
int * thepointer = &theinteger;

fp = fopen("/home/myuser/myfile.txt", "a");
if ( fp != NULL )
{
  fprintf(fp, "string %s integer %d pointer %p\n",
          thestring, theinteger, thepointer);
  fclose(fp);
}


Quote:
But I donot want to spend too much time modifying the program as my job is administrator.

Is this exit code supported by the app development group? Perhaps they can assist.
Back to top
View user's profile Send private message
WBI_user
PostPosted: Mon Jun 19, 2006 2:39 pm    Post subject: Reply with quote

Partisan

Joined: 07 Aug 2001
Posts: 386

As I mentoned earlier, the author of the exit is on vacation and I just need to do as much as I can within my ability get the exit going.

I inserted the code to open a file and changed the printf to fprintf as suggested.

void MQStart() {;} /* dummy entry point */
void MQENTRY ChannelExit ( PMQCXP ChannelParms,
PMQCD ChannelDef,
:
MQLONG ExitBuffLen,
MQPTR ExitBuffAddr)

{
FILE *pFile;
pFile = fopen("/var/mqm/exits/Scyout.txt", "w");
fprintf (pFile, "exit code follows \n");
:
Original exit code with printfs changed to fprintf
:

fprintf (pFile, "exit code is done \n");
fclose(pFile);
:
}

Very strange, only the first fprintfs at the beginning and the end that I added were output to the file. All the other fprintfs (changed from printf in the exit code) were not.

Any idea ? Is there any limitation on writing to external file when the exit is running ?

Any suggesiton on how to trace the execuion of the exit other than trying to track the printfs to determine at what point is the exit failing ?
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Mon Jun 19, 2006 9:19 pm    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
Location: London, ON Canada

WBI_user wrote:
Any idea ? Is there any limitation on writing to external file when the exit is running ?

No.

WBI_user wrote:
Any suggesiton on how to trace the execuion of the exit other than trying to track the printfs to determine at what point is the exit failing ?

You are dabbling in a very complex area of programming. I strongly suggest you read the following posting:
http://www.mqseries.net/phpBB2/viewtopic.php?t=20523

Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
mvic
PostPosted: Tue Jun 20, 2006 12:41 am    Post subject: Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

WBI_user wrote:
Any idea ?

Try changing the "w" to "a" in your fopen call.
Back to top
View user's profile Send private message
WBI_user
PostPosted: Tue Jun 20, 2006 8:40 pm    Post subject: Reply with quote

Partisan

Joined: 07 Aug 2001
Posts: 386

I found the problem but don't understand why. It is permission. Once I change the permission of the log file to 777, I can now see the fprintf messages. The log file Scyout.txt was created by the program and the first and last message was written to it. Why the other fprintfs cannot. The only explaination is the channel exit code is using a different userId.
Back to top
View user's profile Send private message
mvic
PostPosted: Wed Jun 21, 2006 3:24 am    Post subject: Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

WBI_user wrote:
Why the other fprintfs cannot. The only explaination is the channel exit code is using a different userId.

Who can write to files in the directory /var/mqm/exits ? Hopefully not too many people... On one of my machines it's only mqm user and group that can write there.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » Help on security exit testing
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.