AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题

问题[selinux](unix)

Martin Hope
GetShifting
Asked: 2025-04-11 17:21:43 +0800 CST

将所有日志消息记录到 AWS Cloudwatch

  • 6

我正在将我们现有的 Amazon Linux 2 服务器迁移到 Amazon Linux 2023。其中一项变化是 AL2023 现在使用 journald 进行日志记录。我要求将所有日志记录到 AWS Cloudwatch 中。

我已经启用了常规的 CloudWatch 代理来监控指标和一些日志文件。一切运行正常。

对于 journald,我测试了各种方案,最终决定实现journald-cloudwatch-logs,因为它看起来最有前景。我已经配置好了,但遇到了一个问题:

  • 服务启动成功,但我根本没在 cloudwatch 中看到任何日志。

这是配置:

aws_region = "eu-central-1"
ec2_instance_id = "i-xxxxxxxxxx"
log_group = "LogGroup"
log_stream = "server01-systemctl"
state_file = "/var/lib/journald-cloudwatch-logs/state"
log_priority = "INFO"

我检查了 journalctl,没有错误或任何其他异常迹象。此外,由于正常的 CloudWatch 代理能够成功记录到另一个日志流,因此我知道 IAM 权限没有问题。

我的问题:

  • 我怎样才能让 journald-cloudwatch-logs 真正记录到 cloudwatch 中?

非常感谢您的帮助。

编辑:我也愿意接受其他方法将日志消息记录到 cloudwatch

selinux
  • 2 个回答
  • 45 Views
Martin Hope
Christian
Asked: 2023-12-14 19:57:05 +0800 CST

SELINUX 政策不适用

  • 6

我有一个作为虚拟机运行的 Fedora Server v39(最小安装)(主机也是 Fedora Server v39)。

我已使用 VM 与 VM 共享主机目录virtiofs并将其映射到/etc/wireguardVM 中。

drwx------. 4 root root system_u:object_r:virtiofs_t:s0                   109 Dec 13 22:03 wireguard

我已经安装了wireguard从 读取它的配置/etc/wireguard,除了 SELINUX 被阻止

# ausearch -m AVC -i
----
type=AVC msg=audit(13/12/23 21:19:26.166:194) : avc:  denied  { search } for  pid=1151 comm=wg-quick name=/ dev="virtiofs" ino=981467275 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=dir permissive=0 
----
type=AVC msg=audit(13/12/23 22:00:40.880:204) : avc:  denied  { search } for  pid=1250 comm=wg-quick name=/ dev="virtiofs" ino=981467275 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=dir permissive=0 
----
type=AVC msg=audit(13/12/23 22:01:47.028:208) : avc:  denied  { search } for  pid=1265 comm=wg-quick name=/ dev="virtiofs" ino=981467275 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=dir permissive=1 
----
type=AVC msg=audit(13/12/23 22:01:47.028:209) : avc:  denied  { getattr } for  pid=1265 comm=wg-quick path=/etc/wireguard/wg0.conf dev="virtiofs" ino=981467299 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=file permissive=1 
----
type=AVC msg=audit(13/12/23 22:01:47.033:210) : avc:  denied  { getattr } for  pid=1269 comm=stat path=/etc/wireguard dev="virtiofs" ino=981467275 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=dir permissive=1 
----
type=AVC msg=audit(13/12/23 22:01:47.034:211) : avc:  denied  { read } for  pid=1265 comm=wg-quick name=wg0.conf dev="virtiofs" ino=981467299 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=file permissive=1 
----
type=AVC msg=audit(13/12/23 22:01:47.034:212) : avc:  denied  { open } for  pid=1265 comm=wg-quick path=/etc/wireguard/wg0.conf dev="virtiofs" ino=981467299 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=file permissive=1 
----
type=AVC msg=audit(13/12/23 22:01:47.035:213) : avc:  denied  { ioctl } for  pid=1265 comm=wg-quick path=/etc/wireguard/wg0.conf dev="virtiofs" ino=981467299 ioctlcmd=TCGETS scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=file permissive=1 
----
type=AVC msg=audit(13/12/23 22:30:26.574:372) : avc:  denied  { search } for  pid=1692 comm=wg-quick name=/ dev="virtiofs" ino=981467275 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=dir permissive=1 
----
type=AVC msg=audit(13/12/23 22:30:26.574:373) : avc:  denied  { getattr } for  pid=1692 comm=wg-quick path=/etc/wireguard/wg0.conf dev="virtiofs" ino=981467299 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=file permissive=1 
----
type=AVC msg=audit(13/12/23 22:30:26.584:376) : avc:  denied  { search } for  pid=1702 comm=stat name=/ dev="virtiofs" ino=981467275 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=dir permissive=1 
----
type=AVC msg=audit(13/12/23 22:30:26.588:377) : avc:  denied  { getattr } for  pid=1704 comm=stat path=/etc/wireguard dev="virtiofs" ino=981467275 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=dir permissive=1 
----
type=AVC msg=audit(13/12/23 22:30:26.588:378) : avc:  denied  { read } for  pid=1692 comm=wg-quick name=wg0.conf dev="virtiofs" ino=981467299 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=file permissive=1 
----
type=AVC msg=audit(13/12/23 22:30:26.589:379) : avc:  denied  { open } for  pid=1692 comm=wg-quick path=/etc/wireguard/wg0.conf dev="virtiofs" ino=981467299 scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=file permissive=1 
----
type=AVC msg=audit(13/12/23 22:30:26.593:380) : avc:  denied  { ioctl } for  pid=1692 comm=wg-quick path=/etc/wireguard/wg0.conf dev="virtiofs" ino=981467299 ioctlcmd=TCGETS scontext=system_u:system_r:wireguard_t:s0 tcontext=system_u:object_r:virtiofs_t:s0 tclass=file permissive=1

