WeBWorK Main Forum

permissions on course directories

permissions on course directories

by Hal Sadofsky -
Number of replies: 3
For reasons having to do with making it easy to administer class lists, I'd like to configure webwork so that when a new course is created (from the web interface) the templates directory has group write permission.

Anyone know how to do this?

thanks, Hal
In reply to Hal Sadofsky

Re: permissions on course directories

by Gavin LaRose -
Hi Hal,

I think this will require small modification to the CourseManagement.pm module to implement as you've described it (that is, to have just the templates directory created with write permission given to the group).

I believe that making something like the following changes at about line 220 of CourseManagement.pm (in WeBWorK_Root/lib/WeBWorK/Utils/) will do what you want:

The existing code should look something like
                # try to create it
                mkdir $courseDir or warn "Failed to create $courseDirName directory '$courseDir': $!. You will have to create this directory manually.\n";
        }
We want to change this so that when it's creating the templates directory it uses a different umask and possibly permissions:
                # try to create it
                if ( $courseDir =~ /templates/ ) {
                       my $umaskVal = umask;
                       umask 0002;
                       mkdir( $courseDir, 0770 ) or warn "Failed to create $courseDirName directory '$courseDir': $!. You will have to create this directory manually.\n";
                       umask($umaskVal)
                } else {
                       mkdir $courseDir or warn "Failed to create $courseDirName directory '$courseDir': $!. You will have to create this directory manually.\n";
                }
        }

I think that will result in the templates directory being created with a umask 0002 (deny write permission to other) and the rest of the class directories being created with the usual umask for the user the webserver runs as.

To state the perhaps obvious, I haven't tested this.

Cheers,
Gavin

In reply to Gavin LaRose

Re: permissions on course directories

by Hal Sadofsky -
Thanks Gavin,

That worked with an appropriate adjustment to get the permissions I wanted on the templates directory.

I guess I need to make a note to myself to remember this when we do our next CVS update.

-Hal
In reply to Hal Sadofsky

Re: permissions on course directories

by Gavin LaRose -
Hi Hal,

Excellent. I think CVS should preserve your changes when you update, though it's certainly worth checking to make sure that it doesn't end up derailing when doing the update. If you save the output of the update command and then look for conflicts ("C") that is probably sufficient to determine whether there were problems in merging your changes with the new version.

Gavin