<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Gather environment variables for arbitrary process in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710338#M488240</link>
    <description>&lt;P&gt;The 'gdb' program may be installed by default on 11.31.&amp;nbsp; It would be worth a shot to try it on those servers at least.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would/should be in the /opt/langtools/bin directory if it's there.&lt;/P&gt;</description>
    <pubDate>Wed, 18 Feb 2015 20:15:14 GMT</pubDate>
    <dc:creator>Patrick Wallek</dc:creator>
    <dc:date>2015-02-18T20:15:14Z</dc:date>
    <item>
      <title>Gather environment variables for arbitrary process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710301#M488234</link>
      <description>&lt;P&gt;More of a Perl programmer than HP-UX Sys Admin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are a few posts related to this, but, none of the answer work for me, yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am in the situation of determining security compliance for a&amp;nbsp; number of machines.&amp;nbsp; The rule set I must check includes checking the environment variables for arbitrary processes.&amp;nbsp; I don't know what process will be the target until the rule is read.&amp;nbsp; So, I must collect the environment vars for a give process on the fly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On other operating systems, this is trivial.&amp;nbsp; I don't see a direct way to do it on HP-UX.&amp;nbsp;&amp;nbsp; I'm usually on 11.31, but, this chore needs to work on recent versions of HP-UX.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hoped pstat_getproc would work, but, it does not return what would be considered the env vars.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Feb 2015 18:38:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710301#M488234</guid>
      <dc:creator>PalmerScott</dc:creator>
      <dc:date>2015-02-18T18:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Gather environment variables for arbitrary process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710329#M488235</link>
      <description>&lt;P&gt;To do this you will have to use the 'gdb' command to query the process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I elected to do this against PID 2965, which is an httpd process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To invoke 'gdb'&amp;nbsp; against a specific PID you use the '-p' option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# gdb -p 2965&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once you are at the "(gdb)" prompt you type in:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(gdb) p ((char**)_environ)[0]@30&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The "@30" is the number of environment variables that it will return.&amp;nbsp; To increase the number of variables returned just increase the number.&amp;nbsp; If you get a "Error reading address" then there isn't an variable at that address.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the complete log of my testing with gdb:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;# gdb -p 2965
HP gdb 6.2 for HP Itanium (32 or 64 bit) and target HP-UX 11iv2 and 11iv3.
Copyright 1986 - 2011 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 6.2 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.

Attaching to process 2965
Reading symbols from /opt/hpws/apache/bin/httpd...done.
0xc000000000552650:0 in _accept_sys+0x30 () from /usr/lib/hpux64/libc.so.1
(gdb) p ((char**)_environ)[0]@30
$1 = {0x9ffffffffffffc38 "_=/opt/hpws/apache/bin/httpd",
  0x9ffffffffffffc55 "SENDMAIL_SERVER=1", 0x9ffffffffffffc67 "DDFA=0",
  0x9ffffffffffffc6e "SNMP_MASTER_START=0",
  0x9ffffffffffffc82 "MROUTED_ARGS=",
  0x9ffffffffffffc90 "SHLIB_PATH=/opt/hpws/apache/lib:/opt/hpws/apache/lib/LDAP:", 0x9ffffffffffffccb "PATH=/usr/sbin:/usr/bin:/sbin",
  0x9ffffffffffffce9 "XNTPD_ARGS=-l /var/adm/xntpd.log",
  0x9ffffffffffffd0a "DHCPV6CLNTD_ARGS=", 0x9ffffffffffffd1c "XNTPD=1",
  0x9ffffffffffffd24 "SNMP_TRAPDEST_START=0",
  0x9ffffffffffffd3a "INETD_ARGS=",
  0x9ffffffffffffd46 "MIPARMS=-fileio_traces -p",
  0x9ffffffffffffd60 "TFTPD_STANDALONE_START=0",
  0x9ffffffffffffd79 "MROUTED=0", 0x9ffffffffffffd83 "SNMP_MIB2_START=0",
  0x9ffffffffffffd95 "ERASE=^H", 0x9ffffffffffffd9e "STOPEMAIL=1",
  0x9ffffffffffffdaa "INIT_STATE=3", 0x9ffffffffffffdb7 "SENDMAIL_SENDONLY=0",
  0x9ffffffffffffdcb "RWHOD=0", 0x9ffffffffffffdd3 "SNMP_CMDVW_START=0",
  0x9ffffffffffffde6 "DHCPV6D=0", 0x9ffffffffffffdf0 "SNMP_HPUNIX_START=0",
  0x9ffffffffffffe04 "STARTEMAIL=1",
  0x9ffffffffffffe11 "TFTPD_STANDALONE_OPTIONS= -l -s -S -i",
  0x9ffffffffffffe37 "PRE_U95=true",
  0x9ffffffffffffe44 "STARTSTOPADDR=bhassell@sourcedirect.com",
  0x9ffffffffffffe6c "SNMP_NAA_START=0",
  0x9ffffffffffffe7d "SNMP_IPv6_START=0"}&lt;BR /&gt;
