Loading ...
Sorry, an error occurred while loading the content.

Doing a chmod on a nfs file using a cgi script

Expand Messages
  • greg.hering@bench.com
    I get permission denied when trying to chmod a nfs mounted file or directory. I know I m running as nobody and that s the problem but what can I do? I m in a
    Message 1 of 3 , May 4, 2004
    • 0 Attachment
      I get permission denied when trying to chmod a nfs mounted file or
      directory.

      I know I'm running as 'nobody' and that's the problem but what can I do?
      I'm in a closed network and I could run the web server as root but I'd
      rather change my code than the machine. The chmod is hard coded in the
      Perl script and there are no execs of unknown code so it's pretty safe
      anyway. The script is owned by root so someone would have to gain root
      access to modify it.

      I want to capture stderr and print it on the web page I'm generating so
      I can see who's setup wrong.

      I tried changing this script to 4755 and the owner is root but that
      didn't help.



      Ideas?



      Thanks.



      sub do_chmod {

      my $host = shift;

      my $mode = shift;

      my $dirpath = shift;



      my $command = "";

      my $pid = 0;



      printf( "host=%s,       mode=%s,  
          path=%s\n", $host, $mode, $dirpath );

      # system( 'rsh', $host, 'chmod', $mode, $dirpath) or die "can't
      system chmod: $!";

      $command = sprintf("rsh %s chmod %s %s", $host, $mode,
      $dirpath);

      print "<br>      command is ", $command,
      "\n";

      $pid = qx/$command/;

      print "<td> ";

      print "after system", "result is '", $pid, "'";

      print "</td>\n";

      }



      sub check_logs_directory_exists {

      my $host = shift;

      my $logdir = "/net/$host/export/home/logs";

      my $returnval = 0;



      if ( -d $logdir ) {

      $returnval = 1;

      do_chmod($host, 777, $logdir);

      }

      return( $returnval );

      }



      sub check_directories {

      my $host = shift;

      my $logs_status = 0;



      $logs_status = check_logs_directory_exists( $host );



      print_directory( $host, $logs_status );

      }





      check_directories( $host );







      [Non-text portions of this message have been removed]
    • perlmedian
      Can t help you on the permission problem but if you are using a CGI script you should have a use CGI::Carp fatalsToBrowser ; to get your STDERR to come out
      Message 2 of 3 , May 4, 2004
      • 0 Attachment
        Can't help you on the permission problem but if you are using a CGI
        script you should have a "use CGI::Carp 'fatalsToBrowser';" to get
        your STDERR to come out to the browser. (You can capture STDERR
        otherways also if you want to parse first then print). TWIMTOWTDI.

        For the permission problem, only the owner of the file can chmod it
        (or root). So either the file owner has to change or user running the
        script has to change. Just curious what/why are you trying to change
        permissions? Perhaps there is another way around the problem.

        Sorry couldn't help more,
        Perl Median (Nik)

        Perhaps someone else has more input.


        --- In perl-beginner@yahoogroups.com, <greg.hering@b...> wrote:
        > I get permission denied when trying to chmod a nfs mounted file or
        > directory.
        >
        > I know I'm running as 'nobody' and that's the problem but what can I do?
        > I'm in a closed network and I could run the web server as root but I'd
        > rather change my code than the machine. The chmod is hard coded in the
        > Perl script and there are no execs of unknown code so it's pretty safe
        > anyway. The script is owned by root so someone would have to gain root
        > access to modify it.
        >
        > I want to capture stderr and print it on the web page I'm generating so
        > I can see who's setup wrong.
        >
        > I tried changing this script to 4755 and the owner is root but that
        > didn't help.
        >
        >
        >
        > Ideas?
        >
        >
        >
        > Thanks.
        >
        [SNIP]
      • Emanuel G Calso
        ... If the server configured your nfs mount to be seen only as nobody it s basically impossible to get around it. Try telnet/ssh - ing your nfs server (the
        Message 3 of 3 , May 5, 2004
        • 0 Attachment
          On Wednesday 2004 May 05 01:55, greg.hering@... wrote:
          > I get permission denied when trying to chmod a nfs mounted file or
          > directory.
          >
          > I know I'm running as 'nobody' and that's the problem but what can I do?
          > I'm in a closed network and I could run the web server as root but I'd
          > rather change my code than the machine. The chmod is hard coded in the
          > Perl script and there are no execs of unknown code so it's pretty safe
          > anyway. The script is owned by root so someone would have to gain root
          > access to modify it.
          >
          > I want to capture stderr and print it on the web page I'm generating so
          > I can see who's setup wrong.
          >
          > I tried changing this script to 4755 and the owner is root but that
          > didn't help.

          If the server configured your nfs mount to be seen only as "nobody" it's
          basically impossible to get around it.
          Try telnet/ssh - ing your nfs server (the one who's serving files) and look
          at /etc/exports
          and check if there's "anonuid", if that's the case. I doubt anyone can help
          you... unless you can edit that file.

          --
          eman calso
          http://www.bloodpet.tk/
          New members are urgently needed in the Society for Prevention of
          Cruelty to Yourself. Apply within.
        Your message has been successfully submitted and would be delivered to recipients shortly.