apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Pilch-Bisson <ke...@pilch-bisson.net>
Subject Re: umasks, apr_file_perms_set and APR_OS_DEFAULT
Date Thu, 22 Nov 2001 20:49:53 GMT
On Thu, Nov 22, 2001 at 02:48:15PM -0500, Kevin Pilch-Bisson wrote:
> Hi All,
> 
> I'm a developer on the subversion project, and one of the things I'm
> trying to do is make the files in the .svn administrative directory
> read-only.
> 
> In order to do that I have to play around with permissions on a bunch of
> files.  The problem I have run into is that if APR_OS_DEFAULT is is
> passed to apr_file_open, the resulting permissions are the result of the
> umask and APR_OS_DEFAULT.  However, if apr_file_perms_set is used, the
> umask doesn't get applied, and all my files end up being rwxrwxrwx.
> 
> Any ideas on a way to retrieve the umask, so that I can reliably use
> apr_file_perms_set to set file permissions to the users default
> preference?

For the sake of clarity, what I am doing now is this:

apr_fileperms_t uperms = apr_unix_mode2perms (umask (0777));
apr_fileperms_t perms = (APR_UREAD | APR_UWRITE | APR_GREAD
                        | APR_GWRITE | APR_WREAD | APR_WWRITE)
                        & ~uperms;
status = apr_file_perms_set (full_dest_path->data, perms);
umask ( apr_unix_perms2mode(uperms));


I would like to be able to do that in a portable way, since neither
umask nor apr_unix_perms2mode are portable.

Something like:

apr_fileperms_t perms = apr_umask(APR_OS_DEFAULT)
status = apr_file_perms_set(full_dest_path->data, APR_OS_DEFAULT & ~perms);
apr_umask(perms);

Doing this would require implementing apr_umask, and changing APR_OS_DEFAULT
from 0xFFF to 0x777.

What do people think?  I can write the patch for unix if people think
this approach is alright.  If not I would love to hear suggestions.
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Pilch-Bisson                    http://www.pilch-bisson.net
     "Historically speaking, the presences of wheels in Unix
     has never precluded their reinvention." - Larry Wall
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Mime
View raw message