Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am a non-root user, and have made a directory into which other users in my group can write. The directory is setgid, so files and directories within it have the same group.

I can delete files placed into this directory, but if a user creates a subdirectory with files in it, I can't seem to delete those. Is there something special I can do (other than, say, bothering the user in question or the sysadmin about it) to get rid of this subdirectory?

EDIT: Inevitably, of course, someone asks "why?"

The shared folder in question is a mercurial repository. We can't use a shared-account ssh-key-based server for this like mercurial-server, and we can't just host it externally for various reasons. But that part works fine. We use Redmine for project management, but it does not yet read the repo index for file contents - it reads the working directory. So the working directory must be kept up-to-date. crontab has been disabled by the sysadmin, so that's out. So I naïvely put a changeset hook in the shared repo that performed an "hg update". This seemed to work fine initially, until, of course, someone pushed a commit with a new directory. While I had vague thoughts of trying to make a setuid script for the hook, I'll probably just consider safer avenues.

share|improve this question
    
What command are you using to remove the subdirectory? –  Michael Todd Apr 12 '10 at 20:45
    
rm -rf subdir. I also poked around in rmdir and unlink to no avail. –  kwatford Apr 12 '10 at 20:55
    
Basically, the problem is that you can't remove the directory because it is not empty, and you can't remove the files in the directory because you don't have write permission. Basically you can't do anything about it. What I am curious about is if there is a flag that allows other users to create files but not directories in a certain directory. –  petersohn Apr 12 '10 at 21:02

1 Answer 1

up vote 3 down vote accepted

In order to delete a file in a directory, you need to have write permission to that directory. Obviously the users are creating directories without you having write permission, in which case the answer to your question is no, you can't do anything without talking to the user in question or the sysadmin.

However, if I was the sysadmin, I would be worried about what you're doing. It is not normal for users to be creating files in other users directories. Is there a better way of doing what you're doing? For example, uploading to a suitable web application would give better control, and also mean that you don't have to worry about this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.