| 1 |
$FreeWRT$ |
| 2 |
|
| 3 |
cjb.net support by <tg@freewrt.org> |
| 4 |
|
| 5 |
--- ez-ipupdate-3.0.11b8.orig/ez-ipupdate.c Mon Mar 11 23:31:25 2002 |
| 6 |
+++ ez-ipupdate-3.0.11b8/ez-ipupdate.c Tue Jul 31 14:05:00 2007 |
| 7 |
@@ -87,6 +87,10 @@ |
| 8 |
#define JUSTL_REQUEST "/bin/controlpanel/dyndns/jlc.pl" |
| 9 |
#define JUSTL_VERSION "2.0" |
| 10 |
|
| 11 |
+#define CJB_DEFAULT_SERVER "www.cjb.net" |
| 12 |
+#define CJB_DEFAULT_PORT "80" |
| 13 |
+#define CJB_REQUEST "/cgi-bin/dynip.cgi" |
| 14 |
+ |
| 15 |
#define DYNS_DEFAULT_SERVER "www.dyns.cx" |
| 16 |
#define DYNS_DEFAULT_PORT "80" |
| 17 |
#define DYNS_REQUEST "/postscript.php" |
| 18 |
@@ -139,6 +143,9 @@ |
| 19 |
#if HAVE_SIGNAL_H |
| 20 |
# include <signal.h> |
| 21 |
#endif |
| 22 |
+#if HAVE_TIME_H |
| 23 |
+# include <time.h> |
| 24 |
+#endif |
| 25 |
#if HAVE_SYS_TIME_H |
| 26 |
# include <sys/time.h> |
| 27 |
#endif |
| 28 |
@@ -165,7 +172,7 @@ |
| 29 |
#endif |
| 30 |
|
| 31 |
|
| 32 |
-#if __linux__ || __SVR4 || __OpenBSD__ || __FreeBSD__ || __NetBSD__ |
| 33 |
+#if __GLIBC__ || __SVR4 || __OpenBSD__ || __FreeBSD__ || __NetBSD__ |
| 34 |
# define IF_LOOKUP 1 |
| 35 |
# include <sys/ioctl.h> |
| 36 |
# include <net/if.h> |
| 37 |
@@ -325,6 +332,10 @@ int JUSTL_update_entry(void); |
| 38 |
int JUSTL_check_info(void); |
| 39 |
static char *JUSTL_fields_used[] = { "server", "user", "host", NULL }; |
| 40 |
|
| 41 |
+int CJB_update_entry(void); |
| 42 |
+int CJB_check_info(void); |
| 43 |
+static char *CJB_fields_used[] = { "server", "user", NULL }; |
| 44 |
+ |
| 45 |
int DYNS_update_entry(void); |
| 46 |
int DYNS_check_info(void); |
| 47 |
static char *DYNS_fields_used[] = { "server", "user", "host", NULL }; |
| 48 |
@@ -474,6 +485,16 @@ struct service_t services[] = { |
| 49 |
JUSTL_DEFAULT_PORT, |
| 50 |
JUSTL_REQUEST |
| 51 |
}, |
| 52 |
+ { "cjb.net", |
| 53 |
+ { "cjb", 0, 0, }, |
| 54 |
+ NULL, |
| 55 |
+ CJB_update_entry, |
| 56 |
+ CJB_check_info, |
| 57 |
+ CJB_fields_used, |
| 58 |
+ CJB_DEFAULT_SERVER, |
| 59 |
+ CJB_DEFAULT_PORT, |
| 60 |
+ CJB_REQUEST |
| 61 |
+ }, |
| 62 |
{ "dyns", |
| 63 |
{ "dyns", 0, 0, }, |
| 64 |
NULL, |
| 65 |
@@ -640,7 +661,7 @@ void print_usage( void ) |
| 66 |
fprintf(stdout, " -q, --quiet \t\t\tbe quiet\n"); |
| 67 |
fprintf(stdout, " -r, --retrys <num>\t\tnumber of trys (default: 1)\n"); |
| 68 |
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"); |
| 69 |
- 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"); |
| 70 |
+ 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"); |
| 71 |
fprintf(stdout, " -s, --server <server[:port]>\tthe server to connect to\n"); |
| 72 |
fprintf(stdout, " -S, --service-type <server>\tthe type of service that you are using\n"); |
| 73 |
width = fprintf(stdout, "\t\t\t\ttry one of: ") + 4*7; |
| 74 |
@@ -682,7 +703,7 @@ void print_credits( void ) |
| 75 |
|
| 76 |
void print_signalhelp( void ) |
| 77 |
{ |
| 78 |
- fprintf(stdout, "\nsignals are only really used when in daemon mode.\n\n"); |
| 79 |
+ fprintf(stdout, "\nsignals are only really used when in daemon mode\n\n"); |
| 80 |
fprintf(stdout, "signals: \n"); |
| 81 |
fprintf(stdout, " HUP\t\tcauses it to re-read its config file\n"); |
| 82 |
fprintf(stdout, " TERM\t\twake up and possibly perform an update\n"); |
| 83 |
@@ -693,7 +714,7 @@ void print_signalhelp( void ) |
| 84 |
#if HAVE_SIGNAL_H |
| 85 |
RETSIGTYPE sigint_handler(int sig) |
| 86 |
{ |
| 87 |
- char message[] = "interupted.\n"; |
| 88 |
+ char message[] = "interrupted\n"; |
| 89 |
close(client_sockfd); |
| 90 |
write(2, message, sizeof(message)-1); |
| 91 |
|
| 92 |
@@ -704,6 +725,10 @@ RETSIGTYPE sigint_handler(int sig) |
| 93 |
} |
| 94 |
#endif |
| 95 |
|
| 96 |
+#if HAVE_SYSLOG_H |
| 97 |
+ closelog(); |
| 98 |
+#endif |
| 99 |
+ |
| 100 |
exit(1); |
| 101 |
} |
| 102 |
RETSIGTYPE generic_sig_handler(int sig) |
| 103 |
@@ -798,7 +823,7 @@ void show_message(char *fmt, ...) |
| 104 |
sprintf(buf, "message incomplete because your OS sucks: %s\n", fmt); |
| 105 |
#endif |
| 106 |
|
| 107 |
- syslog(LOG_NOTICE, buf); |
| 108 |
+ syslog(LOG_NOTICE, "%s", buf); |
| 109 |
} |
| 110 |
else |
| 111 |
{ |
| 112 |
@@ -1439,7 +1464,7 @@ int do_connect(int *sock, char *host, ch |
| 113 |
if(!(options & OPT_QUIET)) |
| 114 |
{ |
| 115 |
fprintf(stderr, |
| 116 |
- "connected to %s (%s) on port %d.\n", |
| 117 |
+ "connected to %s (%s) on port %d\n", |
| 118 |
host, |
| 119 |
inet_ntoa(address.sin_addr), |
| 120 |
ntohs(address.sin_port)); |
| 121 |
@@ -1683,7 +1708,7 @@ static int ODS_read_response(char *buf, |
| 122 |
close(client_sockfd); |
| 123 |
return(-1); |
| 124 |
} |
| 125 |
- if(strstr(buf, "\r\n") > 0) |
| 126 |
+ if(strstr(buf, "\n") != NULL) |
| 127 |
{ |
| 128 |
break; |
| 129 |
} |
| 130 |
@@ -1702,8 +1727,8 @@ int NULL_check_info(void) |
| 131 |
|
| 132 |
if(options & OPT_DAEMON) |
| 133 |
{ |
| 134 |
- fprintf(stderr, "no compile time default service was set therefor you must " |
| 135 |
- "specify a service type.\n"); |
| 136 |
+ fprintf(stderr, "no compile time default service was set, you must " |
| 137 |
+ "specify a service type\n"); |
| 138 |
|
| 139 |
return(-1); |
| 140 |
} |
| 141 |
@@ -2039,7 +2064,7 @@ int DYNDNS_update_entry(void) |
| 142 |
} |
| 143 |
else if(strstr(buf, "\nnumhost") != NULL) |
| 144 |
{ |
| 145 |
- show_message("Too many or too few hosts found\n"); |
| 146 |
+ show_message("too many or too few hosts found\n"); |
| 147 |
retval = UPDATERES_SHUTDOWN; |
| 148 |
} |
| 149 |
else if(strstr(buf, "\ndnserr") != NULL) |
| 150 |
@@ -2051,17 +2076,17 @@ int DYNDNS_update_entry(void) |
| 151 |
} |
| 152 |
else if(strstr(buf, "\n911") != NULL) |
| 153 |
{ |
| 154 |
- show_message("Ahhhh! call 911!\n"); |
| 155 |
+ show_message("ahhhh! call 911!\n"); |
| 156 |
retval = UPDATERES_SHUTDOWN; |
| 157 |
} |
| 158 |
else if(strstr(buf, "\n999") != NULL) |
| 159 |
{ |
| 160 |
- show_message("Ahhhh! call 999!\n"); |
| 161 |
+ show_message("ahhhh! call 999!\n"); |
| 162 |
retval = UPDATERES_SHUTDOWN; |
| 163 |
} |
| 164 |
else if(strstr(buf, "\n!donator") != NULL) |
| 165 |
{ |
| 166 |
- show_message("a feature requested is only available to donators, please donate.\n", host); |
| 167 |
+ show_message("a feature requested is only available to donators, please donate\n", host); |
| 168 |
retval = UPDATERES_OK; |
| 169 |
} |
| 170 |
// this one should be last as it is a stupid string to signify waits |
| 171 |
@@ -2095,9 +2120,9 @@ int DYNDNS_update_entry(void) |
| 172 |
sprintf(reason, "problem parsing reason for wait response"); |
| 173 |
} |
| 174 |
|
| 175 |
- show_message("Wait response received, waiting for %s before next update.\n", |
| 176 |
+ show_message("wait response received, waiting for %s before next update\n", |
| 177 |
format_time(howlong)); |
| 178 |
- show_message("Wait response reason: %d\n", N_STR(reason)); |
| 179 |
+ show_message("wait response reason: %d\n", N_STR(reason)); |
| 180 |
sleep(howlong); |
| 181 |
retval = UPDATERES_ERROR; |
| 182 |
} |
| 183 |
@@ -3370,7 +3395,7 @@ int GNUDIP_check_info(void) |
| 184 |
{ |
| 185 |
if(!(options & OPT_QUIET)) |
| 186 |
{ |
| 187 |
- fprintf(stderr, "warning: for GNUDIP the \"address\" parpameter is only used if set to \"0.0.0.0\" thus making an offline request.\n"); |
| 188 |
+ fprintf(stderr, "warning: for GNUDIP the \"address\" parameter is only used if set to \"0.0.0.0\" thus making an offline request\n"); |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
@@ -3392,7 +3417,7 @@ int GNUDIP_update_entry(void) |
| 193 |
|
| 194 |
// send an offline request if address 0.0.0.0 is used |
| 195 |
// otherwise, we ignore the address and send an update request |
| 196 |
- gnudip_request[0] = strcmp(address, "0.0.0.0") == 0 ? '1' : '0'; |
| 197 |
+ gnudip_request[0] = address && strcmp(address, "0.0.0.0") == 0 ? '1' : '0'; |
| 198 |
gnudip_request[1] = '\0'; |
| 199 |
|
| 200 |
// find domainname |
| 201 |
@@ -3660,6 +3685,140 @@ int JUSTL_update_entry(void) |
| 202 |
return(UPDATERES_OK); |
| 203 |
} |
| 204 |
|
| 205 |
+int CJB_check_info(void) |
| 206 |
+{ |
| 207 |
+ char buf[BUFSIZ+1]; |
| 208 |
+ |
| 209 |
+ if(interface == NULL && address == NULL) |
| 210 |
+ { |
| 211 |
+ if(options & OPT_DAEMON) |
| 212 |
+ { |
| 213 |
+ fprintf(stderr, "you must provide either an interface or an address\n"); |
| 214 |
+ return(-1); |
| 215 |
+ } |
| 216 |
+ if(interface) { free(interface); } |
| 217 |
+ printf("interface: "); |
| 218 |
+ *buf = '\0'; |
| 219 |
+ fgets(buf, BUFSIZ, stdin); |
| 220 |
+ chomp(buf); |
| 221 |
+ option_handler(CMD_interface, buf); |
| 222 |
+ } |
| 223 |
+ |
| 224 |
+ warn_fields(service->fields_used); |
| 225 |
+ |
| 226 |
+ return 0; |
| 227 |
+} |
| 228 |
+ |
| 229 |
+int CJB_update_entry(void) |
| 230 |
+{ |
| 231 |
+ char buf[BUFFER_SIZE+1]; |
| 232 |
+ char *bp = buf; |
| 233 |
+ int bytes; |
| 234 |
+ int btot; |
| 235 |
+ int ret; |
| 236 |
+ |
| 237 |
+ buf[BUFFER_SIZE] = '\0'; |
| 238 |
+ |
| 239 |
+ if(do_connect((int*)&client_sockfd, server, port) != 0) |
| 240 |
+ { |
| 241 |
+ if(!(options & OPT_QUIET)) |
| 242 |
+ { |
| 243 |
+ show_message("error connecting to %s:%s\n", server, port); |
| 244 |
+ } |
| 245 |
+ return(UPDATERES_ERROR); |
| 246 |
+ } |
| 247 |
+ |
| 248 |
+ snprintf(buf, BUFFER_SIZE, "GET %s?", request); |
| 249 |
+ output(buf); |
| 250 |
+ snprintf(buf, BUFFER_SIZE, "%s=%s&", "username", user_name); |
| 251 |
+ output(buf); |
| 252 |
+ snprintf(buf, BUFFER_SIZE, "%s=%s", "password", password); |
| 253 |
+ output(buf); |
| 254 |
+#if 0 |
| 255 |
+ /* cjb does IP address autodetection */ |
| 256 |
+ snprintf(buf, BUFFER_SIZE, "&%s=%s", "ip", address); |
| 257 |
+ output(buf); |
| 258 |
+#endif |
| 259 |
+ snprintf(buf, BUFFER_SIZE, " HTTP/1.0\015\012"); |
| 260 |
+ output(buf); |
| 261 |
+ snprintf(buf, BUFFER_SIZE, "User-Agent: %s-%s %s [%s] (%s)\015\012", |
| 262 |
+ "ez-update", VERSION, OS, (options & OPT_DAEMON) ? "daemon" : "", "by FreeWRT"); |
| 263 |
+ output(buf); |
| 264 |
+ snprintf(buf, BUFFER_SIZE, "\015\012"); |
| 265 |
+ output(buf); |
| 266 |
+ |
| 267 |
+ bp = buf; |
| 268 |
+ bytes = 0; |
| 269 |
+ btot = 0; |
| 270 |
+ while((bytes=read_input(bp, BUFFER_SIZE-btot)) > 0) |
| 271 |
+ { |
| 272 |
+ bp += bytes; |
| 273 |
+ btot += bytes; |
| 274 |
+ dprintf((stderr, "btot: %d\n", btot)); |
| 275 |
+ } |
| 276 |
+ close(client_sockfd); |
| 277 |
+ buf[btot] = '\0'; |
| 278 |
+ |
| 279 |
+ dprintf((stderr, "server output: %s\n", buf)); |
| 280 |
+ |
| 281 |
+ if(sscanf(buf, " HTTP/1.%*c %3d", &ret) != 1) |
| 282 |
+ { |
| 283 |
+ ret = -1; |
| 284 |
+ } |
| 285 |
+ |
| 286 |
+ switch(ret) |
| 287 |
+ { |
| 288 |
+ case -1: |
| 289 |
+ if(!(options & OPT_QUIET)) |
| 290 |
+ { |
| 291 |
+ show_message("strange server response, are you connecting to the right server?\n"); |
| 292 |
+ } |
| 293 |
+ return(UPDATERES_ERROR); |
| 294 |
+ break; |
| 295 |
+ |
| 296 |
+ case 200: |
| 297 |
+ if(strstr(buf, " updated ") != NULL) |
| 298 |
+ { |
| 299 |
+ if(!(options & OPT_QUIET)) |
| 300 |
+ { |
| 301 |
+ printf("request successful\n"); |
| 302 |
+ } |
| 303 |
+ } |
| 304 |
+ else |
| 305 |
+ { |
| 306 |
+ show_message("error processing request\n"); |
| 307 |
+ if(!(options & OPT_QUIET)) |
| 308 |
+ { |
| 309 |
+ fprintf(stderr, "server output: %s\n", buf); |
| 310 |
+ } |
| 311 |
+ return(UPDATERES_ERROR); |
| 312 |
+ } |
| 313 |
+ break; |
| 314 |
+ |
| 315 |
+ case 401: |
| 316 |
+ if(!(options & OPT_QUIET)) |
| 317 |
+ { |
| 318 |
+ show_message("authentication failure\n"); |
| 319 |
+ } |
| 320 |
+ return(UPDATERES_SHUTDOWN); |
| 321 |
+ break; |
| 322 |
+ |
| 323 |
+ default: |
| 324 |
+ if(!(options & OPT_QUIET)) |
| 325 |
+ { |
| 326 |
+ // reuse the auth buffer |
| 327 |
+ *auth = '\0'; |
| 328 |
+ sscanf(buf, " HTTP/1.%*c %*3d %255[^\r\n]", auth); |
| 329 |
+ show_message("unknown return code: %d\n", ret); |
| 330 |
+ show_message("server response: %s\n", auth); |
| 331 |
+ } |
| 332 |
+ return(UPDATERES_ERROR); |
| 333 |
+ break; |
| 334 |
+ } |
| 335 |
+ |
| 336 |
+ return(UPDATERES_OK); |
| 337 |
+} |
| 338 |
+ |
| 339 |
int DYNS_check_info(void) |
| 340 |
{ |
| 341 |
char buf[BUFSIZ+1]; |
| 342 |
@@ -3943,22 +4102,22 @@ int HN_update_entry(void) |
| 343 |
break; |
| 344 |
|
| 345 |
case 201: |
| 346 |
- show_message("Last update was less than %d seconds ago.\n", 300); |
| 347 |
+ show_message("last update was less than %d seconds ago\n", 300); |
| 348 |
return(UPDATERES_ERROR); |
| 349 |
break; |
| 350 |
|
| 351 |
case 202: |
| 352 |
- show_message("Server error.\n"); |
| 353 |
+ show_message("server error\n"); |
| 354 |
return(UPDATERES_ERROR); |
| 355 |
break; |
| 356 |
|
| 357 |
case 203: |
| 358 |
- show_message("Failure because account is frozen (by admin).\n"); |
| 359 |
+ show_message("failure because account is frozen (by admin)\n"); |
| 360 |
return(UPDATERES_SHUTDOWN); |
| 361 |
break; |
| 362 |
|
| 363 |
case 204: |
| 364 |
- show_message("Failure because account is locked (by user).\n"); |
| 365 |
+ show_message("failure because account is locked (by user)\n"); |
| 366 |
return(UPDATERES_SHUTDOWN); |
| 367 |
break; |
| 368 |
|
| 369 |
@@ -4215,8 +4374,6 @@ int HEIPV6TB_update_entry(void) |
| 370 |
|
| 371 |
switch(ret) |
| 372 |
{ |
| 373 |
- char *p; |
| 374 |
- |
| 375 |
case -1: |
| 376 |
if(!(options & OPT_QUIET)) |
| 377 |
{ |
| 378 |
@@ -4349,7 +4506,7 @@ void handle_sig(int sig) |
| 379 |
case SIGHUP: |
| 380 |
if(config_file) |
| 381 |
{ |
| 382 |
- show_message("SIGHUP recieved, re-reading config file\n"); |
| 383 |
+ show_message("SIGHUP received, re-reading config file\n"); |
| 384 |
if(parse_conf_file(config_file, conf_commands) != 0) |
| 385 |
{ |
| 386 |
show_message("error parsing config file \"%s\"\n", config_file); |
| 387 |
@@ -4384,6 +4541,7 @@ void handle_sig(int sig) |
| 388 |
|
| 389 |
int main(int argc, char **argv) |
| 390 |
{ |
| 391 |
+ char *tmp; |
| 392 |
int ifresolve_warned = 0; |
| 393 |
int i; |
| 394 |
int retval = 1; |
| 395 |
@@ -4395,9 +4553,10 @@ int main(int argc, char **argv) |
| 396 |
mcheck(NULL); |
| 397 |
#endif |
| 398 |
|
| 399 |
- dprintf((stderr, "staring...\n")); |
| 400 |
+ dprintf((stderr, "starting...\n")); |
| 401 |
|
| 402 |
- program_name = argv[0]; |
| 403 |
+ tmp = strrchr(argv[0], '/'); |
| 404 |
+ program_name = tmp ? tmp + 1 : argv[0]; |
| 405 |
options = 0; |
| 406 |
*user = '\0'; |
| 407 |
timeout.tv_sec = DEFAULT_TIMEOUT; |
| 408 |
@@ -4417,7 +4576,7 @@ int main(int argc, char **argv) |
| 409 |
|
| 410 |
if(!(options & OPT_QUIET) && !(options & OPT_DAEMON)) |
| 411 |
{ |
| 412 |
- fprintf(stderr, "ez-ipupdate Version %s\nCopyright (C) 1998-2001 Angus Mackay.\n", VERSION); |
| 413 |
+ fprintf(stderr, "%s Version %s\nCopyright (C) 1998-2001 Angus Mackay\n", program_name, VERSION); |
| 414 |
} |
| 415 |
|
| 416 |
dprintf((stderr, "options: 0x%04X\n", options)); |
| 417 |
@@ -4434,7 +4593,7 @@ int main(int argc, char **argv) |
| 418 |
{ |
| 419 |
if(service->check_info() != 0) |
| 420 |
{ |
| 421 |
- fprintf(stderr, "invalid data to perform requested action.\n"); |
| 422 |
+ fprintf(stderr, "invalid data to perform requested action\n"); |
| 423 |
exit(1); |
| 424 |
} |
| 425 |
} |
| 426 |
@@ -4456,13 +4615,13 @@ int main(int argc, char **argv) |
| 427 |
dprintf((stderr, "user_name: %s\n", user_name)); |
| 428 |
dprintf((stderr, "password: %s\n", password)); |
| 429 |
} |
| 430 |
- if(*user_name == '\0') |
| 431 |
+ if(*user_name == '\0' && !(options & OPT_DAEMON)) |
| 432 |
{ |
| 433 |
printf("user name: "); |
| 434 |
fgets(user_name, sizeof(user_name), stdin); |
| 435 |
chomp(user_name); |
| 436 |
} |
| 437 |
- if(*password == '\0') |
| 438 |
+ if(*password == '\0' && !(options & OPT_DAEMON)) |
| 439 |
{ |
| 440 |
strncpy(password, getpass("password: "), sizeof(password)); |
| 441 |
} |
| 442 |
@@ -4480,7 +4639,7 @@ int main(int argc, char **argv) |
| 443 |
|
| 444 |
if(service->check_info() != 0) |
| 445 |
{ |
| 446 |
- fprintf(stderr, "invalid data to perform requested action.\n"); |
| 447 |
+ fprintf(stderr, "invalid data to perform requested action\n"); |
| 448 |
exit(1); |
| 449 |
} |
| 450 |
|
| 451 |
@@ -4503,7 +4662,7 @@ int main(int argc, char **argv) |
| 452 |
|
| 453 |
if(interface == NULL) |
| 454 |
{ |
| 455 |
- fprintf(stderr, "invalid data to perform requested action.\n"); |
| 456 |
+ fprintf(stderr, "invalid data to perform requested action\n"); |
| 457 |
fprintf(stderr, "you must provide an interface for daemon mode"); |
| 458 |
exit(1); |
| 459 |
} |
| 460 |
@@ -4519,23 +4678,25 @@ int main(int argc, char **argv) |
| 461 |
if(fork() > 0) { exit(0); } /* parent */ |
| 462 |
} |
| 463 |
|
| 464 |
+# if HAVE_SYSLOG_H |
| 465 |
+ openlog(program_name, LOG_PID, LOG_DAEMON ); |
| 466 |
+ //options |= OPT_QUIET; |
| 467 |
+# endif |
| 468 |
+ show_message("version %s, interface %s, host %s, server %s, service %s\n", |
| 469 |
+ VERSION, N_STR(interface), N_STR(host), server, service->title); |
| 470 |
+ |
| 471 |
#if HAVE_GETPID |
| 472 |
if(pid_file && pid_file_create(pid_file) != 0) |
| 473 |
{ |
| 474 |
- fprintf(stderr, "exiting...\n"); |
| 475 |
+ show_message("could not create pid file %s (%s), exiting\n", |
| 476 |
+ pid_file, strerror(errno)); |
| 477 |
+#if HAVE_SYSLOG_H |
| 478 |
+ closelog(); |
| 479 |
+#endif |
| 480 |
exit(1); |
| 481 |
} |
| 482 |
#endif |
| 483 |
|
| 484 |
-# if HAVE_SYSLOG_H |
| 485 |
- openlog(program_name, LOG_PID, LOG_USER ); |
| 486 |
- options |= OPT_QUIET; |
| 487 |
-# endif |
| 488 |
- show_message("ez-ipupdate Version %s, Copyright (C) 1998-2001 Angus Mackay.\n", |
| 489 |
- VERSION); |
| 490 |
- show_message("%s started for interface %s host %s using server %s and service %s\n", |
| 491 |
- program_name, N_STR(interface), N_STR(host), server, service->title); |
| 492 |
- |
| 493 |
memset(&sin, 0, sizeof(sin)); |
| 494 |
|
| 495 |
if(cache_file) |
| 496 |
@@ -4560,7 +4721,7 @@ int main(int argc, char **argv) |
| 497 |
strftime(timebuf, sizeof(timebuf), "%Y/%m/%d %H:%M", ts); |
| 498 |
show_message("got last update %s on %s from cache file\n", ipstr, timebuf); |
| 499 |
} |
| 500 |
- else |
| 501 |
+ else if(ipstr||ipdate) |
| 502 |
{ |
| 503 |
show_message("malformed cache file: %s\n", cache_file); |
| 504 |
} |
| 505 |
@@ -4647,7 +4808,7 @@ int main(int argc, char **argv) |
| 506 |
} |
| 507 |
else |
| 508 |
{ |
| 509 |
- show_message("failure to update %s->%s (%s)\n", |
| 510 |
+ show_message("failed to update %s->%s (%s)\n", |
| 511 |
interface, inet_ntoa(sin.sin_addr), N_STR(host)); |
| 512 |
memset(&sin, 0, sizeof(sin)); |
| 513 |
|
| 514 |
@@ -4671,7 +4832,7 @@ int main(int argc, char **argv) |
| 515 |
dprintf((stderr, "updateres: %d\n", updateres)); |
| 516 |
if(updateres == UPDATERES_SHUTDOWN) |
| 517 |
{ |
| 518 |
- show_message("shuting down updater for %s due to fatal error\n", |
| 519 |
+ show_message("shutting down updater for %s due to fatal error\n", |
| 520 |
N_STR(host)); |
| 521 |
|
| 522 |
if(notify_email && *notify_email != '\0') |
| 523 |
@@ -4711,7 +4872,7 @@ int main(int argc, char **argv) |
| 524 |
#endif |
| 525 |
|
| 526 |
#else |
| 527 |
- fprintf(stderr, "sorry, this mode is only available on platforms that the "); |
| 528 |
+ fprintf(stderr, "sorry, this mode is only available on platforms where the "); |
| 529 |
fprintf(stderr, "IP address \ncan be determined. feel free to hack the code"); |
| 530 |
fprintf(stderr, " though.\n"); |
| 531 |
exit(1); |
| 532 |
@@ -4799,7 +4960,7 @@ int main(int argc, char **argv) |
| 533 |
} |
| 534 |
else |
| 535 |
{ |
| 536 |
- show_message("could not resolve ip address for %s.\n", interface); |
| 537 |
+ show_message("could not resolve ip address for %s\n", interface); |
| 538 |
exit(1); |
| 539 |
} |
| 540 |
close(sock); |