BUG: Using the source-file permissions by default for installation is somewhat unpredictable because users can extract source code with almost any permissions (umask). Changing the default to use 644 for files and 755 for programs. No release has documented the old behavior so we do not need compatibility.

This commit is contained in:
Brad King 2006-04-18 10:30:56 -04:00
parent 016e689f57
commit 84f672155c
2 changed files with 10 additions and 21 deletions

View File

@ -649,7 +649,6 @@ bool cmFileCommand::HandleInstallCommand(
// If permissions were not specified set default permissions for // If permissions were not specified set default permissions for
// this target type. // this target type.
bool use_source_permissions = false;
if(!use_given_permissions) if(!use_given_permissions)
{ {
switch(itype) switch(itype)
@ -658,7 +657,6 @@ bool cmFileCommand::HandleInstallCommand(
case cmTarget::MODULE_LIBRARY: case cmTarget::MODULE_LIBRARY:
#if defined(__linux__) #if defined(__linux__)
// Use read/write permissions. // Use read/write permissions.
use_given_permissions = true;
permissions = 0; permissions = 0;
permissions |= mode_owner_read; permissions |= mode_owner_read;
permissions |= mode_owner_write; permissions |= mode_owner_write;
@ -669,7 +667,6 @@ bool cmFileCommand::HandleInstallCommand(
case cmTarget::EXECUTABLE: case cmTarget::EXECUTABLE:
case cmTarget::INSTALL_PROGRAMS: case cmTarget::INSTALL_PROGRAMS:
// Use read/write/executable permissions. // Use read/write/executable permissions.
use_given_permissions = true;
permissions = 0; permissions = 0;
permissions |= mode_owner_read; permissions |= mode_owner_read;
permissions |= mode_owner_write; permissions |= mode_owner_write;
@ -680,8 +677,12 @@ bool cmFileCommand::HandleInstallCommand(
permissions |= mode_world_execute; permissions |= mode_world_execute;
break; break;
default: default:
// Use the permissions of the file being copied. // Use read/write permissions.
use_source_permissions = true; permissions = 0;
permissions |= mode_owner_read;
permissions |= mode_owner_write;
permissions |= mode_group_read;
permissions |= mode_world_read;
break; break;
} }
} }
@ -840,20 +841,6 @@ bool cmFileCommand::HandleInstallCommand(
message += toFile.c_str(); message += toFile.c_str();
this->Makefile->DisplayStatus(message.c_str(), -1); this->Makefile->DisplayStatus(message.c_str(), -1);
// If no permissions were already given use the permissions of
// the file being copied.
if(!use_given_permissions &&
(!use_source_permissions ||
!cmSystemTools::GetPermissions(fromFile.c_str(), permissions)))
{
// Set default permissions.
permissions = 0;
permissions |= mode_owner_read;
permissions |= mode_owner_write;
permissions |= mode_group_read;
permissions |= mode_world_read;
}
// Copy the file, but only if it has changed. // Copy the file, but only if it has changed.
if(!cmSystemTools::CopyFileIfDifferent(fromFile.c_str(), if(!cmSystemTools::CopyFileIfDifferent(fromFile.c_str(),
toFile.c_str())) toFile.c_str()))

View File

@ -143,7 +143,8 @@ public:
"The FILES form specifies rules for installing files for a " "The FILES form specifies rules for installing files for a "
"project. File names given as relative paths are interpreted with " "project. File names given as relative paths are interpreted with "
"respect to the current source directory. Files installed by this " "respect to the current source directory. Files installed by this "
"form are given the same permissions as the original file by default." "form are by default given permissions OWNER_WRITE, OWNER_READ, "
"GROUP_READ, and WORLD_READ if no PERMISSIONS argument is given."
"\n" "\n"
"The PROGRAMS signature:\n" "The PROGRAMS signature:\n"
" INSTALL(PROGRAMS files... DESTINATION <dir>\n" " INSTALL(PROGRAMS files... DESTINATION <dir>\n"
@ -151,7 +152,8 @@ public:
" [COMPONENT <component>]\n" " [COMPONENT <component>]\n"
" [RENAME <name>])\n" " [RENAME <name>])\n"
"The PROGRAMS form is identical to the FILES form except that the " "The PROGRAMS form is identical to the FILES form except that the "
"default permissions for the installed file mark it as executable. " "default permissions for the installed file also include "
"OWNER_EXECUTE, GROUP_EXECUTE, and WORLD_EXECUTE. "
"This form is intended to install programs that are not targets, " "This form is intended to install programs that are not targets, "
"such as shell scripts. Use the TARGETS form to install targets " "such as shell scripts. Use the TARGETS form to install targets "
"built within the project." "built within the project."