in reply to Re: Remote ptkdb behind firewall
in thread Remote ptkdb behind firewall
but you don't have a BEGIN block, you have a subroutine called BEGIN, which isn't the same thing at all.
AFAIK, there's no functional difference between a BEGIN block with and without "sub". The docs say
"These code blocks can be prefixed with "sub" to give the appearance of a subroutine (although this is not considered good style)."
Where would you think a functional difference lies?
As for the OP's problem, the issue presumably is that the www-data user doesn't have a cookie that would allow authentication with the X server.  The fact that it works via a separate ssh connection (with X forwarding) doesn't say much — it is because the ssh server sets up an appropriate DISPLAY/socket and cookie for the connection. But that cookie can be transferred to a different account, if desired. For this, list it from within the ssh connection's terminal with xauth. You'd get something like
$ xauth list $DISPLAY somehost.domain.com:10 MIT-MAGIC-COOKIE-1 b412a470ac5605e443cd330f48 +bbc62e
Then switch to the www-data account and run (or run the same command from within the BEGIN block in the CGI)
xauth add somehost.domain.com:10 MIT-MAGIC-COOKIE-1 b412a470ac5605e443 +cd330f48bbc62e
and set DISPLAY to somehost.domain.com:10. This adds the cookie to the user's xauth database file (by default ~/.Xauthority), and hence allows www-data to connect to the X server via the same tunnel that is used by the ssh connection. Of course, this only works as long as the ssh connection is established (so you should keep it open while debugging).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Remote ptkdb behind firewall
by oko1 (Deacon) on Feb 19, 2012 at 18:38 UTC | |
by Eliya (Vicar) on Feb 19, 2012 at 19:00 UTC |