Bug in utils.php

In the file include/utils.php there is a function called make_sugar_config which manipulates for some purpose which I do not know the global variable $sugar_config.

I noticed that the array default_permissions contains two keys (chown and chgroup) that, from the core definitions found at http://support.sugarcrm.com/02_Documentation/04_Sugar_Developer/Sugar_Developer_Guide_6.5/02_Application_Framework/Helper_Classes/Configurator/Core_Settings/, do not exist.

I believe that these should be replaced by user and group (which are the keys defined in the above link as well as in config.php.

In addition, the values of file_mode and of dir_mode are expressed in octal instead of their decimal equivalents (as specified in the above mentioned core definitions link as well as in config.php).

I am not an expert, but I believe there are some inconsistencies to be checked

In the file include/utils.php there is a function called make_sugar_config which manipulates for some purpose which I do not know the global variable $sugar_config.

I noticed that the array default_permissions contains two keys (chown and chgroup) that, from the core definitions found at http://support.sugarcrm.com/02_Documentation/04_Sugar_Developer/Sugar_Developer_Guide_6.5/02_Application_Framework/Helper_Classes/Configurator/Core_Settings/, do not exist.

I believe that these should be replaced by user and group (which are the keys defined in the above link as well as in config.php.

In addition, the values of file_mode and of dir_mode are expressed in octal instead of their decimal equivalents (as specified in the above mentioned core definitions link as well as in config.php).

Further in the code there is another function called get_sugar_config_defaults which correctly refers to user and group but sets dir_mode and file_mode in octal rather than their decimal equivalents.

I am not an expert, but I believe there are some inconsistencies to be checked

for completeness here is what the manual says:

default_permissions

Array that defines the ownership and permissions for directories and files created naturally by the application.
Type: Array 
Versions: 5.2.0+ 
Editions: CE, Pro, Ent, Corp, and Ult 
Override Example:

$sugar_config['default_permissions'] = array();
default_permissions.dir_mode

Part of the ‘default_permissions’ array. Used in UNIX-based systems only to define the permissions on newly created directories. The value is stored in decimal notation while UNIX file permissions are octal. For example, a value of 1528 in this setting equates to 2770 permissions.
Type: Integer 
Versions: 5.2.0+ 
Editions: CE, Pro, Ent, Corp, and Ult 
Override Example:

$sugar_config['default_permissions']['dir_mode'] = 1528;
default_permissions.file_mode

Part of the ‘default_permissions’ array. Used in UNIX-based systems only to define the permissions on newly created files. The value is stored in decimal notation while UNIX file permissions are octal. For example, a value of 432 in this setting equates to 660 permissions.
Type: Integer 
Versions: 5.2.0+ 
Editions: CE, Pro, Ent, Corp, and Ult 
Override Example:

$sugar_config['default_permissions']['file_mode'] = 432;
default_permissions.group

Part of the ‘default_permissions’ array. Used in UNIX-based systems only to define the group membership of any newly created directories and files. This value should be a group that the Apache user is a member of to help ensure proper functionality.
Type: String: Group for the Apache user 
Versions: 5.2.0+ 
Editions: CE, Pro, Ent, Corp, and Ult 
Override Example:

$sugar_config['default_permissions']['group'] = 'apache';

Can you do a “find in files” in the entire codebase of SuiteCRM / SugarCRM, and see if there’s any reference to “$sugar_config->chown” or “$sugar_config->chgroup” ? So that if these were renamed , if doing that would break a dependency on these variable names…?

I did more. I serached for the words chown and chgroup and they appear in three files but as part of the names of Sugar functions or the PHP functions.

They are never the indices of a variable or of an array.

I also found two functions (sugar:chown and sugar_chgroup) which both modify the arrays:

$GLOBALS['sugar_config']['default_permissions']['user']
and
$GLOBALS['sugar_config']['default_permissions']['group']

respectively.

Good work. Since this is probably a “bug of inconsistency” in the original SugarCRM codebase, it should be fixed so as to prevent further bugs from occurring, so I suggest you go to the SugarCRM CE github page at https://github.com/sugarcrm/sugarcrm_dev , fix the code file, and do “pull request” which basically asks the sugarcrm_dev code maintainers to have look at your fixed code file and add it into the official SugarCRM CE codebase for the next release. Your fix will then most likely be part of the next release of both SugarCRM CE and SuiteCRM (which draws its code from SugarCRM CE).

Done.