Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用systemd运行auth-thu服务失败 #22

Closed
Sphekes opened this issue Sep 2, 2022 · 6 comments · Fixed by ouuan/AUR-packages#2
Closed

使用systemd运行auth-thu服务失败 #22

Sphekes opened this issue Sep 2, 2022 · 6 comments · Fixed by ouuan/AUR-packages#2

Comments

@Sphekes
Copy link

Sphekes commented Sep 2, 2022

我使用的系统是Arch Linux,安装了aur中auth-thu-bin这一软件包,包里含有systemd的配置文件/usr/lib/systemd/user/goauthing@.service,我用这一命令启动服务systemctl --user start goauthing@<用户名>.service,之后查看运行状态systemctl --user staus goauthing@<用户名>.service显示如下错误

● goauthing@***.service - Authenticating utility for auth.tsinghua.edu.cn
Loaded: loaded (/usr/lib/systemd/user/goauthing@.service; disabled; preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Fri 2022-09-02 18:03:17 CST; 1s ago
Process: 1808 ExecStartPre=/usr/bin/auth-thu --debug -D deauth (code=exited, status=216/GROUP)
Process: 1809 ExecStartPre=/usr/bin/auth-thu --debug -D auth (code=exited, status=216/GROUP)
Process: 1810 ExecStartPre=/usr/bin/auth-thu --debug -D login (code=exited, status=216/GROUP)
Process: 1811 ExecStart=/usr/bin/auth-thu --debug -D online (code=exited, status=216/GROUP)
Main PID: 1811 (code=exited, status=216/GROUP)
CPU: 7ms

用journalctl查看日志如下

Sep 02 17:51:05 ****** systemd[623]: Stopped Authenticating utility for auth.tsinghua.edu.cn.
Sep 02 17:51:05 ****** systemd[623]: Starting Authenticating utility for auth.tsinghua.edu.cn...
Sep 02 17:51:05 ****** systemd[3085]: goauthing.service: Failed to determine supplementary groups: Operation not permitted
Sep 02 17:51:05 ****** systemd[3085]: goauthing.service: Failed at step GROUP spawning /usr/bin/auth-thu: Operation not permitted
Sep 02 17:51:05 ****** systemd[3086]: goauthing.service: Failed to determine supplementary groups: Operation not permitted
Sep 02 17:51:05 ****** systemd[3086]: goauthing.service: Failed at step GROUP spawning /usr/bin/auth-thu: Operation not permitted
Sep 02 17:51:05 ****** systemd[3087]: goauthing.service: Failed to determine supplementary groups: Operation not permitted
Sep 02 17:51:05 ****** systemd[3087]: goauthing.service: Failed at step GROUP spawning /usr/bin/auth-thu: Operation not permitted
Sep 02 17:51:05 ****** systemd[623]: Started Authenticating utility for auth.tsinghua.edu.cn.
Sep 02 17:51:05 ****** systemd[3088]: goauthing.service: Failed to determine supplementary groups: Operation not permitted
Sep 02 17:51:05 ****** systemd[3088]: goauthing.service: Failed at step GROUP spawning /usr/bin/auth-thu: Operation not permitted
Sep 02 17:51:05 ****** systemd[623]: goauthing.service: Main process exited, code=exited, status=216/GROUP
Sep 02 17:51:05 ****** systemd[623]: goauthing.service: Failed with result 'exit-code'.
Sep 02 17:51:10 ****** systemd[623]: goauthing.service: Scheduled restart job, restart counter is at 110.

我的.auth-thu文件是没问题的,因为我直接在命令行运行auth-thu是可以登录的
请问是怎么回事?谢谢

@ZenithalHourlyRate
Copy link
Collaborator

你好,goauthing@<username>.service 不是通过 systemctl --user 激活的(@NickCao 打的包倒确实是这样激活的,@ouuan 的不是)

正确的激活方式是在 root 用户下 systemctl start goauthing@<username>

另外,如果需要开机即激活并定时认证,可以在 root 用户下

systemctl enable --now goauthing@<username>.timer

我的 timer 样例如下,我似乎忘了 commit 上来……

[Unit]

[Timer]
OnBootSec=60
OnUnitActiveSec=2min
#OnCalendar=hourly

[Install]
WantedBy=timers.target

@Sphekes
Copy link
Author

Sphekes commented Sep 3, 2022

非常感谢您的解答。使用sudo systemctl start/enable确实可以正常运行,但是我还有一些疑问:

auth-thu-bin这个包将一系列goauthing.serivce放在了/usr/lib/systemd/user/,这一目录是用来放用户单元文件的,用systemctl --user管理的,而用系统级的systemctl是找不到这一文件的。我是将这一文件拷贝到/etc/systemd/system/中才可以运行的。所以有没有可能是维护者打包打错了啊?

还有就是用系统权限去执行网络验证权限好像有点太高了,这对于个人电脑当然无所谓,但是多用户不知root密码就会很麻烦。尤其是goauthing@<username>.service加了@参数很明显就是想让单个用户去执行的。

@ouuan
Copy link

ouuan commented Sep 3, 2022

auth-thu-bin这个包将一系列goauthing.serivce放在了/usr/lib/systemd/user/,这一目录是用来放用户单元文件的,用systemctl --user管理的,而用系统级的systemctl是找不到这一文件的。我是将这一文件拷贝到/etc/systemd/system/中才可以运行的。所以有没有可能是维护者打包打错了啊?

很可能是的,我自己没有在用这些 service,直接看的 auth-thu 是放在 /usr/lib/systemd/user 就放了。这个应该是要怎么放呢 🤔 全放 /etc/systemd/system

@NickCao
Copy link

NickCao commented Sep 3, 2022

较为安全的做法是将 unit file 置于 /usr/lib/systemd/user/,此时由于本身已经是 user unit,也无需使用template unit (即@<用户名>) 这一方式。不过这一做法有一个缺陷是在默认情况下,user unit 并不会随着系统的启动而启动,但是可以通过 loginctl enable-linger 开启这一行为。

@ZenithalHourlyRate
Copy link
Collaborator

很可能是的,我自己没有在用这些 service,直接看的 auth-thu 是放在 /usr/lib/systemd/user 就放了。这个应该是要怎么放呢 全放 /etc/systemd/system

用户自己加系统服务是放在 /etc/systemd/system 的,打成包的话是放在 /usr/lib/systemd/system 的。

不过这一做法有一个缺陷是在默认情况下,user unit 并不会随着系统的启动而启动,但是可以通过 loginctl enable-linger 开启这一行为。

这几个 service 是为了开机自认证而服务的(虽然我没扔进来 timer)。既然 loginctl enable-linger 需要 root,那放在 user 然后给用户开机自启和放在 system 然后降格为各个用户所需要的权限是一样的。

多用户的情景中,如果系统管理员知道 auth-thu 然后安装了,如果只有一个管理员,这时候一般会让系统管理员自己配置认证,毕竟密码是明文存放的,其他用户存放密码并不安全。

如果系统管理员不知道,没有 root 权限的用户登录以后自己需要认证,为了方便可以将服务放在 ~/.config/systemd/user/,这时候就需要用户自己修改 service 了(因为二进制路径各不相同)。

在多管理员或用户没有权限的情景下,我们也不推荐使用 service,因为这需要填写 ~/.auth-thu,而(其他)系统管理员能读取到该文件,所以这时我们推荐用户手动调用 auth-thu。

@Sphekes
Copy link
Author

Sphekes commented Sep 3, 2022

大概明白了,感谢各位的耐心解答。

之前只会用别人的service文件,自己没有写过调过,看来还是要多加学习。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants