mirror of
https://github.com/fadden/nulib2.git
synced 2025-08-15 11:27:23 +00:00
Use umask in chmod call when fixing permissions on "locked" files we're
extracting. (Still need to verify this works right under Win32.)
This commit is contained in:
@@ -591,10 +591,16 @@ Nu_SetFileAccess(NuArchive* pArchive, const NuRecord* pRecord,
|
|||||||
#if defined(UNIX_LIKE) || defined(WINDOWS_LIKE)
|
#if defined(UNIX_LIKE) || defined(WINDOWS_LIKE)
|
||||||
/* only need to do something if the file was "locked" */
|
/* only need to do something if the file was "locked" */
|
||||||
if (Nu_IsRecordLocked(pRecord)) {
|
if (Nu_IsRecordLocked(pRecord)) {
|
||||||
/* set it to 444 */
|
mode_t mask;
|
||||||
if (chmod(pathname, S_IRUSR | S_IRGRP | S_IROTH) < 0) {
|
|
||||||
|
/* set it to 444, modified by umask */
|
||||||
|
mask = umask(0);
|
||||||
|
umask(mask);
|
||||||
|
//DBUG(("+++ chmod '%s' %03o (mask=%03o)\n", pathname,
|
||||||
|
// (S_IRUSR | S_IRGRP | S_IROTH) & ~mask, mask));
|
||||||
|
if (chmod(pathname, (S_IRUSR | S_IRGRP | S_IROTH) & ~mask) < 0) {
|
||||||
Nu_ReportError(NU_BLOB, errno,
|
Nu_ReportError(NU_BLOB, errno,
|
||||||
"unable to set access for '%s'", pathname);
|
"unable to set access for '%s' to %03o", pathname, mask);
|
||||||
err = kNuErrFileSetAccess;
|
err = kNuErrFileSetAccess;
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user