Undocumented Features

Download Report

Transcript Undocumented Features

Undocumented
Features
Sandeep Ramavana
OpenVMS Engineering
Sep 2009
Germany Technical Update Days 2009
© 2009 Hewlett-Packard Development Company, L.P.
The information contained herein is subject to change without notice
Disclaimer
• Warning!
−These tools/commands mentioned in this
presentation are undocumented, unsupported
and subject to change/removal without notice
2
7 July 2015
Agenda
• Commands
• Passwords
• Monitoring components
•
•
•
•
•
Process Quotas
XQP
Image Activation
EFI FAT partition
Images
• Operator Forced Crash
• TCP/IP Configuration
• System Services
• Pthreads
• $SETENV
3
• Toolbox
• Fun with Documented Features
7 July 2015
Undocumented
Commands
4
7 July 2015
OpenVMS version
Fastest method to upgrade to the newer version of OpenVMS 
$ set def sys$loadable_images
$ run sysver
SYSVERSION> show
00010938: V8.3
SYSVERSION> replace V8.5-1
SYSVERSION> write
SYSVERSION> show
00010938: V8.5-1
SYSVERSION> exit
Reboot the system… And give $ SHOW SYSTEM
$ sh system /noproc
OpenVMS V8.5-1 on node DIA64
3-SEP-2009 15:37:27.29
Uptime
0 14:36:12
Fastest method to upgrade to the newer version of OpenVMS 
5
7 July 2015
Playing with Passwords
•
Password history
• How to overcome the restriction?
• Change the password multiple times . . .
•
How to prevent this?
− DEFINE /SYSTEM /EXEC LGI$PASSWORD_NOCHANGE_DAYS 10
•
Set warning before password expires
− DEFINE /SYSTEM /EXEC LGI$EXPIRATION_WARNING_DAYS 20
6
7 July 2015
Monitor Process Quota
•
How to monitor the quota of a process
continuously?
•
Use $ SHOW PROCESS/CONTINUOUS with ‘Q’
•
While the continuous display is running, hit ‘Q’ and
dynamically monitor the process quotas
7
7 July 2015
Monitor Process Quota
Process HB_CHECKER
01:28:39
State
CUR
Working set
167
PID
29400273
Page faults
3540
UIC
[VENU,HB_CHECKER]
Event flags
C0000002
FE000000
# open files remaining
127/128
( 99%)
Direct I/O count/limit
150/150
(100%)
Buffered I/O count/limit
149/150
( 99%)
127488/127616
( 99%)
ASTs remaining
296/300
( 98%)
Timer entries remaining
100/100
(100%)
15637/16000
( 97%)
3997/4000
( 99%)
BUFIO byte count/limit
PGFL quota count/limit
ENQ quota count/limit
8
7 July 2015
Monitor XQP
•
9
$ SET WATCH FILE/CLASS=keyword
ALL
Enable all file activity monitoring.
ATTRIBUTE
Reading and writing of file attributes; such as
done with the directory command.
CONTROL_FUNCTION
Use of file system control functions.
DIRECTORY_OPERATIONS
Modifications to directories by creating,
deleting and renaming files.
DUMP
Dump contents of File Information Blocks
(FIB).
MAJOR_FUNCTIONS
Log activities for major functions including
file lookup, access and deaccess.
QUOTA_OPERATIONS
Activity associated with changes to disk quotas
and usage.
NONE
Turn off all file activity monitoring.
7 July 2015
Special Logicals
•
Show Device
− If you define the logical SHOW$DEBUG to anything,
then the SHOW DEVICE command will give a lot of
debugging information.
Lock 43000510, length of items 00180030, $ENQ status 00000001, value
$ sh dev DIA64$DKA100:
Locks queued to device lock "SYS$_DIA64$DKA100:":
k 0F98BA75 00000000 00000000 00000019
LOCKID
PID
SYSID
(node)
GRMODE
STATE
- 0100007C 00000000 00000000 ()
01
01
[ PW / CR / GRANTED ]
- 43000510 00000454 00000000 ()
00
01
[ NL / NL / GRANTED ]
Device
Name
DIA64$DKA100:
10
7 July 2015
Device
Status
Mounted
REMLKID
REMSYSID
bloc
RQMODE
0100007C
00000000 ()
04
43000510
00000000 ()
00
Error
Count
2
Volume
Label
CTM
Free Trans Mnt
Blocks Count Cnt
6275232
270
1
Special Logicals
•
Image Activation
DEFINE IAC$DEBUG FF
11
7 July 2015
EFI FAT Partitions
•
Visible from EFI Shell> (console) prompt
•
Can be mounted and examined via EFI$CP
$ MC EFI$CP
EFI$CP> HELP
12
7 July 2015
More about OpenVMS Images
$ analyze/image/out=nl:/select=(ident,link) test.exe
$ show symbol analyze*
ANALYZE$ARCHITECTURE = ""
ANALYZE$BUILD_IDENTIFICATION = ""
ANALYZE$FILE_TYPE = ""
ANALYZE$IDENTIFICATION = "V5.9"
ANALYZE$IMAGE_TYPE = ""
ANALYZE$LINKER_IDENTIFICATION = ""
ANALYZE$LINK_TIME = "25-OCT-2008 13:06:41.01"
ANALYZE$NAME = ""
13
7 July 2015
OPCCRASH.EXE
Logical Name
Action taken by OPCCRASH
OPC$REBOOT
Enables automatic reboot
OPC$NODUMP
Disables writing the dump
OPC$CLUSTER_SHUTDOW
Cluster shutdown
N
OPC$REMOVE_NODE
Node is leaving the cluster
OPC$GALAXY_SHUTDOWN Galaxy is shutting down
OPC$POWER_OFF
Power down
OPC$UNLOAD
Causes disk unload/spindown
14
7 July 2015
TCP/IP Configuration
HP
TCP/IP Services
OpenVMS
Core
Environment
Configuration Menu
WARNING:
You are for
about
to discard
*all*
TCPIP configuration
information from your present system. This includes your host's
Configuration options:
own name and IP address, names of other hosts and networks,
1 - services,
Domain BIND servers, static routes, exported
enabled
2 - Interfaces
filesystems,
proxy entries and more.
3 - Routing
4 - BIND Resolver
5 - Time Zone
While existing versions of these database files will remain on
- Configure
1-5
your Asystem,
there isoptions
no automated
procedure to revert to them.
[E] - Exit menu
You should proceed only if it is your intention to completely
start from scratch
on 6this system, giving it a new name and IP
Enter configuration
option:
address, new BIND resolver information, a new list of enabled
services, and so forth.
* Proceed to discard configuration information? [NO]:
15
7 July 2015
No Auto-Forward in MAIL
•
16
If you send mail to "_username" instead of "username",
then the mail will not be forwarded even though username
has made a SET FORWARD.
7 July 2015
Unexpected Status Values 
$ exit %xB70
%SYSTEM-W-FISH, my hovercraft is full of eels
$ exit %x3F30074
%KATIE-F-DEVNOTMBX, device is not a mailbox
$ exit %x34B4
%SYSTEM-F-GAMEOVER, all your base are belong to
us
17
7 July 2015
Undocumented
System Services
18
7 July 2015
Undocumented pthread features
Process-Shared Objects
SYS$PSHARED_REGISTER
Mutex M1
Process
B
Process
A
Process B crashes while holding mutex
Process A waits
indefinitely for the
mutex
20
7 July 2015
Undocumented pthread features
pthread_mutex_tryforcedlock_np
This will be returned if the mutex is
abandoned, and the thread which called
this routine is the new owner of the
mutex
0
EPERM
If the mutex is already locked by some
other thread and is no longer
abandoned
EINVAL
If the mutex is not a pshared mutex
ENOSYS
Illegal system service, if the system
service is not loaded
21
7 July 2015
Undocumented pthread features
Get per-thread CPU time
extern int pthread_getcputime_np(pthread_t, struct
timespec*);
0
Success
EINVAL
NULL cputime parameter
ESRCH
handle is not a thread
ESTALE
warning that value is out of date (target
is running)
22
7 July 2015
Set the environment variables
SYS$SETENV
23
7 July 2015
Undocumented
Toolbox
24
7 July 2015
Toolbox Overview
CNX connection manager tracing
EXC exception tracing
FC Fibrechannel debug and tracing
FLT alignment fault tracing
IO buffered and direct I/O tracing
LCK lock manager tracing
LNM logical name tracing
MTX mutex tracing
PCS PC sampling
PRF performance utility
PSH pshared debug utility
RMS indexed file tracing
SPL spinlock tracing
TQE timer entry tracing
TR debug and trace prints
XFC eXtended File Cache diagnostics
25
7 July 2015
First shipped in
V7.2-2
V8.2
V7.2-2
V8.1
V7.3-2
V7.2-2
V7.3-1
V7.3
V7.3-2
V8.2
V8.2-1
V8.2-1
V7.2-1H1
V7.3-1
V7.3
V7.3
Undocumented Toolbox
Hooks in the VMS executive
Invoked from within SDA
Can be loaded and unloaded without reboot
Trace data is stored in ring buffer in memory
− Buffer can be large (multi GB if needed)
− Mapped into S2 space
− User-mode read/writeable
Trace data can be displayed from within a crash
dump if tracing was turned on at the time of a
system crash
26
7 July 2015
General Tools
xxx$DEBUG.EXE
− loadable execlet
− Located in SYS$LOADABLE_IMAGES
xxx$SDA.EXE
− user-mode SDA extension
− Located in SYS$SHARE
Common commands
−
−
−
−
−
−
−
27
SDA> xxx
! Displays brief command help
SDA> xxx LOAD
SDA> xxx START TRACE /BUFFER=3000
SDA> xxx SHOW TRACE
SDA> xxx STOP TRACE
SDA> xxx UNLOAD
SDA>
READ /EXEC /NOLOG
7 July 2015
Tracing during Early Boot
How to start tracing early during bootstrap?
$ mc sysman sys_load add spl$debug spl$debug /load=init
$ @sys$update:vms$system_images
How to stop early-boot tracing?
SYS$LOADABLE_IMAGES:VMS$SYSTEM_IMAGES.DATA
$ mc sysman sys_load remove spl$debug spl$debug
$ @sys$update:vms$system_images
28
7 July 2015
Alignment Fault Tracing
•
Alignment faults
Alignment faults are more expensive on IA64, than on
Alpha!!!
Some alignment faults are easy to fix, some are very
hard.
•
•
• Align structure fields, use SDL over hand-crafted .H files
• Change code to use for example 2 LD4 over a single LD8
• Use appropriate directives (__unaligned)
C example:
typedef __unaligned unsigned __int32 * UNALIGNED_UINT32_PQ;
UNALIGNED_UINT32_PQ ptr;
*ptr = x;
29
7 July 2015
Alignment Fault Tracing
Unaligned
FaultInformation:
Trace Information:
Fault Data
Trace
(at
9-SEP-2009 09:18:18.42, trace time 00:11:18.094343)
---------------------------------------
FLT Extension for SDA
--------------------------------------------------------------------------------Timestamp
CPU Exception PC
Unaligned VA
Access
EPID
Trace Buffer
---------------------- ---
-----------------------------------------------
-----------------
------
--------
-----------------
00000000.7B745060
00000000.00208D24
User
00000498
FFFFFFFF.7E457990
− SDA> FLT START TRACE
9-SEP 09:15:01.274079 01 00000000.7B745060
00000000.0053AC60
0.17
9-SEP 09:15:01.274066 01 00000000.7B745050
− SDA> FLT SHOW TRACE /SUMMARY
9-SEP 09:15:01.258356 01 00000000.7B742C50 0.06
0000182A.B444BEE7
00000000.00208D24
User
00000498
FFFFFFFF.7E457928
00000000.001E30E4
User
00000498
FFFFFFFF.7E4578C0
00000000.001E30E4
User
00000498
FFFFFFFF.7E457858
00000000.001E30E4
User
00000498
FFFFFFFF.7E4577F0
9-SEP 09:15:01.258346
01
00000000.7B742C20
00000000.001E30E4
User
00000498
FFFFFFFF.7E457788
9-SEP 09:15:01.258322
01
00000000.7B742A70
00000000.001E30E4
User
00000498
FFFFFFFF.7E457720
00000000.001E30E4
User
00000498
FFFFFFFF.7E4576B8
00000000.001E30E4
User
00000498
FFFFFFFF.7E457650
00000000.001E30E4
User
00000498
FFFFFFFF.7E4575E8
9-SEP 09:14:59.311847 01 00000000.7B742C20 0.04
00000000.00E98240
00000000.001E30E4
User
00000498
FFFFFFFF.7E457580
9-SEP 09:14:59.311813
00000000.001E30E4
User
00000498
FFFFFFFF.7E457518
00000000.001E30E4
User
00000498
FFFFFFFF.7E4574B0
00000000.001E30E4
User
00000498
FFFFFFFF.7E457448
00000000.001E30E4
User
00000498
FFFFFFFF.7E4573E0
00000000.00E97730
0.03
9-SEP
01 00000000.7B742C20
−09:14:37.108811
FLT START
TRACE [/BUFFER=pages]
00000000.001E30E4
User
00000498
FFFFFFFF.7E457378
9-SEP 09:14:37.108780
00000000.001E30E4
User
00000498
FFFFFFFF.7E457310
Exception
PC 1:
Example
9-SEP 09:15:01.314295
01
Rate
----------------------------9-SEP 09:15:01.314283 01 00000000.7B745050
00000000.00834620
0.06
9-SEP 09:15:01.258272 01 00000000.7B745F60 0.06
00000000.0053A150
Example 2:
9-SEP 09:15:01.258253
01
00000000.7B745F50
00000000.00833B10
0.05
9-SEP 09:14:59.311857 01 00000000.7B742C50
− SDA> FLT SHOW TRACE
01
00000000.7B742AC1
00000000.0053B170
9-SEP 09:14:59.311805 01 00000000.7B742AA0 0.03
9-SEP 09:14:59.311761 01 00000000.7B742A70
00000000.00BBBFB0
0.03
FLT commands:
9-SEP 09:14:37.108821
01
01
00000000.01270B50
00000000.7B742C50
00000000.7B742AC1
0.03
00000000.001E30E4
User
00000498 FFFFFFFF.7E4572A8
[/BEGIN=pc_range_low]
[/END=pc_range_high]
9-SEP 09:14:37.108735 01 00000000.7B742A70 0.03
00000000.001E30E4 User
00000498 FFFFFFFF.7E457240
00000000.00BBB4A0
− FLT SHOW TRACE [/SUMMARY]
00000000.01270040
0.03
9-SEP 09:14:37.108772
01
00001870.E04F0CF6
30
7 July 2015
00000000.7B742AA0
0.02
Fun with Documented
Commands
31
7 July 2015
Query Number of lines in a file
$ sear/nooutput/stat test.c ""
Files searched:
Records searched:
Characters searched:
Records matched:
Lines printed:
1
7
93
6
0
Buffered I/O count:
7
Direct I/O count:
1
Page faults:
22
Elapsed CPU time: 0 00:00:00.00
Elapsed time:
0 00:00:00.00
$ sh sym search*
SEARCH$CHARACTERS_SEARCHED = "93"
SEARCH$FILES_SEARCHED = "1"
SEARCH$LINES_PRINTED = "0"
SEARCH$RECORDS_MATCHED = "6"
SEARCH$RECORDS_SEARCHED = "7"
32
7 July 2015
% -> match
one
character
Wildcards search
Wildcards search
$ type test.txt
first line
second line
third line
forth line
fifth line
sixth line
$
search test.txt "c%n"
%SEARCH-I-NOMATCHES, no strings matched
$
search test.txt "c%n"/WILDCARD
second line
Skip the first 3 matches and display only 2 matches
$
search test.txt line/limit=2/skip=3
fourth line
fifth line
33
7 July 2015
Type part of a file
The /SKIP qualifier can be used to type a file from a given line
Example:
Typing from the 4th line
$ search test.txt/skip=3/match=nor
fourth line
fifth line
sixth line
34
7 July 2015
"nonexistantstring"
Write to sys$output without a CRLF
To write to sys$output without generating a CRLF use
$ type CRLF.COM
$ READ/TIME=0/ERROR=LABEL SYS$COMMAND GARBAGE/PROMPT="I am at first line "
$LABEL:
$ READ/TIME=0/ERROR=LABEL1 SYS$COMMAND GARBAGE/PROMPT="I am at second line"
$LABEL1:
$ @CRLF
I am at first line I am at second line
$
35
7 July 2015
Lost System Password?
Methods to recover
Option 1: Conversational boot
SYSBOOT> SET/STARTUP _OPA0:
SYSBOOT> CONTINUE
$ SET NOON
fix the problem
$ MCR SYSGEN
SYSGEN> USE CURRENT
SYSGEN> SET/STARTUP SYS$SYSTEM:STARTUP.COM
SYSGEN> WRITE CURRENT
SYSGEN> EXIT
$ @SYS$SYSTEM:STARTUP
36
7 July 2015
Lost System Password?
Option 2:
SYSBOOT> SET UAFALTERNATE 1
SYSBOOT> CONTINUE
$ SET NOON
fix the problem
$ MCR SYSGEN
SYSGEN> USE CURRENT
SYSGEN> SET UAFALTERNATE 0
SYSGEN> WRITE CURRENT
SYSGEN> EXIT
$ @SYS$SYSTEM:SHUTDOWN
37
7 July 2015
Current Executing Image
$ SHOW SYSTEM /IMAGE
•
Can be used on remote systems
• SHOW SYSTEM/NODE=FOO /IMAGE
•
Can be combined with any existing qualifier
• SHOW SYSTEM/IMAGE/INTER
• Gets list of images being executed by all the interactive users
on the system
38
7 July 2015
Undelete
$ DEL*ETE :== @SYS$LOGIN:MYDELETE.COM
•
Procedure invoked whenever user enters DEL
command.
•
The Procedure can copy the file(s) to a Recycle
folder before doing the real Delete.
•
Have procedure to retrieve the files and cleanout
the directory.
39
7 July 2015
Session Logging
SET HOST /LOG
− Saves the session log to a file
Eg : SET HOST /LOG=BANFF_23NOV.LOG BANFF
TELNET /LOG_FILE
− Saves the session log to a file
Eg: TELNET /LOG=BANFF_23NOV.LOG BANFF
40
7 July 2015
Save Recall Buffer
Store the Contents of recall buffer
$ RECALL/OUT=session.lis
Load this file to the recall buffer on subsequent
logins
$ RECALL /INPUT=session.lis
41
7 July 2015
Q&A
42
7 July 2015