develooper Front page | perl.perl5.porters | Postings from August 2001

[ID 20010821.003] bug in getpwnam

August 21, 2001 08:50
[ID 20010821.003] bug in getpwnam
Message ID:
This is a bug report for perl from,
generated with the help of perlbug 1.28 running under perl v5.6.0.


I want to change the owner of a file by using the following command:
  chown (getpwnam ($username))[2], (getgrnam ($groupname))[2],  $destfile;
and I get an syntax error near )[. After I replace the getpwnam call by a sub
which uses the same expression, it works fine. The function getgrnam works in
the same context without problems.  Two smilar functions
one runs the other not - is this ok so?


This example can show your my problem:

#!/usr/bin/perl -w
# you should create this file first
my $destfile="/tmp/test";
my $username="nobody";
my $groupname="nogroup";

sub user_to_uid {  return (getpwnam($_[0]))[2]; }  

# the follow line runs
chown user_to_uid($username), (getgrnam ($groupname))[2],  $destfile;
# the follow line don't run
#chown (getpwnam ($username))[2], (getgrnam ($groupname))[2],  $destfile;

[Please do not change anything below this line]
Site configuration information for perl v5.6.0:

Configured by root at Fri Jan 19 05:40:28 GMT 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
    osname=linux, osvers=2.4.0, archname=i586-linux
    uname='linux manson 2.4.0 #1 wed aug 2 20:22:26 gmt 2000 i686 unknown '
    config_args='-ds -e -Dprefix=/usr -Di_db -Di_dbm -Di_ndbm -Di_gdbm'
    hint=recommended, 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
    cc='cc', optimize='-O2 -pipe', gccversion=2.95.2 19991024 (release)
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lc -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:

@INC for perl v5.6.0:

Environment for perl v5.6.0:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/bin/bash Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About