Skip to content

Commit fa5fdb7

Browse files
Merge branch 'master' into fix/sys_pread64
2 parents a756668 + 54c2a45 commit fa5fdb7

File tree

50 files changed

+1399
-339
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1399
-339
lines changed

.github/workflows/makefile.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ jobs:
1111
name: Format check ${{ matrix.arch }}
1212
runs-on: ubuntu-latest
1313
continue-on-error: true
14-
container: dragonos/dragonos-dev:v1.16
14+
container: dragonos/dragonos-dev:v1.17
1515

1616
strategy:
1717
matrix:
1818
arch: [x86_64, riscv64, loongarch64]
1919

2020
steps:
21-
- run: echo "Running in dragonos/dragonos-dev:v1.16"
21+
- run: echo "Running in dragonos/dragonos-dev:v1.17"
2222
- uses: actions/checkout@v3
2323

2424
- name: Format check
@@ -36,14 +36,14 @@ jobs:
3636
name: Kernel static test ${{ matrix.arch }}
3737
runs-on: ubuntu-latest
3838
continue-on-error: true
39-
container: dragonos/dragonos-dev:v1.16
39+
container: dragonos/dragonos-dev:v1.17
4040

4141
strategy:
4242
matrix:
4343
arch: [x86_64, riscv64, loongarch64]
4444

4545
steps:
46-
- run: echo "Running in dragonos/dragonos-dev:v1.16"
46+
- run: echo "Running in dragonos/dragonos-dev:v1.17"
4747

4848
- uses: actions/checkout@v3
4949

@@ -57,7 +57,7 @@ jobs:
5757
build:
5858
name: Build ${{ matrix.arch }}
5959
runs-on: ubuntu-latest
60-
container: dragonos/dragonos-dev:v1.16
60+
container: dragonos/dragonos-dev:v1.17
6161
continue-on-error: true
6262
strategy:
6363
matrix:
@@ -74,7 +74,7 @@ jobs:
7474
checkout_params: {}
7575

7676
steps:
77-
- run: echo "Running in dragonos/dragonos-dev:v1.16"
77+
- run: echo "Running in dragonos/dragonos-dev:v1.17"
7878

7979
- uses: actions/checkout@v3
8080
with: ${{ matrix.checkout_params }}

.github/workflows/test-x86.yml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
timeout-minutes: 60
2121
container:
22-
image: dragonos/dragonos-dev:v1.16
22+
image: dragonos/dragonos-dev:v1.17
2323
options: --privileged -v /dev:/dev
2424
steps:
2525
- name: Checkout DragonOS code
@@ -32,15 +32,15 @@ jobs:
3232
make -j$(nproc) all
3333
3434
- name: Run syscall test
35+
id: test-syscall
3536
shell: bash -ileo pipefail {0}
36-
continue-on-error: true
3737
env:
3838
DISK_SAVE_MODE: "1"
3939
run: |
4040
make test-syscall
4141
4242
- name: Upload test results
43-
if: github.repository == 'DragonOS-Community/DragonOS'
43+
if: always() && github.repository == 'DragonOS-Community/DragonOS'
4444
shell: bash -ileo pipefail {0}
4545
env:
4646
API_KEY: ${{ secrets.CI_DASHBOARD_UPLOAD_API_KEY }}
@@ -69,22 +69,28 @@ jobs:
6969
BRANCH_NAME="${{ github.head_ref }}"
7070
fi
7171
72-
# 检查API_KEY是否存在
73-
if [ -z "$API_KEY" ]; then
74-
echo "警告: CI_DASHBOARD_UPLOAD_API_KEY secret未设置,跳过上传"
75-
exit 0
76-
fi
77-
7872
# 检查日志文件是否存在
7973
if [ ! -f "serial_opt.txt" ]; then
8074
echo "警告: serial_opt.txt文件不存在,跳过上传"
8175
exit 0
8276
fi
8377
84-
# 上传测试结果
85-
python3 tools/test-upload/parse_and_upload.py \
86-
serial_opt.txt \
87-
"$API_URL" \
88-
--branch "$BRANCH_NAME" \
89-
--commit "$COMMIT_ID" \
90-
--test-type "gvisor"
78+
# 检查API_KEY是否存在,如果不存在则使用dry-run模式
79+
if [ -z "$API_KEY" ]; then
80+
echo "警告: CI_DASHBOARD_UPLOAD_API_KEY secret未设置,使用dry-run模式"
81+
python3 tools/test-upload/parse_and_upload.py \
82+
serial_opt.txt \
83+
"$API_URL" \
84+
--branch "$BRANCH_NAME" \
85+
--commit "$COMMIT_ID" \
86+
--test-type "gvisor" \
87+
--dry-run
88+
else
89+
# 上传测试结果
90+
python3 tools/test-upload/parse_and_upload.py \
91+
serial_opt.txt \
92+
"$API_URL" \
93+
--branch "$BRANCH_NAME" \
94+
--commit "$COMMIT_ID" \
95+
--test-type "gvisor"
96+
fi

