小编am3*_*am3的帖子

使用 C 开始使用 wpa_supplicant

在人们得出结论说这是重复的帖子之前,我想指出的是,我已经浏览了有关该主题的其他帖子,但实际上还没有找到解决方案。


我需要的

我的目标是从 C 程序访问 wpa_supplicant 来执行以下操作:

  1. 查看活动连接
  2. 检测接口何时关闭
  3. 连接AP/设置AP等

我发现了什么

  • 如果我需要编写C程序与wpa_supplicant通信,我不需要DBus
  • wpa_ctrl.h我只需将这些文件包含在我的项目目录中即可使用其中的功能
  • 以下是我发现的与此问题相关的一些链接。1 , 2 , 3
  • 我还浏览了官方文档,其中讨论了使用外部程序wpa_ctrl.c

为什么上面的方法并没有真正解决问题

  • 我在 SO 和其他相关网站上找到的有关此问题的大多数帖子都指向官方文档等资源,这些资源很好,但不能解决问题
  • 在很多这样的帖子中,人们已经放弃了追求这个目标,或者已经找到了解决方案,但没有发布到网上。
  • 对于本主题的新手来说,如果能够发布一个工作示例(wpa_supplicant 的“hello world”)将会很有帮助。

到目前为止我做了什么

  • 这个链接,我复制 wpa_supplicant-2.5/src/common/wpa_ctrl.hwpa_supplicant-2.5/src/utils目录中(因为common.h有很多依赖项)。然后我在同一目录中编写了一个简单的 C 程序hostapd_cli.c,如下所示。我收到对“wpa_ctrl_open”错误的未定义引用

    #include "includes.h"
    #include <dirent.h>
    #include "wpa_ctrl.h"
    #include "common.h"
    static struct wpa_ctrl *ctrl_conn;
    static int hostapd_cli_quit = 0;
    static int hostapd_cli_attached = 0;
    static const char *ctrl_iface_dir = "/var/run/wpa_supplicant";
    static char *ctrl_ifname = …
    Run Code Online (Sandbox Code Playgroud)

c linux wpa-supplicant

6
推荐指数
2
解决办法
5907
查看次数

记录cron.daily?

我在cron.daily中有几个cron作业,应该每天执行.我知道这些任务会被执行,因为我可以看到最终结果.例如:我正在备份MySQL数据库,我可以看到备份文件.但是,我找不到这个日志.

  • /var/log/sysloggrep CRON /var/log/syslog命令检查了所有我能找到的是php5 session clean cronjob(我真的不知道那是什么)

我在哪里可以找到cron.daily的日志?

ubuntu cron crontab

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

Angular 2:在创建组件时动态插入捕获元素(动态)

我的目标是创建子组件并插入父组件模板.有一些例子可以做到这一点.但是,我在父组件中动态创建父组件模板(DOM元素),而大多数示例静态创建带有capture元素的模板.

这是代码

app.component

import {Component, ViewChild, ViewContainerRef, ComponentFactoryResolver} from '@angular/core';
import {NewChildComponent} from "./newChild.component";

@Component({
 selector: 'app-main',
 templateUrl: 'app.component.html'
})
export class AppComponent {

 @ViewChild('captureElement', {read: ViewContainerRef})
 captureElement: ViewContainerRef;

 constructor (private componentFactoryResolver: ComponentFactoryResolver) {
 var childComponent = this.componentFactoryResolver.resolveComponentFactory(NewChildComponent); 

 var myArea = document.getElementById('myArea');
 var myRow = document.createElement("div");
 myArea.appendChild(myRow);

 //I want to add the capture element #myCapture as a child of myRow
 //Add something like this <div #captureElement></div> programmatically through JS/TS
 // How can I do this?

 // I then …
Run Code Online (Sandbox Code Playgroud)

typescript angular2-template angular

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

Gtk-Message:无法加载模块“canberra-gtk-module”无法连接到 dbus - Sublime text

我正在通过 SSH -X 在远程服务器(Ubuntu 14.04)上工作。我已经安装了 Sublime Text,当我尝试打开它时,我得到了

Gtk-Message: Failed to load module "canberra-gtk-module"
Unable to connect to dbus
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

gtk sublimetext ubuntu-14.04

3
推荐指数
1
解决办法
8408
查看次数

授权失败(没有经过身份验证的用户) - .htaccess错误,Apache

我正在运行Apache/2.4.7(Ubuntu)服务器,我正在尝试保护其中一个'myFolder'位于/var/www/html/myFolder

我做了以下编辑 /etc/apache2/apache2.conf file

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>


<Directory /var/www/html/myFolder>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>
Run Code Online (Sandbox Code Playgroud)

我创建.htaccess/var/www/myFolder包含以下内容

AuthUserFile /var/www/html/myFolder/.htpasswd
AuthName "Authorization Required"
AuthType Basic
require valid-user
Run Code Online (Sandbox Code Playgroud)

还创建了htpasswd

htpasswd -c /var/www/html/myFolder/.htpasswd admin
Run Code Online (Sandbox Code Playgroud)

然后提示输入密码.

然后我尝试在浏览器www.mydoman.com/myFolder/hello.html上访问该文件,并提示输入用户名和密码.但是,身份验证不会通过.

这是error.log文件中的错误

[authz_core:error] [pid 30042] [client xxx.xxx.xx.xxx:53348] AH01629:授权失败(未经过身份验证的用户):/ myFolder/hello.html

我该如何解决这个问题?

apache .htaccess ubuntu-server ubuntu-14.04

3
推荐指数
1
解决办法
3791
查看次数

使用C中的snprintf将char转换为字符串

我正在使用下面的代码将字符数组转换为字符串C.但是输出与我的预期不同.

#include<stdio.h>
int main() 
{
    char data[5] = {
        'a', 'b', 'c', 'd', '\0'
    };
    char buff[100];
    int i = 0;

    while (data[i] != '\0')
    {
        printf("%c Character here \n", data[i]);
        snprintf(buff, 100, "%s", & data[i]);
        printf("%s String here\n", buff);
        i++;
    }
}
Run Code Online (Sandbox Code Playgroud)

我期望的结果是

a Character here 
a String here
b Character here 
b String here
c Character here 
c String here
d Character here 
d String here
Run Code Online (Sandbox Code Playgroud)

但是我把它作为输出

a Character here 
abcd String here
b Character here 
bcd String …
Run Code Online (Sandbox Code Playgroud)

c string char

0
推荐指数
1
解决办法
768
查看次数