Linux operation » History » Version 1
jun chen, 04/22/2025 04:40 PM
1 | 1 | jun chen | # Linux operation |
---|---|---|---|
2 | |||
3 | |||
4 | ## owner wrapper |
||
5 | |||
6 | 如果需要征用其他人权限,移交文件所属权 |
||
7 | |||
8 | Wrapper script |
||
9 | |||
10 | ``` |
||
11 | g++ getid.cpp -O3 -o br_pc_wrapper |
||
12 | chmod +s br_pc_wrapper |
||
13 | ``` |
||
14 | |||
15 | Wrapper code |
||
16 | |||
17 | ``` |
||
18 | #include <unistd.h> |
||
19 | #include <sys/types.h> |
||
20 | #include <stdio.h> |
||
21 | #include <stdlib.h> |
||
22 | #include <cstring> |
||
23 | |||
24 | real_uid = getuid(); |
||
25 | effective_uid = getuid(); |
||
26 | seteuid(4219); |
||
27 | setuid(4219); |
||
28 | setreuid(4249, 4249); |
||
29 | system(argv[1]); |
||
30 | |||
31 | ``` |