docs/.translation_cache.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@
264264
"hash": "8b840ec6af5782d8f793f746b1061ed9"
265265
},
266266
"en:index.rst": {
267-
"hash": "58f858acd19efc845ebef5dd55ec8375"
267+
"hash": "139ea63381896ae9f861c37ca13c888d"
268268
},
269269
"en:questions/index.rst": {
270270
"hash": "b1cee9bfde04d6375f24c93a29ce3c71"
@@ -282,7 +282,7 @@
282282
"hash": "de9331f8d0bc5fe8c4705ad5807c9e8d"
283283
},
284284
"en:kernel/net/index.rst": {
285-
"hash": "3fe30ab290231ef4507a358d86fb3021"
285+
"hash": "2b7f07b2896787800e902f9f4bb5d2e4"
286286
},
287287
"en:kernel/net/inet.md": {
288288
"hash": "549622e87eeafbeae8fed7f84aba5db9"
@@ -310,5 +310,8 @@
310310
},
311311
"en:community/ChangeLog/V0.3.x/V0.3.0.md": {
312312
"hash": "a3b5ae01c7a5f3ad9d26f71b54d01790"
313+
},
314+
"en:kernel/net/ssh.md": {
315+
"hash": "7ebf2f5934c0ef1ff4f922e48d5d1748"
313316
}
314317
}

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
kernel/net/index
4949
kernel/trace/index
5050
kernel/syscall/index
51+
kernel/device/index
5152

5253

5354

docs/kernel/net/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ DragonOS 网络子系统
66
:maxdepth: 1
77

88
inet
9-
unix
9+
unix
10+
ssh

