/
format.c
651 lines (563 loc) · 17.4 KB
/
format.c
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
#include <rc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef RTCONFIG_OPENVPN
#include <openvpn_config.h>
#endif
#if defined(RTCONFIG_VPN_FUSION)
#include <vpnc_fusion.h>
extern int vpnc_load_profile(VPNC_PROFILE *list, const int list_size, const int prof_ver);
#endif
#if defined(RTCONFIG_NOTIFICATION_CENTER)
#include <libnt.h>
#endif
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifdef RTCONFIG_DNSFILTER
#include "dnsfilter.h"
#endif
void adjust_merlin_config(void)
{
#ifdef RTCONFIG_OPENVPN
int unit;
char varname_ori[32], varname_ori2[32], varname_new[32];
int rgw, plan, converted;
char buffer[8000];
char *desc, *source, *dest, *iface, newiface[8];
#endif
char *newstr, *hostnames;
char *nv, *nvp, *entry;
char *name, *mac, *mode, *ipaddr, *nvname;
char tmp[64];
#ifdef RTCONFIG_DNSFILTER
int globalmode;
#endif
int count;
int need_commit=0;
#ifdef RTCONFIG_OPENVPN
/* Migrate OVPN clientlist rules to VPN Director (386.3) */
*buffer = '\0';
for (unit = 1; unit <= OVPN_CLIENT_MAX; unit++) {
sprintf(varname_ori, "vpn_client%d_clientlist", unit);
if (!nvram_is_empty(varname_ori)) {
need_commit = 1;
#ifdef HND_ROUTER
nv = nvp = malloc(255 * 6 + 1);
if (nv) nvram_split_get(varname_ori, nv, 255 * 6 + 1, 5);
#else
nv = nvp = strdup(nvram_safe_get(varname_ori));
#endif
while (nv && (entry = strsep(&nvp, "<")) != NULL) {
if (vstrsep(entry, ">", &desc, &source, &dest, &iface) != 4)
continue;
if (!strcmp(iface, "WAN"))
strcpy(newiface, "WAN");
else if (!strcmp(iface, "VPN"))
sprintf(newiface, "OVPN%d", unit);
else
continue; // invalid rule
snprintf(tmp, sizeof(tmp), "<1>%s>%s>%s>%s", desc, source, dest, newiface);
strlcat(buffer, tmp, 8000);
}
nvram_unset(varname_ori);
#ifdef HND_ROUTER
nvram_unset(sprintf(varname_ori, "vpn_client%d_clientlist1", unit));
nvram_unset(sprintf(varname_ori, "vpn_client%d_clientlist2", unit));
nvram_unset(sprintf(varname_ori, "vpn_client%d_clientlist3", unit));
nvram_unset(sprintf(varname_ori, "vpn_client%d_clientlist4", unit));
nvram_unset(sprintf(varname_ori, "vpn_client%d_clientlist5", unit));
#endif
free(nv);
}
}
if (*buffer)
ovpn_set_policy_rules(buffer);
/* Migrate OVPN custom settings, either from stock _custom, or previous AM _custom2 and _cust2 (386.3) */
for (unit = 1; unit <= OVPN_SERVER_MAX; unit++) {
/* Handle custom2 migration */
converted = 0;
sprintf(varname_ori, "vpn_server%d_custom2", unit);
if(!nvram_is_empty(varname_ori)) {
strlcpy(buffer, nvram_safe_get(varname_ori), sizeof (buffer));
nvram_unset(varname_ori);
#ifdef HND_ROUTER
sprintf(varname_ori, "vpn_server%d_custom21", unit);
strlcat(buffer, nvram_safe_get(varname_ori), sizeof (buffer));
nvram_unset(varname_ori);
sprintf(varname_ori, "vpn_server%d_custom22", unit);
strlcat(buffer, nvram_safe_get(varname_ori), sizeof (buffer));
nvram_unset(varname_ori);
#endif
set_ovpn_custom(OVPN_TYPE_SERVER, unit, buffer);
converted = 1;
}
/* Handle cust2 base64 migration */
sprintf(varname_ori, "vpn_server%d_cust2", unit);
if(!converted && !nvram_is_empty(varname_ori)) {
get_ovpn_custom_old(OVPN_TYPE_SERVER, unit, buffer, sizeof (buffer));
set_ovpn_custom(OVPN_TYPE_SERVER, unit, buffer);
nvram_unset(varname_ori);
converted = 1;
}
/* Handle stock or very old migration */
sprintf(varname_ori, "vpn_server%d_custom", unit);
if(!converted && !nvram_is_empty(varname_ori)) {
set_ovpn_custom(OVPN_TYPE_SERVER, unit, nvram_safe_get(varname_ori));
nvram_unset(varname_ori);
}
}
need_commit |= converted;
for (unit = 1; unit <= OVPN_CLIENT_MAX; unit++) {
/* Handle custom2 migration */
converted = 0;
sprintf(varname_ori, "vpn_client%d_custom2", unit);
if(!nvram_is_empty(varname_ori)) {
strlcpy(buffer, nvram_safe_get(varname_ori), sizeof (buffer));
nvram_unset(varname_ori);
#ifdef HND_ROUTER
sprintf(varname_ori, "vpn_client%d_custom21", unit);
strlcat(buffer, nvram_safe_get(varname_ori), sizeof (buffer));
nvram_unset(varname_ori);
sprintf(varname_ori, "vpn_client%d_custom22", unit);
strlcat(buffer, nvram_safe_get(varname_ori), sizeof (buffer));
nvram_unset(varname_ori);
#endif
set_ovpn_custom(OVPN_TYPE_CLIENT, unit, buffer);
converted = 1;
}
/* Handle cust2 base64 migration */
sprintf(varname_ori, "vpn_client%d_cust2", unit);
if(!converted && !nvram_is_empty(varname_ori)) {
get_ovpn_custom_old(OVPN_TYPE_CLIENT, unit, buffer, sizeof (buffer));
set_ovpn_custom(OVPN_TYPE_CLIENT, unit, buffer);
nvram_unset(varname_ori);
converted = 1;
}
/* Handle stock or very old migration */
sprintf(varname_ori, "vpn_client%d_custom", unit);
if(!converted && !nvram_is_empty(varname_ori)) {
set_ovpn_custom(OVPN_TYPE_CLIENT, unit, nvram_safe_get(varname_ori));
nvram_unset(varname_ori);
}
}
need_commit |= converted;
/* Migrate "remote gateway" and "push lan" to "client_access" (384.5) */
for (unit = 1; unit <= OVPN_SERVER_MAX; unit++) {
sprintf(varname_ori, "vpn_server%d_rgw", unit);
if(!nvram_is_empty(varname_ori)) {
need_commit = 1;
sprintf(varname_new, "vpn_server%d_client_access", unit);
sprintf(varname_ori2, "vpn_server%d_plan", unit);
rgw = nvram_get_int(varname_ori);
plan = nvram_get_int(varname_ori2);
if (rgw && plan)
nvram_set(varname_new, "2");
else if (rgw && !plan)
nvram_set(varname_new, "1");
else
nvram_set(varname_new, "0");
nvram_unset(varname_ori);
nvram_unset(varname_ori2);
}
}
#endif
/* migrate dhcpc_options to wanxxx_clientid */
char *oldclientid = nvram_safe_get("wan0_dhcpc_options");
if (*oldclientid) {
need_commit = 1;
nvram_set("wan0_clientid", oldclientid);
nvram_unset("wan0_dhcpc_options");
}
oldclientid = nvram_safe_get("wan1_dhcpc_options");
if (*oldclientid) {
need_commit = 1;
nvram_set("wan1_clientid", oldclientid);
nvram_unset("wan1_dhcpc_options");
}
#ifdef RTCONFIG_SSH
/* Migrate to Asus's new tri-state sshd_enable to our dual nvram setup */
if (nvram_match("sshd_enable", "1")) {
if (nvram_match("sshd_wan", "0"))
nvram_set("sshd_enable", "2"); // LAN-only
// else stay WAN+LAN
nvram_unset("sshd_wan");
}
#endif
/* Adjust automatic reboot count on failed radio - reduce from 3 to 1 reboot */
if (nvram_match("dev_fail_reboot", "3")) {
nvram_set("dev_fail_reboot", "1");
}
/* Remove discontinued DNSFilter services (384.7) */
#ifdef RTCONFIG_DNSFILTER
globalmode = nvram_get_int("dnsfilter_mode");
if (globalmode == DNSF_SRV_NORTON1 || globalmode == DNSF_SRV_NORTON2 || globalmode == DNSF_SRV_NORTON3)
nvram_set_int("dnsfilter_mode", DNSF_SRV_OPENDNS_FAMILY);
#ifdef HND_ROUTER
nv = nvp = malloc(255 * 6 + 1);
if (nv) nvram_split_get("dnsfilter_rulelist", nv, 255 * 6 + 1, 5);
#else
nv = nvp = strdup(nvram_safe_get("dnsfilter_rulelist"));
#endif
newstr = malloc(strlen(nv) + 1);
if (newstr) {
newstr[0] = '\0';
while (nv && (entry = strsep(&nvp, "<")) != NULL) {
if (vstrsep(entry, ">", &name, &mac, &mode) != 3)
continue;
if (!*mac || !*mode )
continue;
if (atoi(mode) == DNSF_SRV_NORTON1 || atoi(mode) == DNSF_SRV_NORTON2 || atoi(mode) == DNSF_SRV_NORTON3) {
need_commit = 1;
snprintf(tmp, sizeof(tmp), "<%s>%s>%d", name, mac, DNSF_SRV_OPENDNS_FAMILY);
}
else
snprintf(tmp, sizeof(tmp), "<%s>%s>%s", name, mac, mode);
strcat(newstr, tmp);
}
#ifdef HND_ROUTER
nvram_split_set("dnsfilter_rulelist", newstr, 255 * 6 + 1, 5);
#else
nvram_set("dnsfilter_rulelist", newstr);
#endif
free(newstr);
}
free(nv);
#endif
/* Migrate lan_dns_fwd_local (384.11) */
if (nvram_get_int("lan_dns_fwd_local")) {
need_commit = 1;
nvram_set("dns_fwd_local", "1");
nvram_unset("lan_dns_fwd_local");
}
/* Migrate dhcp_staticlist hostnames to dhcp_hostnames */
#ifdef HND_ROUTER
nvname = jffs_nvram_get("dhcp_hostnames");
#else
nvname = nvram_safe_get("dhcp_hostnames");
#endif
if ((!nvname) || (!*nvname)) {
nv = nvp = strdup(nvram_safe_get("dhcp_staticlist"));
newstr = malloc(strlen(nv) + 1);
hostnames = malloc(strlen(nv) + 1);
if (newstr && hostnames && nv && *nv) {
newstr[0] = '\0';
hostnames[0] = '\0';
while ((entry = strsep(&nvp, "<")) != NULL) {
count = vstrsep(entry, ">", &mac, &ipaddr, &name);
switch (count) {
case 0:
continue;
case 2: // No conversion needed
strlcpy(tmp, entry, sizeof(tmp));
break;
case 3:
if (*name) {
snprintf(tmp, sizeof(tmp), "<%s>%s", mac, name);
strcat(hostnames, tmp);
}
snprintf(tmp, sizeof(tmp), "<%s>%s", mac, ipaddr);
break;
default: // Unknown, just leave it as-is
strlcpy(tmp, entry, sizeof(tmp));
break;
}
strcat(newstr, tmp);
}
if (*hostnames) {
need_commit = 1;
nvram_set("dhcp_staticlist", newstr);
#ifdef HND_ROUTER
jffs_nvram_set("dhcp_hostnames", hostnames);
#else
nvram_set("dhcp_hostnames", hostnames);
#endif
}
}
if (nv) free(nv);
if (newstr) free(newstr);
if (hostnames) free(hostnames);
}
/* Migrade DDNS external IP check (386.1) */
if(!nvram_is_empty("ddns_ipcheck")) {
need_commit = 1;
nvram_set("ddns_realip_x", nvram_get("ddns_ipcheck"));
nvram_unset("ddns_ipcheck");
}
#ifdef RTCONFIG_SSH
/* Migrate SSH keys from nvram (386.1) */
if (!d_exists("/jffs/.ssh")) {
need_commit = 1;
mkdir("/jffs/.ssh", 0700);
if (nvram_get_file("sshd_hostkey", "/jffs/.ssh/dropbear_rsa_host_key", 2048))
nvram_unset("sshd_hostkey");
if (nvram_get_file("sshd_dsskey", "/jffs/.ssh/dropbear_dss_host_key", 2048))
nvram_unset("sshd_dsskey");
if (nvram_get_file("sshd_ecdsakey", "/jffs/.ssh/dropbear_ecdsa_host_key", 2048))
nvram_unset("sshd_ecdsakey");
}
#endif
if (need_commit)
nvram_commit();
}
void adjust_url_urlelist(void)
{
char *nv, *nvp, *b, *chk, *chkp = NULL;
char *url;
char replacebox[2048], rerule[256];
int cnt = 0;
int RESAVE = OFF;
nv = nvp = strdup(nvram_safe_get("url_rulelist"));
/* Change setting format
From:[<str1<str2<str3]
To: [<1>ALL>str1<1>ALL>str2<1>ALL>str3]
*/
memset(replacebox, 0, sizeof(replacebox));
while (nvp && (b = strsep(&nvp, "<")) != NULL) {
chkp = chk = strdup(b);
//dbg("[%s(%d)] %s\n", __FUNCTION__, __LINE__, chk);
while( *chk != '\0') {
if(*chk == '>') cnt++;
chk++;
}
if (cnt != 2) {
if (vstrsep(b, ">", &url) != 1) continue;
if (*url) {
memset(rerule, 0, sizeof(rerule));
snprintf(rerule, sizeof(rerule), "<1>ALL>%s", url);
//dbg("[%s(%d)] %s\n", __FUNCTION__, __LINE__, rerule);
strcat(replacebox, rerule);
RESAVE = ON;
}
}
cnt = 0;
}
if (RESAVE)
nvram_set("url_rulelist", replacebox);
if(nv) free(nv);
if(chkp) free(chkp);
}
void adjust_ddns_config(void)
{
char *server;
server = nvram_safe_get("ddns_server_x");
if(!strcmp(server, "WWW.GOOGLE-DDNS.COM") ||
!strcmp(server, "WWW.GOOGLE-DOMAINS.COM")) {
nvram_set("ddns_server_x", "DOMAINS.GOOGLE.COM");
}
}
void adjust_access_restrict_config(void)
{
char *nv, *nvp, *b, *chk, *chkp = NULL;
char *ipAddr;
char *http_list;
char *restrict_list;
char replacebox[2048], rerule[256];
int cnt = 0;
int RESAVE = OFF;
int nCount = 0;
http_list = nvram_safe_get("http_clientlist");
restrict_list = nvram_safe_get("restrict_rulelist");
if ( (restrict_list[0] == '\0' && nvram_get_int("enable_acc_restriction") == 0) &&
(http_list[0] != '\0') ) {
nvram_set_int("enable_acc_restriction", nvram_get_int("http_client"));
nv = nvp = strdup(nvram_safe_get("http_clientlist"));
/* Change setting format
From:[<ipAddr1<ipAddr2<ipAddr3]
To: [<1>ipAddr1>7<1>ipAddr2>7<1>ipAddr3>7]
*/
memset(replacebox, 0, sizeof(replacebox));
while (nvp && (b = strsep(&nvp, "<")) != NULL) {
chkp = chk = strdup(b);
//dbg("[%s(%d)] %s\n", __FUNCTION__, __LINE__, chk);
while( *chk != '\0') {
if(*chk == '>') cnt++;
chk++;
}
if (cnt != 2) {
if (vstrsep(b, ">", &ipAddr) != 1) continue;
if (*ipAddr) {
memset(rerule, 0, sizeof(rerule));
snprintf(rerule, sizeof(rerule), "<1>%s>7", ipAddr);
//dbg("[%s(%d)] %s\n", __FUNCTION__, __LINE__, rerule);
nCount = sizeof(replacebox) - strlen(replacebox);
strncat(replacebox, rerule, nCount-1);
RESAVE = ON;
}
}
cnt = 0;
}
if (RESAVE)
nvram_set("restrict_rulelist", replacebox);
if(nv) free(nv);
if(chkp) free(chkp);
}
}
#if defined(RTCONFIG_VPN_FUSION)
static VPNC_PROFILE vpnc_profile_tmp[MAX_VPNC_PROFILE] = {{0}};
static int vpnc_prof_cnt_tmp;
static int _find_active_vpnc_id()
{
char *vpnc_proto, *vpnc_heartbeat_x, *vpn_clientx_eas, *vpnc_pppoe_username, *vpnc_pppoe_passwd;
int i, proto_id = -1, ovpn_idx;
vpnc_proto = nvram_safe_get("vpnc_proto");
if(vpnc_proto[0] == '\0' || !strcmp(vpnc_proto, "disable"))
return -1; //no active vpn client
if(!strcmp(vpnc_proto, "pptp"))
proto_id = VPNC_PROTO_PPTP;
if(!strcmp(vpnc_proto, "l2tp"))
proto_id = VPNC_PROTO_L2TP;
if(!strcmp(vpnc_proto, "openvpn"))
proto_id = VPNC_PROTO_OVPN;
switch(proto_id)
{
case VPNC_PROTO_PPTP:
case VPNC_PROTO_L2TP:
{
vpnc_heartbeat_x = nvram_safe_get("vpnc_heartbeat_x");
vpnc_pppoe_username = nvram_safe_get("vpnc_pppoe_username");
vpnc_pppoe_passwd = nvram_safe_get("vpnc_pppoe_passwd");
for(i = 0; i < vpnc_prof_cnt_tmp; ++i)
{
if(vpnc_profile_tmp[i].protocol == proto_id &&
!strcmp(vpnc_profile_tmp[i].basic.server, vpnc_heartbeat_x) &&
!strcmp(vpnc_profile_tmp[i].basic.username, vpnc_pppoe_username) &&
!strcmp(vpnc_profile_tmp[i].basic.password, vpnc_pppoe_passwd))
{
return i;
}
}
}
break;
case VPNC_PROTO_OVPN:
{
vpn_clientx_eas = nvram_safe_get("vpn_clientx_eas");
ovpn_idx = atoi(vpn_clientx_eas);
for(i = 0; i < vpnc_prof_cnt_tmp; ++i)
{
if(vpnc_profile_tmp[i].protocol == proto_id &&
vpnc_profile_tmp[i].config.ovpn.ovpn_idx == ovpn_idx)
{
return i;
}
}
}
break;
default:
break;
}
return -1;
}
void adjust_vpnc_config(void)
{
char *vpnc_clientlist;
char *vpnc_dev_policy_list;
int active_id, i, default_wan_idx = 0, flag = 0;
char buf[1024];
char *nv = NULL, *nvp = NULL, *b = NULL, *mac, *static_ip, *desc, *proto, *server, *username, *passwd, *dns;
_dprintf("[%s, %d]\n", __FUNCTION__, __LINE__);
vpnc_clientlist = nvram_safe_get("vpnc_clientlist");
if(vpnc_clientlist[0] != '\0')
{
vpnc_prof_cnt_tmp = vpnc_load_profile(vpnc_profile_tmp, MAX_VPNC_PROFILE, VPNC_PROFILE_VER1);
if(!vpnc_prof_cnt_tmp) // there is value in vpnc_clientlist but cannot be parsered. It might be old format.
{
vpnc_prof_cnt_tmp = vpnc_load_profile(vpnc_profile_tmp, MAX_VPNC_PROFILE, VPNC_PROFILE_VER_OLD);
//find active id
active_id = _find_active_vpnc_id();
nv = nvp = strdup(nvram_safe_get("vpnc_clientlist"));
i = 0;
memset(buf, 0, sizeof(buf));
while (nv && (b = strsep(&nvp, "<")) != NULL && i <= MAX_VPNC_PROFILE) {
if (vstrsep(b, ">", &desc, &proto, &server, &username, &passwd) < 3)
continue;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
i? "<%s>%s>%s>%s>%s>%d>%d": "%s>%s>%s>%s>%s>%d>%d",
desc? desc: "",
proto? proto: "",
server? server: "",
username? username: "",
passwd? passwd: "",
(i == active_id)? 1: 0,
VPNC_UNIT_BASIC + i);
if(i == active_id)
{
default_wan_idx = VPNC_UNIT_BASIC + i;
}
++i;
}
if(nv) SAFE_FREE(nv);
nvram_set("vpnc_clientlist", buf);
snprintf(buf, sizeof(buf), "%d", default_wan_idx);
nvram_set("vpnc_default_wan", buf);
flag = 1;
}
}
vpnc_dev_policy_list = nvram_safe_get("vpnc_dev_policy_list");
if(vpnc_dev_policy_list[0] == '\0' || flag) //have dhcp_staticlist but no vpnc_dev_policy_list
{
nv = nvp = strdup(nvram_safe_get("dhcp_staticlist"));
memset(buf, 0, sizeof(buf));
i = 0;
while (nv && (b = strsep(&nvp, "<")) != NULL ) {
if (vstrsep(b, ">", &mac, &static_ip, &dns) < 2)
continue;
#ifdef USE_IPTABLE_ROUTE_TARGE
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), i?"<0>%s>>0": "0>%s>>0", mac);
#else
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), i?"<0>%s>>0": "0>%s>>0", static_ip);
#endif
++i;
}
if(nv) SAFE_FREE(nv);
nvram_set("vpnc_dev_policy_list", buf);
}
}
#endif
#if defined(RTCONFIG_NOTIFICATION_CENTER)
void force_off_push_msg(void)
{
char *nv, *nvp, *b;
char *eID, *eAct, *eType;
char replacebox[4096], rerule[256];
int action;
int RESAVE = OFF;
/* force disable push msg.
Format:[<eID>eAction>eType]
*/
memset(replacebox, 0, sizeof(replacebox));
nv = nvp = strdup(nvram_safe_get("nc_setting_conf"));
while(nvp)
{
if ((b = strsep(&nvp, "<")) == NULL) break;
if ((vstrsep(b, ">", &eID, &eAct, &eType)) != 3) continue;
memset(rerule, 0, sizeof(rerule));
action = atoi(eAct);
if ((action & ACTION_NOTIFY_APP)) {
RESAVE = ON;
}
NC_ACTION_CLR(action, NC_ACT_APP_BIT);
snprintf(rerule, sizeof(rerule), "<%s>%d>%s", eID, action, eType);
//dbg("[%s(%d)] %s\n", __FUNCTION__, __LINE__, rerule);
strcat(replacebox, rerule);
}
if (RESAVE)
nvram_set("nc_setting_conf", replacebox);
if(nv) free(nv);
}
#endif
void adjust_jffs_content(void)
{
/* migrate httpd/ssh key/cert to same location as Asus */
if (d_exists("/jffs/ssl")) {
system("/bin/mv -f /jffs/ssl/* /jffs/.cert/"); /* */
rmdir("/jffs/ssl");
}
/* Remove legacy 1.xxx Trend Micro signatures if present */
#ifdef RTCONFIG_BWDPI
if (f_exists("/jffs/signature/rule.trf") &&
f_size("/jffs/signature/rule.trf") < 50000)
unlink("/jffs/signature/rule.trf");
#endif
}