title: perl script fails to change group for file uploaded with apache on linux
body: <p>I'm using a perl cgi script to upload a file on Linux using Apache. The file has owner:group set to apache:apache as expected. I want user1 to have access to the file, but not other. The apache user is a member of the default group for user1, as can be seen as follows:</p>
  
  <pre><code>[user1@files ~]$ grep user1 /etc/group
  user1:x:513:apache
  </code></pre>
  
  <p>The perl script running as apache ends with the following lines:</p>
  
  <pre><code>system("ls -l $file")
  my $uid = getpwnam( 'apache' );
  my $gid = getgrnam( 'user1' );
  print "&lt;br /&gt;attempting: chown $uid, $gid, $file&lt;br /&gt;";
  chown $uid, $gid, $file or die "$!";
  </code></pre>
  
  <p>The output below shows the attempt to change the group failed:</p>
  
  <pre><code>-rw-r----- 1 apache apache 197927 Jul 19 02:10 /var/www/uploads/testfile.txt
  attempting: chown 48, 513, /var/www/uploads/testfile.txt
  Software error:
  Operation not permitted at /var/www/cgi-bin/upload.pl line 67.
  </code></pre>
  
  <p>Any idea why the apache user cannot change the group for the file? </p>