1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
pLogin=gtk_entry_new();
pPass=gtk_entry_new();
gtk_entry_set_visibility(GTK_ENTRY(pPass),FALSE);
gtk_entry_set_max_length(GTK_ENTRY(pLogin),25);
gtk_entry_set_max_length(GTK_ENTRY(pPass),25);
char tempo1[150];
char tmplogin[25], tmplogin1[25];
char tmppass[25], tmppass1[25];
FILE *fd;
system("gawk -F \\\" 'NR==1 {print $2}' /etc/ppp/peers/ueagle-atm>/tmp/login.tmp"); //je récupère le login
fd = fopen ("/tmp/login.tmp","r");
if (fd != NULL)
{
fgets(tmplogin,25,fd);
fclose(fd);
strncpy(tmplogin1,tmplogin,strlen(tmplogin)-1);
sprintf(tempo1,"%s","cat /etc/ppp/chap-secrets|grep "); //le fichier peut contenir plusieurs login, donc je localise le login que je cherche.
strcat(tempo1,tmplogin1);
strcat(tempo1,"|gawk -F \\* '{print $2}'|gawk -F \\\" ' {print $2}'>/tmp/pass.tmp"); //je récupère le mot de passe correspondant
system(tempo1);
fd=fopen("/tmp/pass.tmp","r");
if (fd != NULL)
{
fgets(tmppass,25,fd);
fclose(fd);
strncpy(tmppass1,tmppass,strlen(tmppass)-1);
gtk_entry_set_text(GTK_ENTRY(pLogin),tmplogin1);
gtk_entry_set_text(GTK_ENTRY(pPass),tmppass1);
}
} |
Partager