[14014] in Perl-Users-Digest
Perl-Users Digest, Issue: 1424 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 18 18:41:27 1999
Date: Thu, 18 Nov 1999 15:41:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942968468-v9-i1424@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 18 Nov 1999 Volume: 9 Number: 1424
Today's topics:
SU problem m_scheferhoff@my-deja.com
Re: SU problem (Kragen Sitaker)
Re: SU problem <asd@ds.aw>
Re: SU problem (Martien Verbruggen)
Re: Substitute for gethostbyaddr? <gellyfish@gellyfish.com>
Re: Substitute for gethostbyaddr? (Martien Verbruggen)
True Type font Support for GD in Perl (Michael F. Loll)
Re: Tying a pseudo-hash (M.J.T. Guy)
Re: Tying a pseudo-hash <mel@disc.com>
Re: Using variables with pattern matching <t.dillerNOt.SPAM@xpres.com.invalid>
Re: Using variables with pattern matching (Kragen Sitaker)
want to convert blocking read socket into nonblocking dinodesk@hotmail.com
Re: want to convert blocking read socket into nonblocki dinodesk@hotmail.com
Re: want to convert blocking read socket into nonblocki (Kragen Sitaker)
Re: Writing data to file on another server. mark_r_jones@my-deja.com
Re: Writing data to file on another server. <gellyfish@gellyfish.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 Nov 1999 13:54:58 GMT
From: m_scheferhoff@my-deja.com
Subject: SU problem
Message-Id: <8110fg$ni3$1@nnrp1.deja.com>
Hello,
I wrote a webapplication. The name of my webuser is nobody. My user
nobody isn't allowed to do anything!!! So, to be able to execute
commands or to open files, nobody isn't allowed to, I would like to
make a "su news" for example, but then a password is required. Is there
an elegant way for me to solve my problem? How is it with opening
files, reading files and writing new values to files. Is this also
possible with "su"?
Thanks for your help.
Michael
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 18 Nov 1999 21:20:30 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: SU problem
Message-Id: <y4_Y3.26020$YI2.1163013@typ11.nn.bcandid.com>
In article <8110fg$ni3$1@nnrp1.deja.com>, <m_scheferhoff@my-deja.com> wrote:
>I wrote a webapplication. The name of my webuser is nobody. My user
>nobody isn't allowed to do anything!!! So, to be able to execute
>commands or to open files, nobody isn't allowed to, I would like to
>make a "su news" for example, but then a password is required. Is there
>an elegant way for me to solve my problem? How is it with opening
>files, reading files and writing new values to files. Is this also
>possible with "su"?
What's your Perl question?
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 18 Nov 1999 15:02:02 +0100
From: "Jakob" <asd@ds.aw>
Subject: Re: SU problem
Message-Id: <8111c0$p8e@sdaw04.seinf.abb.se>
You might want to have a look at the Expect module.
Rgrds
Jakob
<m_scheferhoff@my-deja.com> wrote in message
news:8110fg$ni3$1@nnrp1.deja.com...
> Hello,
>
> I wrote a webapplication. The name of my webuser is nobody. My user
> nobody isn't allowed to do anything!!! So, to be able to execute
> commands or to open files, nobody isn't allowed to, I would like to
> make a "su news" for example, but then a password is required. Is there
> an elegant way for me to solve my problem? How is it with opening
> files, reading files and writing new values to files. Is this also
> possible with "su"?
>
> Thanks for your help.
>
> Michael
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Thu, 18 Nov 1999 22:08:34 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: SU problem
Message-Id: <CN_Y3.79$eR.2075@nsw.nnrp.telstra.net>
On Thu, 18 Nov 1999 13:54:58 GMT,
m_scheferhoff@my-deja.com <m_scheferhoff@my-deja.com> wrote:
> Hello,
>
> I wrote a webapplication. The name of my webuser is nobody. My user
> nobody isn't allowed to do anything!!! So, to be able to execute
That's what that user's purpose in life is. Sit around, do a lot of
things, but not being allowed to do much.
> commands or to open files, nobody isn't allowed to, I would like to
> make a "su news" for example, but then a password is required. Is there
> an elegant way for me to solve my problem? How is it with opening
> files, reading files and writing new values to files. Is this also
> possible with "su"?
This is not at all a Perl question.
To find out what sort of techniques you need to use to get su to do
what you want, you should ask in a unix group. (But you're going about
it the wrong way)
To find out what is necessary for you to be able to do things like
that from a CGI program, you should ask in a CGI group.
But you'll probably find that the su command is not what you want. To
find out more about setuid and setgid, you'll have to dive into the
manuals for your system. And to give it at least a little bit of perl
relevance: You want to read the perlsec documentation:
# perldoc perlsec
Martien
--
Martien Verbruggen |
Interactive Media Division | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: 18 Nov 1999 09:41:11 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Substitute for gethostbyaddr?
Message-Id: <3833c9b7_2@newsread3.dircon.co.uk>
AcCeSsDeNiEd <dillon_rm@magix.com.sg> wrote:
> Hi folks,
> Firstly, thanks for all the help I got from you guys (Thread: Can't
> get hostname with gethostbyaddr).
>
> Also, sorry for the repeated post for that thread. I was having
> problems with my news server.
>
> The perl ver on the webhost machine (SCO Unix) has been upgraded to
> 5.005_03. But I still can't use "gethostbyaddr".
>
> I think the problem running "gethostbyaddr" has been found out:-
>
> This is what the Webhost System Administrator has to say:
>
> "The function which you are trying to implement can only be run as
> root,
> "gethostbyaddr" needs to be run as root or superuser. You need to use
> functions which don't need superuser as it might compromise system
> securities".
>
>
> The question is, the problem with "gethostbyadd" or is it just the
> config of the server? That means I suppose there is no way to retrieve
> hostname from an IP on this machine with any method/s unless I'm the
> root/superuser acc?
>
It is is the configuration of the server :
[pigment.dircon.net] $ id
uid=202(tdcjs) gid=102(devel) groups=102(devel),50(group),100(informix)
[pigment.dircon.net] $ cat hostname.pl
#!/usr/bin/perl
use Socket;
use Sys::Hostname;
$ip = '203.120.90.111';
$host_name = gethostbyaddr(inet_aton($ip),AF_INET)||
die "Could not find host: $!\n";
print $host_name,"\n";
[pigment.dircon.net] $ perl hostname.pl
shoot.pacific.net.sg
[pigment.dircon.net] $ uname -a
SCO_SV pigment 3.2 5.0.5 i386
I have tested this with a user with absolutely no subsystem authorizations
whatsoever and it works - the resolver is incorrectly configured - take this
to a comp.unix.sco.* group.
/J\
--
"They're called Virgin Trains because they don't go all the way" -
Simon Hoggart, The Guardian
------------------------------
Date: 18 Nov 1999 11:16:48 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: Substitute for gethostbyaddr?
Message-Id: <slrn837o1v.1qp.mgjv@wobbie.heliotrope.home>
On 18 Nov 1999 09:41:11 GMT,
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> AcCeSsDeNiEd <dillon_rm@magix.com.sg> wrote:
> > "The function which you are trying to implement can only be run as
> > root,
> > "gethostbyaddr" needs to be run as root or superuser. You need to use
> > functions which don't need superuser as it might compromise system
> > securities".
Excessive paranoia, is what comes to mind.
> > The question is, the problem with "gethostbyadd" or is it just the
> > config of the server? That means I suppose there is no way to retrieve
> > hostname from an IP on this machine with any method/s unless I'm the
> > root/superuser acc?
It's a configuration issue.
Martien
--
Martien Verbruggen |
Interactive Media Division | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 18 Nov 1999 22:18:30 GMT
From: mloll@wam.umd.edu (Michael F. Loll)
Subject: True Type font Support for GD in Perl
Message-Id: <811tvl$ohc$1@dailyplanet.wam.umd.edu>
I need true type font support in GD in perl so I have to recompile the gd
library (atleast that is what gd said). IS ther any add on to perl that
adds the true type font support or must I recompile gd. I've been trying
to recompile gd with no success.
Thanks.
Please cc: mloll@wam.umd.edu
--
Mike Loll mloll@wam.umd.edu
"Opportunities multiply as they are seized."
-- Sun Tzu, The Art of War
------------------------------
Date: 18 Nov 1999 16:53:02 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Tying a pseudo-hash
Message-Id: <811ate$q7m$1@pegasus.csx.cam.ac.uk>
In article <FLDGsv.K8z@news.boeing.com>,
Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>In article <80cpu2$i3f$1@nnrp1.deja.com>, Mark Lofdahl <mel@disc.com> wrote:
>>Is there a way to tie a psuedo-hash as a hash instead of an array?
>
>You have to use the underlying hash
>rather than the pseudohash ref, e.g.,
>
>package My_Tie;
>
>use Tie::Hash;
>@ISA = qw( Tie::StdHash);
>sub FETCH {
> my ($self, $key) = @_;
> warn "fetched $key\n";
>}
>package main;
>
>my $k = {"a" => 1, "b" => 2};
>my $pseudo_hash = [$k];
>tie( %{$k}, 'My_Tie') or die "can't tie\n";
>my $var = $pseudo_hash->{a}; #--> "fetched a"
>__END__
Err.. no. That just ties the index hash. Not what he wants at all.
Seems to me it's a bug that
>> tie(%$pseudohash, "Tie::StdHash");
doesn't Do The Right Thing. At the very least, it ought to complain
that you are trying to do a hash tie on an array (or do I mean vice versa?)
Mike Guy
------------------------------
Date: Thu, 18 Nov 1999 16:57:14 GMT
From: Mark Lofdahl <mel@disc.com>
Subject: Re: Tying a pseudo-hash
Message-Id: <811b57$ae$1@nnrp1.deja.com>
In article <FLDGsv.K8z@news.boeing.com>,
ced@bcstec.ca.boeing.com (Charles DeRykus) wrote:
>
> You have to use the underlying hash
> rather than the pseudohash ref, e.g.,
>
> package My_Tie;
>
> use Tie::Hash;
> @ISA = qw( Tie::StdHash);
> sub FETCH {
> my ($self, $key) = @_;
> warn "fetched $key\n";
> }
> package main;
>
> my $k = {"a" => 1, "b" => 2};
> my $pseudo_hash = [$k];
> tie( %{$k}, 'My_Tie') or die "can't tie\n";
> my $var = $pseudo_hash->{a}; #--> "fetched a"
> __END__
>
Thanks. I tried that, and got it to work. One caveat: you need to tie
the underlying hash when it is empty, instead of after putting things
into it. If you do it after, tying it will clear its contents (because
Tie::StdHash will bless it into an empty hash). So keys(%$k) or keys(%
$pseudo_hash) will be empty, and then things will NOT work, because the
underlying hash is empty when it tries to figure out what to do with
index "a".
For example...
my $k = {"a" => 1, "b" => 2};
my $pseudo_hash = [$k];
tie( %{$k}, 'Tie::StdHash') or die "can't tie\n";
my $var = $pseudo_hash->{a};
prints error: Bad index while coercing array into hash at ...
So do this instead...
my $k = {};
tie( %{$k}, 'Tie::StdHash') or die "can't tie\n";
$k->{a} = 1;
$k->{b} = 2;
my $pseudo_hash = [$k];
my $var = $pseudo_hash->{a};
Mark
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 18 Nov 1999 13:16:29 -0800
From: Tim Diller <t.dillerNOt.SPAM@xpres.com.invalid>
Subject: Re: Using variables with pattern matching
Message-Id: <000b8d9b.7e1640ed@usw-ex0102-012.remarq.com>
In article <811kcc$7mv$1@nnrp1.deja.com>, nkaiser@my-deja.com wrote:
> I'm trying to do something like this:
> $from = "(\d+)";
> $to = "test $1";
> $string = "this is a 25 test.";
> $string =~s/$from/$to/;
> I would like this to act just as if I did:
> $string =~s/(\d+)/test $1/;
> How is this possible?
> Sent via Deja.com http://www.deja.com/
> Before you buy.
It doesn't work because of the "" around the value you assign to the
$from variable. If you add
print $from;
after assing your value to $from, it returns (d+)
The \ has been lost due to the magic of backslash interpretation. If
you want it to work, either change the "" to '' or put an additional \
in the value, ie: $from = "(\\d+)";
Tim
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Thu, 18 Nov 1999 22:26:06 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Using variables with pattern matching
Message-Id: <22%Y3.26107$YI2.1171775@typ11.nn.bcandid.com>
In article <811kcc$7mv$1@nnrp1.deja.com>, <nkaiser@my-deja.com> wrote:
>$from = "(\d+)";
>$to = "test $1";
>$string = "this is a 25 test.";
>$string =~s/$from/$to/;
>
>I would like this to act just as if I did:
>
>$string =~s/(\d+)/test $1/;
>
>How is this possible?
Use single quotes first. Then make $to be an expression, and evaluate
it twice.
#!/usr/bin/perl -w
use strict;
my $from='(\d+)';
my $to=' "test $1" ';
$_ = "this is a 25 test.\n";
s/$from/$to/ee;
print;
this is a test 25 test.
Maybe there's a better way? This is a kind of eval STRING.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 18 Nov 1999 20:15:05 GMT
From: dinodesk@hotmail.com
Subject: want to convert blocking read socket into nonblocking
Message-Id: <811mnj$9kr$1@nnrp1.deja.com>
Hi,
I have a small piece of TCP/IP client side code, which connects to
server and start reading.
....
while(defined($line = <SOCK>))
{
if ($line == "")
{
print $line;
}
else
{
print "It does not come in this line"
}
}
....
How do i change read into a nonblocking call? I just want process to
wait for 5secs on read.
The select($line=<SOCK>,undef,undef,5) does not help me, or I am using
it is wrong way.
Thanks
Dinesh Verma
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 18 Nov 1999 20:34:44 GMT
From: dinodesk@hotmail.com
Subject: Re: want to convert blocking read socket into nonblocking
Message-Id: <811nt4$aj7$1@nnrp1.deja.com>
Hi again,
Just want add more, I want to get rid of using fork(), which I am
currently using. One for read and other for write, to same socket.
Thanks
Dinesh Verma.
In article <811mnj$9kr$1@nnrp1.deja.com>,
dinodesk@hotmail.com wrote:
> Hi,
> I have a small piece of TCP/IP client side code, which connects to
> server and start reading.
>
> ....
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 18 Nov 1999 22:28:23 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: want to convert blocking read socket into nonblocking
Message-Id: <b4%Y3.26116$YI2.1172107@typ11.nn.bcandid.com>
In article <811mnj$9kr$1@nnrp1.deja.com>, <dinodesk@hotmail.com> wrote:
>How do i change read into a nonblocking call? I just want process to
>wait for 5secs on read.
>The select($line=<SOCK>,undef,undef,5) does not help me, or I am using
>it is wrong way.
You are using it the wrong way. perldoc -f select and perldoc perlipc.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 18 Nov 1999 11:36:31 GMT
From: mark_r_jones@my-deja.com
Subject: Re: Writing data to file on another server.
Message-Id: <810obv$hts$1@nnrp1.deja.com>
I'm trying to find out how to use CGI to create a file on the server.
The text for the file will be supplied from an applet running on the
user's PC and he will have accessed it from the web site to which the
file must be written. Do you have a code sample I could see?
In article <U1nX3.8176$YI2.325914@typ11.nn.bcandid.com>,
kragen@dnaco.net (Kragen Sitaker) wrote:
> In article <01bf2d94$31d33c00$c534d8c0@default>,
> Crawfishy <cans1@hotmail.com> wrote:
> >OK, I just spent the last 3 hours researching this and I think I
have a
> >handle on it.... But just so I don't beat my head against the wall
for a
> >week, let me just be sure...
> >If I understand correctly, instead of using OPEN and PRINT to write
data to
> >a file as I am doing now, Instead I would create a routine that
utilized
> >the http::request using the PUT method. Correct?
>
> Well, maybe. If your web server supports PUT. You might be better
off
> using a CGI script on the destination server to modify data.db -- you
> can invoke said CGI script with a POST request from your original
> machine.
>
> >If this is correct, then will I need to have anything special on the
> >receiving site to accept this PUT data.
>
> At least set up authentication; probably you'll have to do something
to
> support PUT as well. (mod_webdav for Apache?)
>
> > Bear in mind that the receiving
> >site is just going to be running a simple web server program over a
static
> >IP on Win98 not something "web advanced" like Linux.
>
> Apache runs on both -- it's just less stable and mature on Winxx
platforms.
> --
> <kragen@pobox.com> Kragen Sitaker
<http://www.pobox.com/~kragen/>
> The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
> <URL:http://www.pobox.com/~kragen/bubble.html>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 18 Nov 1999 12:46:39 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Writing data to file on another server.
Message-Id: <3833f52f_1@newsread3.dircon.co.uk>
mark_r_jones@my-deja.com wrote:
> I'm trying to find out how to use CGI to create a file on the server.
> The text for the file will be supplied from an applet running on the
> user's PC and he will have accessed it from the web site to which the
> file must be written. Do you have a code sample I could see?
>
OK this is a quicky ...
#!/usr/bin/perl -w
use strict;
use Fcntl qw(:flock);
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
my $file = 'out.txt';
open(OUTFILE,">>out.txt") || die "Can't open $file - $!\n";
flock(OUTFILE,LOCK_EX) || die "Can't flock $file - $!\n";
foreach (param)
{
print OUTFILE "$_=",param($_),"\n";
}
print OUTFILE "&&\n";
close OUTFILE;
print header,
start_html("Form submission"),
h1('thanks'),
end_html;
However you *will* now go and read the man pages for the CGI module and
the perlfunc entries for open,flock,print ...
>
>
> In article <U1nX3.8176$YI2.325914@typ11.nn.bcandid.com>,
> kragen@dnaco.net (Kragen Sitaker) wrote:
>> In article <01bf2d94$31d33c00$c534d8c0@default>,
>> Crawfishy <cans1@hotmail.com> wrote:
>> >OK, I just spent the last 3 hours researching this and I think I
> have a
>> >handle on it.... But just so I don't beat my head against the wall
> for a
>> >week, let me just be sure...
>> >If I understand correctly, instead of using OPEN and PRINT to write
> data to
>> >a file as I am doing now, Instead I would create a routine that
> utilized
>> >the http::request using the PUT method. Correct?
>>
>> Well, maybe. If your web server supports PUT. You might be better
> off
>> using a CGI script on the destination server to modify data.db -- you
>> can invoke said CGI script with a POST request from your original
>> machine.
>>
>> >If this is correct, then will I need to have anything special on the
>> >receiving site to accept this PUT data.
>>
>> At least set up authentication; probably you'll have to do something
> to
>> support PUT as well. (mod_webdav for Apache?)
>>
>> > Bear in mind that the receiving
>> >site is just going to be running a simple web server program over a
> static
>> >IP on Win98 not something "web advanced" like Linux.
>>
>> Apache runs on both -- it's just less stable and mature on Winxx
> platforms.
>> --
>> <kragen@pobox.com> Kragen Sitaker
> <http://www.pobox.com/~kragen/>
>> The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
>> <URL:http://www.pobox.com/~kragen/bubble.html>
>>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--
"What is the future for beef? Curtains?" - Graham Norton
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 1424
**************************************