blob: e90cc8b0370cd16af1242c9dff24b4ee8fd945c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#!/usr/dt/bin/dtksh
#
# accept dialog script for x11vnc
# 2004-07-13 stefan.radman@ctbto.org
# should work in any CDE environment (Sun,HP,IBM,...)
#
# when called without parameters shows a CDE question dialog:
# Do you want to accept a VNC connection
# from IP address $RFB_CLIENT_IP to your desktop?
# Note:
# After 30 seconds the screen will
# be locked and the connection will be
# accepted automatically."
# [Yes} {__No__] [View/Only]
# and counts down a timer in the dialog title bar
# when the timer is down to 0, it locks the display and returns 0
# (if the screenlock was successful or if the login prompt was active)
#
# buttons=retcode:
# Yes = 0
# No = 1 (same as closing the dialog windows)
# View/Only = 3
#
# usage: x11vnc -forever -shared -accept "yes:0,no:*,view:3 dtVncPopup" -gone "dtVncPopup lock"
#
# security considerations: when you return to your console and unlock the display
# you can never know if enyone else is connected to your display
#
# timeout until accept
timeout=30
# dialog message
test -z "${RFB_CLIENT_IP}" && unknown="an unknown " || ip="$RFB_CLIENT_IP "
message="\
Do you want to accept a VNC connection
from ${unknown}IP address ${ip}to your desktop?
Note:
After $timeout seconds the screen will
be locked and the connection will be
accepted automatically."
# action functions
accept () {
exit 0
}
reject () {
exit 1
}
view () {
exit 3
}
lock () {
# lock only if dtsession active
xrdb -query | grep -c '^dtsession*' || accept
# accept only if lock succeeds
/usr/dt/bin/dtaction LockDisplay && accept || reject
}
# main
# actions can be called directly
test $# -gt 0 && $@
# initialize the display
XtInitialize TOPLEVEL vncPopup VncPopup "$0" "$@"
# create a message dialog containing the contents of the specified file
XmCreateQuestionDialog DIALOG $TOPLEVEL dialog \
dialogTitle:"$DTKSH_APPNAME" \
messageString:"$message" \
unmapCallback:reject \
# symbolPixmap:/usr/dt/appconfig/icons/C/DtFlag.m.pm
# change the OK button to "Yes"
XmMessageBoxGetChild OK_BUTTON $DIALOG DIALOG_OK_BUTTON
XtSetValues $OK_BUTTON \
labelString:"Yes" \
activateCallback:accept
# change the Cancel Button to "No"
XmMessageBoxGetChild CANCEL_BUTTON $DIALOG DIALOG_CANCEL_BUTTON
XtSetValues $CANCEL_BUTTON \
labelString:"No" \
activateCallback:reject
# change Help button to View-Only, set focus and make it the default
XmMessageBoxGetChild HELP_BUTTON $DIALOG DIALOG_HELP_BUTTON
XtSetValues $HELP_BUTTON \
labelString:"View\nOnly" \
activateCallback:view
# make "No" the default (for unmap as well)
XtSetValues $DIALOG \
defaultButton:$CANCEL_BUTTON initialFocus:$CANCEL_BUTTON \
# create the ticker
ticker () {
test $timeout -eq 0 && lock
XtSetValues $DIALOG dialogTitle:"accepting in $timeout seconds"
XtAddTimeOut TICKER 1000 ticker
timeout=`expr $timeout - 1`
}
# display dialog and activate ticker
XtAddTimeOut TICKER 1000 ticker
XtManageChild $DIALOG
XtMainLoop
|