所以我安装了policycoreutils-python-utilsSELINUX 工具并运行grep AVC /var/log/audit/audit.log | audit2allow -M wireguard以获取以下策略

# cat wireguard.te

module wireguard 1.0;

require {
    type wireguard_t;
    type virtiofs_t;
    class dir { getattr search };
    class file { getattr ioctl open read };
}

#============= wireguard_t ==============
allow wireguard_t virtiofs_t:dir { getattr search };
allow wireguard_t virtiofs_t:file { getattr ioctl open read };

但是,当我尝试安装它时,出现错误

# semodule -i wireguard.pp
libsemanage.semanage_direct_install_info: Overriding wireguard module at lower priority 100 with module at priority 400.
Failed to resolve typepermissive statement at /var/lib/selinux/targeted/tmp/modules/400/permissive_wireguard_t/cil:1
Failed to resolve AST
semodule:  Failed!

我现在不知所措,因为我找到的每个帮助页面都说要这样做......任何帮助表示赞赏。

selinux
  • 1 个回答
  • 34 Views
Martin Hope
stackpws
Asked: 2023-02-25 03:14:45 +0800 CST

SELinux 不允许我使用 ftpd

  • 5

我在 AlmaLinuxOS 9。

当我尝试运行时setsebool -P ftpd_full_access on,它向我发送一条消息说 boolean ftpd_full_access not defined。

我不知道我怎么能让它工作,也不知道出了什么问题。

selinux
  • 1 个回答
  • 18 Views
Martin Hope
foo
Asked: 2022-09-14 06:04:27 +0800 CST

Firefox 将 SECCOMP 事件发送到日志/系统日志 - 如何修复?

  • 6

由于我最近在 Ubuntu 上更新到基于 snap 的 Firefox,我看到它在某个应用程序绘制画布时向日志报告 SECCOMP_RET_TRAP 消息。

而且由于应用程序绘制画布通常以每秒 30 帧的速度进行,因此日志中有大量无用的垃圾邮件,事实上,还消耗了大量的 CPU 使用率。

