POV-Ray : Newsgroups : povray.unix : small bugfix in unix.cpp? Server Time
29 Oct 2024 22:47:48 EDT (-0400)
  small bugfix in unix.cpp? (Message 1 to 7 of 7)  
From: fjansson
Subject: small bugfix in unix.cpp?
Date: 8 Jun 2003 05:49:30
Message: <3ee306aa$1@news.povray.org>
I am using povray 3.50c for linux. When I try to start povray remotely on
an other linux box with rsh,

rsh computer povray options

povray segfaults. The problem seems to be theese lines in unix.cpp:

  1840    /* if this isn't actually a TTY, no need for SVGA */
  1841    if (!strstr(ttyname(0), "tty"))
  1842      {
  1843        return (false);
  1844      }

It seems that ttyname returns NULL when run with rsh (maybe there is no real tty?),
and then strstr segfaults. Something similar occurs when I run a script
that does some calculations and then start povray. If I log out before povray is
started
povray crashes, for the same reason, I think.

Inserting the lines:

 if (ttyname(0) == NULL)
    return (false);

before the lines above seems to solve the problem, at least in the first case.
The manpage for ttyname says it returns NULL if an error occurs.
Comments?

Fredrik


Post a reply to this message

From: Christoph Hormann
Subject: Re: small bugfix in unix.cpp?
Date: 8 Jun 2003 06:45:22
Message: <3EE313EA.6B620D82@gmx.de>
fja### [at] abofi wrote:
> 
> [...]
> 
> Inserting the lines:
> 
>  if (ttyname(0) == NULL)
>     return (false);
> 
> before the lines above seems to solve the problem, at least in the first case.
> The manpage for ttyname says it returns NULL if an error occurs.
> Comments?

I don't remember any such problem when running povray remotely but since
the specs say ttyname() can return NULL this should be handled correctly.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 28 Feb. 2003 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Wolfgang Wieser
Subject: Re: small bugfix in unix.cpp?
Date: 8 Jun 2003 07:27:27
Message: <3ee31d9f@news.povray.org>
> I don't remember any such problem when running povray remotely but since
> the specs say ttyname() can return NULL this should be handled correctly.
> 
Maybe this is the reason why people repeatedly report POVRay crashing 
when started from a script or cron job?

Just what came to my mind instantly without checking if it is true...

Wolfgang


Post a reply to this message

From: Christopher James Huff
Subject: Re: small bugfix in unix.cpp?
Date: 8 Jun 2003 10:05:02
Message: <cjameshuff-E253CB.08562408062003@netplex.aussie.org>
In article <3ee306aa$1@news.povray.org>, fja### [at] abofi wrote:

> I am using povray 3.50c for linux. When I try to start povray remotely on
> an other linux box with rsh,

Have you tried/can you try ssh? I use it often to render POV scenes on 
my fast machine (a Mandrake Linux box) from my slow machine, with no 
trouble. It also includes an option to force pseudo-tty allocation, 
which I use to get the remote POV to close on demand, but it seems to 
render fine without that.
You've already got a fixed version, I'm just wondering why it would work 
in ssh but not rsh.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: small bugfix in unix.cpp?
Date: 8 Jun 2003 11:18:34
Message: <3ee353c9@news.povray.org>
fja### [at] abofi wrote:
> It seems that ttyname returns NULL

  ttyname() can certainly return NULL and you are completely right that
it should be checked.
  To me this looks like a genuine bug, which is easy to fix, as you
suggested.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: fjansson
Subject: Re: small bugfix in unix.cpp?
Date: 9 Jun 2003 03:42:45
Message: <3ee43a75$1@news.povray.org>
I have used ssh, and it works fine. rlogin works too.
I suspect this has something to do with how rsh handles tty:s.
When I run:
[fjansson@clus ~]$ rsh clusn2 ps
  PID TTY          TIME CMD
20430 ?        00:00:00 ps
The questionmark seems to imply that there is no real terminal.

Fredrik


Post a reply to this message

From: fsdck
Subject: Re: small bugfix in unix.cpp?
Date: 17 Jul 2003 04:46:36
Message: <3f16626b@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

fja### [at] abofi wrote:
[ ... ]
> 
> Inserting the lines:
> 
>  if (ttyname(0) == NULL)
>     return (false);
> 
> before the lines above seems to solve the problem, at least in the first case.
> The manpage for ttyname says it returns NULL if an error occurs.
> Comments?
> 
> Fredrik
> 

Yup, that'll fix 'er, but the program will no longer do what the author was
trying to do with that line anymore.  The code that you quoted, and that
around it, looks to be a kluge where someone was trying to check to see
whether or not the user should have permission to use povray with svgalib.
The author is trying to make sure that you are sitting at the console and
that you have access to the root account before it will attempt to use
svgalib.

As a matter of style, you generally don't check for things like this in a
unix application unless you are writing a server, or something to be run
suid root.  Normally, I would suggest ripping the lines out that are
checking for TTYs and root privs since it's the OS's job to check user
privileges, however, I don't know whether povray will properly handle an
error due to insufficient privleges elsewhere in the application if it
runs across one.

Enough ranting :).  The easiest fix would probably be to use the -D0 flag
on the command line, or set Display to false in the ini.  If you want to
modify the source, and you want to keep it close to what it origianlly
was, you could do something like this instead:

  if (!isatty (0) || !strstr (ttyname (0), "tty"))
    return (false);

If you can rip the if statement out, and it still runs properly from an
xterm, you should probably do that instead.  The check that the author was
making doesn't really do what they intended.  Someone can still log in over
a serial port and render to the screen; what's more you can't render to the
screen using svgalib from an xterm (should you have some odd reason to do
so).  According to svgalib, it is supposed to grab the next free virtual
console when run from X.

Good Luck,
  Karmix
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE/FluC8/zoYc8slRERAm8/AJ4x5TzXjZw53mV81OyhwGIfJFVOIwCfRac3
35yCY87djJT6rc9jqRLeqgo=
=BLIt
-----END PGP SIGNATURE-----


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.