[K12OSN] Hopefully the last permission question
Petre Scheie
petre at maltzen.net
Thu Apr 29 18:40:48 UTC 2004
Yes, put this in a file, put the file in, say, /usr/local/bin, and then call it
via root's crontab. BTW, after looking at the script I suggested, it occurs to
me that this would be better:
#!/bin/bash
for file in /home/Drop/*
do
owner=$(ls -ld $file|awk '{print $3}')
chown -R $owner $file
done
The problem with my first draft is if there is a directory in which the owner is
not the same name as the directory itself. For example:
drwx------ 4 jwilliams user2 4096 Aug 21 2003 /home/user2/
Here jwilliams is the owner but the directory is named user2; my first draft
would fail on this one. This may not be an issue for you, but the revised
version is more precise, so use that one. I also changed the variable name from
x to file to make it easier to read.
Petre
Jim Kronebusch wrote:
> I'll give it a try this afternoon. Is this a script to run as a cron?
>
> -----Original Message-----
> From: k12osn-bounces at redhat.com [mailto:k12osn-bounces at redhat.com] On
> Behalf Of Petre Scheie
> Sent: Thursday, April 29, 2004 1:23 PM
> To: Support list for opensource software in schools.
> Subject: Re: [K12OSN] Hopefully the last permission question
>
>
> Off the top of my head...
>
> #!/bin/bash
> for x in /home/Drop/*
> do
> owner=${x##*/}
> chown -R $owner $x
> done
>
> Petre
>
> Jim Kronebusch wrote:
>
>>Okay, if I set a cron to run:
>>chown -R teacher1 /home/Drop/Teacher1
>>This does what I want. Only problem now is creating a cron for every
>>teachers drop folder. How would I write a cron that will run on
>>/home/Drop and look at the owner of folder TeacherX and automatically
>>recursively set any files under that folder with the owner of the
>>enclosing folder? Does that make sense? That way if Teacher1 is
>
> owned
>
>>by user Teacher1 the cron will figure that out and substitute this in,
>
>
>>or if Teacher2 is owned by Teacher2, you get the point. Can one enter
>
> a
>
>>variable for owner? Or do I just have to buck-up and write one for
>>every teacher drop created?
>>
>> -----Original Message-----
>> *From:* k12osn-bounces at redhat.com
>
> [mailto:k12osn-bounces at redhat.com]
>
>> *On Behalf Of *Huck
>> *Sent:* Thursday, April 29, 2004 12:11 PM
>> *To:* 'Support list for opensource software in schools.'
>> *Subject:* RE: [K12OSN] Hopefully the last permission question
>>
>> think you'd be looking at a cron solution there?
>> something run'n every hour to automagically chown and chgrp?
>>
>> --Huck
>>
>>
>> -----Original Message-----
>> *From:* k12osn-bounces at redhat.com
>> [mailto:k12osn-bounces at redhat.com] *On Behalf Of *Jim
>
> Kronebusch
>
>> *Sent:* Thursday, April 29, 2004 9:26 AM
>> *To:* k12osn at redhat.com
>> *Subject:* [K12OSN] Hopefully the last permission question
>>
>> Last problem I seem to be having is that when a student drops
>> homework into /home/drop/teacher1/class1 folder which is owned
>> by teacher1 and group teacher1 with Set Uid and Gid checked,
>
> the
>
>> file the student drops is still owned by the student. I would
>> like the user and group set to teacher1. The reason being
>
> that
>
>> if the student still owns the file the teacher cannot delete
>
> it,
>
>> and it messes with the students user quota. Once in the drop
>> folder it is the teachers responsibility to remove the file
>
> and
>
>> no longer the students, so I believe these files should affect
>> teacher quotas not the student. So how do I set any file
>> dropped in this folder to reset the owner and group to that of
>> the enclosing folder? I would like to not have a script
>
> option,
>
>> but something via chmod or whatever is immediate.
>>
>> Thanks
>>
>>
>>----------------------------------------------------------------------
>>--
>>
>>_______________________________________________
>>K12OSN mailing list
>>K12OSN at redhat.com https://www.redhat.com/mailman/listinfo/k12osn
>>For more info see <http://www.k12os.org>
>
>
>
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
>
>
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
>
More information about the K12OSN
mailing list