MXS-2119: Fix file permissions
The admin files are now created with 640 permissions and automatically created directories now properly set the permissions for the group as well. All files and directories created by avrorouter and binlogrouter also now correctly limit the read and write permissions only to the owner and the group.
This commit is contained in:
@ -1274,7 +1274,7 @@ static bool ensure_dir_ok(const char* path, int mode)
|
||||
if (rp)
|
||||
{
|
||||
/** Make sure the directory exists */
|
||||
if (mkdir(rp, 0774) == 0 || errno == EEXIST)
|
||||
if (mkdir(rp, 0770) == 0 || errno == EEXIST)
|
||||
{
|
||||
if (access(rp, mode) == 0)
|
||||
{
|
||||
|
@ -511,7 +511,7 @@ blr_file_create(ROUTER_INSTANCE *router, char *orig_file)
|
||||
// Set final file name full path
|
||||
strcat(path, file);
|
||||
|
||||
int fd = open(path, O_RDWR | O_CREAT, 0666);
|
||||
int fd = open(path, O_RDWR | O_CREAT, 0660);
|
||||
|
||||
if (fd != -1)
|
||||
{
|
||||
@ -614,7 +614,7 @@ blr_file_append(ROUTER_INSTANCE *router, char *file)
|
||||
//Add filename
|
||||
strcat(path, file);
|
||||
|
||||
if ((fd = open(path, flags, 0666)) == -1)
|
||||
if ((fd = open(path, flags, 0660)) == -1)
|
||||
{
|
||||
MXS_ERROR("Failed to open binlog file %s for append.",
|
||||
path);
|
||||
@ -937,7 +937,7 @@ blr_open_binlog(ROUTER_INSTANCE *router,
|
||||
/* Add file name */
|
||||
strcat(path, binlog);
|
||||
|
||||
if ((file->fd = open(path, O_RDONLY, 0666)) == -1)
|
||||
if ((file->fd = open(path, O_RDONLY, 0660)) == -1)
|
||||
{
|
||||
MXS_ERROR("Failed to open binlog file %s", path);
|
||||
MXS_FREE(file);
|
||||
@ -1526,7 +1526,7 @@ blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf)
|
||||
strcat(path, "/");
|
||||
strcat(path, response);
|
||||
|
||||
if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666)) == -1)
|
||||
if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0660)) == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ int main(int argc, char **argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int fd = open(path, binlog_file.fix ? O_RDWR : O_RDONLY, 0666);
|
||||
int fd = open(path, binlog_file.fix ? O_RDWR : O_RDONLY, 0660);
|
||||
if (fd == -1)
|
||||
{
|
||||
printf("ERROR: Failed to open binlog file %s: %s.\n",
|
||||
|
Reference in New Issue
Block a user