我已经根据评论中的建议重新格式化以提高可读性。
我有一个使用 google 身份验证器的 RADIUS 服务器,SELinux 阻止 RADIUS 访问用户主目录中的 .google_authenticator 文件(这些也是 winbind 用户,主目录在/home/API)。我尝试通过构建以下策略文件来授予它访问权限:
$ cat ./google-authenticator.fc
/home/API(/.*)?/\.google_authenticator gen_context(system_u:object_r:radiusd_google_authenticator_t,s0)
$ cat ./google-authenticator.te
policy_module(radiusd_google_authenticator, 0.0.10)
require {
type radiusd_t;
type user_home_dir_t;
type admin_home_t;
}
type radiusd_google_authenticator_t;
role object_r types radiusd_google_authenticator_t;
allow radiusd_t radiusd_google_authenticator_t:file { rename create unlink rw_file_perms };
files_type(radiusd_google_authenticator_t)
filetrans_pattern(radiusd_t, user_home_dir_t, radiusd_google_authenticator_t, file, ".google_authenticator")
filetrans_pattern(radiusd_t, admin_home_t, radiusd_google_authenticator_t, file, ".google_authenticator")
Run Code Online (Sandbox Code Playgroud)
安装这些会显示 中的路径semanage fcontext -l,但它不起作用:
$ sudo semanage fcontext -l | grep google_authenticator
/home/API(/.*)?/\.google_authenticator all files system_u:object_r:radiusd_google_authenticator_t:s0
$ matchpathcon …Run Code Online (Sandbox Code Playgroud) 我在文件中有如下内容。
dataDir=/var/lib/zookeeper
4lw.commands.whitelist=mntr,conf,ruok,stat
syncLimit=2
Run Code Online (Sandbox Code Playgroud)
我想使用 Ansible读取dataDir的值并将其设置为变量。我已经编写了以下代码,但是正则表达式和存储变量都有一些问题。
- name: Read zoo.cfg content
shell:
cmd: cat zoo.cfg
register: zoo_config_content
- set_fact:
my_var: "{{ zoo_config_content.stdout | regex_search('dataDir.*')}}"
- name: Print
debug:
var: my_var
Run Code Online (Sandbox Code Playgroud)
Q1.) 如何改进正则表达式以仅获取/var/lib/zookeeper?
Q2.) 如何存储提取的值以在另一个任务中使用?
我需要在perl 脚本中就地编辑一个文件,所以经常使用一个班轮:
perl -p -e s/<value>/<value>/ig
Run Code Online (Sandbox Code Playgroud)
不适用于这种情况。如何从 perl 脚本中获得相同的结果?
open(CRONTAB, "+<file" || die "...";
while (<CRONTAB>) {
if ($_ =~ /value/) {
s/^\#+//;
print "$_\n";
}
}
Run Code Online (Sandbox Code Playgroud)
我的印刷品正好显示了我想要的东西。这只是我正在寻找的就地编辑。
我正在尝试创建一个 bash 脚本,该脚本将使用 egrep 从文件中 grep 行。我已经创建了应该对我想要的信息进行分组的正则表达式,问题是试图获得输出。我一直在使用以下命令对其进行测试,但运行时没有打印任何内容。如何打印 -{80} 和 Disconnected 之间的多行?
egrep -E "^-{80}$\r?\n?([:ascii:]*)Disconnected from Server" testing.txt
Run Code Online (Sandbox Code Playgroud)
文件:testing.txt
Connected to the server: name here
Some header text.
More text to go though...
--------------------------------------------------------------------------------
The information that I want, would be in here;
Including this line as well #$
and this one.
Disconnected from Server...
Run Code Online (Sandbox Code Playgroud) 我在我的邮件服务器上使用fail2ban。我今天早上发现通过 SMTP 有大约 5000 次失败的登录尝试(在 1 小时内)没有被我的 sasl 过滤器检测到。这是 /var/log/mail.log 中条目的示例
Jan 25 04:39:56 ***** postfix/smtpd[23828]: warning: 114-32-231-17.HINET-IP.hinet.net[114.32.231.17]: SASL LOGIN authentication failed: authentication failure
Run Code Online (Sandbox Code Playgroud)
这是我的(未修改的)fail2ban 的 sasl 过滤器定义:
# Fail2Ban configuration file
#
# Author: Yaroslav Halchenko
#
# $Revision: 728 $
#
[Definition]
# Option: failregex
# Notes.: regex to match the password failures messages in the logfile. The
# host must be matched by a group named "host". The tag "<HOST>" can
# be used for …Run Code Online (Sandbox Code Playgroud) 我认为从一个小片段开始是最明智的:
location ^~ /test/ {
proxy_pass http://frontend;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $server_port;
if ( $remote_addr ~* "123.123.123.123" ) {
proxy_cache cache_base;
proxy_cache_valid 720m;
}
}
Run Code Online (Sandbox Code Playgroud)
因此,本质上我们想要做的是基于条件 IF 语句设置代理缓存。
上面的方法不起作用,因为 proxy_cache 在 IF 内部无效。
有谁知道如何根据众多 nginx 内部变量之一的正则表达式匹配来代理缓存?
笔记:
我们希望基于 $remote_addr regexp 基本上禁用/启用 proxy_caching。不指定不同的 proxy_cache 值。
谢谢。
我正在尝试以这种链接的方式编写模式:
http://www.mysite.com/link/go/emailadress@gmail.com
解释如下:
http://www.mysite.com/process.php?email=emailadress@gmail.com
但是我不知道怎么写。我尝试了这个,但它不起作用。需要帮助请。
这是我在 .htaccess 文件中写的但不起作用:
选项 +FollowSymlinks 重写引擎开启 RewriteRule ^link/go/overview/([A-Za-z0-9-]+)$ /process.php?email=$1 [NC,L]
谢谢
如何向 logcheck 忽略规则添加注释?
到目前为止我尝试过的事情:
有没有比用$^开始行更好的方法?
是否保证以$^开头的行永远不会匹配?性能呢?
我正在尝试限制对特定 URL 的访问。它不应该被允许访问/admin.php。
frontend example
acl restricted_page path_beg -i /admin\.php
http-request deny if restricted_page
Run Code Online (Sandbox Code Playgroud)
这工作正常,HAProxy 阻止访问此 URL。但是当我输入http://example.org/ad%6Din.php(%6D = "m" 的十六进制代码)时,HAProxy 不会限制访问。
做这个的最好方式是什么?
谢谢!
我正在将我的网站迁移到另一个平台,但是当我完成新网站的所有页面的开发时,我需要我的用户在这两个平台之间导航。
因此,我需要对包含 1 个特定单词但不包含其他单词的所有 URL 进行 301 重定向:
例子:
我需要重定向所有包含“www2.misite.com/travel(.*)”但不包含“reservation”和“hotel”一词的 URL。
我的服务器是Nginx,不知道是用正则表达式还是用nginx语句完成的。
非常感谢。