(gdb) p ((char**)_environ)[0]@60
$3 = {0x9ffffffffffffc38 "_=/opt/hpws/apache/bin/httpd",
  0x9ffffffffffffc55 "SENDMAIL_SERVER=1", 0x9ffffffffffffc67 "DDFA=0",
  0x9ffffffffffffc6e "SNMP_MASTER_START=0",
  0x9ffffffffffffc82 "MROUTED_ARGS=",
  0x9ffffffffffffc90 "SHLIB_PATH=/opt/hpws/apache/lib:/opt/hpws/apache/lib/LDAP:", 0x9ffffffffffffccb "PATH=/usr/sbin:/usr/bin:/sbin",
  0x9ffffffffffffce9 "XNTPD_ARGS=-l /var/adm/xntpd.log",
  0x9ffffffffffffd0a "DHCPV6CLNTD_ARGS=", 0x9ffffffffffffd1c "XNTPD=1",
  0x9ffffffffffffd24 "SNMP_TRAPDEST_START=0",
  0x9ffffffffffffd3a "INETD_ARGS=",
  0x9ffffffffffffd46 "MIPARMS=-fileio_traces -p",
  0x9ffffffffffffd60 "TFTPD_STANDALONE_START=0",
  0x9ffffffffffffd79 "MROUTED=0", 0x9ffffffffffffd83 "SNMP_MIB2_START=0",
  0x9ffffffffffffd95 "ERASE=^H", 0x9ffffffffffffd9e "STOPEMAIL=1",
  0x9ffffffffffffdaa "INIT_STATE=3", 0x9ffffffffffffdb7 "SENDMAIL_SENDONLY=0",
  0x9ffffffffffffdcb "RWHOD=0", 0x9ffffffffffffdd3 "SNMP_CMDVW_START=0",
  0x9ffffffffffffde6 "DHCPV6D=0", 0x9ffffffffffffdf0 "SNMP_HPUNIX_START=0",
  0x9ffffffffffffe04 "STARTEMAIL=1",
  0x9ffffffffffffe11 "TFTPD_STANDALONE_OPTIONS= -l -s -S -i",
  0x9ffffffffffffe37 "PRE_U95=true",
  0x9ffffffffffffe44 "STARTSTOPADDR=bhassell@sourcedirect.com",
  0x9ffffffffffffe6c "SNMP_NAA_START=0",
  0x9ffffffffffffe7d "SNMP_IPv6_START=0",
---Type &amp;lt;return&amp;gt; to continue, or q &amp;lt;return&amp;gt; to quit---
  0x9ffffffffffffe8f "PHPRC=/opt/hpws/apache/conf",
  0x9ffffffffffffeab "HPWS_APACHE_HOME=/opt/hpws/apache",
  0x9ffffffffffffecd "SENDMAIL_RECVONLY=0",
  0x9ffffffffffffee1 "DHCPV6SRVRD_ARGS=",
  0x9ffffffffffffef3 "LD_LIBRARY_PATH=/opt/hpws/apache/lib:",
  0x9fffffffffffff19 "TERM=unknown", 0x9fffffffffffff26 "PWD=/",
  0x9fffffffffffff2c "PERL5LIB=/opt/hpws/apache/lib/perl/lib/site_perl/5.8.8/IA64.ARCHREV_0-thread-multi-LP64:/opt/hpws/apache/lib/perl/lib:",
  0x9fffffffffffffa3 "TZ=EST5EDT", 0x9fffffffffffffae "INETD=1",
  0x9fffffffffffffb6 "SENDMAIL_SERVER_NAME=",
  0x9fffffffffffffcc "NTPDATE_SERVER=0.north-america.pool.ntp.org", 0x0,
  0x2f6f70742f687077 &amp;lt;Error reading address 0x2f6f70742f687077: Bad address&amp;gt;,
  0x732f617061636865 &amp;lt;Error reading address 0x732f617061636865: Bad address&amp;gt;,
  0x2f62696e2f687474 &amp;lt;Error reading address 0x2f62696e2f687474: Bad address&amp;gt;,
  0x7064002d64002f6f &amp;lt;Error reading address 0x7064002d64002f6f: Bad address&amp;gt;,
  0x70742f687077732f &amp;lt;Error reading address 0x70742f687077732f: Bad address&amp;gt;,
  0x617061636865002d &amp;lt;Error reading address 0x617061636865002d: Bad address&amp;gt;,
  0x6b00737461727400 &amp;lt;Error reading address 0x6b00737461727400: Bad address&amp;gt;,
  0x5f3d2f6f70742f68 &amp;lt;Error reading address 0x5f3d2f6f70742f68: Bad address&amp;gt;,
  0x7077732f61706163 &amp;lt;Error reading address 0x7077732f61706163: Bad address&amp;gt;,
  0x68652f62696e2f68 &amp;lt;Error reading address 0x68652f62696e2f68: Bad address&amp;gt;,
  0x747470640053454e &amp;lt;Error reading address 0x747470640053454e: Bad address&amp;gt;,
  0x444d41494c5f5345 &amp;lt;Error reading address 0x444d41494c5f5345: Bad address&amp;gt;,
---Type &amp;lt;return&amp;gt; to continue, or q &amp;lt;return&amp;gt; to quit---
  0x525645523d310044 &amp;lt;Error reading address 0x525645523d310044: Bad address&amp;gt;,
  0x4446413d3000534e &amp;lt;Error reading address 0x4446413d3000534e: Bad address&amp;gt;,
  0x4d505f4d41535445 &amp;lt;Error reading address 0x4d505f4d41535445: Bad address&amp;gt;,
  0x525f53544152543d &amp;lt;Error reading address 0x525f53544152543d: Bad address&amp;gt;,
  0x30004d524f555445 &amp;lt;Error reading address 0x30004d524f555445: Bad address&amp;gt;}
