2 * Copyright 2021 Andrei Pangin
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <sys/types.h>
24 extern char tmp_path[];
26 // Gets /tmp path of the specified process, as it can be accessed from the host.
27 // The obtained path is stored in the global tmp_path buffer.
28 void get_tmp_path(int pid);
30 // The reentrant version of get_tmp_path.
31 // Stores the process-specific temporary path into the provided buffer.
32 // Returns 0 on success, -1 on failure.
33 int get_tmp_path_r(int pid, char* buf, size_t bufsize);
35 // Gets the owner uid/gid of the target process, and also its pid inside the container.
36 // Returns 0 on success, -1 on failure.
37 int get_process_info(int pid, uid_t* uid, gid_t* gid, int* nspid);
39 // Tries to enter the namespace of the target process.
40 // type of the namespace can be "mnt", "net", "pid", etc.
41 // Returns 1, if the namespace has been successfully changed,
42 // 0, if the target process is in the same namespace as the host,
43 // -1, if the attempt failed.
44 int enter_ns(int pid, const char* type);