H-2
我们赚哪部分钱?
高校的网络管理是各成一派的,我们又不愿意投入研发成本,打造有技术壁垒甚至门槛的产品
结果就是赚辛苦钱
Kylin Linux Advanced Server 10
chromium 版本仅为 81.0.4044.138
想要编译个新点儿的版本太难了,gcc 仅为 7.3.0
强烈谴责国产操作系统这种只生不养的行为!
undefined symbol: FT_Palette_Select,需要 kylinos 源中的1 | cat <<EOT >> /etc/yum.repo.d/kylinos.repo |
之前家里的 PC 网卡有一些问题,现象是在打 Dota 的时候网络会崩
排查过程极其复杂与漫长,但可能的结论非常平常,在此记录一下这个令人感概的过程
记录一下,希望有可能帮助到其他人
ssh -v查看报debug1: send pubkey test: no mutual signature algorithm
Ventura 自带 OpenSSH_9.0p1, LibreSSL 3.3.6 而从 8.2 开始默认不再支持 ssh-rsa
可以在.ssh/config中临时添加
1 | HostKeyAlgorithms +ssh-rsa |
如果是 ca 签的则需要添加
1 | HostKeyAlgorithms [email protected] |
日常并不写 c++ 项目,看到 Acl 这个库比较有意思,就试着编译了一下 samples
照猫画虎,记录一下遇到的相关问题
https://github.com/acl-dev/acl
Acl – One Advanced C/C++ Library for Unix/Windows
有 BUILD.md 但感觉写的比较简单,还是看了 Makefile
最后用make all_lib && make packinstall生成 include 和 lib
Sample 代码如下
1 | #include <thread> |
环境为 macOS,g++ 为 clang,vim 编辑会提示一些问题
expected_expression: expected expression第一个是因为 clang 不知道你的 include 路径
第二个是[=] {} lambda 表达式是C++11标准,也需要告诉一下 clang
这两个问题都可以用compile_flags.txt解决
方法是在本文件同目录下生成compile_flags.txt文件,内容为
1 | -std=c++11 |
就跟传给 gcc / g++ 的参数一样,但更推荐的是compile_commands.json的方式,并且是在编译时自动生成
于是我们写CMakeLists.txt
引入 CMake 调整目录结构如下
1 | . |
1 | cmake_minimum_required(VERSION 3.5) |
在 CMakeLists 中指定 C++ 标准 11
指定 include 的头文件地址,include 为第三方库目录,src 为私有代码库目录
指定 libacl_all.a 文件所在路径
最后在 build 目录下
1 | cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. |
会生成compile_commands.json
1 | [ |
这里还会报一个错,ld: entry point (_main) undefined.
原因 clang 没找到入口的 main 函数,把 samples 中的 void run 改成 int main 并修改一下 return 细节就可以了
此时的 vim 中,已经可以正确的根据生成的 compile_commands.json 找到 include 的头文件地址
以及认识[=] {}这样的 C++11 标准了
可喜可贺
遇到了 macOS 上的ESC键失效,在 vim 中只能使用Ctrl + C退出插入模式
原因竟然是因为 Siri
死去的 Siri 突然开始攻击我,焯!
It appears that this escape key issue is caused by Siri. More specifically, this issue may occur when Siri freezes. To address this, force-quit Siri and ESC will start working again. Here is how:
REF: https://macreports.com/esc-escape-key-not-working-on-mac-fix/
使用自建 GitLab,通过 CI build Docker 的过程
弯弯绕很多,值得记录
附一份官方中文文档 极狐 https://docs.gitlab.cn/jh/ci/
在项目的 Setting -> CI/CD -> Runners 中查看 Runner 情况
其中 Specific runners 为该项目专用 Runners,以外还支持 Shared runners 共享的 Runners
Show Runner installation instructions 可查看安装指引
gitlab-runner 可直接装在 linux 环境下,或跑在 Docker 环境中
这里我们按照 Environment: Linux, Architecture: amd64 的指引
1 | # Download the binary for your system |
注册过程中的 url, token 皆可在 Specific runners 中查看,其它需要关注的有
.gitlab-ci.yml的 tags 字段中指明<working-directory>/builds/<short-token>/<concurrent-id>/<namespace>/<project-name>.gitlab-ci.yml中的指定,拉起一个 container 去作业,好处是环境隔离、干净,需要注意的是,如果作业是要 docker build,则需要 Docker-in-Docker,详情参考 https://docs.gitlab.cn/jh/ci/docker/using_docker_build.html还需要关注的有
由于 gitlab-runner 是以非 root 权限跑的,需要添加对 docker 的权限并验证
1 | usermod -aG docker gitlab-runner |
参考 https://docs.gitlab.cn/jh/administration/packages/container_registry.html
根据搭建 GitLab 的方式,修改gitlab.yml或者gitlab.rb,以gitlab.rb为例,添加如下
1 | registry['enable'] = true |
使用docker login <url>登录到 GitLab Container Registry
如果该 URL 未启用 HTTPS,则需要在/etc/docker/daemon.json中指定
1 | { |
登录到需要用户名密码认证的 Registry,若未使用 Credentials store,docker 会在$HOME/.docker/config.json中存储 auth 信息,并附上安全提示
如果是通过gitlab-ci.yml进行的操作,参考 https://docs.gitlab.cn/jh/user/packages/container_registry/
可以使用$CI_REGISTRY_USER, $CI_REGISTRY_PASSWORD, $CI_JOB_TOKEN等方式登录,密码是一次性的,并无安全风险
也可以使用 credentials helpers
但要注意 gpg 生成 key 时,不能有 phrase
因为 pass 在提取密码时,如果是有 phrase 的 key,需要输入 phrase,但 docker push/pull 等操作直接跳过了这一步并 exit 2
1 | read(9, "exit status 2: gpg: public key d"..., 512) = 127 |
导致直接 denied: access forbidden
除非预先手动使用pass,并输入 phrase,让 session 记录,但这显然不适合 GitLab CI 场景
Docker 提供四种 credentials helpers
linux 上可使用 pass
自行安装 pass
1 | dnf install pass |
使用 docker-credential-pass-xxx,下载,解压,并 mv 到合适的 bin 目录
编辑$HOME/.docker/config.json
1 | { |
初始化 pass 需要用到 gpg-id,需要先生成
安装 pinentry,并生成 key
1 | dnf install pinentry |
但这里有一个坑点,参考 https://unix.stackexchange.com/questions/477445/www-data-user-cannot-generate-gpg-key
When using pinentry, you must have the proper permissions of the terminal device (e.g. /dev/tty1) in use. However, with su (or sudo), the ownership stays with the original user, not the new one. This means that pinentry will fail with a Permission denied error, even as root.
也就是说,sudo/su 后的用户可能用不了,会提示 Permission denied,甚至你 sudo 之后是 root
比如这里我们要在 gitlab-runner 的账户下 gpg2 --gen-key,就不能以 root 登录然后su gitlab-runner
要么直接以 gitlab-runner 登录,要么使用文章中给出的一个方法
1 | mkdir /path/to/gpg-alt |
1 | pass init <gpg-id> |
不容易,后面的事就是写.gitlab-ci.yml了,给份最基本的参考
1 | stages: |
之前有关于 SSH Aruba AC 提示 port 22:2: Too many authentication failures
添加了选项 IdentitiesOnly=yes 就好了的文章
今天再继续记录一下原因
sshd 会有一个MaxAuthTries的限制,作用是在多次认证失败后直接断开TCP连接
但是这里会有一个问题,key 交换也是算次数的
可以通过ssh-add -l查看目前 load 了多少 key
key 会依次与对端 sshd 进行尝试
所以如果对端 sshd 的 MaxAuthTries 设置的很小,则会产生还没试到正确的 key,就报 Too many authentication failures 了
IdentitiesOnly=yes的作用,即是只使用IdentityFile设置的 key,不用默认已 load 的 key 进行尝试,减少 AuthTries
Aruba AC 应该就是默认的 MaxAuthTries 估计只有 1 或 2,只启用了 password 认证,你一尝试用 key 就失败
好用的日志浏览器,实用且 Colorful
dnf 可直接 install
1 | lnav.x86_64 : Curses-based tool for viewing and analyzing log files |
Features
需要 Net-SNMP >= 5.5
在snmpd.conf中加入以下配置,realStorageUnits 0
详见 https://linux.die.net/man/5/snmpd.conf
realStorageUnits
controlls how the agent reports hrStorageAllocationUnits, hrStorageSize and hrStorageUsed in hrStorageTable. With this option set to ‘0’, the agent re-calculates these values for big storage drives with small allocation units so hrStorageAllocationUnits x hrStorageSize gives real size of the storage.
Example:
Linux xfs 16TB filesystem with 4096 bytes large blocks will be reported as hrStorageAllocationUnits = 8192 and hrStorageSize = 2147483647, so 8192 x 2147483647 gives real size of the filesystem (=16 TB).Setting this directive to ‘1’ (=default) turns off this calculation and the agent reports real hrStorageAllocationUnits, but it might report wrong hrStorageSize for big drives because the value won’t fit into Integer32. In this case, hrStorageAllocationUnits x hrStorageSize won’t give real size of the storage.
总就来说就是,默认情况下 SNMP 的 hrStorageAllocationUnits 是真实的 Block size,常见为 4096 bytes
1 | [root@pan ~]# stat -f . |
于是 hrStorageSize 就会超过 Integer32 的最大值