:: Re: [DNG] How to test the backend o…
Página Principal
Delete this message
Reply to this message
Autor: aitor_czr
Data:  
Para: dng
Tópicos Antigos: Re: [DNG] How to test the backend of simple-netaid
Assunto: Re: [DNG] How to test the backend of simple-netaid
Hi,

On 7/9/18 19:37, aitor_czr wrote:
>
> Hi Edward,
>
> El 07/09/18 a las 17:59, Edward Bartolo escribió:
>> On 07/09/2018, aitor_czr<aitor_czr@???> wrote:
>>> El 07/09/18 a las 12:00, Edward Bartolo escribió:
>>>> Aitor wrote:
>>>> "I spent a lot of time downgrading the frontend from Gtk3 to Gtk2,
>>>> because of the general preference in favor of this second one. The
>>>> packages for jessie will be available in a couple of days."
>>>>
>>>> Thank you for caring about users.
>>>>
>>>> edbarx
>>> Not at all:)
>>>
>> Why are you in denial? Don't bother, you will not get a halo above
>> your head, but if you care, why don't you admit it?
>>
>> This parallels as to when I wrote that there is no ordering in complex
>> numbers. I got a reply contradicting my statement, notwithstanding,
>> there is a mathematical proof clearly illustrating this property.
>> Irrelevant statements like the argument that complex numbers have
>> moduli and the Argand Diagram were posted to prove how ignorant I am
>> in the subject. This is narciscism; it is very immature to live in
>> denial of other people's abilities. Those abilities will still
>> continue to exist whether one accepts them or not. Another case is the
>> denial that negative numbers decrease in value as their modulus
>> increases. Again, a narciscist came to the defense of the
>> indefensible. A mistake like that in a book intended for university
>> students should be corrected.
>>
>> Please, make an effort to grow up.
> This is the simple script used for the wireless connection attempts:
>
> ifdown <device_name>
> ip link set <device_name> up
> pkill wpa_supplicant
> wpa_passphrase <essid> <password> > <conf_file>
> wpa_supplicant -B -c<conf_file> -i<device_name>
> rm -f /run/network/ifstate.<device_name>
> ip link set <device_name> up
> sleep 1
> ifup <device_name>
>
> Maybe, the lines nº 6 and nº7 are superfluous. The line nº8 (that is,
> "sleep 1") is important, believe it.
> As sysadmins, what do you think about the use of "pkill wpa_supplicant"?
>
>   Aitor.


I answer myself, referring to the use of pkill wpa_supplicant:

#include <signal.h>

int kill_wpa_supplicant(void)
{
    pid_t wpa_pid;
    FILE *fp;

    fp = (fopen("/var/run/wpa_supplicant.pid", "r"));
    if (fp == NULL) {
        printf("Couldn't read Wpasupplicant pid file, not trying to
kill.");
        return 0;
    }
    else {
        if (fscanf(fp, "%d", &wpa_pid) != 1) {
            printf("Couldn't read pid from Wpasupplicant pid file, not
trying to kill.");
            return 0;
        }
        fclose(fp);
    }
      if ((kill(wpa_pid, SIGTERM)) == 0)
          return 0;
      else {
          kill(wpa_pid, SIGKILL);
          unlink("/var/run/wpa_supplicant.pid");
          return 0;
      }
}

The <signal.h> header is required for the SIGTERM and SIGKILL:

https://unix.superglobalmegacorp.com/Net2/newsrc/sys/signal.h.html

As i said in a previous thread, i have also the C code for "ip link set
<device_name> up/down".

Cheers,

Aitor.