2 src/plugins/Makefile.in | 3
3 src/plugins/zoneedit.c | 280 ++++++++++++++++++++++++++++++++++++++++++++++++
4 src/plugins/zoneedit.h | 82 ++++++++++++++
5 3 files changed, 364 insertions(+), 1 deletion(-)
7 Index: updatedd-2.5/src/plugins/zoneedit.c
8 ===================================================================
10 +++ updatedd-2.5/src/plugins/zoneedit.c
12 +/* -- updatedd: zoneedit.c --
14 + * Copyright (C) 2002, 2003, 2004, 2005 Philipp Benner
16 + * This file is part of UpdateDD - http://updatedd.philipp-benner.de.
18 + * UpdateDD is free software; you can redistribute it and/or modify
19 + * it under the terms of the GNU General Public License as published by
20 + * the Free Software Foundation; either version 2 of the License, or
21 + * any later version.
23 + * UpdateDD is distributed in the hope that it will be useful,
24 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 + * GNU General Public License for more details.
28 + * You should have received a copy of the GNU General Public License
29 + * along with UpdateDD; if not, write to the Free Software
30 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
42 +#include <base64encode.h>
43 +#include <get_connection.h>
45 +#include <libexception_handle.h>
46 +#include <ret_codes.h>
49 +#include "zoneedit.h"
52 +print_usage(char *pname, FILE *fp)
55 + "\nUsage: %s [...] %s -- [OPTION]... [USERNAME:PASSWORD] HOSTNAME\n\n",
56 + pname, COLORED("zoneedit"));
58 + "For security reasons use the environment variable LOGIN instead of\n"
59 + "passing the login information directly.\n\n"
61 + " -4 --ipv4 <address> ip address version 4\n"
62 + " -o --offline host is currently offline\n"
63 + " --help print help and exit\n"
64 + " --version display version information and exit\n\n"
66 + "Report bugs to <"EMAIL">.\n\n");
72 +print_version(FILE *fp)
76 + "\n" PNAME " plugin for zoneedit.com version " VERSION ",\n"
77 + "Copyright (C) 2005 Philipp Benner.\n"
80 + "This is free software, and you are welcome to redistribute it\n"
81 + "under certain conditions; see the source for copying conditions.\n"
82 + "There is NO warranty; not even for MERCHANTABILITY or FITNESS\n"
83 + "FOR A PARTICULAR PURPOSE.\n\n");
90 +ret_msg(int mode, const char *fmt, ...)
96 + (void)vs_warn(ret_msg_buf, BUFSIZE, mode, fmt, az);
104 +dyndns(int argc, char *argv[])
107 + struct arguments args;
111 + (void)memset(&args, 0, sizeof(struct arguments));
113 + if(get_flags(&args, argc, argv) != RET_OK) {
114 + return RET_WRONG_USAGE;
117 + s = get_connection(DYNDNSHOST, PORT, &ptr);
119 + ret_msg(HERR, "%s: %s", ptr, DYNDNSHOST);
122 + ret = update_dyndns(s, &args);
123 + if(ret == RET_OK) {
124 + ret = check_server_msg(s, args.hostname);
134 +get_flags(struct arguments *args, int argc, char *argv[])
141 + int option_index = 0;
142 + static struct option long_options[] = {
143 + { "ipv4", 1, 0, '4' },
144 + { "help", 0, 0, 'h' },
145 + { "offline", 0, 0, 'o' },
146 + { "version", 0, 0, 'v' },
150 + c = getopt_long(argc, argv, "4:o",
151 + long_options, &option_index);
157 + args->ipv4 = optarg;
163 + print_usage(argv[ARGV_PNAME], stdout);
164 + exit(EXIT_SUCCESS);
166 + print_version(stdout);
167 + exit(EXIT_SUCCESS);
171 + switch(argc-optind) {
173 + ret_msg(NONE, "wrong usage");
174 + return RET_WRONG_USAGE;
177 + args->login = getenv("LOGIN");
178 + if(args->login == NULL) {
180 + "environment variable LOGIN is empty");
181 + return RET_WRONG_USAGE;
185 + args->login = argv[ARGV_LOGIN];
187 + args->hostname = argv[ARGV_HOSTNAME];
194 +#define BUFFREE(name) BUFLEN - strlen(name)
197 +update_dyndns(const int s, struct arguments *args)
201 + char message[BUFLEN];
203 + if(strlen(args->login) > 128) {
204 + ret_msg(NONE, "username is too long");
207 + b64user = (char *)malloc((2 * strlen(args->login) + 1));
208 + if(b64user == NULL) {
209 + ret_msg(PERR, "malloc() failed");
210 + return RET_WARNING;
212 + (void)memset(b64user, 0, 2 * strlen(args->login) + 1);
214 + base64encode(args->login, b64user);
215 + (void)snprintf(message, BUFLEN,
216 + "GET https://%s/auth/dynamic.html?host=%s",
217 + DYNDNSHOST, args->hostname);
219 + if(args->offline) {
220 + (void)strncat(message, "&dnsto=0.0.0.0", BUFFREE(message));
222 + else if(args->ipv4) {
223 + (void)strncat(message, "&dnsto=", BUFFREE(message));
224 + (void)strncat(message, args->ipv4, BUFFREE(message));
230 + (void)snprintf(buffer, 1024,
233 + "Authorization: Basic %s\r\n"
234 + "User-Agent: %s %s - %s\r\n"
235 + "Connection: close\r\n"
236 + "Pragma: no-cache\r\n\r\n",
237 + DYNDNSHOST, b64user, PNAME, VERSION, HOMEPAGE);
238 + (void)strncat(message, buffer, BUFLEN - 1 - strlen(message));
240 + print_debug("\n\nMessage:"
241 + "\n--------------------------------------\n"
242 + "%s--------------------------------------\n\n",
245 + if(write(s, message, strlen(message)) == -1) {
246 + ret_msg(PERR, "write() failed");
247 + return RET_WARNING;
256 +check_server_msg(int s, const char *hostname)
259 + char server_msg[BUFSIZE];
261 + /* get server_msg */
262 + (void)memset(server_msg, 0, sizeof(server_msg));
263 + if(read(s, server_msg, sizeof(server_msg) - 1) < 0) {
264 + ret_msg(PERR, "read() failed");
265 + return RET_WARNING;
268 + print_debug("\n\nServer message:"
269 + "\n--------------------------------------\n"
270 + "%s--------------------------------------\n\n",
273 + if(strstr(server_msg, "HTTP/1.1 200 OK") ||
274 + strstr(server_msg, "HTTP/1.0 200 OK")) {
275 + if(strstr(server_msg, "SUCCESS CODE=")) {
276 + ret_msg(NONE, "%s: Successful Update!", hostname);
278 + } else if(strstr(server_msg, "ERROR CODE=")) {
279 + ret_msg(NONE, "%s: Error! - %s", hostname, server_msg);
282 + ret_msg(NONE, "%s: Unknown fault - %s", hostname, server_msg);
284 + } else if(strstr(server_msg, "401 Authorization Required")) {
285 + ret_msg(NONE, "zoneedit.com: wrong username or password");
287 + ret_msg(NONE, "zoneedit.com: Internal Server Error - %s", server_msg);
292 Index: updatedd-2.5/src/plugins/Makefile.in
293 ===================================================================
294 --- updatedd-2.5.orig/src/plugins/Makefile.in
295 +++ updatedd-2.5/src/plugins/Makefile.in
297 CFLAGS = -I$(top_builddir) -I$(top_srcdir)/include @CFLAGS@ -fPIC
298 LIBERROR = $(top_builddir)/libexception_handle/libexception_handle.a
300 -OBJECTS := changeip.o dyndns.o eurodyndns.o hn.o noip.o ods.o ovh.o regfish.o tzo.o
301 +OBJECTS := changeip.o dyndns.o eurodyndns.o hn.o noip.o ods.o ovh.o regfish.o tzo.o zoneedit.o
302 PLUGINS_ROOT := $(OBJECTS:.o= )
304 UNAME:=$(shell uname -s)
309 +zoneedit.o: zoneedit.h
311 .PHONY: all plugins install uninstall clean distclean
312 Index: updatedd-2.5/src/plugins/zoneedit.h
313 ===================================================================
315 +++ updatedd-2.5/src/plugins/zoneedit.h
317 +/* -- updatedd: zoneedit.h --
319 + * Copyright (C) 2002, 2003, 2004, 2005 Philipp Benner
321 + * This file is part of UpdateDD - http://updatedd.philipp-benner.de.
323 + * UpdateDD is free software; you can redistribute it and/or modify
324 + * it under the terms of the GNU General Public License as published by
325 + * the Free Software Foundation; either version 2 of the License, or
326 + * any later version.
328 + * UpdateDD is distributed in the hope that it will be useful,
329 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
330 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
331 + * GNU General Public License for more details.
333 + * You should have received a copy of the GNU General Public License
334 + * along with UpdateDD; if not, write to the Free Software
335 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
338 +#include <ret_codes.h>
340 +#define DYNDNSHOST "www.zoneedit.com"
343 +#define BUFSIZE 4096
345 +#define ARGV_PNAME 0
346 +#define ARGV_LOGIN argc-2
347 +#define ARGV_HOSTNAME argc-1
349 +#define COLORED(x) "\033[0;39;1m"x"\033[0m"
351 +static char ret_msg_buf[BUFSIZE];
354 + const char *hostname;
360 +/* static struct dyndns_return_codes { */
361 +/* const char *code; */
362 +/* const char *message; */
363 +/* const int error; */
364 +/* } return_codes[] = { */
365 +/* { "badauth", "Bad authorization (username or password).", 1 }, */
366 +/* { "badsys", "The system parameter given was not valid.", 1 }, */
367 +/* { "badagent", "The useragent your client sent has been blocked " */
368 +/* "at the access level.", 1 */
370 +/* { "good", "Update good and successful, IP updated.", 0 }, */
371 +/* { "nochg", "No changes, update considered abusive.", 0 }, */
372 +/* { "notfqdn", "A Fully-Qualified Domain Name was not provided.", 1 }, */
373 +/* { "nohost", "The hostname specified does not exist.", 1 }, */
374 +/* { "!donator", "The offline setting was set, when the user is " */
375 +/* "not a donator.", 1 */
377 +/* { "!yours", "The hostname specified exists, but not under " */
378 +/* "the username currently being used.", 1 */
380 +/* { "!active", "The hostname specified is in a Custom DNS " */
381 +/* "domain which has not yet been activated.", 1 */
383 +/* { "abuse", "The hostname specified is blocked for abuse", 1 }, */
384 +/* { "notfqdn", "No hosts are given.", 1 }, */
385 +/* { "numhost", "Too many or too few hosts found.", 1 }, */
386 +/* { "dnserr", "DNS error encountered.", 1 }, */
387 +/* { NULL, NULL, 0 } */
390 +static int get_flags(struct arguments *args, int argc, char *argv[]);
391 +static int update_dyndns(const int s, struct arguments *args);
392 +static int check_server_msg(const int s, const char *hostnames);
397 + return ret_msg_buf;