4.1. Verification utility chdbfl
This utility is designed for offline verification and correction of database files.
WARNING! Before using this utility, it is necessary to make a backup copy of the database file.
This utility is designed to work only with the file database. The utility is available only in the 32-bit version. A file database is used:
- To store a file infobase
- To store a configuration storage
To start the utility from 1C:Enterprise installation directory, you need to run chdbfl application. This will display a window (see ).
In the field Name of infobase file, specify or select the infobase file name.
Select the check box Fix detected errors to fix the errors found during verification. Also, select this check box to optimize the storage of internal information that accelerates infobase opening (see page ).
To start the utility, click Execute. Make sure the infobase is not yet opened in Designer or in 1C:Enterprise mode.
Messages about the errors found are displayed in a text box.
Messages about the results of the utility's performance are displayed below the text box.
This utility can also be used for verification of configuration storage.
It is recommended to follow these steps when using the utility:
- Create a backup copy of the database file.
- Perform verification without selecting the check box Fix detected errors
- If during verification no issues have been detected, then a verification with the checked check box Fix errors detected can be performed; at the same time, the operation of re-indexing of infobase or infobase storage will be executed. It is recommended to perform such an operation regularly.
- If any issues have been detected during verification, you should correct the infobase errors. If the utility reports lost data, it is not recommended to continue working with this infobase. You can:
- Retrieve the remaining data and configuration that can be used to create a new infobase
- Get the latest version of configuration that can be used to create a new storage
4.2. The integrity monitoring utility ci
4.2.1. General information
The integrity monitoring utility (ci) is designed to monitor the state of the file system objects and the database used in 1C:Enterprise, and to detect the situation of changes in these objects. To determine whether an object has remained unchanged, a comparison of the hash sums of the monitored objects ((control objects)), which are calculated using the SHA-1 algorithm (the cryptographic hashing algorithm), is used. Verification process consists of generating the template hash sum values and the subsequent regular verification.
NOTE. The utility is not supported in macOS.
The utility works with the following control objects:
- Files located in the file system
- Some tables of 1C:Enterprise database
Lists of control objects are specified using the data source template. The data source template is described by a universal data source descriptor (see p. ). Such templates can be specified in the utility startup command line directly or as content of the file specified in the in parameter (see page ). Such file is known as a template list (see page ).
A list of control objects and the corresponding hash sums (this pair is called reference) is stored in a special reference database that is generated by the utility when started in the template database generation mode. When the utility is started in verification mode, the hash sums are calculated and reconciled with the template database generated earlier. As a result, a report file is generated.
The utility does not automatically control self-integrity. To restrict access to the utility, template database, and verification results, use the operating system functionality.
If it is necessary to specify several control objects for a simultaneous verification (or a set of objects), a special file list of information source templates can be used Each line in this file contains a template of the source of information. The number of lines in the file is unlimited. For a detailed description of the format of data source templates, see page. . A comment starts with the character "#". A comment line as well as the empty lines and the lines consisting of spaces, are ignored while generating a list of control objects.
A template list file should be in the UTF-8 encoding only.
Examples of universal descriptors of data sources:
# Control object – file /tmp/vokas/spru.cvs file:///tmp/vokas/spru.cvs # Control object – all files in c:\Program Files\1cv8\220.127.116.118\bin rdir://c:\Program Files\1cv8\18.104.22.1688\bin # Control object – all .rc and .cfg files in /home/user/.kde and subdirectories rdir:///home/user/.kde?*.rc,*.cfg # Control object – all files beginning with "V8", files in directory /tmp, without subdirectories. ndir:///tmp?V8*.txt # Control object – all tables supported in the database located on the MS SQL Server mssql://user:password@server/instance/dbname # Control object – "users" and "config" tables on the PostrgeSQL server postgre://user:password@server:123/dbname?users,config # Control object – "users" tables in the file database dbe://c:\DB\checked_db?users
4.2.3. A universal descriptor of the source of information
To describe the object of control, a special format is used: the universal descriptor of the source of information. In general, the universal descriptor of the information source looks like:
Let's consider in detail each component part of the descriptor:
- proto Description of the Object of control's kind. As a work mode, the following files can be taken:
- file A separate file from the file system;
- ndir Files located in directory (without traversing subdirectories);
- rdir Files located in directory and all the nested directories;
- mssql Database , located in the Microsoft SQL Server DBMS;
- ora Database located in the Oracle Database DBMS;
- postgre Database located in the PostgreSQL DBMS;
- db2 Database located in the DB2 DBMS;
- dbe A file version of the 1C:Enterprise database.
- user:password@. Describes the username (user) and password (password) required to access the control object. If the database tables are monitored, then the DBMS user is specified as a user instead of the 1C:Enterprise database user. It is recommended that you use the parameters of the user on whose behalf the 1C:Enterprise database was created. The “@” character is required if the username and password are specified.
- server: port A name of computer (and access port) on which is launched the DBMS serving the 1C:Enterprise database;
- /path/resource A full path to the file or directory in the notation of the operating system used. In the OS Windows, a system should begin with the name of a disk; in the OS Linux - with designation of a root file system (/). If a connection to the client/server version of the database is used, then as a path can be taken the name of database in terms of the used DBMS if the DBMS does not support the organization of server instances and a combination consisting of the name of instance and the database name for the DBMS supporting this organization. If a database name with an indication of a DBMS instance is specified as a path to a resource, then an access to DBMS is performed using the default access port, and a specification of the port number in description of the name of server on which the DBMS operates, is not supported.
- ?mask A list of information source descriptor parameters separated by commas. Depends on protocol If the files described by the ndir or rdir protocols are used as a control object, the file masks can be used as parameters. If as an object of control the 1C:Enterprise database table is acting, then the table names can be used as parameters:
- config Configuration of database;
- users A table of the configuration users;
Both of these tables are virtual and contain information from several tables of the 1C:Enterprise database. If the universal data descriptor contains a link to one of the above tables, the hash sum is calculated for all data in the table (physical tables, completely or not). Capability to control a table fragment is not supported.
NOTE. When generating a universal data source descriptor, avoid the following characters: @ (except in case of separation of the username/password and the name of computer running the DBMS), /, \,:,? (except when specifying in the file masks but not earlier), ~.
Hash sums of objects of control are stored in a special file of the database of templates. A file contains information in the UTF-8 format. File location and name are specified when the utility is started. The file format is as follows:
In this format, Normalized view of universal data source descriptor contains a string in the same way as it is specified in the data source template. However, a universal data source descriptor is converted to a normalized view. During normalization, the following actions are performed:
- For all protocols, a forward slash (“/”) is added to the end of the description of objects of control (before the “?”)
- For protocols describing directories, mask “*" is added if no mask was found
- For protocols describing databases, an explicit specification of the parameters config,users is added if no mask was found
- For protocols describing databases, the “*” mask is replaced with the explicit indication of config,users
- Masks are lexicographically sorted
- Back slashes ("\") are replaced with the forward slashes ("/")
- Multiple consecutive slashes (back or forward) are replaced by one forward slash (for example, “//\\//” is replaced by “/”)
String <object> = <hash>. Contains a name and a hash sum of the control object. There may be more than one such line. If a universal data source descriptor contains a reference to a specific file, then the <object> expression is absent and the line begins with the “=” character.
An example of a fragment from the template database:
[dbe://C:/1C DB/DB folder/?config] config = FEC3FC5E46AE98299217D6885B3BE28C4F4D6FB9 [dbe://C:/1C DB/Another DB folder/?config,users] config = FEC3FC5E46AE98299217D6885B3BE28C4F4D6FB9 users = A244BE3830C2B7075C0BB684896B97A0324984A0 [file://C:/Program Files (x86)/1cv82/22.214.171.1246/docs/ru/V8UpdateFrom82Beta.htm] = 392BC75149AE02565C7E31592EDCD60F00BFA03C [ndir://C:/Program Files (x86)/1cv8/126.96.36.1995/bin/?*] 1cv8.exe = 232F2BCCE6ABB95FD56E3CB3FADE528D851A5D69 1cv8_root.hbk = 025B4C8465D3CD851363B2102478B1CAF2EC444E 1cv8_root.res = 8F48869F82BB222EE25E18502605AC117BB5736A 1cv8_ru.hbk = 81CBB0D5573D8517913053EA88AAADE9785AB443 ...
Results of the utility's performance are recorded in a report file. A file contains information in the UTF-8 format. File location and name are specified when the utility is started. However, the specified name will be converted as follows: date and time of the report generation will be added to the file name; for example, if a report is to be saved to C:\temp\report.rpt, the actual file name will look like C:\temp\report-14.02.26-14.07.58.019446.rpt.
The file has the following format:
[.params] Key=value [Normalized view of universal data source descriptor] <Control object> = <Detected change>
The .params section is always included and contains a description of the utility startup parameters. Key can take the following values:
- datetime Date and time of launching a utility;
- workdir a working directory at launching utility;
- exepath A path to the executable file containing a utility;
- mode A launching utility mode:
- create A mode of generating a base of templates;
- check A template verification mode.
- etalon A path to the base of templates;
- report A path to the report file (as specified in the command line at launching a utility);
- debug A path to the file containing debug information or an empty string if debug information output is not specified;
- in A path to the file containing parameters. If more than one -in parameter is specified in the start command line, then a presence of several in keys is possible in the .params section
- param all the recognized command line parameters at launching a utility separated by commas.
If any source (from the database of templates) detects differences between the database of templates and the actual state of files on disk, then a section describing the changed source is placed in the report file and the detected changes for objects of control are displayed below. If an object of control has not changed , then information on such an object is not displayed.
The following possible changes are processed:
- A A new control object has been detected in the source of information;
- D An object of control that existed at the time of generating a base of templates, was deleted from the source of information;
- M An object of control has been modified.
Let's review a fragment of the report file:
[dbe://C:/1C DB/DB folder/?config,users] users = M [ndir://C:/Program Files (x86)/1cv81/bin/?*] 1CMailV8.dll = D 1CMailV8.dll.32 = A
This report file indicates that:
- Content of the user table has been changed for the file infobase located in the C:/1C DB/DB directory.
- In the directory C:/Program Files (x86)/1cv81/bin, file 1CmailV8.dll was deleted and a new file 1CmailV8.dll.32 is detected.
The utility is started using the command line with the following parameters:
ci <mode> --in <SourceTemplate> --etalon <ReferenceDatabaseFile> --report <ReportFile> --debug <DebugInformationFile> [description of source]
Parameters have the following values:
A utility's working mode:
- --version, -v show a version number of the integrity monitoring utility.
- --help, -h show reference information on the make and check modes. In this case, a mode should be indicated with a space after the command for receiving reference information.
- make To create a file of the database of templates or to update data on any information sources (if the database of templates exists and it contains data on the source that was specified when the utility started).
- check To check integrity of the transmitted list of sources on the base of templates.
The following parameters are only required when starting the utility in make or check modes.
This parameter is used to specify a path to the data sources template (see page ). There may be more than one such parameter.
For the make and check modes, at least one description of a source must be specified. This can be the --in (-i) parameter or a simple indication of the source description (see source description parameter below).
This parameter is used to specify a full path to the report file (see page ).
It is required for the make and check modes.
This parameter is used to specify a full path to the file with debug information. The file is needed for the 1C technical personnel in case of an investigation into the utility’s incorrect behavior.
--method=<value>, -m=<value>only for make
Allows you to select the hash function calculation algorithm for calculating checksums. The parameter can have one of the following values:
- sha1. SHA-1 algorithm is used.
- sha256. SHA-256 algorithm is used. This is the default value.
- gost2012. The algorithm described in GOST R 34.11-2012 (512 bit) is used.
Specifies a data source without specifying a template file (including multiple descriptions). For that, a source should be specified in exactly the same format as each row of the data source template list (see page ). The utility uses all source descriptions specified during startup (both using parameter in and explicitly).
4.2.7. Recommendations for installation and use
The integrity monitoring utility does not have self-monitoring functions. Therefore, integrity monitoring of the utility files is entrusted to the system administrator. It can be protected by using the file system permissions for the utility directory, reference database files, and report files.
A viable use case is as follows:
- The utility is installed in the directory different from the 1C:Enterprise installation directory.
- A privileged user with restricted rights (sufficient to view all control objects) is created.
- Access rights to the executable and configuration files of the utility are only granted to this user (any access by any other users is denied).
- The utility is always started on behalf of this user.
The above rules will ensure high level of protection against unauthorized access and misuse.
The general usage procedure is as follows:
- To run the utility, sign in as a privileged user. If the utility is started from the system scheduler, make sure that the scheduler runs it on behalf of the privileged user.
- The utility is started in one of these modes: creating a reference database, or checking integrity of data sources.
- Analysis of the utility performance report is performed.
Thus, the utility (and its performance results) is only accessible to the trusted persons who know the name and password of a privileged user created to run the integrity monitoring utility.