Decompressing archive and setting files' owner

Posted on 2006-05-03
Last Modified: 2011-09-20
I'm creating an install program which needs to decompress an archive and make sure all files extracted are set to the hosting account owner which is proving harder than I thought! It's my own server and only running code which I control and so I'm using apache/mod_php rather than php as CGI/FastCGI etc although I'm considering the those options given the hassle of this.

At the moment I'm using PclZip to decompress a zip file and therefore the files extracted are owned by "apache" group/user. I then tried to use chown() and chgrp() to change the file/folder ownership/group but I get the error message "Operation not permitted" for both functions.

Surely there must be an easier way to do this? Thanks in advance for any help!
Question by:wjdashwood
    LVL 49

    Accepted Solution

    You might possibly be able to sudo a chmod / chown using exec() or system() function. This depends on your server security settings though.


    Author Comment

    Tried that and afraid that doesn't work but I think there may have been an error in the code I used original using PHP's own chown() and chgrp() functions so I'll go back and try that if there isn't an alternative.


    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now