我可以挖掘的是,这种行为以前被报道过,但双方都试图推卸责任,然后又回到了一个普通的“不会修复”。( https://bugzilla.mozilla.org/show_bug.cgi?id=1465152 , https://bugzilla.redhat.com/show_bug.cgi?id=1507282 , https://linux-audit.redhat.narkive.com /BnWpkAXa/limiting-seccomp-audit-events )

那么,如何才能不让日记中充斥着无用的“您的浏览器中已绘制了一张画布!Oy vey!快跑寻求帮助”的消息呢?是否有一些配置可以过滤特定的 SECCOMP 消息,或者更好:阻止 Firefox 生成这些消息?

(补充:采样线 Sep 13 16:01:48 MYHOST audit[97745]: SECCOMP auid=1000 uid=1000 gid=1000 ses=3 subj=? pid=97745 comm="CanvasRenderer" exe="/snap/firefox/1775/usr/lib/firefox/firefox" sig=0 arch=c000003e syscall=312 compat=0 ip=0x7f48ae38573d code=0x50000)

编辑:我不想

  • 完全关闭安全性
  • 阻止所有安全事件被记录
  • 重新编译应用程序或内核

我想以可重复的方式通过配置降低/关闭垃圾邮件,因此遇到相同问题的每个人都可以应用该解决方案。例如,删除与特定“comm”字段值匹配的消息。

selinux firefox
  • 1 个回答
  • 105 Views
Martin Hope
Rock
Asked: 2022-06-03 10:18:34 +0800 CST

我的用户 (tom) 通过 semanage 拥有 user_u 、 user_r 和 user_t 但它仍然可以执行 sudo

  • 0

我的用户 (tom) 通过 semanage 映射到 user_u 用户、 user_r 角色和 user_t 域

[tom@localhost ~]$ id -Z
user_u:user_r:user_t:s0
[tom@localhost ~]$ 

因为我已将“默认”设置为“user_u”

[tom@localhos ~]$ sudo semanage login -l

Login Name           SELinux User         MLS/MCS Range        Service

__default__          user_u               s0                   *
root                 unconfined_u         s0-s0:c0.c1023       *
system_u             system_u             s0-s0:c0.c1023       *
[tom@localhos ~]$ 

但它仍然可以执行 sudo

[tom@localhost ~]$ sudo -l
Matching Defaults entries for tom on localhost:

User tom may run the following commands on localhost:
    (ALL) NOPASSWD: ALL
[tom@localhost ~]$

看来,这是因为 sudoers 中的“%<user tom's group> ALL = (ALL) NOPASSWD:ALL”

[tom@localhost ~]$ sudo cat /etc/sudoers
root ALL = (ALL) NOPASSWD:ALL
%<user tom's group> ALL = (ALL) NOPASSWD:ALL
admin ALL = (ALL) NOPASSWD:ALL
[tom@localhost ~]$

请帮我解决我的问题

linux selinux
  • 1 个回答
  • 26 Views
Martin Hope
Cruise5
Asked: 2022-03-18 15:11:17 +0800 CST

在 fstab 条目后挂载 lvm 不会在新的 lvm 中创建 SElinux 标签

  • 0

在 RHEL8 上,我用 ext4 文件系统创建了一个 lvm。将其添加到/etc/fstab但当我使用时mount -av,我收到以下错误:

You just mounted an file system that supports labels which does not
       contain labels, onto an SELinux box. It is likely that confined
       applications will generate AVC messages and not be allowed access to
       this file system.  For more details see restorecon(8) and mount(8).
/lvext4                  : successfully mounted

如果我在里面创建一个文件/lvext4,它的 SELinux 上下文是unconfined_u:object_r:unlabeled_t:s0 file1

挂载 XFS lvm 时出现同样的错误。

linux selinux
  • 1 个回答
  • 438 Views
Martin Hope
dcom-launch
Asked: 2022-02-02 10:35:20 +0800 CST

有什么方法可以使 sysfs 文件不可变?

  • 2

我试图让/sys/fs/selinux/enforce总是包含“1”,并防止它被改变。

我已经能够/etc/selinux/config通过运行来做到这一点chattr +i /etc/selinux/config

但是,当我在 selinux sysfs 中的文件上尝试此操作时,出现以下错误:

chattr: Inappropriate ioctl for device while reading flags on /sys/fs/selinux/enforce

我假设这是由于 sysfs 文件与实际文件不同。

任何已知的方法来实现相同的结果?

selinux sysfs
  • 1 个回答
  • 88 Views
Martin Hope
Alexis Wilke
Asked: 2021-10-03 10:19:15 +0800 CST

即使 SELinux 不可用,是否始终创建 /proc/[pid]/attr 目录?

  • 1

我有两台机器,一台基于 Intel 的标准 Ubuntu 和一台 Jetson Xavier,它们都有一个/proc/self/attr/current文件。但是,Jetson 计算机上的那个似乎不起作用:

这是我基于英特尔的标准 Ubuntu 上的输出:

$ xxd /proc/self/attr/current
00000000: 756e 636f 6e66 696e 6564 0a              unconfined.

但是,看起来我在 Jetson(基于 ARM)上遇到了错误:

$ xxd /proc/self/attr/current
xxd: Invalid argument

环顾四周,它似乎是 SELinux 扩展的一部分,我认为它没有安装在 Jetson 上。/proc但是,如果不可用,为什么该文件会出现在下面?

ubuntu selinux
  • 1 个回答
  • 80 Views
Martin Hope
Adrian
Asked: 2020-01-02 12:20:20 +0800 CST

SELinux 正在阻止从 Amavis 回到自身的连接:无法进出?

  • 2

在此处运行全新的 CentOS8 安装,MTA 是连接了 Amavis 的 Postfix。我想让 Amavis 在(内部)DKIM 签名后将来自 ORIGINATING 的消息(从端口 587/Postfix 到 10026/Amavis 的传入提交)注入 Amavis(端口 10024) . 但是端口 10024 已经被分配用于监听来自 25/Postfix 的传入 smtp 连接,所以我不能将它添加为 SELinux 配置中的发送端口。

消息流:

  • 25/smtp -> 后缀 -> smtp-amavis/10024
  • 10024 -> Amavis:扫描 -> 10025
  • 10025 -> 后缀 -> 交付
  • 587/提交 -> 后缀 -> smtp-amavis/10026
  • 10026 -> Amavis 发起:扫描和 DKIM 标志 -> smtp-amavis/10024

我遇到的问题是 SELinux 不允许我在端口 10024(Amavis 到 Amavis)将来自最后一个流的消息反馈到 smtp-amavis,因为该端口已被分配用于接收:

[root@services amavisd]# semanage port -l | grep 1002
amavisd_recv_port_t            tcp      10026, 10024
amavisd_send_port_t            tcp      10027, 10025
spamd_port_t                   tcp      783, 10026, 10027

有趣的是,当我分别添加到 amavisd_recv_port_t 和 amavisd_send_port_t 时,SELinux 并没有抱怨端口 10026、10027 已经分配给 spamd:

[root@services amavisd]# semanage port -lC
SELinux Port Type              Proto    Port Number
amavisd_recv_port_t            tcp      10026
amavisd_send_port_t            tcp      10027

我怎样才能解决这个问题?因为 SELinux 也不允许我添加 10024 作为发送端口:

[root@services amavisd]# semanage port -a -t amavisd_send_port_t -p tcp 10024
ValueError: Port tcp/10024 already defined

还是我完全走错了路,并且提交的消息根本不应该通过端口 10024 反馈到 Amavis(这使得这是一个 Amavis 而不是 SELinux 问题)?最初,Amavis 配置将提交的消息转发到端口 10027 以供 OpenDKIM 进行(外部)DKIM 签名,如您在此处看到的:

# forward to a smtpd service providing DKIM signing service
#forward_method => 'smtp:[127.0.0.1]:10027',
forward_method => 'smtp:[127.0.0.1]:10024',

所以最后一个流程最初是:

  • 10026 -> Amavis 发起:扫描 -> OpenDKIM@10027:签名 -> 交付

但是 OpenDKIM 还不能用于 CentOS8(以前是通过 EPEL 存储库),而且 Amavis 现在支持我正在尝试使用的内部 DKIM 签名服务。

所以我看到有两种方法:

  • 配置 SELinux,以便它可以将来自提交流的 DKIM 签名消息送回基本的 smtp 流(假设这个有点循环的设置有效)
  • 保留原始的 Amavis 配置,这意味着必须在端口 10027 后面有一个服务来传递传出(即提交的)消息

走哪条路,怎么做?

selinux postfix
  • 1 个回答
  • 280 Views
Martin Hope
goldilocks
Asked: 2019-10-12 00:51:58 +0800 CST

获取与套接字基础关联的 SELinux 权限列表

  • 2

这显示了与类关联的权限tcp_socket:

> seinfo -c tcp_socket -x

Classes: 1
   class tcp_socket
inherits socket
{
        connectto
        name_connect
        node_bind
        newconn
        acceptfrom
}

但是向下钻取并不是那么有用:

seinfo -c socket -x

Classes: 1
   class socket
inherits socket

我知道这一点,并且我可以通过参考政策来源进行挖掘,并希望找到规范的答案,但前者“现在有点历史”(“来自 Fedora F-20 政策来源的列表”)和后者有点乏味。

selinux
  • 1 个回答
  • 195 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve