Skip Menu |
Report information
Id: 3242
Status: resolved
Priority: 0/
Queue: perl5

Owner: stmpeters <steve [at] fisharerojo.org>
Requestors: mjtg [at] cus.cam.ac.uk
Cc:
AdminCc:

Operating System: Solaris
PatchStatus: (no value)
Severity: low
Type: notabug
Perl Version: (no value)
Fixed In: (no value)



To: perlbug [...] perl.org
Subject: No error on assignment to $>
From: "M.J.T. Guy" <mjtg [...] cus.cam.ac.uk>
Date: Fri, 12 May 2000 19:19:34 +0100
Download (untitled) / with headers
text/plain 1.9k
Shouldn't this (run in an unprivileged environment) cause some sort of error or at least a warning, rather than the assignment being silently ignored? perl5.6.0 -wle '$> = 0; print $>' 1189 Mike Guy % perl -V Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration: Platform: osname=solaris, osvers=2.6, archname=sun4-solaris uname='' config_args='-dOes -f confug.sh' hint=previous, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef Compiler: cc='gcc', optimize='-O', gccversion=2.7.2.3 cppflags='-I/usr/local/include -I/opt/local/include -DREG_INFTY=22786' ccflags ='-I/usr/local/include -I/opt/local/include -DREG_INFTY=22786' stdchar='unsigned char', d_stdstdio=define, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4 alignbytes=8, usemymalloc=y, prototype=define Linker and Libraries: ld='gcc', ldflags =' -L/usr/local/lib -L/opt/local/lib' libpth=/usr/local/lib /opt/local/lib /lib /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lc -lcrypt libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-fpic', lddlflags='-G -L/usr/local/lib -L/opt/local/lib' Characteristics of this binary (from libperl): Compile-time options: USE_LARGE_FILES Locally applied patches: diag.format perldoc.vers installman.opt undef.opcode Built under solaris Compiled at Apr 4 2000 17:17:26 @INC: /home/mjtg/perl5.6.0/lib /home/mjtg/perl5.6.0/lib /home/mjtg/perl5.6.0/lib /home/mjtg/perl5.6.0/lib .
To: "M.J.T. Guy" <mjtg [...] cus.cam.ac.uk>
Cc: perl5-porters [...] perl.org
Subject: Re: [ID 20000512.007] No error on assignment to $>
Date: Fri, 12 May 2000 12:23:06 -0600
From: Tom Christiansen <tchrist [...] chthon.perl.com>
Download (untitled) / with headers
text/plain 269b
Show quoted text
>Shouldn't this (run in an unprivileged environment) cause some sort >of error or at least a warning, rather than the assignment being >silently ignored?
Show quoted text
> perl5.6.0 -wle '$> = 0; print $>' > 1189
Perl doesn't give warnings on syscall failures. --tom
To: perl5-porters [...] perl.org
Subject: Re: [ID 20000512.007] No error on assignment to $>
From: "M.J.T. Guy" <mjtg [...] cus.cam.ac.uk>
Date: Fri, 12 May 2000 19:40:16 +0100
Download (untitled) / with headers
text/plain 387b
Tom Christiansen <tchrist@chthon.perl.com> wrote Show quoted text
> Perl doesn't give warnings on syscall failures.
Ah! Of course it doesn't. Silly me. But perhaps the documentation of $> (and all the rest that hide system calls) should the mention the need to check $! afterwards. And therefore the need to set $! to 0 first, since there's no other way of detecting success/failure. Mike Guy
Subject: [PATCH]No error on assignment to $>
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 570b
Show quoted text
> [RT_System - Fri May 12 04:40:31 2000]: > > Tom Christiansen <tchrist@chthon.perl.com> wrote
> > Perl doesn't give warnings on syscall failures.
> > Ah! Of course it doesn't. Silly me. > > But perhaps the documentation of $> (and all the rest that hide system > calls) should the mention the need to check $! afterwards. And > therefore the need to set $! to 0 first, since there's no other way of > detecting success/failure. > > > Mike Guy >
Attached is a patch to perlvar.pod to document the variables I found that implement a system call underneath.
Subject: perlvar.pod.patch
Download perlvar.pod.patch
text/plain 1.7k
--- perlvar.pod.orig Sat Nov 20 22:18:40 2004 +++ perlvar.pod Sat Nov 20 22:34:55 2004 @@ -765,7 +765,9 @@ The real uid of this process. (Mnemonic: it's the uid you came I<from>, if you're running setuid.) You can change both the real uid and -the effective uid at the same time by using POSIX::setuid(). +the effective uid at the same time by using POSIX::setuid(). Since +changes to $< require a system call, check $! after a change attempt to +detect any possible errors. =item $EFFECTIVE_USER_ID @@ -779,7 +781,8 @@ ($<,$>) = ($>,$<); # swap real and effective uid You can change both the effective uid and the real uid at the same -time by using POSIX::setuid(). +time by using POSIX::setuid(). Changes to $> require a check to $! +to detect any possible errors after an attempted change. (Mnemonic: it's the uid you went I<to>, if you're running setuid.) C<< $< >> and C<< $> >> can be swapped only on machines @@ -802,7 +805,8 @@ back to C<$(> without being forced numeric, such as by adding zero. You can change both the real gid and the effective gid at the same -time by using POSIX::setgid(). +time by using POSIX::setgid(). Changes to $( require a check to $! +to detect any possible errors after an attempted change. (Mnemonic: parentheses are used to I<group> things. The real gid is the group you I<left>, if you're running setgid.) @@ -828,6 +832,8 @@ You can change both the effective gid and the real gid at the same time by using POSIX::setgid() (use only a single numeric argument). +Changes to $) require a check to $! to detect any possible errors +after an attempted change. (Mnemonic: parentheses are used to I<group> things. The effective gid is the group that's I<right> for you, if you're running setgid.)
Subject: Re: [perl #3242] [PATCH]No error on assignment to $>
Date: Sun, 21 Nov 2004 01:13:45 -0500
To: "OtherRecipients of perl Ticket #3242": ;, perl5-porters [...] perl.org
From: Rick Delaney <rick [...] bort.ca>
Download (untitled) / with headers
text/plain 851b
On Sun, Nov 21, 2004 at 04:38:09AM -0000, Steve Peters via RT wrote: Show quoted text
> > [RT_System - Fri May 12 04:40:31 2000]: > > > > Tom Christiansen <tchrist@chthon.perl.com> wrote
> > > Perl doesn't give warnings on syscall failures.
> > > > Ah! Of course it doesn't. Silly me. > > > > But perhaps the documentation of $> (and all the rest that hide system > > calls) should the mention the need to check $! afterwards. And > > therefore the need to set $! to 0 first, since there's no other way of > > detecting success/failure. > > > > > > Mike Guy > >
> > Attached is a patch to perlvar.pod to document the variables I found > that implement a system call underneath.
You neglected to mention the need to initialize $! to 0 before the store. Though I personally don't see any reason not to warn in these cases. -- Rick Delaney rick@bort.ca
Subject: Re: [perl #3242] [PATCH]No error on assignment to $>
Date: Wed, 24 Nov 2004 16:14:41 +0100
To: perl5-porters [...] perl.org
From: Rafael Garcia-Suarez <rgarciasuarez [...] mandrakesoft.com>
Download (untitled) / with headers
text/plain 536b
Steve Peters via RT wrote: Show quoted text
> > But perhaps the documentation of $> (and all the rest that hide system > > calls) should the mention the need to check $! afterwards. And > > therefore the need to set $! to 0 first, since there's no other way of > > detecting success/failure.
> > Attached is a patch to perlvar.pod to document the variables I found > that implement a system call underneath.
Thanks, applied as change #23532 to bleadperl. -- Phil Blake's weekly Pat and Bull story. Uncle Toby's page for tiny tots. -- Ulysses


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org