POV-Ray : Newsgroups : povray.unix : small bugfix in unix.cpp? : Re: small bugfix in unix.cpp? Server Time
8 Jul 2024 17:51:02 EDT (-0400)
  Re: small bugfix in unix.cpp?  
From: fsdck
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.