systemd: SULOGIN 为什么要大写呢; sulogin
systemd
meson.build文件中有这么一段。最后会将progs的第一个元素转换成大写:prog[0].to_upper();这个是将其转换为宏定义。在程序使用时使用比如:static const char* const sulogin_cmdline[] = {SULOGIN, NULL}; ;这个会为代码阅读搜索带来麻烦。
# if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
# /usr/sbin, /sbin, and fall back to the default from middle column.
progs = [['quotaon', '/usr/sbin/quotaon' ],
['quotacheck', '/usr/sbin/quotacheck' ],
['kmod', '/usr/bin/kmod' ],
['kexec', '/usr/sbin/kexec' ],
['sulogin', '/usr/sbin/sulogin' ],
['mount', '/usr/bin/mount', 'MOUNT_PATH'],
['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
]
foreach prog : progs
path = get_option(prog[0] + '-path')
if path != ''
message('Using @1@ for @0@'.format(prog[0], path))
else
exe = find_program(prog[0],
'/usr/sbin/' + prog[0],
'/sbin/' + prog[0],
required: false)
path = exe.found() ? exe.path() : prog[1]
endif
name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
conf.set_quoted(name, path)
substs.set(name, path)
endforeach
sulogin
sulogin - single-user login
用法:sulogin [options] [tty]
如果系统进入单用户模式时(比如进入emergency mode),由init、systemd 带起来sulogin。
会提示用户输入密码,进入系统维护窗口(或者键入Ctrl-D,继续正常的启动,就不会进入单用户,紧急模式)。
如果root用户被锁定,并且带有选项:–force,不需要密码就可以之间进入系统。
sulogin will be connected to the current terminal, or to the optional tty device that can be specified on the command line (typically /dev/console).
When the user exits from the single-user shell, or presses control-D at the prompt, the system will continue to boot.
选项
-e, --force If the default method of obtaining the root password from the system via getpwnam(3) fails, then examine /etc/passwd and /etc/shadow to get the password. If these files are damaged or nonexistent, or when root account is locked by ‘!’ or ‘*’ at the begin of the password then sulogin will start a root shell without asking for a password. Only use the -e option if you are sure the console is physically protected against unauthorized access.
-p, --login-shell Specifying this option causes sulogin to start the shell process as a login shell.
-t, --timeout seconds Specify the maximum amount of time to wait for user input. By default, sulogin will wait forever.
-h, --help Display help text and exit.
-V, --version Display version information and exit.
环境变量
使用到的环境变量是:SUSHELL or sushell,指明要启动什么shell。If the environment variable is not set, it will try to execute root’s shell from /etc/passwd. If that fails, it will fall back to /bin/sh.
https://www.kernel.org/pub/linux/utils/util-linux/
sulogin 编译选项
[root@10 ~]# rpm -q --queryformat=“%{NAME}: %{OPTFLAGS}\n” util-linux-2.32.1-35.el8.x86_64
util-linux: -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
相关文章
- fopen函数打开文件失败原因_为什么打开文件失败
- 关联规则算法Apriori algorithm详解以及为什么它不适用于所有的推荐系统
- 数据仓库为什么要分层 ?
- 虹科分享 | 移动目标防御 | 为什么要关心内存中的攻击?
- React循环DOM时为什么需要添加key
- Linus Torvalds 谈为什么他表现粗鲁
- 医生Linux:为什么开源软件是医学领域必备技术?(doctorlinux)
- 提升Redis性能,你需要Redis分片(为什么要做redis分片)
- 为何Redis采用跳表存储数据(为什么redis要用跳表)
- Oracle为什么要把它写成大写(oracle为什么大写)
- 原因为什么MySQL不会存储视图,而只是用查询语句来创建它们(mysql不存放视图的)
- 为什么winwebmail只能开25个用户