(gdb) quit
The program is running.  Quit anyway (and detach it)? (y or n) y
Detaching from program: /opt/hpws/apache/bin/httpd, process 2965&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a sample from the 'lpsched' process:&lt;/P&gt;&lt;PRE&gt;# gdb -p 1836
HP gdb 6.2 for HP Itanium (32 or 64 bit) and target HP-UX 11iv2 and 11iv3.
Copyright 1986 - 2011 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 6.2 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.

Attaching to process 1836
Reading symbols from /usr/sbin/lpsched...(no debugging symbols found)...done.
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...
0x60000000c056afd0:0 in _select_sys+0x30 () from /usr/lib/hpux32/libc.so.1
(gdb) p ((char**)_environ)[0]@60
$1 = {0x200000007efcd9b0 "PATH=/usr/bin", 0x200000007fffff9e "TZ=EST5EDT",
  0x0 &amp;lt;repeats 36 times&amp;gt;,
  0x2f757372 &amp;lt;Error reading address 0x2f757372: Bad address&amp;gt;,
  0x2f736269 &amp;lt;Error reading address 0x2f736269: Bad address&amp;gt;,
  0x200000006e2f6c70 &amp;lt;Error reading address 0x200000006e2f6c70: Bad address&amp;gt;,
  0x2000000073636865 &amp;lt;Error reading address 0x2000000073636865: Bad address&amp;gt;,
  0x2000000064000000 &amp;lt;Error reading address 0x2000000064000000: Bad address&amp;gt;,
  0x0 &amp;lt;repeats 17 times&amp;gt;}

(gdb) p ((char**)_environ)[0]@10
$2 = {0x200000007efcd9b0 "PATH=/usr/bin", 0x200000007fffff9e "TZ=EST5EDT",
  0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
(gdb) quit
The program is running.  Quit anyway (and detach it)? (y or n) y
Detaching from program: /usr/sbin/lpsched, process 1836
#&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you do not have GDB loaded you can get it for 11.11, 11.23 and 11.31 here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://hpux.connect.org.uk/hppd/hpux/Gnu/gdb-7.6.2/" target="_blank"&gt;http://hpux.connect.org.uk/hppd/hpux/Gnu/gdb-7.6.2/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Feb 2015 19:51:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710329#M488235</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2015-02-18T19:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Gather environment variables for arbitrary process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710331#M488237</link>
      <description>&lt;P&gt;Patrick,&lt;/P&gt;&lt;P&gt;Thanks very much for the detailed response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I do not have the ability to require gdb on all target machines.&amp;nbsp; Consequently, I must stay within the tools available on a base plan-vanilla OS install.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Feb 2015 19:56:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710331#M488237</guid>
      <dc:creator>PalmerScott</dc:creator>
      <dc:date>2015-02-18T19:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Gather environment variables for arbitrary process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710332#M488238</link>
      <description>&lt;P&gt;&amp;gt;&amp;gt;I do not have the ability to require gdb on all target machines.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then it likely won't be possible to get the information you need.&amp;nbsp; I know of no other way query a process to that level.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Feb 2015 19:59:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710332#M488238</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2015-02-18T19:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: Gather environment variables for arbitrary process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710335#M488239</link>
      <description>&lt;P&gt;After reading quite and few man pages, white papers, and forum posts, that's my conclusion, also.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your time and input.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Feb 2015 20:03:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710335#M488239</guid>
      <dc:creator>PalmerScott</dc:creator>
      <dc:date>2015-02-18T20:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Gather environment variables for arbitrary process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710338#M488240</link>
      <description>&lt;P&gt;The 'gdb' program may be installed by default on 11.31.&amp;nbsp; It would be worth a shot to try it on those servers at least.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would/should be in the /opt/langtools/bin directory if it's there.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Feb 2015 20:15:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/gather-environment-variables-for-arbitrary-process/m-p/6710338#M488240</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2015-02-18T20:15:14Z</dc:date>
    </item>
  </channel>
</rss>

