View previous topic :: View next topic |
Author |
Message |
gotluru Beginner
Joined: 17 Dec 2002 Posts: 29 Topics: 6
|
Posted: Fri Dec 20, 2002 12:51 pm Post subject: Called Program Name |
|
|
Hi,
How i am going to know which program is called?
My Environmnet is: Cobol/MVS
Thanks,
Prasad |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
|
Posted: Fri Dec 20, 2002 1:46 pm Post subject: |
|
|
Gotluru,
There are 2 macro's which will give information about the load modules.
1.CSVINFO -- Obtain Information about Loaded Modules
2.CSVQUERY -- Contents Supervisor Query Service
The macro CSVQUERY will tell you what module (not CSECT) is at a particular address. If the program you are using uses standard linkage conventions, then you can look at Reg 14 on entry (or from your save area) and pass that address to CSVQUERY. You'll get the load module name and starting address. Then you subtract that from your R14 and you get an offset.If standard linkage conventions are in use, the R12 on entry might point to the module name, depending on the compiler used to compile the caller.
Check this link for Retrieving Information About Loaded Modules
To make things simpler, pass the called program name to the calling program as a variable.
Hope this helps...
cheers
kolusu |
|
Back to top |
|
|
gotluru Beginner
Joined: 17 Dec 2002 Posts: 29 Topics: 6
|
Posted: Fri Dec 20, 2002 1:57 pm Post subject: |
|
|
Hi Kolusu,
Thanks for the information.
How to get return code's to be displayed at runtime? Can you help me with example..
Thanks,
Prasad |
|
Back to top |
|
|
hari_uss Beginner
Joined: 19 Dec 2002 Posts: 78 Topics: 6 Location: Trivandrum, India
|
Posted: Sun Dec 22, 2002 3:39 am Post subject: |
|
|
Gotluru,
Check this link..
Return Code
Implicit declaration for Return code is PIC S9(04) COMP. I think you can find a way to display that.
-----
Hari. |
|
Back to top |
|
|
gotluru Beginner
Joined: 17 Dec 2002 Posts: 29 Topics: 6
|
Posted: Mon Dec 23, 2002 10:57 am Post subject: |
|
|
Hi Hari,
Thanks for the help.
I am looking in other way. I need program name from where the call is came from?
Thanks,
Prasad |
|
Back to top |
|
|
hari_uss Beginner
Joined: 19 Dec 2002 Posts: 78 Topics: 6 Location: Trivandrum, India
|
Posted: Mon Dec 23, 2002 12:56 pm Post subject: |
|
|
Hi Prasad,
I dont know any built-in function to get that info. I would pass the name of the calling program as a parameter through the linkage
Or,
Define an EXTERNAL variable WS-CALLING-PGM in all your calling programs and in the called program.
-----
Hari. |
|
Back to top |
|
|
gotluru Beginner
Joined: 17 Dec 2002 Posts: 29 Topics: 6
|
Posted: Mon Dec 23, 2002 2:15 pm Post subject: |
|
|
Hi Hari,
Thanks for immediate reply..
Code: | Define an EXTERNAL variable WS-CALLING-PGM in all your calling programs and in the called program. |
How to accomplish this? Is it same as passing parms or differant?
Can you please explain..
Thanks,
Prasad |
|
Back to top |
|
|
hari_uss Beginner
Joined: 19 Dec 2002 Posts: 78 Topics: 6 Location: Trivandrum, India
|
Posted: Mon Dec 23, 2002 11:01 pm Post subject: |
|
|
It is different from passing parameters.
Program-1.
Code: |
Program-ID. PGM1.
Working-Storage Section.
01 Ws-pgm-name Pic X(08) External.
Procedure Division.
Move 'PGM1' To Ws-pgm-name.
Call 'PGM2' Using ws-1 ws-2.
<<control goes to PGM2>>
|
Program-2.
Code: |
Program-ID. PGM2.
Working-Storage Section.
01 Ws-pgm-name Pic X(08) External.
Linkage-Section.
01 ws-1 Pic x(02).
01 ws-2 Pic x(02).
Procedure Division using ws-1 ws-2.
Display 'This program is called by ' Ws-pgm-name .
|
Since Ws-pgm-name is declared as EXTERNAL, we can access the value in PGM2 also.
The variable name you are using for declaring EXTERNAL should be same in all modules.
Hope this is clear for you...
Hari. |
|
Back to top |
|
|
gotluru Beginner
Joined: 17 Dec 2002 Posts: 29 Topics: 6
|
Posted: Thu Dec 26, 2002 2:17 pm Post subject: |
|
|
Hi Hari,
Thanks for your help. External clause is working fine and easier than passing parms.
Thanks,
Prasad |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Wed Jun 16, 2010 11:20 am Post subject: |
|
|
Hi,
I need to verify if a calling program is authorised to call the called program or not. And to prevent unauthorised program from getting access by pretending to be someone else, I don't trust the program name passed by the calling program. So I need a way to find the name of calling program. This should work in any environment (CICS/TSO) and calling method (Call/Link/XCTL/Start).
After going through all the posts on this subject and available material on the web I don't find any example that can get calling program name irrespective of the calling method.
Only method that doesn't seem to care about the calling methods is to use PPA1. Please let me know if that is correct and the right approach. And if someone can provide an example, preferably in COBOL. Another question, will this work if I have a static call? _________________ Regards,
Diba |
|
Back to top |
|
|
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Wed Jun 16, 2010 2:07 pm Post subject: |
|
|
Any restrictions should be handled by external security. . . (racf, acf2, tss).
No program needs (or should be permitted) to do this. . .
fwiw. _________________ All the best,
di |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Wed Jun 16, 2010 5:11 pm Post subject: |
|
|
Quote: |
Any restrictions should be handled by external security
|
di,
This is the argument we are also trying. But I cannot say what will be the final decision. Currently we are trying find if it is feasible to write a program to get caller's name, without any restriction. _________________ Regards,
Diba |
|
Back to top |
|
|
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Wed Jun 16, 2010 5:50 pm Post subject: |
|
|
For fun, let us assume i want to "break in". Let us also assume that a program named GOODGUY is allowed to call this "restricted" module.
If i create my own code that does something "bad" and name it GOODGUY, how will this restricted module know that my GOODGUY module should be denied. . .? _________________ All the best,
di |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Wed Jun 16, 2010 8:09 pm Post subject: |
|
|
This program will never get promoted to production library as a simple comparison with the old GOODGUY would reveal that it is doing something fishy. Without this manual check any security tool would fail in this case. _________________ Regards,
Diba |
|
Back to top |
|
|
nevilh Beginner
Joined: 11 Aug 2004 Posts: 115 Topics: 0
|
Posted: Thu Jun 17, 2010 6:52 am Post subject: |
|
|
Dibakar wrote: | This program will never get promoted to production library. | And what happens if the user copies the GOODGUY to a user library and invokes it from there |
|
Back to top |
|
|
|
|