CN113742716A - Code running method, device, electronic equipment, storage medium and program product - Google Patents

Code running method, device, electronic equipment, storage medium and program product Download PDF

Info

Publication number
CN113742716A
CN113742716A CN202111297637.8A CN202111297637A CN113742716A CN 113742716 A CN113742716 A CN 113742716A CN 202111297637 A CN202111297637 A CN 202111297637A CN 113742716 A CN113742716 A CN 113742716A
Authority
CN
China
Prior art keywords
directory
target
code
file
user
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111297637.8A
Other languages
Chinese (zh)
Other versions
CN113742716B (en
Inventor
詹晋楠
梁捷锋
魏振文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202111297637.8A priority Critical patent/CN113742716B/en
Publication of CN113742716A publication Critical patent/CN113742716A/en
Application granted granted Critical
Publication of CN113742716B publication Critical patent/CN113742716B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/52Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow
    • G06F21/53Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow by executing in a restricted environment, e.g. sandbox or secure virtual machine

Abstract

The embodiment of the invention discloses a code running method, a code running device, electronic equipment, a storage medium and a program product; the code operation request including the user identification of the target user can be obtained, the target code storage directory corresponding to the target user is determined according to the user identification, the target code file under the target code storage directory is mounted under the target operation directory corresponding to the target user, the target operation environment file under the shared directory is mounted under the target operation directory based on the target code file, the target operation environment file mounted under the target operation directory and the target code file do not have the file with the same file identification, and the target code file mounted under the target operation directory is operated based on the target operation environment file mounted under the target operation directory; the method and the device can avoid the damage of destructive codes written by a user to a system or equipment where the code running process is located, and improve the safety of the code running environment.

Description

Code running method, device, electronic equipment, storage medium and program product
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a code running method, apparatus, electronic device, storage medium, and program product.
Background
With the rapid development of programming education, more and more people begin to learn programming skills. For example, a school information technology teacher or a student parent may autonomously arrange a programming environment on a device used by the student, or install existing programming education software for the student to perform programming learning.
By adopting the scheme of autonomously arranging the programming environment or using the existing programming education software, due to the programming capacity limit of the user or the malicious mind of part of the user, code which is destructive to the system where the code running process is positioned can be written, and the normal running of the system is damaged.
Disclosure of Invention
The embodiment of the invention provides a code running method, a code running device, electronic equipment, a storage medium and a program product, which can avoid damage of a system or equipment where a code running process is located by a destructive code written by a user and improve the safety of a code running environment.
The embodiment of the invention provides a code running method, which comprises the following steps:
acquiring a code running request of a target user, wherein the code running request comprises a user identifier of the target user;
determining a target code storage directory corresponding to the target user from a code storage directory of a code operating system according to the user identification, wherein the code storage directory corresponds to the users of the code operating system one by one, and the code storage directory is used for storing code files of the corresponding users;
mounting the target code files in the target code storage directory to a target operation directory corresponding to the target user, wherein the operation directories in the code operation system correspond to the users one by one, and the operation directories are used for mounting all files required by the corresponding users when the codes are operated;
based on the target code file, mounting a target operation environment file in a shared directory to the target operation directory, wherein the shared directory is used for storing operation environment files shared by users of the code operation system, and the target operation environment file mounted in the target operation directory and the target code file do not have files with the same file identification;
and operating the target code file mounted in the target operation directory based on the target operation environment file mounted in the target operation directory.
Correspondingly, an embodiment of the present invention further provides a code running apparatus, including:
the code execution device comprises a request acquisition unit, a code execution unit and a code execution unit, wherein the request acquisition unit is used for acquiring a code execution request of a target user, and the code execution request comprises a user identifier of the target user;
the directory determining unit is used for determining a target code storage directory corresponding to the target user from a code storage directory of a code operating system according to the user identification, wherein the code storage directory is in one-to-one correspondence with the users of the code operating system, and the code storage directory is used for storing code files of the corresponding users;
the first mounting unit is used for mounting target code files in the target code storage directory to a target operation directory corresponding to the target user, wherein the operation directories in the code operation system correspond to the users one by one, and the operation directories are used for mounting all files required by the corresponding users when the users operate codes;
a second mounting unit, configured to mount, based on the target code file, a target operating environment file in a shared directory to the target operating directory, where the shared directory is used to store an operating environment file shared by a user of the code operating system, and there is no file with the same file identifier in the target operating environment file and the target code file mounted in the target operating directory;
and the code running unit is used for running the target code file mounted in the target running directory based on the target running environment file mounted in the target running directory.
Optionally, the second mount unit is configured to obtain an object code file identifier of each object code file, and an operating environment file identifier of each operating environment file in the shared directory;
determining a target operation environment file with different operation environment file identifications and all target code file identifications;
and mounting the target operation environment file to the target operation directory.
Optionally, a directory hierarchy relationship exists among the target code storage directory, the target operating directory and the shared directory, where the shared directory has the lowest hierarchy and the target operating directory has the highest hierarchy;
the first mounting unit is used for acquiring a file identifier of a mounted file in a target operation directory corresponding to the target user;
when a first identified file exists in the mounted file, determining a source directory hierarchy of the first identified file, wherein the file identifier of the first identified file is the same as the file identifier of a file in the target code file;
when the source directory hierarchy is lower than the directory hierarchy of the target code storage directory, mounting a target code file under the target code storage directory to the target operation directory, and covering the first common identification file based on the target code file;
the second mounting unit is used for acquiring the file identifier of the mounted file in the target operation directory;
when a second identical identification file exists in the mounted files, determining the source directory hierarchy of the second identical identification file, wherein the file identification of the second identical identification file is the same as the file identification of a next operation environment file in the shared directory;
when the source directory hierarchy is higher than the directory hierarchy of the shared directory, determining a target operation environment file which is different from the file identifier of the second identified file from the operation environment files;
and mounting the target operation environment file to the target operation directory.
Optionally, the code running apparatus provided in the embodiment of the present invention further includes a content updating unit, configured to monitor a file update condition under a preset directory in the user equipment of the target user, where the preset directory is a directory in the user equipment where the code file is locally stored;
if the local code file corresponding to the target code file under the preset directory is updated, reading the updating content of the local code file;
and updating the file content of the target code file according to the updating content of the local code file to obtain a new target code file.
Optionally, the code running apparatus provided in the embodiment of the present invention further includes a space isolation unit, configured to create a namespace corresponding to the target user;
creating the target code storage directory and the target operation directory in a name space corresponding to the target user;
correspondingly, the code running unit is used for configuring a code running environment required by the running of the target code file based on the target running environment file mounted under the target running directory in the name space corresponding to the target user;
and operating the target code file mounted in the target operation directory according to the code operation environment.
Optionally, the code running apparatus provided in the embodiment of the present invention further includes a directory creating unit, configured to create a pseudo root directory as the shared directory under a root directory of the code running system, and store the running environment file in the shared directory;
creating a superior directory of the shared directory as the target code storage directory of the target user;
and creating an upper-level directory of the code storage directory as a target operation directory of the target user.
Optionally, the code running apparatus provided in the embodiment of the present invention further includes a directory access unit, configured to obtain a root directory access request of the target user, where the root directory access request includes a user identifier of the target user;
judging whether the target user meets a preset root directory access condition or not according to the user identifier of the target user;
and when the target user does not meet the root directory access condition, accessing the shared directory.
Optionally, the directory access unit is configured to invoke a directory switch command when the target user does not satisfy the root directory access condition;
switching the currently accessed directory from the root directory to the shared directory based on the directory switching command;
the shared directory is accessed.
Optionally, the code running apparatus provided in the embodiment of the present invention further includes a system quitting unit, configured to respond to a system quitting operation of the target user, and store the target code file in a database corresponding to the target user;
and deleting the target code storage directory and the target operation directory.
Optionally, the code operating apparatus provided in the embodiment of the present invention further includes a file obtaining unit, configured to obtain a code obtaining request of the target user, where the code obtaining request includes a user identifier of the target user;
acquiring the target code file corresponding to the target user from the database according to the user identification of the target user;
and storing the object code file into the object code storage directory created in advance.
Correspondingly, the embodiment of the invention also provides the electronic equipment, which comprises a memory and a processor; the memory stores an application program, and the processor is used for running the application program in the memory to execute the steps in any code running method provided by the embodiment of the invention.
Correspondingly, the embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to perform the steps in any one of the code execution methods provided by the embodiment of the present invention.
In addition, the embodiment of the present invention further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the computer program or instructions implement the steps in any one of the code execution methods provided by the embodiment of the present invention.
By adopting the scheme of the embodiment of the invention, the code operation request of a target user can be obtained, the code operation request comprises the user identification of the target user, the target code storage directory corresponding to the target user is determined from the code storage directory of the code operation system according to the user identification, wherein the code storage directory is in one-to-one correspondence with the user of the code operation system, the code storage directory is used for storing the code file of the corresponding user, the target code file under the target code storage directory is mounted to the target operation directory corresponding to the target user, wherein the operation directory in the code operation system is in one-to-one correspondence with the user, the operation directory is used for mounting all files required by the corresponding user when the code is operated, the target operation environment file under the shared directory is mounted to the target operation directory based on the target code file, the shared directory is used for storing an operating environment file shared by a user of the code operating system, the target operating environment file mounted in the target operating directory and the target code file do not have files with the same file identification, and the target code file mounted in the target operating directory is operated based on the target operating environment file mounted in the target operating directory; in the embodiment of the invention, the code edited by the user is stored in the target code storage directory as the target code file, the operating environment file required by the operating code is stored in the shared directory, and the target code file and the target operating environment file without the same file identifier as the target code file are mounted in the target operating directory during mounting, so that even if the operating environment file is maliciously modified by the user, the maliciously modified operating environment file can be stored in the target code storage directory as the target code file, the original operating environment file in the shared directory cannot be influenced, the damage of the destructive code written by the user to a system or equipment in which a code operating process is positioned can be avoided, and the safety of the code operating environment is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic diagram of a scenario of a code running method according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method for running code according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a process for mounting an object code file and an object operating environment file to an object operating directory according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a directory structure of a code running system after a pseudo root directory is built under a root directory according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a code execution system provided by an embodiment of the present invention;
FIG. 6 is another flowchart illustrating a method for running code according to an embodiment of the present invention;
FIG. 7 is a schematic structural diagram of a code running apparatus according to an embodiment of the present invention;
FIG. 8 is another schematic structural diagram of a code running device according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
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.
The embodiment of the invention provides a code running method and device, electronic equipment and a computer readable storage medium. In particular, embodiments of the present invention provide a code running method suitable for a code running apparatus, which may be integrated in an electronic device.
The electronic device may be a terminal or other devices, including but not limited to a mobile terminal and a fixed terminal, for example, the mobile terminal includes but is not limited to a smart phone, a smart speaker, a smart watch, a tablet computer, a notebook computer, a vehicle-mounted terminal, and the like, wherein the fixed terminal includes but is not limited to a desktop computer, a smart television, and the like.
The electronic device may also be a device such as a server, and the server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a CDN (Content Delivery Network), and a big data and artificial intelligence platform, but is not limited thereto.
The code running method of the embodiment of the invention can be realized by a server or a terminal, and can also be realized by the terminal and the server together.
The following describes the method by taking an example in which the terminal and the server implement the code running method together.
As shown in fig. 1, the code running system provided by the embodiment of the present invention includes a terminal 10, a server 20, and the like; the terminal 10 and the server 20 are connected via a network, for example, a wired or wireless network connection, and the terminal 10 may exist as a terminal for a target user to send client data to be analyzed to the server 20.
The terminal 10 may be a terminal for editing and generating a code file for a target user, and may also be configured to send a code operation request to the server 20.
The server 20 may be configured to obtain a code operation request of a target user, where the code operation request includes a user identifier of the target user;
the server 20 may determine, according to the user identifier, an object code storage directory corresponding to the object user from a code storage directory of the code running system, where the code storage directory corresponds to the user of the code running system one to one, and the code storage directory is used to store the code file of the corresponding user;
the server 20 mounts the target code file in the target code storage directory to a target operation directory corresponding to a target user, wherein the operation directories in the code operation system correspond to the users one by one, and the operation directory is used for mounting all files required by the corresponding user when the user operates the code;
the server 20 mounts the target operating environment file in the shared directory to the target operating directory based on the target code file, wherein the shared directory is used for storing the operating environment file shared by the users of the code operating system, and the target operating environment file mounted in the target operating directory and the target code file do not have files with the same file identification;
the server 20 executes the target code file mounted in the target operation directory based on the target operation environment file mounted in the target operation directory.
In some alternative embodiments, the server 20 may return the operation result of the object code file to the terminal 10, so that the terminal 10 may display the operation result of the object code file.
The following are detailed below. It should be noted that the following description of the embodiments is not intended to limit the preferred order of the embodiments.
Embodiments of the present invention will be described in terms of a code running apparatus, which may be specifically integrated in a server and/or a terminal.
As shown in fig. 2, a specific flow of the code running method of this embodiment may be as follows:
201. and acquiring a code operation request of the target user, wherein the code operation request comprises the user identification of the target user.
Wherein the target user is a user who is currently using the code operating system. One or more target users can be provided, and the code running system can provide services such as running codes and the like for a plurality of target users simultaneously through technologies such as multithread concurrent processing and the like.
In an actual application process, user accounts that can be established by multiple users in the code running system may be set up, for example, at a certain time, a part of users who are using the code running system may be present, and all the users who are using the code running system may be target users.
The code running request can be a request for running a certain code file or certain code files generated according to the trigger operation of the target user. The code running request may include, but is not limited to, a user identifier of the target user, indication information of a code file that needs to be run, and/or running resource information that is specified by the target user and is needed when the code is run, and the like.
For example, in the programming and learning process, the code running system may be used for a student who learns programming to run a written code, and at this time, the code running request may include a user identifier corresponding to a user account number in which the student logs in, a storage address of a code file written by the student, and the like.
For another example, in order to enhance the programming learning interest of students, the students can be programmed and trained in the form of games. For example, the game form may be that a student selects a certain programming sentence on a used terminal interface to run a game code file corresponding to the programming sentence, so as to realize the game effect. At this time, the code running request may include, but is not limited to, indication information of a game code file corresponding to the programming sentence selected by the student, and the like.
Alternatively, the user identifier of the target user may be any information capable of indicating the identity of the target user, for example, the user identifier of the target user may be an account number of the target user or a character combination that can distinguish the target user from other users, and the like. The embodiment of the invention does not limit the form and content of the user identifier.
Specifically, the trigger operation of the target user may be an operation such as clicking a code running control on a user visual interface of the code running system, or may also be an operation in which the target user manually inputs a code running command, or may also be a code running setting preset by the user or a technician at regular time or irregular time, or the like.
In the actual application process, since the service resources that can provide the code running service for the user are limited, in order to provide sufficient computing resources for each user and avoid idle resources, the computing resources of the user can be recovered and released after the user finishes using the code running system each time. But this may result in changes made by the user in the code running system, such as written code files, all disappearing.
Therefore, the content edited by the target user on the equipment can be stored, and the change of the user can be persisted and stored in the database. That is to say, before the step "obtaining the code running request of the target user", the code running method provided in the embodiment of the present invention may further include:
monitoring the file updating condition under a preset directory in user equipment of a target user, wherein the preset directory is a directory of a local storage code file in the user equipment;
if the local code file corresponding to the target code file under the preset directory is updated, reading the updating content of the local code file;
and updating the file content of the target code file according to the updating content of the local code file to obtain a new target code file.
The file update condition may include, but is not limited to, modification, addition, deletion of the content in the file, deletion of the native code file, and the like.
Specifically, the step of "updating the file content of the target code file according to the update content of the local code file" may specifically include:
acquiring a file identifier of a local code file and a file identifier of a target code file;
and when the file identification of the local code is matched with the file identification of the target code, updating the file content of the target code file according to the updating content of the local code file.
The file identifier may be a file name, a file number, or the like.
It will be appreciated that the update operations performed on the file contents of the target code file are generally consistent with the update operations performed on the native code file by the target user. For example, when a target user writes a piece of code at a certain position in a native code file and updates the file content of the target code file, the same content is generally written at the same position in the target code file.
In some optional embodiments, in order to improve readability of the object code file and increase the amount of information in the object code file, when the object code file is updated, besides synchronizing the update content of the local code file, update related information may be added to the object code file. That is, the step of updating the file content of the object code file according to the updated content of the local code file to obtain a new object code file may include:
according to the updating content of the local code file, the file content of the target code file is updated in the same way;
and adding update related information in the object code file based on the update of the file content of the object code file to obtain a new object code file.
The update-related information may include, but is not limited to, the time when the target user updates in the native code file, the time when the file content of the target code file updates, the content of the target code file updates, and the like.
It will be appreciated that the update related information may be written in the object code file in the form of a code annotation in order not to affect the normal operation of the object code file.
In some specific embodiments, in order to ensure that users of the code running system do not affect each other, before the step "obtaining a code running request of a target user", the code running method provided in the embodiments of the present invention may further include:
creating a name space corresponding to a target user;
creating a target code storage directory and a target operation directory in a name space corresponding to a target user;
correspondingly, the step "operating the target code file mounted in the target operation directory based on the target operation environment file mounted in the target operation directory" may include:
configuring a code operating environment required by the operation of a target code file in a name space corresponding to a target user based on a target operating environment file mounted under a target operating directory;
and operating the target code file mounted under the target operation directory according to the code operation environment.
The namespaces (namespaces) are also called namespaces, and can isolate part of system resources of the code operating system, so that processes in different namespaces cannot see the resources used by each other.
For example, in the Linux system, a Linux namespace (Linux Namesapce) is a characteristic of isolating and virtualizing system resources including process IDs, host names, user IDs, network access, interprocess communication, and the like, by a Linux kernel.
The Linux system supports multiple types of commands, such as the CLONE _ NEWNS command to isolate mount point information, the CLONE _ NEWUTS command to isolate host names, the CLONE _ NEWIPC command to isolate inter-process communications, the CLONE _ NEWPID command to isolate process IDs, so that processes in different PID namespaces can be repeated without affecting each other and without seeing processes in other namespaces, and the CLONE _ NEWNET command to isolate networks.
One namespace can be understood as a virtual machine, and all operations of a user on one namespace can not affect other namespaces.
202. And according to the user identification, determining a target code storage directory corresponding to the target user from the code storage directory of the code operating system.
The code storage directory is in one-to-one correspondence with users of the code running system, and the code storage directory is used for storing code files of the corresponding users.
It is understood that the code storage directories are in one-to-one correspondence with the users of the code operating system, which means that each code storage directory corresponds to a unique user, and each user also only corresponds to one code storage directory. For example, the code storage directory a corresponds only to the user a.
The code file refers to a file containing specific codes, and the format of the code file can be. The code storage directory may store only one code file, or may store two or more code files.
The code file may be obtained by a code written by the target user, or may be obtained by a code preset or generated for the target user by a technician.
For example, in a general programming scenario, such as a program development process or a program learning process, a code file may be a file composed of code written by a target user according to the programming requirement of the target user.
For another example, in a usage scenario of some application programs, such as a game program running scenario, the code file may be composed of code set by the game application program according to the operation of the target user. For example, the target user may create or adjust a game character and/or a game scene, etc. by himself or herself when using the game application, and at this time, the game application may generate a game code file corresponding to the target user according to the creation or adjustment operation of the target user, so as to achieve the game effect required by the target user.
When the target user runs the game application program, the code running system corresponding to the game application program can call the game code file corresponding to the target user, and display the game characters and the game scenes created or adjusted by the target user in the game interface.
The code running system refers to an entity capable of realizing the code running function. The code running system can be built on the personal electronic device of one user or can be built by connecting the personal electronic devices of a plurality of users.
For example, a system which is deployed in a personal terminal of a user and can implement the functions of the embodiment of the present invention may be considered as a code running system in the embodiment of the present invention, or a system which is connected to personal terminals of a plurality of users and runs codes through a cloud server may be considered as a code running system in the embodiment of the present invention.
Specifically, the target code storage directory is a code storage directory corresponding to the target user in the code storage directory.
203. And mounting the target code file in the target code storage directory to a target operation directory corresponding to the target user.
The operation directories in the code operation system correspond to the users one by one, and the operation directories are used for mounting all files required by the corresponding users when the codes are operated.
It can be understood that the one-to-one correspondence between the run directories and the users of the code running system means that each run directory corresponds to a unique user, and each user also corresponds to only one run directory. For example, run directory B corresponds only to user B.
Wherein, all the required files at least comprise an object code file and an object operating environment file.
Specifically, the target operation directory is an operation directory corresponding to the target user in the operation directories of the code operation system.
Mount, refers to a process by which the operating system makes computer files and directories on a storage device (such as a hard disk, CD-ROM, or shared resource) available to a user for access through the computer's file system. By mounting, files in the original directories (e.g., the object code storage directory and the shared directory) can be hidden.
In some optional embodiments, when the target code file in the target code storage directory is mounted in the target running directory corresponding to the target user, only the target code file specified by the user may be mounted. Or, there may be other code files besides the target code file under the target code storage directory, and when mounting, all the code files under the target code storage directory may be mounted under a target operation directory corresponding to the target user, and all the code files include the target code file.
In other alternative embodiments, a hierarchical relationship between various directories may be set, and the specific operation during mounting may be determined according to the hierarchical relationship. As shown in fig. 3, a directory hierarchy relationship exists between the target code storage directory, the target run directory, and the shared directory, where the shared directory has the lowest hierarchy and the target run directory has the highest hierarchy.
Specifically, a directory hierarchy refers to a hierarchical relationship between different directories. The hierarchical relationship may be obtained according to the corresponding positions of different directories in the directory structure, but the hierarchical relationship does not necessarily mean that the hierarchical relationship between the directories exists in the structure between the parent directory and the child directory, and may also be obtained by specification of a technician.
For example, the target run directory and the target code storage directory may be temporarily created directories in the directory structure, the path of the target run directory may be "/path/session/aggregated", the path of the target code storage directory may be "/path/session/upper", and the path of the shared directory may be "/data/system".
At this time, the target run directory, the target code storage directory, and the shared directory are not in a relationship of the parent directory and the child directory. The target run directory level may be specified by the technician to be higher than the target code store directory level, which is higher than the shared directory.
Alternatively, the path of the target run directory may be "/data/system/upper/merged", the path of the target code store directory may be "/data/system/upper", and the path of the shared directory may be "/data/system".
At this time, the target run directory, the target code storage directory, and the shared directory have a relationship of a parent directory and a child directory therebetween. The shared directory is a father directory of the target code storage directory, the target code storage directory is a father directory of the target operation directory, the hierarchy of the default child directory is higher than that of the father directory, and the directory hierarchy relationship is obtained according to corresponding positions of different directories in the directory structure.
For example, the specific operation at the time of mounting may be to mount a file in a directory that is not the highest directory hierarchy in the directory hierarchy into a directory that is the highest directory hierarchy, and a file in a directory that is lower in the directory hierarchy at the time of mounting may be overwritten by a file in a directory that is higher in the directory hierarchy.
In the embodiment of the present invention, the execution sequence of step 203 and step 204 is not limited, step 203 may be executed first and then step 204 is executed, or step 204 may be executed first and then step 203 is executed, or step 203 and step 204 may be executed simultaneously.
For example, if step 204 is executed first, and the runtime environment file in the shared directory is mounted in the target runtime directory, in this case, when step 203 is executed, it may be: acquiring a file identifier of a mounted file under a target operation directory corresponding to a target user;
when a first identified file exists in the mounted file, determining a source directory hierarchy of the first identified file, wherein the file identifier of the first identified file is the same as the file identifier of a file in the target code file;
when the source directory hierarchy is lower than the directory hierarchy of the target code storage directory, mounting the target code file under the target code storage directory to the target operation directory, and covering the first peer identification file based on the target code file.
The source directory hierarchy refers to a hierarchy of a source directory of the first peer identity file, and the source directory is a directory in which a file in the directory is mounted to obtain the first peer identity file. For example, the first peer identification file is obtained by mounting a file in a shared directory, where the shared directory is a source directory, and a level of the shared directory in the directory hierarchy relationship is a source directory level.
That is, in the scenario where step 204 is executed before step 203 is executed, all the runtime environment files in the shared directory may be mounted in the target runtime directory, and then step 203 may be executed. In step 203, if the file identifier of some or some operating environment files is the same as the file identifier of some or some object code files in the operating environment files already mounted to the target operating directory, these operating environment files are the first co-identified files.
At this time, when the object code file is mounted, the first identity file may be directly overwritten by the object code file having the same file identity as the first identity file.
As shown in fig. 3, the shared directory stores a file a and a file B, and the target code storage directory stores a file a and a file C, where the file a in the shared directory has the same file name as the file a in the target code storage directory, the shared directory has the lowest hierarchy, and the target operating directory has the highest hierarchy.
If step 204 is executed first and step 203 is executed second, when step 203 is executed, the first common identification file (file a in the target operating directory) of file a in the target code storage directory already exists in the target operating directory, at this time, the source directory of the first common identification file is a shared directory, and the hierarchy of the source directory is lower than that of the target code storage directory, so that file a in the target code storage directory can be mounted in the target operating directory, and the original file a in the target operating directory is covered.
Specifically, the step of "overwriting the first peer identification file based on the object code file" may be to delete the corresponding first peer identification file after mounting the object code file having the same file identification as the first peer identification file, or may be to replace the file content in the corresponding first peer identification file with the file content of the object code file having the same file identification as the first peer identification file.
For another example, when step 203 and step 204 are executed simultaneously, file a and file C in the target code storage directory may be mounted in the target operation directory, and file B in the shared directory may be mounted in the target operation directory. Since the directory hierarchy of the shared directory is lower than that of the target code storage directory, the file a in the shared directory is not mounted.
For another example, if step 203 is executed first and then step 204 is executed, when step 204 is executed, the first common identification file of file a in the shared directory (file a in the target operating directory) already exists in the target operating directory, at this time, the source directory of the first common identification file is the target code storage directory, and the source directory level is higher than the directory level of the shared directory, so that file a in the shared directory may not be mounted.
204. And mounting the target operation environment file under the shared directory to a target operation directory based on the target code file, wherein the target operation environment file mounted under the target operation directory and the target code file do not have files with the same file identification.
The shared directory is used for storing the operating environment files shared by users of the code operating system.
The execution environment file is a file that can construct a desired environment for the execution of the object code file when the object code file is executed. For example, the runtime environment file may be an extension library of one or more programming languages, a compilation environment configuration file of one or more languages, and the like.
In some optional embodiments, when the target operating environment file in the shared directory is mounted in the target operating directory, only a part of the operating environment file required for operating the target code file may be mounted, and the part of the operating environment file may be used as the target operating environment file.
Or, besides a part of the operating environment files required by the target code file, other operating environment files may also be provided under the shared directory, and when mounting, all the operating environment files under the shared directory may be mounted under a target operating directory corresponding to a target user, and all the operating environment files include the target operating environment files.
In some alternative embodiments, a hierarchical relationship between various directories may be set, and specific operations when the target operating environment file is mounted may be determined according to the hierarchical relationship. For example, a directory hierarchy relationship exists between the target code storage directory, the target run directory, and the shared directory, with the shared directory having the lowest hierarchy and the target run directory having the highest hierarchy.
In the scenario that step 203 is executed first and then step 204 is executed, the step "mount the target operating environment file in the shared directory to the target operating directory based on the target code file" may include:
acquiring a file identifier of a mounted file in a target operation directory;
when a second identical identification file exists in the mounted files, determining the source directory hierarchy of the second identical identification file, wherein the file identification of the second identical identification file is the same as the file identification of the next operation environment file in the shared directory;
when the source directory hierarchy is higher than the directory hierarchy of the shared directory, determining a target operation environment file different from the file identifier of the second file with the same identifier from the operation environment files;
and mounting the target operation environment file to the target operation directory.
It can be understood that, in addition to the target code storage directory, the target run directory and the shared directory, other directories that satisfy the directory hierarchical relationship in the code run system may also be provided, and the category and the number of the directories in the directory hierarchical relationship are not limited in the embodiment of the present invention.
205. And operating the target code file mounted under the target operation directory based on the target operation environment file mounted under the target operation directory.
When the target code file mounted in the target operation directory is operated, the target code file can be operated on an independent terminal or operated at the cloud based on the cloud computing technology.
Among them, cloud computing (cloud computing) is a computing mode that distributes computing tasks over a resource pool formed by a large number of computers, so that various application systems can acquire computing power, storage space, and information services as needed. The network that provides the resources is referred to as the "cloud". Resources in the "cloud" appear to the user as being infinitely expandable and available at any time, available on demand, expandable at any time, and paid for on-demand.
Technical personnel can arrange the establishment and maintenance of programming programs and programming environments required by running codes in a cloud computing resource pool, users do not need to pay attention to details such as a computer operating system, language upgrading, library expanding installation and the like, and the users can be started and used after a browser is opened and a website is input or a client is opened.
In addition, after the cloud-based upgrading, when a user learns programming skills, if a large amount of CPU or GPU resources are consumed for operation, the programming skills can be distributed by a cloud computing platform, so that the performance limit of the personal computer is broken through.
Specifically, the step "operating the target code file mounted in the target operating directory based on the target operating environment file mounted in the target operating directory" may specifically include:
configuring a code operating environment required by the operation of the target code file based on the target operating environment file mounted in the target operating directory;
and operating the target code file mounted under the target operation directory according to the code operation environment.
The running-time system (run-time system) refers to an environment in which a semi-compiled running code is run on a target machine. The runtime environment is a way to run between compilers and interpreters.
For example, in the embodiment of the present invention, an Integrated Development Environment (IDE) may have been already arranged in a cloud computing resource pool corresponding to a personal computer of a user or a code running system, and when configuring a code running Environment, the target running Environment file may be connected to the IDE, so that the target running Environment file may be normally called when the target code file is run in the IDE.
It will be appreciated that since the shared directory stores the runtime environment files shared by the users of the code execution system, the shared directory and the runtime environment files therein are generally established before the users use the code execution system. That is to say, the code running method provided by the embodiment of the present invention may further include:
and establishing a pseudo root directory as a shared directory under the root directory of the code operating system, and storing an operating environment file in the shared directory.
The pseudo root directory is a directory established by a root directory of the simulation code operating system. When the pseudo root directory is created, the directory structure of the pseudo root directory and files stored in each level of directory under the pseudo root directory are the same as the actual root directory of the code operating system.
For example, the code operating system may be built based on the Linux system, and when the pseudo root directory is built, as shown in fig. 4, a directory may be built outside the Linux system root directory, and a complete os directory structure and necessary files (operating environment files) are included therein.
Wherein, the "/" directory at the top layer is the root directory of the linux system, and the "bin", "dev", "etc", "home", "lib" and "data" directories under the "/" directory are the operating system directory structures of the linux system.
The pseudo root directory is a directory structure of a "system" directory rebuilt under a "data" directory of the original linux system, and directory structures of a "bin", "dev", "etc", "home", "lib" and "data" directories under the "system" directory and the "system" directory are directories with the same structure as an operating system directory of the linux system.
By establishing the pseudo root directory, a user without the access authority of the root directory can be prevented from freely accessing the root directory, and the root directory of the code running system and files in the root directory are protected.
However, the above operation only prevents the user process from accessing the system file, and since the same pseudo root directory (such as/data/system/, shown in fig. 4) is shared among users, a malicious user can easily influence the operation of other normal users by modifying the file of this directory.
The first solution to be conceived is to solve this problem by copying the pseudo root directory (/ data/system /), one for each user independently. However, this solution has the disadvantage that each user has a copy of the pseudo root directory, which are identical, resulting in a significant waste of disk space.
In order to solve the problem, the embodiment of the invention creates an upper-level directory of a shared directory as a target code storage directory of a target user on the basis of the shared directory (a pseudo root directory);
and creating an upper directory of the code storage directory as a target operation directory of the target user.
Through the directory hierarchy relationship among all levels of directories and the mounting of files in the code storage directory and the shared directory, the file modification operation of a user can be avoided, and the influence on the files in the shared directory can be avoided.
The target code storage directory may be created simultaneously or non-simultaneously with the target run directory, for example, both the target code storage directory and the target run directory may be created immediately when a user activates the code running system, or the target code storage directory may be created when the user updates a local code file, the target run directory may be created when a code running request of the target user is obtained, and the like. The embodiment of the invention does not limit the creating time and the creating sequence of the target code storage directory and the target operation directory.
It can be understood that, in order to facilitate the technical staff to manage and debug the operating environment files in the root directory of the code operating system, a part of the user accounts may be set to have the right to access the root directory of the code operating system, and for a common user, the user does not have the right to access the root directory, but only has the right to access the shared directory. That is to say, the code running method provided by the embodiment of the present invention may further include:
acquiring a root directory access request of a target user, wherein the root directory access request comprises a user identifier of the target user;
judging whether the target user meets a preset root directory access condition or not according to the user identification of the target user;
and when the target user does not meet the root directory access condition, accessing the shared directory.
The preset root directory access condition may be that the user identifier of the target user is the same as the user identifier of the preset user with the root directory access right, or may be that the user identifier of the target user is the same as the user identifier of the preset user with the root directory access right, and the time for accessing the root directory is within the accessible time period, and so on.
Specifically, a directory switching command may be developed in advance by a technician, and when the target user is not a user who can access the root directory, the directory actually accessed by the user is switched from the root directory to the shared directory. That is, the step "accessing the shared directory when the target user does not satisfy the root directory access condition" may include:
when the target user does not meet the root directory access condition, calling a directory switching command;
switching the access directory from the root directory to a shared directory based on the directory switching command;
a shared directory is accessed.
The switching of the access directory may be switching when the user is accessing the directory, or switching of the access directory may be switching when the user starts the code operating system but does not actually access the directory.
In practical application, if the electronic device is a single electronic device facing a single user, the data can be only stored in a local file. In the embodiment of the invention, the data processing method can be a multi-user multi-device oriented method, and can store the data (including code files) of the users in a database. As shown in fig. 5, the code running method provided in the embodiment of the present invention may further include:
and responding to the program exit operation of the target user, storing the target code file into the database, and deleting the target code storage directory and the target running directory.
Correspondingly, when the user logs in on the same electronic device or different electronic devices, the code file required by the user can be obtained from the database. That is to say, the code running method provided by the embodiment of the present invention may further include:
acquiring a code acquisition request of a target user, wherein the code acquisition request comprises a user identifier of the target user;
acquiring a target code file corresponding to a target user from a database according to the user identification;
and storing the object code file into a pre-created object code storage directory.
As shown in fig. 5, a code file corresponding to each user may be stored in the database. When a target user starts the code running system (for example, the target user logs in a code running website corresponding to the code running system), the code running system may be triggered to request the control center of the cloud computing resource pool to allocate corresponding computing resources to the target user.
When the code running system has the computing resources required by code running, an IDE and an IDE Session corresponding to the target user can be created based on the computing resources, wherein the IDE Session is a Session between the code running website and the control center of the cloud computing resource pool. And an operation instruction of the target user on the code operation website can be sent to a control center of the cloud computing resource pool through the IDE Session.
The control center of the cloud computing resource pool can perform operations such as initializing a directory (for example, creating a target operation directory and a target code storage directory) in the computing resource corresponding to the target user, monitoring a local code file of the target user, reading a target code file corresponding to the target user from a database (reading the database, recovering the file), and starting an IDE in the computing resource corresponding to the target user based on an operation instruction of the user. And when the target user finishes using the code running system, the control center of the cloud computing resource pool can close the IDE and recycle the computing resources.
As can be seen from the above, in the embodiment of the present invention, a code edited by a user is stored in an object code storage directory as an object code file, an operating environment file required by the operating code is stored in a shared directory, and the object code file and an object operating environment file having no same file identifier as the object code file are mounted in the object operating directory during mounting, so that even if the user maliciously modifies the operating environment file, the maliciously modified operating environment file can be stored in the object code storage directory as the object code file, and does not affect the original operating environment file in the shared directory, so that a system or a device where a code operating process is located can be prevented from being damaged by a destructive code written by the user, and the security of the code operating environment is improved.
The method according to the preceding embodiment is illustrated in further detail below by way of example.
In the embodiment of the present invention, a server is taken as an example of a cloud computing server in conjunction with the system in fig. 1.
And (I) constructing a code operating system.
601. A development environment for a programming language is configured in a server.
For example, a development environment of one or more programming languages, such as C language, Python, JAVA, etc., may be arranged in a server of a cloud platform (cloud computing resource pool).
Technicians can arrange modules such as Jupyterlab, Code-server and the like in the cloud computing resource pool so as to provide corresponding services for users. Wherein JupyterLab is a Web-based interactive development environment for Jupyter notebook, code and data computing. The code-server is an online editor based on VScode, and is mainly used for realizing that any equipment can access VScode through a browser in the Linux server environment, and further realizing remote programming.
602. And establishing a pseudo root directory as a shared directory under the root directory of the code operating system, and storing an operating environment file in the shared directory.
The code running system can perform unified management on the computing resources of the cloud platform, such as scheduling and automatic capacity expansion of the computing resources.
The shared directory contains a complete os directory structure and necessary files (runtime environment files).
Thus, when the user runs the system using the code, as shown in fig. 4, the accessed root directory (/) is actually a directory (shared directory) under/data/system, and the real root directory user cannot access the root directory, and cannot cut back to the real root directory through a normal route.
And (II) the code runs the application of the system.
As shown in fig. 6, a specific flow of the code running method according to the embodiment of the present invention may be as follows:
603. the server acquires a system operation request of a target user and establishes communication with user equipment of the target user.
For example, when a user starts a code execution client installed on a personal terminal or logs in a code execution website, a user device used by the user may send a system execution request of a target user to a server.
After acquiring a system operation request of a target user, the server starts a programming environment (IDE) of the cloud end and establishes connection between the cloud end and the user equipment.
Specifically, the identity authentication can be created, and communication between the server at the cloud and the user equipment is realized through a server-side session technology.
604. The server creates an upper-level directory of the shared directory as a target code storage directory of a target user, and creates an upper-level directory of the code storage directory as a target running directory of the target user.
For example, as shown in FIG. 3, the code instrumentation system has three levels of directories outside the root directory. Wherein the content of the first and second substances,
lowerdir (shared directory): representing a directory with a lower layer, and modifying the file of the combined mounting point merged can not affect the lowerdir;
upperdir (object code storage directory): representing a directory of an upper layer, and synchronously modifying the file of the modified combined mounting point merged in the upperdir;
merge (target run catalog): the combined mount directory is formed by combining the lowerdir and the upperdir, and when the mount directory is mounted under the target operation directory, the upper-layer file covers the lower-layer file.
605. And the server monitors the file updating condition under a preset directory in the user equipment of the target user and updates the content of the target code file in the target code storage directory according to the file updating condition.
It can be understood that in the context of a cloud platform, service resources of the cloud platform are also limited, for example, each time a user opens an IDE, the runtime environments of jupyterab/code-server are dynamically generated and may be distributed on different servers, and when the user closes the IDE, resources related to these runtime environments are recycled and released, which results in changes made by the user and disappearance of the written code file. Thus, there is a need to do persistence work on the user's changes, save to the database, and restore the files from the database the next time the user opens the project using the IDE.
The first solution thought was to modify the relevant code of the saved file, saving its contents to be saved in the database. However, the method has the disadvantages that the source code of the Jupitertab/code-serve must be modified, and if the functions of the latest version of the Jupitertab/code-serve are needed subsequently, the code merging operation is carried out, so that the expansion efficiency is influenced. In addition, if a new IDE is to be extended, the code is modified once, which is not beneficial to the extension.
Specifically, in the embodiment of the present invention, the inotify feature provided by the Linux kernel may be utilized. inotify allows an application to listen for changes (e.g., create, write, delete, etc.) in a specified directory, and whenever these events occur, inotify sends a response message to the listening application in time.
In the embodiment of the invention, the preset directory in the user equipment of the target user can be specified in advance, and the preset directory stores the project engineering related files generated by the target user when writing the program. inotify may listen to a preset directory.
When a user has the operation of modifying and saving the file, the interface of the Jupyterlab/code-server stores the file into the local code file, the inotify detects that the local code file in the preset directory is updated, and the update event is notified to the service process of the server. And the service process of the server reads the corresponding file content in the local code file and stores the file content in the target code file through the updating events.
This scheme can save the relevant logic code without changing Jupitertlab/code-serv and easily extend the new IDE.
606. And the server acquires a code operation request of the target user, and determines a target code storage directory corresponding to the target user from a code storage directory of the code operation system according to the user identification.
For example, a namespace corresponding to the target user may be created in the code runtime system. When determining the target code storage directory, the namespace corresponding to the target user may be determined according to the user identifier, and the code storage directory in the namespace corresponding to the target user may be used as the target code storage directory.
Or, the target identifiers of all code storage directories of the code operating system may be acquired, the directory identifiers are matched with the user identifiers, and the code storage directory corresponding to the directory identifier successfully matched is used as the target code storage directory, and so on.
607. And the server mounts the target code file under the target code storage directory and the target operation environment file under the shared directory to a target operation directory corresponding to the target user.
For example, when the target code file and the target operation environment file are mounted, the shared directory has an a.txt file, the content is abcd, and the target code storage directory does not have the a.txt file, so that the user sees the content mounted to the a.txt file under the target operation directory, namely abcd.
If the shared directory has an a.txt file, the content is abcd, the target code storage directory also has an a.txt file, and the content is 1234, then the user sees the content of the a.txt in the target code storage directory mounted to the target running directory, which is 1234.
608. And the server operates the target code file mounted under the target operation directory based on the target operation environment file mounted under the target operation directory.
It will be appreciated that the server may return the results of the running of the object code file to the user device for display.
When the user exits the code running process or exits the code running system, the IDE in the server can be closed, and the occupied computing resources in the code running system can be recycled.
As can be seen from the above, in the embodiment of the present invention, a code edited by a user is stored in an object code storage directory as an object code file, an operating environment file required by the operating code is stored in a shared directory, and the object code file and an object operating environment file having no same file identifier as the object code file are mounted in the object operating directory during mounting, so that even if the user maliciously modifies the operating environment file, the maliciously modified operating environment file can be stored in the object code storage directory as the object code file, and does not affect the original operating environment file in the shared directory, so that a system or a device where a code operating process is located can be prevented from being damaged by a destructive code written by the user, and the security of the code operating environment is improved.
In order to better implement the above method, correspondingly, the embodiment of the present invention further provides a code running apparatus.
Referring to fig. 7, the apparatus includes:
a request obtaining unit 701, configured to obtain a code operation request of a target user, where the code operation request may include a user identifier of the target user;
a directory determining unit 702, configured to determine, according to the user identifier, a target code storage directory corresponding to a target user from a code storage directory of the code running system, where the code storage directory corresponds to users of the code running system one to one, and the code storage directory may be used to store code files corresponding to the target user;
a first mounting unit 703, configured to mount a target code file in a target code storage directory to a target operation directory corresponding to a target user, where the operation directories in the code operation system correspond to the users one to one, and the operation directory may be used to mount all files required by the corresponding target user when the code is operated;
a second mounting unit 704, configured to mount, based on the object code file, the object operating environment file in the shared directory under the object operating directory, where the shared directory may be used to store the operating environment file shared by the user of the code operating system, and no file with the same file identifier exists in the object operating environment file and the object code file mounted under the object operating directory;
the code running unit 705 may be configured to run the target code file mounted in the target running directory based on the target running environment file mounted in the target running directory.
In some optional embodiments, the second mount unit 704 may be configured to obtain an object code file identifier of each object code file, and an operating environment file identifier of each operating environment file in the shared directory;
determining a target operation environment file with different operation environment file identifications and all target code file identifications;
and mounting the target operation environment file to a target operation directory.
In some optional embodiments, a directory hierarchy relationship exists between the target code storage directory, the target operation directory and the shared directory, where the shared directory has the lowest hierarchy and the target operation directory has the highest hierarchy;
the first mount unit 703 may be configured to obtain a file identifier of a mounted file in a target operation directory corresponding to a target user;
when a first identified file exists in the mounted file, determining a source directory hierarchy of the first identified file, wherein the file identifier of the first identified file is the same as the file identifier of a file in the target code file;
when the source directory hierarchy is lower than the directory hierarchy of the target code storage directory, mounting a target code file under the target code storage directory to a target operation directory, and covering a first identity file based on the target code file;
a second mount unit 704, configured to obtain a file identifier of a mounted file in the target operating directory;
when a second identical identification file exists in the mounted files, determining the source directory hierarchy of the second identical identification file, wherein the file identification of the second identical identification file is the same as the file identification of the next operation environment file in the shared directory;
when the source directory hierarchy is higher than the directory hierarchy of the shared directory, determining a target operation environment file different from the file identifier of the second file with the same identifier from the operation environment files;
and mounting the target operation environment file to the target operation directory.
In some optional embodiments, as shown in fig. 8, the code operating apparatus provided in the embodiment of the present invention may further include a content updating unit 706, which is configured to monitor a file update condition under a preset directory in the user equipment of the target user, where the preset directory is a directory in the user equipment, where the code file is stored locally;
if the local code file corresponding to the target code file under the preset directory is updated, reading the updating content of the local code file;
and updating the file content of the target code file according to the updating content of the local code file to obtain a new target code file.
In some optional embodiments, the code running apparatus provided in the embodiment of the present invention may further include a space isolation unit 707, which may be configured to create a namespace corresponding to the target user;
creating a target code storage directory and a target operation directory in a name space corresponding to a target user;
correspondingly, the code running unit 705 may be configured to configure a code running environment required by the running of the target code file based on the target running environment file mounted in the target running directory in the namespace corresponding to the target user;
and operating the target code file mounted under the target operation directory according to the code operation environment.
In some optional embodiments, the code running apparatus provided in the embodiments of the present invention may further include a directory creating unit 708, configured to establish a pseudo root directory as a shared directory under a root directory of the code running system, and store the running environment file in the shared directory;
creating a superior directory of a shared directory as a target code storage directory of a target user;
and creating an upper directory of the code storage directory as a target operation directory of the target user.
In some optional embodiments, the code running apparatus provided in the embodiment of the present invention may further include a directory access unit 709, which may be configured to obtain a root directory access request of the target user, where the root directory access request may include a user identifier of the target user;
judging whether the target user meets a preset root directory access condition or not according to the user identification of the target user;
and when the target user does not meet the root directory access condition, accessing the shared directory.
In some optional embodiments, the directory access unit 709 may be configured to invoke a directory switch command when the target user does not satisfy the root directory access condition;
switching the currently accessed directory from the root directory to a shared directory based on the directory switching command;
a shared directory is accessed.
In some optional embodiments, the code execution apparatus provided in the embodiments of the present invention may further include a system quitting unit 710, configured to, in response to a system quitting operation of a target user, store the target code file in the database corresponding to the target user;
and deleting the target code storage directory and the target operation directory.
In some optional embodiments, the code running apparatus provided in the embodiments of the present invention may further include a file obtaining unit 711, which may be configured to obtain a code obtaining request of the target user, where the code obtaining request may include a user identifier of the target user;
acquiring a target code file corresponding to a target user from a database according to the user identification of the target user;
and storing the object code file into a pre-created object code storage directory.
Therefore, even if the user maliciously modifies the operation environment file, the maliciously modified operation environment file can be stored in the object code storage directory as the object code file, the original operation environment file in the shared directory cannot be influenced, damage to a system or equipment where a code operation process is located by destructive codes written by the user can be avoided, and the safety of the code operation environment is improved.
In addition, an embodiment of the present invention further provides an electronic device, where the electronic device may be a terminal or a server, and as shown in fig. 9, a schematic structural diagram of the electronic device according to the embodiment of the present invention is shown, specifically:
the electronic device may include Radio Frequency (RF) circuitry 901, memory 902 including one or more computer-readable storage media, input unit 903, display unit 904, sensor 905, audio circuitry 906, Wireless Fidelity (WiFi) module 907, processor 908 including one or more processing cores, and power supply 909. Those skilled in the art will appreciate that the electronic device configuration shown in fig. 9 does not constitute a limitation of the electronic device and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
RF circuit 901 may be used for receiving and transmitting signals during a message transmission or communication process, and in particular, for receiving downlink information from a base station and then processing the received downlink information by one or more processors 908; in addition, data relating to uplink is transmitted to the base station. In general, RF circuitry 901 includes, but is not limited to, an antenna, at least one Amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like. In addition, the RF circuit 901 can also communicate with a network and other devices through wireless communication. The wireless communication may use any communication standard or protocol, including but not limited to Global System for Mobile communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Message Service (SMS), and the like.
The memory 902 may be used to store software programs and modules, and the processor 908 executes various functional applications and data processing by operating the software programs and modules stored in the memory 902. The memory 902 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the electronic device, and the like. Further, the memory 902 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 902 may also include a memory controller to provide access to the memory 902 by the processor 908 and the input unit 903.
The input unit 903 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to target user settings and function control. In particular, in one particular embodiment, the input unit 903 may include a touch-sensitive surface as well as other input devices. The touch-sensitive surface, also referred to as a touch display screen or a touch pad, may collect touch operations by a target user (e.g., operations by the target user on or near the touch-sensitive surface using any suitable object or attachment such as a finger, a stylus, etc.) and drive the corresponding connection device according to a predetermined program. Alternatively, the touch sensitive surface may comprise two parts, a touch detection means and a touch controller. The touch detection device detects the touch direction of a target user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 908, and receives and executes commands from the processor 908. In addition, touch sensitive surfaces may be implemented using various types of resistive, capacitive, infrared, and surface acoustic waves. The input unit 903 may include other input devices in addition to a touch-sensitive surface. In particular, other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 904 may be used to display information input by or provided to a target user as well as various graphical target user interfaces of the electronic device, which may be made up of graphics, text, icons, video, and any combination thereof. The Display unit 904 may include a Display panel, and may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. Further, the touch-sensitive surface may overlay the display panel, and when a touch operation is detected on or near the touch-sensitive surface, the touch operation is communicated to the processor 908 to determine the type of touch event, and the processor 908 provides a corresponding visual output on the display panel according to the type of touch event. Although in FIG. 6 the touch-sensitive surface and the display panel are two separate components to implement input and output functions, in some embodiments the touch-sensitive surface may be integrated with the display panel to implement input and output functions.
The electronic device may also include at least one sensor 905, such as light sensors, motion sensors, and other sensors. In particular, the light sensor may include an ambient light sensor that may adjust the brightness of the display panel according to the brightness of ambient light, and a proximity sensor that may turn off the display panel and/or the backlight when the electronic device is moved to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when the mobile phone is stationary, can be used for applications for recognizing the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor and the like which can be configured for the electronic device, and are not described herein again.
Audio circuitry 906, a speaker, and a microphone may provide an audio interface between the target user and the electronic device. The audio circuit 906 may transmit the electrical signal converted from the received audio data to a speaker, and the electrical signal is converted into a sound signal by the speaker and output; on the other hand, the microphone converts the collected sound signal into an electric signal, which is received by the audio circuit 906 and converted into audio data, which is then processed by the audio data output processor 908, and then transmitted to, for example, another electronic device via the RF circuit 901, or the audio data is output to the memory 902 for further processing. The audio circuitry 906 may also include an earbud jack to provide communication of a peripheral headset with the electronic device.
WiFi belongs to short-distance wireless transmission technology, and the electronic equipment can help a target user to send and receive e-mails, browse webpages, access streaming media and the like through the WiFi module 907, and provides wireless broadband internet access for the target user. Although fig. 6 shows the WiFi module 907, it is understood that it does not belong to the essential constitution of the electronic device, and may be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 908 is a control center of the electronic device, connects various parts of the entire cellular phone using various interfaces and lines, and performs various functions of the electronic device and processes data by operating or executing software programs and/or modules stored in the memory 902 and calling data stored in the memory 902, thereby performing overall monitoring of the cellular phone. Optionally, processor 908 may include one or more processing cores; preferably, the processor 908 may integrate an application processor, which primarily handles operating systems, target user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It is to be appreciated that the modem processor described above may not be integrated into processor 908.
The electronic device also includes a power supply 909 (e.g., a battery) that provides power to the various components, which may preferably be logically coupled to the processor 908 via a power management system, such that the functions of managing charging, discharging, and power consumption are performed via the power management system. The power supply 909 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
Although not shown, the electronic device may further include a camera, a bluetooth module, and the like, which are not described in detail herein. Specifically, in this embodiment, the processor 908 in the electronic device loads an executable file corresponding to a process of one or more application programs into the memory 902 according to the following instructions, and the processor 908 runs the application programs stored in the memory 902, thereby implementing various functions as follows:
acquiring a code operation request of a target user, wherein the code operation request comprises a user identifier of the target user;
determining a target code storage directory corresponding to a target user from a code storage directory of a code operating system according to a user identifier, wherein the code storage directory corresponds to users of the code operating system one by one, and the code storage directory is used for storing code files of the corresponding users;
mounting target code files in a target code storage directory to a target operation directory corresponding to a target user, wherein the operation directories in the code operation system correspond to the users one by one, and the operation directories are used for mounting all files required by the corresponding users when the codes are operated;
based on the target code file, mounting the target operation environment file under the shared directory under the target operation directory, wherein the shared directory is used for storing the operation environment file shared by users of the code operation system, and the target operation environment file mounted under the target operation directory and the target code file do not have files with the same file identification;
and operating the target code file mounted under the target operation directory based on the target operation environment file mounted under the target operation directory.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, the embodiment of the present invention provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the code execution methods provided by the embodiment of the present invention. For example, the instructions may perform the steps of:
acquiring a code operation request of a target user, wherein the code operation request comprises a user identifier of the target user;
determining a target code storage directory corresponding to a target user from a code storage directory of a code operating system according to a user identifier, wherein the code storage directory corresponds to users of the code operating system one by one, and the code storage directory is used for storing code files of the corresponding users;
mounting target code files in a target code storage directory to a target operation directory corresponding to a target user, wherein the operation directories in the code operation system correspond to the users one by one, and the operation directories are used for mounting all files required by the corresponding users when the codes are operated;
based on the target code file, mounting the target operation environment file under the shared directory under the target operation directory, wherein the shared directory is used for storing the operation environment file shared by users of the code operation system, and the target operation environment file mounted under the target operation directory and the target code file do not have files with the same file identification;
and operating the target code file mounted under the target operation directory based on the target operation environment file mounted under the target operation directory.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Wherein the computer-readable storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
Since the instructions stored in the computer-readable storage medium can execute the steps in any code execution method provided by the embodiment of the present invention, the beneficial effects that can be achieved by any code execution method provided by the embodiment of the present invention can be achieved, which are detailed in the foregoing embodiments and will not be described again here.
According to an aspect of the application, there is also provided a computer program product or a computer program comprising computer instructions stored in a computer readable storage medium. The processor of the electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the method provided in the various alternative implementations in the above embodiments.
The above detailed description is provided for a code running method, apparatus, electronic device, storage medium and program product according to the embodiments of the present invention, and a specific example is applied in this document to explain the principle and the implementation of the present invention, and the description of the above embodiments is only used to help understanding the method and the core idea of the present invention; meanwhile, for those 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.

Claims (14)

1. A method for code execution, comprising:
acquiring a code running request of a target user, wherein the code running request comprises a user identifier of the target user;
determining a target code storage directory corresponding to the target user from a code storage directory of a code operating system according to the user identification, wherein the code storage directory corresponds to the users of the code operating system one by one, and the code storage directory is used for storing code files of the corresponding users;
mounting the target code files in the target code storage directory to a target operation directory corresponding to the target user, wherein the operation directories in the code operation system correspond to the users one by one, and the operation directories are used for mounting all files required by the corresponding users when the codes are operated;
based on the target code file, mounting a target operation environment file in a shared directory to the target operation directory, wherein the shared directory is used for storing operation environment files shared by users of the code operation system, and the target operation environment file mounted in the target operation directory and the target code file do not have files with the same file identification;
and operating the target code file mounted in the target operation directory based on the target operation environment file mounted in the target operation directory.
2. The code execution method of claim 1, wherein the mounting, based on the target code file, a target execution environment file in a shared directory under the target execution directory comprises:
acquiring an object code file identifier of each object code file and an operating environment file identifier of each operating environment file in a shared directory;
determining a target operation environment file with different operation environment file identifications and all target code file identifications;
and mounting the target operation environment file to the target operation directory.
3. The code execution method according to claim 1, wherein a directory hierarchy relationship exists among the target code storage directory, the target run directory, and the shared directory, the shared directory having a lowest hierarchy and the target run directory having a highest hierarchy;
the mounting the target code file in the target code storage directory to the target operation directory corresponding to the target user includes:
acquiring a file identifier of a mounted file in a target operation directory corresponding to the target user;
when a first identified file exists in the mounted file, determining a source directory hierarchy of the first identified file, wherein the file identifier of the first identified file is the same as the file identifier of a file in the target code file;
when the source directory hierarchy is lower than the directory hierarchy of the target code storage directory, mounting a target code file under the target code storage directory to the target operation directory, and covering the first common identification file based on the target code file;
the mounting of the target operation environment file in the shared directory to the target operation directory based on the target code file comprises the following steps:
acquiring a file identifier of a mounted file in the target operation directory;
when a second identical identification file exists in the mounted files, determining the source directory hierarchy of the second identical identification file, wherein the file identification of the second identical identification file is the same as the file identification of a next operation environment file in the shared directory;
when the source directory hierarchy is higher than the directory hierarchy of the shared directory, determining a target operation environment file which is different from the file identifier of the second identified file from the operation environment files;
and mounting the target operation environment file to the target operation directory.
4. The code execution method according to claim 1, wherein before the obtaining of the code execution request of the target user, the method further comprises:
monitoring the file updating condition under a preset directory in user equipment of the target user, wherein the preset directory is a directory of a local storage code file in the user equipment;
if the local code file corresponding to the target code file under the preset directory is updated, reading the updating content of the local code file;
and updating the file content of the target code file according to the updating content of the local code file to obtain a new target code file.
5. The code execution method according to claim 1, wherein before the obtaining of the code execution request of the target user, the method further comprises:
creating a namespace corresponding to the target user;
creating the target code storage directory and the target operation directory in a name space corresponding to the target user;
the operating the target code file mounted in the target operation directory based on the target operation environment file mounted in the target operation directory includes:
configuring a code operating environment required by the operation of the target code file in a name space corresponding to the target user based on the target operating environment file mounted in the target operating directory;
and operating the target code file mounted in the target operation directory according to the code operation environment.
6. The code execution method of claim 1, further comprising:
establishing a pseudo root directory as the shared directory under a root directory of the code operating system, and storing the operating environment file in the shared directory;
creating a superior directory of the shared directory as the target code storage directory of the target user;
and creating an upper-level directory of the code storage directory as a target operation directory of the target user.
7. The code execution method of claim 6, further comprising:
acquiring a root directory access request of the target user, wherein the root directory access request comprises a user identifier of the target user;
judging whether the target user meets a preset root directory access condition or not according to the user identifier of the target user;
and when the target user does not meet the root directory access condition, accessing the shared directory.
8. The code execution method of claim 7, wherein the accessing the shared directory when the target user does not satisfy the root directory access condition comprises:
when the target user does not meet the root directory access condition, calling a directory switching command;
switching the currently accessed directory from the root directory to the shared directory based on the directory switching command;
the shared directory is accessed.
9. The code execution method of any one of claims 1-8, wherein the method further comprises:
responding to the system exit operation of the target user, and storing the target code file corresponding to the target user into a database;
and deleting the target code storage directory and the target operation directory.
10. The code execution method of claim 9, further comprising:
acquiring a code acquisition request of the target user, wherein the code acquisition request comprises a user identifier of the target user;
acquiring the target code file corresponding to the target user from the database according to the user identification of the target user;
and storing the object code file into the object code storage directory created in advance.
11. A code-running apparatus, comprising:
the code execution device comprises a request acquisition unit, a code execution unit and a code execution unit, wherein the request acquisition unit is used for acquiring a code execution request of a target user, and the code execution request comprises a user identifier of the target user;
the directory determining unit is used for determining a target code storage directory corresponding to the target user from a code storage directory of a code operating system according to the user identification, wherein the code storage directory is in one-to-one correspondence with the users of the code operating system, and the code storage directory is used for storing code files of the corresponding users;
the first mounting unit is used for mounting target code files in the target code storage directory to a target operation directory corresponding to the target user, wherein the operation directories in the code operation system correspond to the users one by one, and the operation directories are used for mounting all files required by the corresponding users when the users operate codes;
a second mounting unit, configured to mount, based on the target code file, a target operating environment file in a shared directory to the target operating directory, where the shared directory is used to store an operating environment file shared by a user of the code operating system, and there is no file with the same file identifier in the target operating environment file and the target code file mounted in the target operating directory;
and the code running unit is used for running the target code file mounted in the target running directory based on the target running environment file mounted in the target running directory.
12. An electronic device comprising a memory and a processor; the memory stores an application program, and the processor is configured to execute the application program in the memory to perform the steps of the code execution method according to any one of claims 1 to 10.
13. A computer readable storage medium storing instructions adapted to be loaded by a processor to perform the steps of the code execution method of any one of claims 1 to 10.
14. A computer program product comprising a computer program or instructions, characterized in that the computer program or instructions, when executed by a processor, implement the steps of a code execution method according to any one of claims 1 to 10.
CN202111297637.8A 2021-11-04 2021-11-04 Code running method, device, electronic equipment, storage medium and program product Active CN113742716B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111297637.8A CN113742716B (en) 2021-11-04 2021-11-04 Code running method, device, electronic equipment, storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111297637.8A CN113742716B (en) 2021-11-04 2021-11-04 Code running method, device, electronic equipment, storage medium and program product

Publications (2)

Publication Number Publication Date
CN113742716A true CN113742716A (en) 2021-12-03
CN113742716B CN113742716B (en) 2022-02-08

Family

ID=78727325

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111297637.8A Active CN113742716B (en) 2021-11-04 2021-11-04 Code running method, device, electronic equipment, storage medium and program product

Country Status (1)

Country Link
CN (1) CN113742716B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115629772A (en) * 2022-09-05 2023-01-20 摩尔线程智能科技(北京)有限责任公司 Kubernetes software installation method and device and electronic equipment

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103488517A (en) * 2013-09-10 2014-01-01 新浪网技术(中国)有限公司 PHP code compiling method and device and PHP code running method and device
US20170161034A1 (en) * 2015-12-03 2017-06-08 International Business Machines Corporation Improving application code execution performance by consolidating accesses to shared resources
US20180060344A1 (en) * 2016-08-31 2018-03-01 Ca, Inc. Merging file storage directory structures through user interface visualization of refactoring decisions
CN109684822A (en) * 2018-12-30 2019-04-26 深圳开立生物医疗科技股份有限公司 Multi-user access environment configurations method, apparatus, equipment and multi-line system
CN112256399A (en) * 2020-10-28 2021-01-22 四川长虹电器股份有限公司 Docker-based Jupyter Lab multi-user remote development method and system
CN112698921A (en) * 2021-01-08 2021-04-23 腾讯科技(深圳)有限公司 Logic code operation method and device, computer equipment and storage medium
CN113094613A (en) * 2021-04-28 2021-07-09 上海商汤智能科技有限公司 Online programming system, online programming method and related product

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103488517A (en) * 2013-09-10 2014-01-01 新浪网技术(中国)有限公司 PHP code compiling method and device and PHP code running method and device
US20170161034A1 (en) * 2015-12-03 2017-06-08 International Business Machines Corporation Improving application code execution performance by consolidating accesses to shared resources
US20180060344A1 (en) * 2016-08-31 2018-03-01 Ca, Inc. Merging file storage directory structures through user interface visualization of refactoring decisions
CN109684822A (en) * 2018-12-30 2019-04-26 深圳开立生物医疗科技股份有限公司 Multi-user access environment configurations method, apparatus, equipment and multi-line system
CN112256399A (en) * 2020-10-28 2021-01-22 四川长虹电器股份有限公司 Docker-based Jupyter Lab multi-user remote development method and system
CN112698921A (en) * 2021-01-08 2021-04-23 腾讯科技(深圳)有限公司 Logic code operation method and device, computer equipment and storage medium
CN113094613A (en) * 2021-04-28 2021-07-09 上海商汤智能科技有限公司 Online programming system, online programming method and related product

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115629772A (en) * 2022-09-05 2023-01-20 摩尔线程智能科技(北京)有限责任公司 Kubernetes software installation method and device and electronic equipment
CN115629772B (en) * 2022-09-05 2023-09-19 摩尔线程智能科技(北京)有限责任公司 Kubernetes software installation method and device and electronic equipment

Also Published As

Publication number Publication date
CN113742716B (en) 2022-02-08

Similar Documents

Publication Publication Date Title
CN113110941B (en) Managing delivery of code and dependency data using application containers
CN106970790B (en) Application program creating method, related equipment and system
CN106502703B (en) Function calling method and device
CN109857403B (en) Page updating method and device, page processing method and device
US10684838B2 (en) Dynamic application deployment
CN111338646B (en) Management method of micro-service architecture and related device
CN108287918B (en) Music playing method and device based on application page, storage medium and electronic equipment
CN114185491B (en) Partition file downloading method and device, storage medium and computer equipment
CN111124412B (en) Game page drawing method, device, equipment and storage medium
CN112130866A (en) Application deployment method and related device
WO2022042233A1 (en) Application interface migration system, method, and related device
CN111330280A (en) Data processing method and device in game, storage medium and electronic equipment
EP3374858A1 (en) Creating and modifying applications from a mobile device
CN113742716B (en) Code running method, device, electronic equipment, storage medium and program product
EP4296849A1 (en) Accelerating application and sub-package installations
CN106095423B (en) Method, terminal and server for providing browsing service
CN107423291B (en) Data translation method and client device
CN111625250B (en) Application updating method and device, storage medium and electronic equipment
CN113176899A (en) Operation method of multi-android operating system and terminal equipment
CN103309677A (en) Built-in resource management method, device and terminal
CN116594616A (en) Component configuration method and device and computer readable storage medium
CN114676371A (en) Page element information replacement method and device, computer equipment and storage medium
CN114095533A (en) Cloud game account login method and device, computer equipment and storage medium
CN110489679B (en) Browser kernel processing method and device and storage medium
CN104156227B (en) Call the method and device in bottom library

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant