Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Changin file premissions -perl/cgi

Options
  • 16-02-2005 12:54am
    #1
    Registered Users Posts: 2,934 ✭✭✭


    HI
    Im using the following line to change a files permissions from
    644 to 646

    No success - any suggestions

    chmod 0646, $open_file or
    die "couldn't chmod $fopen_file to 0646";

    I can't seem to change to anything


Comments

  • Registered Users Posts: 7,739 ✭✭✭mneylon


    Does it work if you try it via FTP or SSH?


  • Registered Users Posts: 2,934 ✭✭✭egan007


    Yeah - i'm ftp'd to the site (cute) and i can change it to any permissions


  • Registered Users Posts: 7,739 ✭✭✭mneylon


    Are you even getting any error messages on screen or in logs?


  • Registered Users Posts: 6,511 ✭✭✭daymobrew


    Add '$!' to the end of the die message to get the system error message.

    chmod 0646, $open_file or
    die "couldn't chmod $fopen_file to 0646: $!";

    Is $open_file the path to the file or a file handle (returned by open function?, it should be the file path).


  • Registered Users Posts: 2,934 ✭✭✭egan007


    - no errors thrown up
    - $open_file is the file path
    I have found a way around it anyway so cheers for the help.


  • Advertisement
  • Closed Accounts Posts: 304 ✭✭Zaltais


    I know you say you found a way around it but the problem probably is this:

    The user that is trying to change the permissions on the file doesn't have the required permission level itself.

    Most apache servers are set up to run as the user 'nobody' or as a user set up just to run the webserver itself (e.g. 'httpd' on RedHat/Fedora or 'www-data' on Debian) if the file is created as '0644' by the root user (for example) then the apache user (which cgi scripts are run as) doesn't have write access to the file, and so can't change it's permissions.

    There's a couple of ways around this, but most of them are potentially insecure, so your 'way around it' may actually be the best course of action anyway.


  • Closed Accounts Posts: 2,525 ✭✭✭JustHalf


    Do you need to change the permissions via this script? Is it possible to change them just using your FTP client?

    I'm pretty sure you can get Perl to report the user it is running the script as... this should help in your debugging. This is a *nix machine, right?

    BTW, a chmod 646 will make your files world-writable. Is this acceptable to you? If it's on a public server, this usually isn't a very good idea.


Advertisement