Disclosure of Invention
The technical problem to be solved by the invention is to provide a user identifier processing method, which can avoid the problem of file permission expansion caused by multiplexing of an application user UID between associated components.
The invention also provides a user identifier processing device which is used for ensuring the realization and the application of the method in practice.
A processing method of user identification comprises the following steps:
receiving an identification request which is sent by a user and aims at a target application component;
judging whether an associated application component of the target application component exists or not;
if the associated application component of the target application component exists, determining whether the identification request contains an identification specified by a user;
if the identification request does not contain the identification appointed by the user, generating a target identification of the user;
judging whether a user identifier consistent with the target identifier exists in the associated component identifier file or not; the association component identification file is used for recording the user identification of the target application component and the user identification of the association application component;
and if the associated component identification file does not have a user identification consistent with the target identification, taking the target identification as the user identification of the user.
Optionally, the above method, wherein the generating the target identifier of the user, includes:
determining a preset minimum identifier value of a cluster system where the target application component is located;
and taking the minimum identification value as the target identification of the user.
The above method, optionally, further includes:
if the associated component identification file has a user identification consistent with the target identification, updating the target identification according to a preset updating mode to obtain a new target identification;
judging whether the new target identifier meets a condition that the new target identifier is larger than a preset maximum identifier value or not;
and if the new target identifier is not greater than the maximum identifier value, re-judging whether a user identifier consistent with the new target identifier exists in the association component identifier file, and when the user identifier consistent with the new target identifier does not exist in the association component identifier file, taking the new target identifier as the user identifier of the user.
The above method, optionally, further includes:
and if the new target identifier is larger than the preset maximum identifier value, sending prompt information, wherein the prompt information is used for prompting that the user identifier is failed to establish.
Optionally, the determining whether there is an associated application component of the target application component includes:
determining a mount point of a shared storage NAS to which the target application component belongs;
judging whether application components except the target application component exist in the mounting point of the NAS or not;
if the application components except the target application component exist, determining the application components as the association components of the target application component;
and if the application components except the target application component do not exist, determining that the associated application component of the target application component does not exist.
A device for processing subscriber identity, comprising:
the receiving unit is used for receiving an identification request which is sent by a user and aims at a target application component;
a first judging unit, configured to judge whether an associated application component of the target application component exists;
the determining unit is used for determining whether the identification request contains the identification specified by the user if the associated application component of the target application component exists;
the generating unit is used for generating a target identifier of the user if the identifier request does not contain the identifier specified by the user;
the second judgment unit is used for judging whether a user identifier consistent with the target identifier exists in the associated component identifier file or not; the association component identification file is used for recording the user identification of the target application component and the user identification of the association application component;
and the first execution unit is used for taking the target identifier as the user identifier of the user if the associated component identifier file does not have the user identifier consistent with the target identifier.
The above apparatus, optionally, the generating unit includes:
the first determining subunit is used for determining a preset minimum identifier value of the cluster system where the target application component is located;
and the execution subunit is used for taking the minimum identifier value as the target identifier of the user.
The above apparatus, optionally, further comprises:
the updating unit is used for updating the target identifier according to a preset updating mode to obtain a new target identifier if the associated component identifier file has a user identifier consistent with the target identifier;
the judging unit is used for judging whether the new target identifier meets the requirement of being larger than a preset maximum identifier value or not;
and the second execution unit is used for judging whether a user identifier consistent with the new target identifier exists in the associated component identifier file again if the new target identifier is not larger than the maximum identifier value, and taking the new target identifier as the user identifier of the user when the user identifier consistent with the new target identifier does not exist in the associated component identifier file.
The above apparatus, optionally, further comprises:
and the sending unit is used for sending prompt information if the new target identifier is larger than a preset maximum identifier value, wherein the prompt information is used for prompting that the user identifier is failed to be established.
Optionally, the apparatus described above, wherein the first determining unit includes:
a second determining subunit, configured to determine a mount point of a shared storage NAS to which the target application component belongs;
a judging subunit, configured to judge whether an application component other than the target application component exists in the mount point of the NAS;
a third determining subunit, configured to determine, if an application component other than the target application component exists, the application component as an association component of the target application component;
a fourth determining subunit, configured to determine that an associated application component of the target application component does not exist if an application component other than the target application component does not exist.
Compared with the prior art, the invention has the following advantages:
the invention provides a method and a device for processing a user identifier, wherein the method comprises the following steps: receiving an identification request which is sent by a user and aims at a target application component; judging whether an associated application component of the target application component exists or not; if the associated application component of the target application component exists, determining whether the identification request contains an identification specified by a user; if the identification request does not contain the identification appointed by the user, generating a target identification of the user; judging whether a user identifier consistent with the target identifier exists in the associated component identifier file or not; the association component identification file is used for recording the user identification of the target application component and the user identification of the association application component; and if the associated component identification file does not have a user identification consistent with the target identification, taking the target identification as the user identification of the user. The method can avoid the file permission rejection problem and the application start-stop problem caused by the difference of the UIDs of the application users in the same component, and can also avoid the file permission expansion problem caused by the multiplexing of the UIDs of the application users among the associated components.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In this application, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
In the related art, a user applies for a user identifier and/or a user group identifier of a system, usually manually applies for a platform, the application user ID and the user group ID have no unified standard and specification, and are mostly defined by an applicant, the applicant has little knowledge about the user identifier between system components, and only considers the uniqueness problem of a single server Linux system UID, but does not consider the uniqueness and consistency problems of the Linux system UID in a cluster mode, which may cause the following disadvantages:
firstly, UIDs of the same component application user in the application system may be inconsistent, so that the file authority rejection problem and the application start-stop problem are caused.
Secondly, UID multiplexing between related components inside the application system can be caused, so that the security risk of file tampering is generated.
Based on this, an embodiment of the present invention provides a method for processing a user identifier, where the method may be applied to an electronic device, where the electronic device may be a computer, and a flowchart of the method is shown in fig. 1, and specifically includes:
s101: and receiving an identification request sent by a user and aiming at the target application component.
In the embodiment of the present invention, the identification request may be used to apply for user identification, the target application component may be an application component deployed in a server cluster, and the target application component may access each server of the server cluster where the target application component is located.
S102: and judging whether the associated application component of the target application component exists or not.
The related application component of the target application component is an application component on which the same NAS volume is mounted as the target application component.
S103: and if the associated application component of the target application component exists, determining whether the identification request contains the identification specified by the user.
In the embodiment of the present invention, if there is an identifier specified by a user, it may be determined whether there is a user identifier that is consistent with the identifier in the association component identifier, and if there is no user identifier that is consistent with the identifier, the identifier may be used as the user identifier of the user.
S104: and if the identification request does not contain the identification appointed by the user, generating the target identification of the user.
Specifically, the target identifier of the user may be generated according to the identifier generation rule of the target application component.
S105: judging whether a user identifier consistent with the target identifier exists in the associated component identifier file or not; the association component identification file is used for recording the user identification of the target application component and the user identification of the association application component.
In the embodiment of the present invention, the user identifier may be a UID or a GID, and the association component identifier file may be a database.
S106: and if the associated component identification file does not have a user identification consistent with the target identification, taking the target identification as the user identification of the user.
In the embodiment of the invention, under the condition that the associated component identification file does not have the user identification consistent with the target identification, the user object user can be created through the target identification, and the target identification is recorded in the associated component identification file, so that the target identification is used as the user identification of the user, and the uniqueness of the user identification of the target application component and the associated component thereof can be ensured.
In the method provided in the embodiment of the present invention, based on the implementation process, specifically, a feasible manner for generating the target identifier of the user includes:
determining a preset minimum identifier value of a cluster system where the target application component is located;
and taking the minimum identification value as the target identification of the user.
In particular, the target identification may be set to the minimum identification allowed by the cluster system of the target application component.
In the method provided in the embodiment of the present invention, based on the implementation process, specifically, the method further includes:
if the associated component identification file has a user identification consistent with the target identification, updating the target identification according to a preset updating mode to obtain a new target identification;
judging whether the new target identifier meets a condition that the new target identifier is larger than a preset maximum identifier value or not;
and if the new target identifier is not greater than the maximum identifier value, re-judging whether a user identifier consistent with the new target identifier exists in the association component identifier file, and when the user identifier consistent with the new target identifier does not exist in the association component identifier file, taking the new target identifier as the user identifier of the user.
In the embodiment of the present invention, one feasible way of updating the target identifier according to the preset updating way is as follows: and adding a preset numerical value to the target identifier to obtain a new target identifier. The value may be any value such as 1, 2 or 5.
The maximum identification value can be set according to actual requirements.
In the method provided in the embodiment of the present invention, based on the implementation process, specifically, the method further includes:
and if the new target identifier is larger than the preset maximum identifier value, sending prompt information, wherein the prompt information is used for prompting that the user identifier is failed to establish.
In the embodiment of the present invention, based on the implementation process, specifically, the implementation process further includes: if the associated application component of the target application component does not exist, determining whether the identification request contains an identification specified by a user; if the identification request does not contain the identification appointed by the user, generating a target identification of the user; judging whether a user identifier consistent with the target identifier exists in the component identifier file or not; the component identification file is used for recording the user identification of the target application component; and if the component identification file does not have the user identification consistent with the target identification, taking the target identification as the user identification of the user.
In the method provided in the embodiment of the present invention, based on the implementation process, specifically, the process of determining whether there is an application component associated with the target application component includes, as shown in fig. 2:
s201: and determining a mounting point of the shared storage NAS to which the target application component belongs.
S202: and judging whether the mounting point of the NAS has application components except the target application component or not.
S203: and if the application components except the target application component exist, determining the application components as the association components of the target application components.
S204: and if the application components except the target application component do not exist, determining that the associated application component of the target application component does not exist.
In an embodiment provided by the present invention, an exemplary diagram of an implementation scenario is provided, as shown in fig. 3, the implementation scenario includes an electronic device that deploys a Linux system, and the system manages each application component deployed in different clusters, specifically, an application component a, an application component B, an application component C, and an application component D. When the electronic device receives an identification request for application component a, application component a can be targeted. After receiving an identification request of a user for an application component a, a flowchart for providing the user with a user identification is shown in fig. 4, and includes the following steps:
s401, judging whether the component A cluster of the application user establishes a UID list database, namely a component identification file.
S402, if the UID list database of the component A cluster is not established, the corresponding database can be established through/etc/password acquisition.
And S403, starting to create a new user flow.
S404, judging whether the component A is associated with other components; if not, entering S405; if yes, the process proceeds to S415.
S405, judging whether the user is appointed UID, if not, entering S406; if yes, the process proceeds to S412.
S406, if the user does not specify the UID, the UID is set to the minimum UID allowed by the component A cluster system, and the operation enters S407.
S407, judging whether the UID exists in the component A cluster UID list database. If yes, entering S408; if not, the process proceeds to S410.
And S408, judging whether the UID is larger than the maximum UID allowed by the system. If yes, entering S409; if not, the UID is incremented by 1, and the process proceeds to S407.
And S409, prompting that the set UID exceeds the maximum UID allowed by the system, and exiting the whole process.
S410, if the set UID does not exist in the component a cluster UID list database, the UID will be used to create a user, and the process proceeds to S411.
And S411, writing the created UID into the UID list database, and ending the whole process.
If the applicant designates the UID, it is further determined whether the designated UID exists in the UID list database S412. If not, go to S413; if yes, the process proceeds to S414.
If the specified UID does not exist in the UID list database, the user is created using the specified UID, and the created user is deployed on all server systems of the component S413.
And S414, if the specified UID exists in the UID list database, the UID is prompted to exist, and the process is ended.
S415, associating the component A with other components, if the UID list database of the associated component does not exist, establishing the UID list database of the associated component, and if the UID list database of the associated component does exist, entering S416; if not, the process proceeds to S417. The UID list database of the associated components is the associated component identification file.
S416: and establishing a UID list database of the associated components.
S417, judging whether the UID is appointed. If yes, go to S418; if not, the process proceeds to S422.
S418, judging whether the UID exists in the associated component UID list database. If not, the step goes to S419; if yes, go to S421.
S419, the applicant designates the UID, and the UID does not exist in the UID list database of the associated component, the UID is used for creating a user, and the created user is deployed on all server systems of the component, and the step S420 is entered.
And S420, writing the created UID into the UID list database of the association component, and ending the process.
S421, the appointed UID exists in the association component, the UID is prompted to exist, and the process is ended.
S422, if the applicant does not specify the UID, the UID is set to the minimum UID allowed by the component A cluster system, and the process goes to S423.
And S423, judging whether the UID exists in the UID list database of the associated component. If yes, go to S424; if not, the process proceeds to S426.
S424, the UID exists in the UID list database of the association component, whether the UID is larger than the UID maximum value allowed by the system is judged, if yes, the operation enters S425; if not, the UID is incremented by 1, and the process proceeds to S423.
And S425, prompting the UID to exceed the maximum UID allowed by the system, and exiting the process.
S426, the UID does not exist in the association component list database, the UID is used to create a user, and the created user is deployed on all server systems of the component, and the process goes to S427.
And S427, writing the created UID into the associated component list data, and ending the process.
By applying the method provided by the embodiment of the invention, the UID obtained by the method is used for creating the user, and the created user is established on all server systems of the component, so that the UID in the independent component is ensured to be uniquely determined, and the UID setting of the component related to other components is ensured to be unique and not to be multiplexed.
Corresponding to the method described in fig. 1, an embodiment of the present invention further provides a processing apparatus for a user identifier, which is used to implement the method in fig. 1 specifically, and the processing apparatus for a user identifier provided in the embodiment of the present invention may be applied to an electronic device, and a schematic structural diagram of the processing apparatus is shown in fig. 5, and specifically includes:
a receivingunit 501, configured to receive an identifier request for a target application component sent by a user;
afirst judging unit 502, configured to judge whether an associated application component of the target application component exists;
a determiningunit 503, configured to determine whether the identifier request includes an identifier specified by a user if an associated application component of the target application component exists;
agenerating unit 504, configured to generate a target identifier of the user if the identifier request does not include an identifier specified by the user;
asecond judging unit 505, configured to judge whether a user identifier consistent with the target identifier exists in the association component identifier file; the association component identification file is used for recording the user identification of the target application component and the user identification of the association application component;
a first executingunit 506, configured to, if the associated component identifier file does not have a user identifier that is consistent with the target identifier, take the target identifier as the user identifier of the user.
In an embodiment provided by the present invention, based on the above scheme, optionally, the generatingunit 504 includes:
the first determining subunit is used for determining a preset minimum identifier value of the cluster system where the target application component is located;
and the execution subunit is used for taking the minimum identifier value as the target identifier of the user.
In an embodiment provided by the present invention, based on the above scheme, optionally, the method further includes:
the updating unit is used for updating the target identifier according to a preset updating mode to obtain a new target identifier if the associated component identifier file has a user identifier consistent with the target identifier;
the judging unit is used for judging whether the new target identifier meets the requirement of being larger than a preset maximum identifier value or not;
and the second execution unit is used for judging whether a user identifier consistent with the new target identifier exists in the associated component identifier file again if the new target identifier is not larger than the maximum identifier value, and taking the new target identifier as the user identifier of the user when the user identifier consistent with the new target identifier does not exist in the associated component identifier file.
In an embodiment provided by the present invention, based on the above scheme, optionally, the method further includes:
and the sending unit is used for sending prompt information if the new target identifier is larger than a preset maximum identifier value, wherein the prompt information is used for prompting that the user identifier is failed to be established.
In an embodiment of the present invention, based on the above scheme, optionally, the first determiningunit 502 includes:
a second determining subunit, configured to determine a mount point of a shared storage NAS to which the target application component belongs;
a judging subunit, configured to judge whether an application component other than the target application component exists in the mount point of the NAS;
a third determining subunit, configured to determine, if an application component other than the target application component exists, the application component as an association component of the target application component;
a fourth determining subunit, configured to determine that an associated application component of the target application component does not exist if an application component other than the target application component does not exist.
The embodiment of the invention also provides a storage medium, which comprises a stored instruction, wherein when the instruction runs, the device where the storage medium is located is controlled to execute the processing method of the user identifier.
An electronic device is provided in an embodiment of the present invention, and the structural diagram of the electronic device is shown in fig. 6, which specifically includes amemory 601 and one ormore instructions 602, where the one ormore instructions 602 are stored in thememory 601 and configured to be executed by one ormore processors 603 to perform the following operations on the one or more instructions 602:
receiving an identification request which is sent by a user and aims at a target application component;
judging whether an associated application component of the target application component exists or not;
if the associated application component of the target application component exists, determining whether the identification request contains an identification specified by a user;
if the identification request does not contain the identification appointed by the user, generating a target identification of the user;
judging whether a user identifier consistent with the target identifier exists in the associated component identifier file or not; the association component identification file is used for recording the user identification of the target application component and the user identification of the association application component;
and if the associated component identification file does not have a user identification consistent with the target identification, taking the target identification as the user identification of the user.
It should be noted that, in the present specification, the embodiments are all described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. For the device-like embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functions of the units may be implemented in the same software and/or hardware or in a plurality of software and/or hardware when implementing the invention.
From the above description of the embodiments, it is clear to those skilled in the art that the present invention can be implemented by software plus necessary general hardware platform. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which may be stored in a storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments.
The foregoing describes in detail a method for processing a user identifier provided by the present invention, and a specific example is applied in the description to explain the principle and the implementation of the present invention, and the description of the foregoing embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.