小编w00*_*row的帖子

检测来自Linux应用程序的ssh/console的身份验证尝试

有一项任务是从Linux C++应用程序中检测成功和不成功的登录尝试.最好的方法是什么?

我只发现了两种方法:1)通过超时检查/ var/logs/secure 2)在/ var/logs/secure上使用inotify

但是有一个问题,/ var/logs/secure中的两个或多个不成功的登录注册表看起来像"PAM 2更多身份验证失败",并且此字符串不会在登录失败的时刻出现.

c++ linux ssh console

5
推荐指数
1
解决办法
229
查看次数

使用 std::ranges 摆脱嵌套的 for 循环

让我有一个代码:

for (auto& a : x.as)
{
    for (auto& b : a.bs)
    {
        for (auto& c : b.cs)
        {
            for (auto& d : c.ds)
            {
                if (d.e == ..)
                {
                    return ...
                }
            }
        }   
    }
}
Run Code Online (Sandbox Code Playgroud)

as, bs, cs, ds - 相应元素的 std::vector。

是否可以使用 std::ranges 将四个丑陋的循环转换为一个漂亮的单行表达式?

c++ nested-loops c++20 std-ranges

4
推荐指数
1
解决办法
106
查看次数

无法访问模板函数内的迭代器

我有以下代码

#include <map>
template <typename Value>
static void Get(std::map<int, Value> & map)
{
    typename std::map<int, Value>::const_iterator it;
    it _it = map.find(1);
}
void main()
{
    std::map<int,std::string> _map;
    _map.insert(std::pair<int,std::string>(1, "1"));
    Get<std::string>(_map);
}
Run Code Online (Sandbox Code Playgroud)

我收到了该行的错误

it _it = map.find(1);
Run Code Online (Sandbox Code Playgroud)

为什么这样?

c++ templates map

2
推荐指数
1
解决办法
76
查看次数

标签 统计

c++ ×3

c++20 ×1

console ×1

linux ×1

map ×1

nested-loops ×1

ssh ×1

std-ranges ×1

templates ×1