docs/kernel/net/ssh.md

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
# ssh支持
2+
3+
4+
5+
目前,我们使用一个轻量级的ssh实现[dropbear](https://matt.ucc.asn.au/dropbear/dropbear.html)
6+
7+
8+
## 初始化步骤
9+
10+
1. 确保/bin/sh存在(应该已经存在,其实是busybox,如果不存在,可以拷贝sysroot/bin目录下的busybox文件: `cp ./bin/sysroot/bin/busybox ./bin/sysroot/bin/sh`)
11+
2. 确保/root目录存在(应该已经存在)
12+
3. 确保/etc/dropbear目录存在
13+
```shell
14+
mkdir /etc/dropbear
15+
```
16+
4. 确保 /var/log/lastlog文件存在(可以是空文件)(不存在也行)
17+
5. 修改root用户的密码
18+
```shell
19+
busybox passwd
20+
```
21+
6. 启动系统后启动dropbear服务器
22+
```shell
23+
dropbear -E -F -R -p 12580
24+
```
25+
26+
7. 在本地终端中连接到服务器
27+
```shell
28+
./dbclient -p 12580 root@localhos
29+
```
30+
如果报错:
31+
```shell
32+
./dbclient: Connection to root@localhost:12580 exited:
33+
34+
ssh-ed25519 host key mismatch for localhost !
35+
Fingerprint is SHA256:hK2KR5QQnSHpcHLYzCVe9IyKEw1NwIXx41K/gyv7NKI
36+
Expected SHA256:W8+kSk+aCm2uoc1ZIKU/RQJSKoqWrOKrFf9URhfFaw8
37+
If you know that the host key is correct you can
38+
remove the bad entry from ~/.ssh/known_hosts
39+
```
40+
解决方法:`ssh-keygen -R localhost` 删除已存在的错误host key
41+
8. 输入root用户的密码,成功登录后即可使用ssh终端
42+
9. 退出ssh终端
43+
```shell
44+
exit
45+
```
46+
47+
48+
## 其它可用命令
49+
50+
生成ssh密钥对
51+
```shell
52+
# 生成dropbear的ssh密钥对
53+
dropbearkey -t rsa -f ~/.ssh/id_dropbear
54+
```
55+
56+
将公钥添加到授权列表
57+
```shell
58+
# 拷贝公钥到指定目录
59+
cp ~/.ssh/id_dropbear.pub ./bin/sysroot
60+
61+
# 使用私钥连接到服务器
62+
./dbclient -i ~/.ssh/id_dropbear -p 12580 root@localhost
63+
```
64+
65+
66+
## SSH相关的系统文件介绍
67+
68+
### /etc/passwd 的作用
69+
70+
- 存储系统用户信息:它包含了每个用户的基本信息,是系统认证和登录的重要数据来源。
71+
72+
- 用于登录和用户管理:系统和应用程序通过读取该文件来验证用户身份、决定用户权限以及加载相应的设置(如默认 shell、主目录等)。
73+
74+
- 提供支持:对于一些应用程序和命令(如 useradd、passwd、chown),它需要通过 /etc/passwd 来获取用户的相关信息。
75+
76+
```bash
77+
username:password:UID:GID:GECOS:home_directory:shell
78+
```
79+
80+
- username(用户名):用户的登录名称。例如:root、john、guest 等。
81+
82+
- password(密码):用户的加密密码。现在大多数系统会将密码的哈希值存储在 /etc/shadow 文件中,因此这个字段通常是一个占位符(如 x 或 *)。在较旧的系统中,密码可能直接存储在此字段中,但这种做法已不安全。
83+
84+
- UID(用户 ID):用户的唯一标识符。每个用户都有一个唯一的 UID,系统通过它来区分不同用户。通常:
85+
86+
- 0 表示 root 用户(超级用户)。
87+
88+
- 普通用户的 UID 从 1000 开始(在一些 Linux 发行版中,可能从 500 开始)。
89+
90+
- GID(组 ID):用户所属的主组的 ID。组 ID 是与组名称相关联的数字。通常,每个用户都会有一个与其用户名相同的组。例如,john 用户可能会有一个主组 john,其 GID 可能是 1001。
91+
92+
- GECOS(用户全名或备注信息):这个字段通常存储用户的全名、电话号码等可选信息。它可以为空或包含一些描述性文字,通常是通过 chfn 命令进行设置。
93+
94+
- home_directory(主目录):用户的登录主目录,用户登录后会被自动带到这个目录。例如:/home/john、/root。如果用户是 root,其主目录通常是 /root。
95+
96+
- shell(默认 shell):用户登录时所使用的 shell 程序。通常是 /bin/bash、/bin/sh 或其他 shell 程序。对于没有实际登录权限的系统用户,这个字段可能是 /usr/sbin/nologin 或 /bin/false,以阻止他们登录系统
97+
98+
99+
### /etc/shadow 文件的作用
100+
101+
- 存储用户的加密密码:/etc/shadow 文件中保存了每个用户的 加密密码,而不是明文密码。这是一个系统的安全机制,防止密码泄漏。
102+
103+
- 账户过期管理:它还包含了与账户过期、密码过期、账户锁定等相关的信息,帮助系统管理员管理用户的登录权限。
104+
105+
- 增强安全性:相比于早期系统中把密码直接存储在 /etc/passwd 中,/etc/shadow 将密码从可公开访问的文件中移除,使得系统更加安全
106+
107+
```bash
108+
username:password:lastchg:min:max:warn:inactive:expire:flag
109+
```
110+
111+
- username(用户名):与 /etc/passwd 中的用户名一致。
112+
113+
- password(密码):这是用户的加密密码。如果密码为空,通常是 *!,表示禁用该账户。正常情况下,这里存储的是密码的加密哈希值。
114+
115+
- lastchg(上次修改日期):密码最后一次修改的日期,表示自 1970 年 1 月 1 日以来的天数。通常这个值是通过 chage 命令查看和更新的。
116+
117+
- min(最小密码年龄):密码的最小使用期限。用户修改密码后,必须等待多少天才能再次修改密码。通常设置为 0,表示没有最小密码年龄限制。
118+
119+
- max(最大密码年龄):密码的最大使用期限。超过这个期限,用户必须修改密码。设置为 99999 表示密码永不过期。
120+
121+
- warn(警告期限):密码过期前,系统会提前多少天开始警告用户密码即将过期。
122+
123+
- inactive(非活动期限):密码过期后,用户仍然有多少天的时间可以继续登录。如果超过该天数,账户将被禁用。
124+
125+
- expire(账户过期日期):账户的过期日期,表示自 1970 年 1 月 1 日以来的天数。如果账户过期,用户将无法登录。
126+
127+
- flag(账户锁定标志):这个字段用于存储账户是否被锁定。如果这个字段是 !!*,表示用户账号被锁定,不能登录
128+
129+
### 不同hash算法生成的密码前缀
130+
131+
- `\$5$` 前缀(SHA-256)
132+
- `\$6$` 前缀(SHA-512)
133+
- `\$y$` 前缀(Yarrow)
134+
135+
136+
137+
138+
139+
### 系统调用支持
140+
141+
- fcntl SETLK https://man7.org/linux/man-pages/man2/fcntl.2.html
142+
- unlink
143+
- fsync
144+
- rename https://man7.org/linux/man-pages/man2/rename.2.html
145+
- ioctl TCFLSH
146+
- renameat2: oldfd: -100, filename_from: /etc/shadow+, newfd: -100, filename_to: /etc/shadow 失败
147+
148+
149+
150+
### 文件系统相关
151+
/proc/self目录:/proc/self 是一个 符号链接,始终指向 访问它的进程自己的 /proc/[pid] 目录
152+
153+
| 路径 | 作用 |
154+
| -------------------- | ---------------------------------------- |
155+
| `/proc/self/cmdline` | 当前进程的命令行参数 |
156+
| `/proc/self/exe` | 当前进程的可执行文件路径(是个符号链接) |
157+
| `/proc/self/fd/` | 当前进程打开的所有文件描述符 |
158+
| `/proc/self/environ` | 当前进程的环境变量 |
159+
| `/proc/self/maps` | 当前进程的内存映射布局 |
160+
| `/proc/self/status` | 当前进程的状态信息(类似于 ps 命令) |
161+
162+
163+
- /proc/fd/{id} 也是一个符号链接,指向进程打开的文件描述符所对应的文件路径。
164+
- /dev/pts/0 这些伪终端需要等待主设备/dev/ptmx被关闭的时候删除
165+
- /root目录必须存在
166+
167+
### linux的setgroups和getgroups的作用和用法是什么
168+
169+
在 Linux 中,一个进程有:
170+
171+
- 真实用户 ID (real UID)、有效用户 ID (effective UID)
172+
- 真实组 ID (real GID)、有效组 ID (effective GID)
173+
- 附加组 ID 列表(supplementary groups)
174+
175+
附加组 ID 让进程除了主组外,还可以属于其他多个组,从而获得对应组的访问权限
176+
177+
178+
179+
#### 用户 ID (UID) 和 组 ID (GID)
180+
这两个是权限身份标识,用来决定一个进程能做什么。
181+
182+
UID(User ID)表示进程属于哪个用户。
183+
常见种类:
184+
185+
- 真实用户 ID (real UID):启动该进程的用户是谁。
186+
- 有效用户 ID (effective UID):实际用于权限检查的 UID(比如 setuid 程序可以让 EUID 暂时变成 root)。
187+
- 保存的 set-user-ID(保存切换前的 EUID,用于临时恢复)。
188+
189+
root 用户的 UID 是 0,其它用户一般是从 1000(或 500)开始分配。
190+
191+
GID(Group ID) 表示进程属于哪个主用户组。同样有 real/effective/saved 三种。
192+
另外还有 附加组列表(supplementary groups),用来赋予额外的组权限。
193+
194+
作用:
195+
当进程访问文件、socket、IPC 等资源时,内核会根据 EUID/EGID + 附加组列表 来判断能否访问。
196+
197+
198+
199+
200+
## Reference
201+
- Linux TTY/PTS概述 https://liujunming.top/2019/09/03/Linux-TTY-PTS%E6%A6%82%E8%BF%B0/
202+
- 伪终端(pseudo terminal) https://zhuanlan.zhihu.com/p/678170056
203+
- 硬件终端 terminal(TTY)
204+
https://www.cnblogs.com/sparkdev/p/11460821.html

docs/locales/en/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ English
66

77
- Source document: index.rst
88

9-
- Translation time: 2025-09-11 16:37:17
9+
- Translation time: 2025-11-22 06:50:01
1010

1111
- Translation model: `hunyuan-turbos-latest`
1212

@@ -47,6 +47,7 @@ English
4747
kernel/net/index
4848
kernel/trace/index
4949
kernel/syscall/index
50+
kernel/device/index
5051

5152
.. toctree::
5253
:maxdepth: 1

0 commit comments

Comments
 (0)