|
Lines 103-108
Link Here
|
| 103 |
#define HEIPV6TB_DEFAULT_PORT "80" |
103 |
#define HEIPV6TB_DEFAULT_PORT "80" |
| 104 |
#define HEIPV6TB_REQUEST "/index.cgi" |
104 |
#define HEIPV6TB_REQUEST "/index.cgi" |
| 105 |
|
105 |
|
|
|
106 |
#define DNSEXIT_DEFAULT_SERVER "www.dnsexit.com" |
| 107 |
#define DNSEXIT_DEFAULT_PORT "80" |
| 108 |
#define DNSEXIT_REQUEST "/RemoteUpdate.sv" |
| 109 |
|
| 106 |
#define DEFAULT_TIMEOUT 120 |
110 |
#define DEFAULT_TIMEOUT 120 |
| 107 |
#define DEFAULT_UPDATE_PERIOD 120 |
111 |
#define DEFAULT_UPDATE_PERIOD 120 |
| 108 |
#define DEFAULT_RESOLV_PERIOD 30 |
112 |
#define DEFAULT_RESOLV_PERIOD 30 |
|
Lines 139-144
Link Here
|
| 139 |
#if HAVE_SIGNAL_H |
143 |
#if HAVE_SIGNAL_H |
| 140 |
# include <signal.h> |
144 |
# include <signal.h> |
| 141 |
#endif |
145 |
#endif |
|
|
146 |
#if HAVE_TIME_H |
| 147 |
# include <time.h> |
| 148 |
#endif |
| 142 |
#if HAVE_SYS_TIME_H |
149 |
#if HAVE_SYS_TIME_H |
| 143 |
# include <sys/time.h> |
150 |
# include <sys/time.h> |
| 144 |
#endif |
151 |
#endif |
|
Lines 165-171
Link Here
|
| 165 |
#endif |
172 |
#endif |
| 166 |
|
173 |
|
| 167 |
|
174 |
|
| 168 |
#if __linux__ || __SVR4 || __OpenBSD__ || __FreeBSD__ || __NetBSD__ |
175 |
#if __GLIBC__ || __SVR4 || __OpenBSD__ || __FreeBSD__ || __NetBSD__ |
| 169 |
# define IF_LOOKUP 1 |
176 |
# define IF_LOOKUP 1 |
| 170 |
# include <sys/ioctl.h> |
177 |
# include <sys/ioctl.h> |
| 171 |
# include <net/if.h> |
178 |
# include <net/if.h> |
|
Lines 341-346
Link Here
|
| 341 |
int HEIPV6TB_check_info(void); |
348 |
int HEIPV6TB_check_info(void); |
| 342 |
static char *HEIPV6TB_fields_used[] = { "server", "user", NULL }; |
349 |
static char *HEIPV6TB_fields_used[] = { "server", "user", NULL }; |
| 343 |
|
350 |
|
|
|
351 |
int DNSEXIT_update_entry(void); |
| 352 |
int DNSEXIT_check_info(void); |
| 353 |
static char *DNSEXIT_fields_used[] = { "server", "user", "address", "wildcard", "mx", "host", NULL }; |
| 354 |
|
| 355 |
|
| 344 |
struct service_t services[] = { |
356 |
struct service_t services[] = { |
| 345 |
{ "NULL", |
357 |
{ "NULL", |
| 346 |
{ "null", "NULL", 0, }, |
358 |
{ "null", "NULL", 0, }, |
|
Lines 514-519
Link Here
|
| 514 |
HEIPV6TB_DEFAULT_PORT, |
526 |
HEIPV6TB_DEFAULT_PORT, |
| 515 |
HEIPV6TB_REQUEST |
527 |
HEIPV6TB_REQUEST |
| 516 |
}, |
528 |
}, |
|
|
529 |
{ "dnsexit", |
| 530 |
{ "dnsexit", 0, 0, }, |
| 531 |
NULL, |
| 532 |
DNSEXIT_update_entry, |
| 533 |
DNSEXIT_check_info, |
| 534 |
DNSEXIT_fields_used, |
| 535 |
DNSEXIT_DEFAULT_SERVER, |
| 536 |
DNSEXIT_DEFAULT_PORT, |
| 537 |
DNSEXIT_REQUEST |
| 538 |
}, |
| 517 |
}; |
539 |
}; |
| 518 |
|
540 |
|
| 519 |
static struct service_t *service = NULL; |
541 |
static struct service_t *service = NULL; |
|
Lines 640-646
Link Here
|
| 640 |
fprintf(stdout, " -q, --quiet \t\t\tbe quiet\n"); |
662 |
fprintf(stdout, " -q, --quiet \t\t\tbe quiet\n"); |
| 641 |
fprintf(stdout, " -r, --retrys <num>\t\tnumber of trys (default: 1)\n"); |
663 |
fprintf(stdout, " -r, --retrys <num>\t\tnumber of trys (default: 1)\n"); |
| 642 |
fprintf(stdout, " -R, --run-as-user <user>\tchange to <user> for running, be ware\n\t\t\t\tthat this can cause problems with handeling\n\t\t\t\tSIGHUP properly if that user can't read the\n\t\t\t\tconfig file. also it can't write it's pid file \n\t\t\t\tto a root directory\n"); |
664 |
fprintf(stdout, " -R, --run-as-user <user>\tchange to <user> for running, be ware\n\t\t\t\tthat this can cause problems with handeling\n\t\t\t\tSIGHUP properly if that user can't read the\n\t\t\t\tconfig file. also it can't write it's pid file \n\t\t\t\tto a root directory\n"); |
| 643 |
fprintf(stdout, " -Q, --run-as-euser <user>\tchange to effective <user> for running, \n\t\t\t\tthis is NOT secure but it does solve the \n\t\t\t\tproblems with run-as-user and config files and \n\t\t\t\tpid files.\n"); |
665 |
fprintf(stdout, " -Q, --run-as-euser <user>\tchange to effective <user> for running, \n\t\t\t\tthis is NOT secure but it does solve the \n\t\t\t\tproblems with run-as-user and config files and \n\t\t\t\tpid files\n"); |
| 644 |
fprintf(stdout, " -s, --server <server[:port]>\tthe server to connect to\n"); |
666 |
fprintf(stdout, " -s, --server <server[:port]>\tthe server to connect to\n"); |
| 645 |
fprintf(stdout, " -S, --service-type <server>\tthe type of service that you are using\n"); |
667 |
fprintf(stdout, " -S, --service-type <server>\tthe type of service that you are using\n"); |
| 646 |
width = fprintf(stdout, "\t\t\t\ttry one of: ") + 4*7; |
668 |
width = fprintf(stdout, "\t\t\t\ttry one of: ") + 4*7; |
|
Lines 682-688
Link Here
|
| 682 |
|
704 |
|
| 683 |
void print_signalhelp( void ) |
705 |
void print_signalhelp( void ) |
| 684 |
{ |
706 |
{ |
| 685 |
fprintf(stdout, "\nsignals are only really used when in daemon mode.\n\n"); |
707 |
fprintf(stdout, "\nsignals are only really used when in daemon mode\n\n"); |
| 686 |
fprintf(stdout, "signals: \n"); |
708 |
fprintf(stdout, "signals: \n"); |
| 687 |
fprintf(stdout, " HUP\t\tcauses it to re-read its config file\n"); |
709 |
fprintf(stdout, " HUP\t\tcauses it to re-read its config file\n"); |
| 688 |
fprintf(stdout, " TERM\t\twake up and possibly perform an update\n"); |
710 |
fprintf(stdout, " TERM\t\twake up and possibly perform an update\n"); |
|
Lines 693-699
Link Here
|
| 693 |
#if HAVE_SIGNAL_H |
715 |
#if HAVE_SIGNAL_H |
| 694 |
RETSIGTYPE sigint_handler(int sig) |
716 |
RETSIGTYPE sigint_handler(int sig) |
| 695 |
{ |
717 |
{ |
| 696 |
char message[] = "interupted.\n"; |
718 |
char message[] = "interrupted\n"; |
| 697 |
close(client_sockfd); |
719 |
close(client_sockfd); |
| 698 |
write(2, message, sizeof(message)-1); |
720 |
write(2, message, sizeof(message)-1); |
| 699 |
|
721 |
|
|
Lines 704-709
Link Here
|
| 704 |
} |
726 |
} |
| 705 |
#endif |
727 |
#endif |
| 706 |
|
728 |
|
|
|
729 |
#if HAVE_SYSLOG_H |
| 730 |
closelog(); |
| 731 |
#endif |
| 732 |
|
| 707 |
exit(1); |
733 |
exit(1); |
| 708 |
} |
734 |
} |
| 709 |
RETSIGTYPE generic_sig_handler(int sig) |
735 |
RETSIGTYPE generic_sig_handler(int sig) |
|
Lines 798-804
Link Here
|
| 798 |
sprintf(buf, "message incomplete because your OS sucks: %s\n", fmt); |
824 |
sprintf(buf, "message incomplete because your OS sucks: %s\n", fmt); |
| 799 |
#endif |
825 |
#endif |
| 800 |
|
826 |
|
| 801 |
syslog(LOG_NOTICE, buf); |
827 |
syslog(LOG_NOTICE, "%s", buf); |
| 802 |
} |
828 |
} |
| 803 |
else |
829 |
else |
| 804 |
{ |
830 |
{ |
|
Lines 1439-1445
Link Here
|
| 1439 |
if(!(options & OPT_QUIET)) |
1465 |
if(!(options & OPT_QUIET)) |
| 1440 |
{ |
1466 |
{ |
| 1441 |
fprintf(stderr, |
1467 |
fprintf(stderr, |
| 1442 |
"connected to %s (%s) on port %d.\n", |
1468 |
"connected to %s (%s) on port %d\n", |
| 1443 |
host, |
1469 |
host, |
| 1444 |
inet_ntoa(address.sin_addr), |
1470 |
inet_ntoa(address.sin_addr), |
| 1445 |
ntohs(address.sin_port)); |
1471 |
ntohs(address.sin_port)); |
|
Lines 1683-1689
Link Here
|
| 1683 |
close(client_sockfd); |
1709 |
close(client_sockfd); |
| 1684 |
return(-1); |
1710 |
return(-1); |
| 1685 |
} |
1711 |
} |
| 1686 |
if(strstr(buf, "\r\n") > 0) |
1712 |
if(strstr(buf, "\n") != NULL) |
| 1687 |
{ |
1713 |
{ |
| 1688 |
break; |
1714 |
break; |
| 1689 |
} |
1715 |
} |
|
Lines 1702-1709
Link Here
|
| 1702 |
|
1728 |
|
| 1703 |
if(options & OPT_DAEMON) |
1729 |
if(options & OPT_DAEMON) |
| 1704 |
{ |
1730 |
{ |
| 1705 |
fprintf(stderr, "no compile time default service was set therefor you must " |
1731 |
fprintf(stderr, "no compile time default service was set, you must " |
| 1706 |
"specify a service type.\n"); |
1732 |
"specify a service type\n"); |
| 1707 |
|
1733 |
|
| 1708 |
return(-1); |
1734 |
return(-1); |
| 1709 |
} |
1735 |
} |
|
Lines 2039-2045
Link Here
|
| 2039 |
} |
2065 |
} |
| 2040 |
else if(strstr(buf, "\nnumhost") != NULL) |
2066 |
else if(strstr(buf, "\nnumhost") != NULL) |
| 2041 |
{ |
2067 |
{ |
| 2042 |
show_message("Too many or too few hosts found\n"); |
2068 |
show_message("too many or too few hosts found\n"); |
| 2043 |
retval = UPDATERES_SHUTDOWN; |
2069 |
retval = UPDATERES_SHUTDOWN; |
| 2044 |
} |
2070 |
} |
| 2045 |
else if(strstr(buf, "\ndnserr") != NULL) |
2071 |
else if(strstr(buf, "\ndnserr") != NULL) |
|
Lines 2051-2067
Link Here
|
| 2051 |
} |
2077 |
} |
| 2052 |
else if(strstr(buf, "\n911") != NULL) |
2078 |
else if(strstr(buf, "\n911") != NULL) |
| 2053 |
{ |
2079 |
{ |
| 2054 |
show_message("Ahhhh! call 911!\n"); |
2080 |
show_message("ahhhh! call 911!\n"); |
| 2055 |
retval = UPDATERES_SHUTDOWN; |
2081 |
retval = UPDATERES_SHUTDOWN; |
| 2056 |
} |
2082 |
} |
| 2057 |
else if(strstr(buf, "\n999") != NULL) |
2083 |
else if(strstr(buf, "\n999") != NULL) |
| 2058 |
{ |
2084 |
{ |
| 2059 |
show_message("Ahhhh! call 999!\n"); |
2085 |
show_message("ahhhh! call 999!\n"); |
| 2060 |
retval = UPDATERES_SHUTDOWN; |
2086 |
retval = UPDATERES_SHUTDOWN; |
| 2061 |
} |
2087 |
} |
| 2062 |
else if(strstr(buf, "\n!donator") != NULL) |
2088 |
else if(strstr(buf, "\n!donator") != NULL) |
| 2063 |
{ |
2089 |
{ |
| 2064 |
show_message("a feature requested is only available to donators, please donate.\n", host); |
2090 |
show_message("a feature requested is only available to donators, please donate\n", host); |
| 2065 |
retval = UPDATERES_OK; |
2091 |
retval = UPDATERES_OK; |
| 2066 |
} |
2092 |
} |
| 2067 |
// this one should be last as it is a stupid string to signify waits |
2093 |
// this one should be last as it is a stupid string to signify waits |
|
Lines 2095-2103
Link Here
|
| 2095 |
sprintf(reason, "problem parsing reason for wait response"); |
2121 |
sprintf(reason, "problem parsing reason for wait response"); |
| 2096 |
} |
2122 |
} |
| 2097 |
|
2123 |
|
| 2098 |
show_message("Wait response received, waiting for %s before next update.\n", |
2124 |
show_message("wait response received, waiting for %s before next update\n", |
| 2099 |
format_time(howlong)); |
2125 |
format_time(howlong)); |
| 2100 |
show_message("Wait response reason: %d\n", N_STR(reason)); |
2126 |
show_message("wait response reason: %d\n", N_STR(reason)); |
| 2101 |
sleep(howlong); |
2127 |
sleep(howlong); |
| 2102 |
retval = UPDATERES_ERROR; |
2128 |
retval = UPDATERES_ERROR; |
| 2103 |
} |
2129 |
} |
|
Lines 3370-3376
Link Here
|
| 3370 |
{ |
3396 |
{ |
| 3371 |
if(!(options & OPT_QUIET)) |
3397 |
if(!(options & OPT_QUIET)) |
| 3372 |
{ |
3398 |
{ |
| 3373 |
fprintf(stderr, "warning: for GNUDIP the \"address\" parpameter is only used if set to \"0.0.0.0\" thus making an offline request.\n"); |
3399 |
fprintf(stderr, "warning: for GNUDIP the \"address\" parameter is only used if set to \"0.0.0.0\" thus making an offline request\n"); |
| 3374 |
} |
3400 |
} |
| 3375 |
} |
3401 |
} |
| 3376 |
|
3402 |
|
|
Lines 3392-3398
Link Here
|
| 3392 |
|
3418 |
|
| 3393 |
// send an offline request if address 0.0.0.0 is used |
3419 |
// send an offline request if address 0.0.0.0 is used |
| 3394 |
// otherwise, we ignore the address and send an update request |
3420 |
// otherwise, we ignore the address and send an update request |
| 3395 |
gnudip_request[0] = strcmp(address, "0.0.0.0") == 0 ? '1' : '0'; |
3421 |
gnudip_request[0] = address && strcmp(address, "0.0.0.0") == 0 ? '1' : '0'; |
| 3396 |
gnudip_request[1] = '\0'; |
3422 |
gnudip_request[1] = '\0'; |
| 3397 |
|
3423 |
|
| 3398 |
// find domainname |
3424 |
// find domainname |
|
Lines 3943-3964
Link Here
|
| 3943 |
break; |
3969 |
break; |
| 3944 |
|
3970 |
|
| 3945 |
case 201: |
3971 |
case 201: |
| 3946 |
show_message("Last update was less than %d seconds ago.\n", 300); |
3972 |
show_message("last update was less than %d seconds ago\n", 300); |
| 3947 |
return(UPDATERES_ERROR); |
3973 |
return(UPDATERES_ERROR); |
| 3948 |
break; |
3974 |
break; |
| 3949 |
|
3975 |
|
| 3950 |
case 202: |
3976 |
case 202: |
| 3951 |
show_message("Server error.\n"); |
3977 |
show_message("server error\n"); |
| 3952 |
return(UPDATERES_ERROR); |
3978 |
return(UPDATERES_ERROR); |
| 3953 |
break; |
3979 |
break; |
| 3954 |
|
3980 |
|
| 3955 |
case 203: |
3981 |
case 203: |
| 3956 |
show_message("Failure because account is frozen (by admin).\n"); |
3982 |
show_message("failure because account is frozen (by admin)\n"); |
| 3957 |
return(UPDATERES_SHUTDOWN); |
3983 |
return(UPDATERES_SHUTDOWN); |
| 3958 |
break; |
3984 |
break; |
| 3959 |
|
3985 |
|
| 3960 |
case 204: |
3986 |
case 204: |
| 3961 |
show_message("Failure because account is locked (by user).\n"); |
3987 |
show_message("failure because account is locked (by user)\n"); |
| 3962 |
return(UPDATERES_SHUTDOWN); |
3988 |
return(UPDATERES_SHUTDOWN); |
| 3963 |
break; |
3989 |
break; |
| 3964 |
|
3990 |
|
|
Lines 4215-4222
Link Here
|
| 4215 |
|
4241 |
|
| 4216 |
switch(ret) |
4242 |
switch(ret) |
| 4217 |
{ |
4243 |
{ |
| 4218 |
char *p; |
|
|
| 4219 |
|
| 4220 |
case -1: |
4244 |
case -1: |
| 4221 |
if(!(options & OPT_QUIET)) |
4245 |
if(!(options & OPT_QUIET)) |
| 4222 |
{ |
4246 |
{ |
|
Lines 4246-4251
Link Here
|
| 4246 |
return(UPDATERES_OK); |
4270 |
return(UPDATERES_OK); |
| 4247 |
} |
4271 |
} |
| 4248 |
|
4272 |
|
|
|
4273 |
int DNSEXIT_check_info(void) |
| 4274 |
{ |
| 4275 |
char buf[BUFSIZ+1]; |
| 4276 |
|
| 4277 |
if((host == NULL) || (*host == '\0')) |
| 4278 |
{ |
| 4279 |
if(options & OPT_DAEMON) |
| 4280 |
{ |
| 4281 |
return(-1); |
| 4282 |
} |
| 4283 |
if(host) { free(host); } |
| 4284 |
printf("host: "); |
| 4285 |
*buf = '\0'; |
| 4286 |
fgets(buf, BUFSIZ, stdin); |
| 4287 |
host = strdup(buf); |
| 4288 |
chomp(host); |
| 4289 |
} |
| 4290 |
|
| 4291 |
if(interface == NULL && address == NULL) |
| 4292 |
{ |
| 4293 |
if(options & OPT_DAEMON) |
| 4294 |
{ |
| 4295 |
fprintf(stderr, "you must provide either an interface or an address\n"); |
| 4296 |
return(-1); |
| 4297 |
} |
| 4298 |
if(interface) { free(interface); } |
| 4299 |
printf("interface: "); |
| 4300 |
*buf = '\0'; |
| 4301 |
fgets(buf, BUFSIZ, stdin); |
| 4302 |
chomp(buf); |
| 4303 |
option_handler(CMD_interface, buf); |
| 4304 |
} |
| 4305 |
|
| 4306 |
warn_fields(service->fields_used); |
| 4307 |
|
| 4308 |
return 0; |
| 4309 |
} |
| 4310 |
|
| 4311 |
int DNSEXIT_update_entry(void) |
| 4312 |
{ |
| 4313 |
char buf[BUFFER_SIZE+1]; |
| 4314 |
char *bp = buf; |
| 4315 |
int bytes; |
| 4316 |
int btot; |
| 4317 |
int ret; |
| 4318 |
|
| 4319 |
buf[BUFFER_SIZE] = '\0'; |
| 4320 |
|
| 4321 |
if(do_connect((int*)&client_sockfd, server, port) != 0) |
| 4322 |
{ |
| 4323 |
if(!(options & OPT_QUIET)) |
| 4324 |
{ |
| 4325 |
show_message("error connecting to %s:%s\n", server, port); |
| 4326 |
} |
| 4327 |
return(UPDATERES_ERROR); |
| 4328 |
} |
| 4329 |
|
| 4330 |
snprintf(buf, BUFFER_SIZE, "GET %s?action=edit&", request); |
| 4331 |
output(buf); |
| 4332 |
if(address != NULL && *address != '\0') |
| 4333 |
{ |
| 4334 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "myip", address); |
| 4335 |
output(buf); |
| 4336 |
} |
| 4337 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "wildcard", wildcard ? "ON" : "OFF"); |
| 4338 |
output(buf); |
| 4339 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "mx", mx); |
| 4340 |
output(buf); |
| 4341 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "backmx", *mx == '\0' ? "NO" : "YES"); |
| 4342 |
output(buf); |
| 4343 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "host", host); |
| 4344 |
output(buf); |
| 4345 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "login", user_name); |
| 4346 |
output(buf); |
| 4347 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "password", password); |
| 4348 |
output(buf); |
| 4349 |
snprintf(buf, BUFFER_SIZE, " HTTP/1.0\015\012"); |
| 4350 |
output(buf); |
| 4351 |
snprintf(buf, BUFFER_SIZE, "Authorization: Basic %s\015\012", auth); |
| 4352 |
output(buf); |
| 4353 |
snprintf(buf, BUFFER_SIZE, "User-Agent: %s-%s %s [%s] (%s)\015\012", |
| 4354 |
"ez-update", VERSION, OS, (options & OPT_DAEMON) ? "daemon" : "", "by Angus Mackay"); |
| 4355 |
output(buf); |
| 4356 |
snprintf(buf, BUFFER_SIZE, "Host: %s\015\012", server); |
| 4357 |
output(buf); |
| 4358 |
snprintf(buf, BUFFER_SIZE, "\015\012"); |
| 4359 |
output(buf); |
| 4360 |
|
| 4361 |
bp = buf; |
| 4362 |
bytes = 0; |
| 4363 |
btot = 0; |
| 4364 |
while((bytes=read_input(bp, BUFFER_SIZE-btot)) > 0) |
| 4365 |
{ |
| 4366 |
bp += bytes; |
| 4367 |
btot += bytes; |
| 4368 |
dprintf((stderr, "btot: %d\n", btot)); |
| 4369 |
} |
| 4370 |
close(client_sockfd); |
| 4371 |
buf[btot] = '\0'; |
| 4372 |
|
| 4373 |
dprintf((stderr, "server output: %s\n", buf)); |
| 4374 |
|
| 4375 |
if(sscanf(buf, " HTTP/1.%*c %3d", &ret) != 1) |
| 4376 |
{ |
| 4377 |
ret = -1; |
| 4378 |
} |
| 4379 |
|
| 4380 |
switch(ret) |
| 4381 |
{ |
| 4382 |
case -1: |
| 4383 |
if(!(options & OPT_QUIET)) |
| 4384 |
{ |
| 4385 |
show_message("strange server response, are you connecting to the right server?\n"); |
| 4386 |
} |
| 4387 |
return(UPDATERES_ERROR); |
| 4388 |
break; |
| 4389 |
|
| 4390 |
case 200: |
| 4391 |
|
| 4392 |
if(strstr(buf, "0=Success") != NULL) |
| 4393 |
{ |
| 4394 |
if(!(options & OPT_QUIET)) |
| 4395 |
{ |
| 4396 |
printf("Request successful\n"); |
| 4397 |
} |
| 4398 |
} |
| 4399 |
else if(strstr(buf, "1=IP stays same") != NULL) |
| 4400 |
{ |
| 4401 |
if(!(options & OPT_QUIET)) |
| 4402 |
{ |
| 4403 |
printf("Request successful but the IP is the same as previous update\n"); |
| 4404 |
} |
| 4405 |
} |
| 4406 |
else |
| 4407 |
{ |
| 4408 |
show_message("Errors return from server\n"); |
| 4409 |
if(!(options & OPT_QUIET)) |
| 4410 |
{ |
| 4411 |
fprintf(stderr, "server output: %s\n", buf); |
| 4412 |
} |
| 4413 |
return(UPDATERES_ERROR); |
| 4414 |
} |
| 4415 |
break; |
| 4416 |
|
| 4417 |
case 401: |
| 4418 |
if(!(options & OPT_QUIET)) |
| 4419 |
{ |
| 4420 |
show_message("authentication failure\n"); |
| 4421 |
} |
| 4422 |
return(UPDATERES_SHUTDOWN); |
| 4423 |
break; |
| 4424 |
|
| 4425 |
default: |
| 4426 |
if(!(options & OPT_QUIET)) |
| 4427 |
{ |
| 4428 |
// reuse the auth buffer |
| 4429 |
*auth = '\0'; |
| 4430 |
sscanf(buf, " HTTP/1.%*c %*3d %255[^\r\n]", auth); |
| 4431 |
show_message("unknown return code: %d\n", ret); |
| 4432 |
show_message("server response: %s\n", auth); |
| 4433 |
} |
| 4434 |
return(UPDATERES_ERROR); |
| 4435 |
break; |
| 4436 |
} |
| 4437 |
|
| 4438 |
return(UPDATERES_OK); |
| 4439 |
} |
| 4440 |
|
| 4249 |
static int is_in_list(char *needle, char **haystack) |
4441 |
static int is_in_list(char *needle, char **haystack) |
| 4250 |
{ |
4442 |
{ |
| 4251 |
char **p; |
4443 |
char **p; |
|
Lines 4349-4355
Link Here
|
| 4349 |
case SIGHUP: |
4541 |
case SIGHUP: |
| 4350 |
if(config_file) |
4542 |
if(config_file) |
| 4351 |
{ |
4543 |
{ |
| 4352 |
show_message("SIGHUP recieved, re-reading config file\n"); |
4544 |
show_message("SIGHUP received, re-reading config file\n"); |
| 4353 |
if(parse_conf_file(config_file, conf_commands) != 0) |
4545 |
if(parse_conf_file(config_file, conf_commands) != 0) |
| 4354 |
{ |
4546 |
{ |
| 4355 |
show_message("error parsing config file \"%s\"\n", config_file); |
4547 |
show_message("error parsing config file \"%s\"\n", config_file); |
|
Lines 4384-4389
Link Here
|
| 4384 |
|
4576 |
|
| 4385 |
int main(int argc, char **argv) |
4577 |
int main(int argc, char **argv) |
| 4386 |
{ |
4578 |
{ |
|
|
4579 |
char *tmp; |
| 4387 |
int ifresolve_warned = 0; |
4580 |
int ifresolve_warned = 0; |
| 4388 |
int i; |
4581 |
int i; |
| 4389 |
int retval = 1; |
4582 |
int retval = 1; |
|
Lines 4395-4403
Link Here
|
| 4395 |
mcheck(NULL); |
4588 |
mcheck(NULL); |
| 4396 |
#endif |
4589 |
#endif |
| 4397 |
|
4590 |
|
| 4398 |
dprintf((stderr, "staring...\n")); |
4591 |
dprintf((stderr, "starting...\n")); |
| 4399 |
|
4592 |
|
| 4400 |
program_name = argv[0]; |
4593 |
tmp = strrchr(argv[0], '/'); |
|
|
4594 |
program_name = tmp ? tmp + 1 : argv[0]; |
| 4401 |
options = 0; |
4595 |
options = 0; |
| 4402 |
*user = '\0'; |
4596 |
*user = '\0'; |
| 4403 |
timeout.tv_sec = DEFAULT_TIMEOUT; |
4597 |
timeout.tv_sec = DEFAULT_TIMEOUT; |
|
Lines 4417-4423
Link Here
|
| 4417 |
|
4611 |
|
| 4418 |
if(!(options & OPT_QUIET) && !(options & OPT_DAEMON)) |
4612 |
if(!(options & OPT_QUIET) && !(options & OPT_DAEMON)) |
| 4419 |
{ |
4613 |
{ |
| 4420 |
fprintf(stderr, "ez-ipupdate Version %s\nCopyright (C) 1998-2001 Angus Mackay.\n", VERSION); |
4614 |
fprintf(stderr, "%s Version %s\nCopyright (C) 1998-2001 Angus Mackay\n", program_name, VERSION); |
| 4421 |
} |
4615 |
} |
| 4422 |
|
4616 |
|
| 4423 |
dprintf((stderr, "options: 0x%04X\n", options)); |
4617 |
dprintf((stderr, "options: 0x%04X\n", options)); |
|
Lines 4434-4440
Link Here
|
| 4434 |
{ |
4628 |
{ |
| 4435 |
if(service->check_info() != 0) |
4629 |
if(service->check_info() != 0) |
| 4436 |
{ |
4630 |
{ |
| 4437 |
fprintf(stderr, "invalid data to perform requested action.\n"); |
4631 |
fprintf(stderr, "invalid data to perform requested action\n"); |
| 4438 |
exit(1); |
4632 |
exit(1); |
| 4439 |
} |
4633 |
} |
| 4440 |
} |
4634 |
} |
|
Lines 4456-4468
Link Here
|
| 4456 |
dprintf((stderr, "user_name: %s\n", user_name)); |
4650 |
dprintf((stderr, "user_name: %s\n", user_name)); |
| 4457 |
dprintf((stderr, "password: %s\n", password)); |
4651 |
dprintf((stderr, "password: %s\n", password)); |
| 4458 |
} |
4652 |
} |
| 4459 |
if(*user_name == '\0') |
4653 |
if(*user_name == '\0' && !(options & OPT_DAEMON)) |
| 4460 |
{ |
4654 |
{ |
| 4461 |
printf("user name: "); |
4655 |
printf("user name: "); |
| 4462 |
fgets(user_name, sizeof(user_name), stdin); |
4656 |
fgets(user_name, sizeof(user_name), stdin); |
| 4463 |
chomp(user_name); |
4657 |
chomp(user_name); |
| 4464 |
} |
4658 |
} |
| 4465 |
if(*password == '\0') |
4659 |
if(*password == '\0' && !(options & OPT_DAEMON)) |
| 4466 |
{ |
4660 |
{ |
| 4467 |
strncpy(password, getpass("password: "), sizeof(password)); |
4661 |
strncpy(password, getpass("password: "), sizeof(password)); |
| 4468 |
} |
4662 |
} |
|
Lines 4480-4486
Link Here
|
| 4480 |
|
4674 |
|
| 4481 |
if(service->check_info() != 0) |
4675 |
if(service->check_info() != 0) |
| 4482 |
{ |
4676 |
{ |
| 4483 |
fprintf(stderr, "invalid data to perform requested action.\n"); |
4677 |
fprintf(stderr, "invalid data to perform requested action\n"); |
| 4484 |
exit(1); |
4678 |
exit(1); |
| 4485 |
} |
4679 |
} |
| 4486 |
|
4680 |
|
|
Lines 4503-4509
Link Here
|
| 4503 |
|
4697 |
|
| 4504 |
if(interface == NULL) |
4698 |
if(interface == NULL) |
| 4505 |
{ |
4699 |
{ |
| 4506 |
fprintf(stderr, "invalid data to perform requested action.\n"); |
4700 |
fprintf(stderr, "invalid data to perform requested action\n"); |
| 4507 |
fprintf(stderr, "you must provide an interface for daemon mode"); |
4701 |
fprintf(stderr, "you must provide an interface for daemon mode"); |
| 4508 |
exit(1); |
4702 |
exit(1); |
| 4509 |
} |
4703 |
} |
|
Lines 4519-4541
Link Here
|
| 4519 |
if(fork() > 0) { exit(0); } /* parent */ |
4713 |
if(fork() > 0) { exit(0); } /* parent */ |
| 4520 |
} |
4714 |
} |
| 4521 |
|
4715 |
|
|
|
4716 |
# if HAVE_SYSLOG_H |
| 4717 |
openlog(program_name, LOG_PID, LOG_DAEMON ); |
| 4718 |
//options |= OPT_QUIET; |
| 4719 |
# endif |
| 4720 |
show_message("version %s, interface %s, host %s, server %s, service %s\n", |
| 4721 |
VERSION, N_STR(interface), N_STR(host), server, service->title); |
| 4722 |
|
| 4522 |
#if HAVE_GETPID |
4723 |
#if HAVE_GETPID |
| 4523 |
if(pid_file && pid_file_create(pid_file) != 0) |
4724 |
if(pid_file && pid_file_create(pid_file) != 0) |
| 4524 |
{ |
4725 |
{ |
| 4525 |
fprintf(stderr, "exiting...\n"); |
4726 |
show_message("could not create pid file %s (%s), exiting\n", |
|
|
4727 |
pid_file, strerror(errno)); |
| 4728 |
#if HAVE_SYSLOG_H |
| 4729 |
closelog(); |
| 4730 |
#endif |
| 4526 |
exit(1); |
4731 |
exit(1); |
| 4527 |
} |
4732 |
} |
| 4528 |
#endif |
4733 |
#endif |
| 4529 |
|
4734 |
|
| 4530 |
# if HAVE_SYSLOG_H |
|
|
| 4531 |
openlog(program_name, LOG_PID, LOG_USER ); |
| 4532 |
options |= OPT_QUIET; |
| 4533 |
# endif |
| 4534 |
show_message("ez-ipupdate Version %s, Copyright (C) 1998-2001 Angus Mackay.\n", |
| 4535 |
VERSION); |
| 4536 |
show_message("%s started for interface %s host %s using server %s and service %s\n", |
| 4537 |
program_name, N_STR(interface), N_STR(host), server, service->title); |
| 4538 |
|
| 4539 |
memset(&sin, 0, sizeof(sin)); |
4735 |
memset(&sin, 0, sizeof(sin)); |
| 4540 |
|
4736 |
|
| 4541 |
if(cache_file) |
4737 |
if(cache_file) |
|
Lines 4560-4566
Link Here
|
| 4560 |
strftime(timebuf, sizeof(timebuf), "%Y/%m/%d %H:%M", ts); |
4756 |
strftime(timebuf, sizeof(timebuf), "%Y/%m/%d %H:%M", ts); |
| 4561 |
show_message("got last update %s on %s from cache file\n", ipstr, timebuf); |
4757 |
show_message("got last update %s on %s from cache file\n", ipstr, timebuf); |
| 4562 |
} |
4758 |
} |
| 4563 |
else |
4759 |
else if(ipstr||ipdate) |
| 4564 |
{ |
4760 |
{ |
| 4565 |
show_message("malformed cache file: %s\n", cache_file); |
4761 |
show_message("malformed cache file: %s\n", cache_file); |
| 4566 |
} |
4762 |
} |
|
Lines 4647-4653
Link Here
|
| 4647 |
} |
4843 |
} |
| 4648 |
else |
4844 |
else |
| 4649 |
{ |
4845 |
{ |
| 4650 |
show_message("failure to update %s->%s (%s)\n", |
4846 |
show_message("failed to update %s->%s (%s)\n", |
| 4651 |
interface, inet_ntoa(sin.sin_addr), N_STR(host)); |
4847 |
interface, inet_ntoa(sin.sin_addr), N_STR(host)); |
| 4652 |
memset(&sin, 0, sizeof(sin)); |
4848 |
memset(&sin, 0, sizeof(sin)); |
| 4653 |
|
4849 |
|
|
Lines 4671-4677
Link Here
|
| 4671 |
dprintf((stderr, "updateres: %d\n", updateres)); |
4867 |
dprintf((stderr, "updateres: %d\n", updateres)); |
| 4672 |
if(updateres == UPDATERES_SHUTDOWN) |
4868 |
if(updateres == UPDATERES_SHUTDOWN) |
| 4673 |
{ |
4869 |
{ |
| 4674 |
show_message("shuting down updater for %s due to fatal error\n", |
4870 |
show_message("shutting down updater for %s due to fatal error\n", |
| 4675 |
N_STR(host)); |
4871 |
N_STR(host)); |
| 4676 |
|
4872 |
|
| 4677 |
if(notify_email && *notify_email != '\0') |
4873 |
if(notify_email && *notify_email != '\0') |
|
Lines 4711-4717
Link Here
|
| 4711 |
#endif |
4907 |
#endif |
| 4712 |
|
4908 |
|
| 4713 |
#else |
4909 |
#else |
| 4714 |
fprintf(stderr, "sorry, this mode is only available on platforms that the "); |
4910 |
fprintf(stderr, "sorry, this mode is only available on platforms where the "); |
| 4715 |
fprintf(stderr, "IP address \ncan be determined. feel free to hack the code"); |
4911 |
fprintf(stderr, "IP address \ncan be determined. feel free to hack the code"); |
| 4716 |
fprintf(stderr, " though.\n"); |
4912 |
fprintf(stderr, " though.\n"); |
| 4717 |
exit(1); |
4913 |
exit(1); |
|
Lines 4799-4805
Link Here
|
| 4799 |
} |
4995 |
} |
| 4800 |
else |
4996 |
else |
| 4801 |
{ |
4997 |
{ |
| 4802 |
show_message("could not resolve ip address for %s.\n", interface); |
4998 |
show_message("could not resolve ip address for %s\n", interface); |
| 4803 |
exit(1); |
4999 |
exit(1); |
| 4804 |
} |
5000 |
} |
| 4805 |
close(sock); |
5001 |
close(sock); |