大网数据广告活动
服务器运维问答

Disabling ctrl+alt+delete in systemd with logging

· 52CE 我爱测

I'm trying to update some of my Puppet manifests that disable CAD on RHEL machines. Right now I'm doing it the over the top way on systemd: masking (ie. linking to /dev/null) $ctrlaltdel_process = '/usr/bin/logger -p security.inf…

问题原文

原帖链接 · Peter Souter · CC BY-SA 3.0

I'm trying to update some of my Puppet manifests that disable CAD on RHEL machines.

Right now I'm doing it the over the top way on systemd: masking (ie. linking to /dev/null)

$ctrlaltdel_process = '/usr/bin/logger -p security.info "Control-Alt-Delete pressed"'

  # Every version of RHEL has a different way of doing this! :)
  case $::operatingsystemmajrelease {
    '4','5': {
      augeas { 'disable-inittab-ctrlaltdel':
        context => '/files/etc/inittab',
        lens    => 'inittab.lns',
        incl    => '/etc/inittab',
        changes => "set *[action = 'ctrlaltdel']/process '${ctrlaltdelprocess}'",
      }
    }
    '6': {
      file { '/etc/init/control-alt-delete.conf':
        ensure  => file,
        content => $ctrlaltdel_process,
      }
    }
    '7': {
      file { '/etc/systemd/system/ctrl-alt-del.target':
        ensure => 'link',
        target => '/dev/null',
      }
    }
    default: {
      fail("Module ${module_name} is not supported on this ${::operatingsystemmajrelease}")
    }
  }

As you can see, on other systems I'm actually writing a security log saying that CAD was pressed, but I wouldn't get this with systemd machines.

I like the idea of actually having the trap in the logs so we can trace if people are doing it.

Can someone give me an example systemd config file for ctrl+alt+delete that would do the same thing?

已采纳解答

原帖链接 · sourcejedi · CC BY-SA 3.0

# ctrl-alt-del.target
[Unit]
DefaultDependencies=no  # Do not affect the system through dependencies
Requires=ctrl-alt-del.service
StopWhenUneeded=yes

# ctrl-alt-del.service
[Service]
DefaultDependencies=no  # Do not affect the system through dependencies
Type=oneshot
ExecStart=/usr/bin/logger -p security.info "Control-Alt-Delete pressed"

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-05-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。