./dhistools-dns-5.0/004075500017500000012000000000000726140316300144165ustar00jcncstaff00001460000000./dhistools-dns-5.0/genid.c010064400017500000012000000050670726140267100156600ustar00jcncstaff00001460000000/*- * Copyright (c) 1999,2000 Joao Cabral (jcnc@dhis.org) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * DHIS(c) Dynamic Host Information System Release 4.0 */ #include #include #include void off_nl(unsigned char *s) { while(*s!='\0' && *s!='\n' && *s!='\r') s++; *s='\0'; return; } unsigned char *line_entry(int idx,unsigned char *buff) { static unsigned char b2[1024],*pb2; int i; idx--; b2[0]='\0'; pb2=b2; while((*buff==' ' || *buff=='\t') && *buff!='\0' && *buff!='\n') buff++; if(*buff=='\0' || *buff=='\n') return(b2); for(i=0;i id) id=atoi(line_entry(1,str)); } } fclose(fp); id++; printf("\thostid\t\t%d\n",id); exit(0); } ./dhistools-dns-5.0/genpass.c010064400017500000012000000034610726140302000162130ustar00jcncstaff00001460000000/*- * Copyright (c) 1999,2000 Joao Cabral (jcnc@dhis.org) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * DHIS(c) Dynamic Host Information System Release 4.0 */ #include #include #include #include void genpass(unsigned char *pass) { int i,j; srandom(time(NULL)); for(j=0;j<15;j++) { do { i=random() % ('z'+1); } while(i<'0' || (i>'9' && i<'a') || i>'z'); *pass++=(unsigned char)i; } *pass='\0'; } int main() { unsigned char pass[16]; genpass(pass); printf("\thostpass\t%s\n",pass); exit(0); } ./dhistools-dns-5.0/Makefile010064400017500000012000000005220726140252400160520ustar00jcncstaff00001460000000CC=gcc all: genpass genkeys genid install: all cp genpass genkeys genid /etc/dhis/bin genpass: genpass.c $(CC) -Wall -o genpass genpass.c genkeys: genkeys.c $(CC) -Wall -o genkeys genkeys.c -I/usr/local/include -L/usr/local/lib -lgmp genid: genid.c $(CC) -Wall -o genid genid.c clean: rm -f core *.core genkeys genpass genid ./dhistools-dns-5.0/genkeys.c010064400017500000012000000055460726140310600162330ustar00jcncstaff00001460000000/*- * Copyright (c) 1999,2000 Joao Cabral (jcnc@dhis.org) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * DHIS(c) Dynamic Host Information System Release 4.0 */ #include #include #include #include #include /* qrc_random() - Generates a random integer of n digits * n may be up to 1024 */ void qrc_random(mpz_t x,int n) { char buff[1024],temp[128]; static int seed=0; if(!seed) { seed++; srandom(time(NULL)); } memset(buff,0,256); memset(temp,0,128); do { sprintf(temp,"%lu",random()); strcat(buff,temp); } while(strlen(buff) < n); buff[n]='\0'; mpz_set_str(x,buff,10); return; } /* qrc_genkey() - Generates an integer of 100 digits being congruent * to 3 mod 4 * */ void qrc_genkey(mpz_t k) { int flag=1; do { mpz_t a,b; /* Get a prime number */ do qrc_random(k,100); while(!mpz_probab_prime_p(k,5)); /* Now see if it is congruent to 3 mod 4 */ mpz_init(a);mpz_init(b); mpz_set_ui(a,4); mpz_mod(b,k,a); mpz_set_ui(a,3); if(!mpz_cmp(a,b)) flag=0; mpz_clear(a); mpz_clear(b); } while(flag); } void show_key(mpz_t key,int n,char *s) { unsigned char buff[1024]; unsigned char chunk[128]; unsigned char *cp; int i; mpz_get_str(buff,10,key); cp=buff; for(i=0;i $TEMP/keys.$$ $GENID > $TEMP/id.$$ # DB File # echo "" >> $DBFILE echo `cat $TEMP/id.$$ | awk '{ print $2 }'`" {" >> $DBFILE echo "\thostname\t$1" >> $DBFILE cat $TEMP/keys.$$ >> $DBFILE echo "\tcontact\t\t$2" >> $DBFILE echo "\temail\t\t$3" >> $DBFILE echo "\tservice\t\tdns" >> $DBFILE echo "}" >> $DBFILE kill -HUP `cat $DHISD_PID` # Update DNS # echo "update add $1. 60 in a 192.168.255.0" > $TEMP/nsupdate.$$ echo "update add $1. 86600 in mx 0 $1." >> $TEMP/nsupdate.$$ echo "update add $1. 86600 in mx 10 $RELAY." >> $TEMP/nsupdate.$$ echo "" >> $TEMP/nsupdate.$$ $NSUPDATE $TEMP/nsupdate.$$ rm -f $TEMP/nsupdate.$$ # Remove Files rm -f $TEMP/id.$$ rm -f $TEMP/keys.$$ ./dhistools-dns-5.0/register-p.sh010070000017500000012000000022170726140314600170240ustar00jcncstaff00001460000000#!/bin/sh # Parameters # 1 = hostname # 2 = contact # 3 = email # # Constants # SENDER=requests@domain.com # Define locations TEMP=/etc/dhis/temp GENID=/etc/dhis/bin/genid GENKEYS=/etc/dhis/bin/genkeys GENPASS=/etc/dhis/bin/genpass DBDIR=/etc/dhis/db DBFILE=/etc/dhis/db/dhis.db ISADDR=123.123.123.123 ; IP address of DHIS server MXADDR=122.222.222.222 ; IP address of relay server DHISD_PID=/etc/dhis/pid/dhisd.pid RELAY=relay.domain.com NSUPDATE=/usr/sbin/nsupdate $GENPASS > $TEMP/pass.$$ $GENID > $TEMP/id.$$ # DB File # echo "" >> $DBFILE echo `cat $TEMP/id.$$ | awk '{ print $2 }'`" {" >> $DBFILE echo "\thostname\t$1" >> $DBFILE cat $TEMP/pass.$$ >> $DBFILE echo "\tcontact\t\t$2" >> $DBFILE echo "\temail\t\t$3" >> $DBFILE echo "\tservice\t\tdns" >> $DBFILE echo "}" >> $DBFILE kill -HUP `cat $DHISD_PID` # Update DNS # echo "update add $1. 60 in a 192.168.255.0" > $TEMP/nsupdate.$$ echo "update add $1. 86600 in mx 0 $1." >> $TEMP/nsupdate.$$ echo "update add $1. 86600 in mx 10 $RELAY." >> $TEMP/nsupdate.$$ echo "" >> $TEMP/nsupdate.$$ $NSUPDATE $TEMP/nsupdate.$$ rm -f $TEMP/nsupdate.$$ # Remove Files rm -f $TEMP/id.$$ rm -f $TEMP/pass.$$ ./dhistools-dns-5.0/README010064400017500000012000000017120726140263400152760ustar00jcncstaff00001460000000 This package includes a set of tools that may be used to manually create DHIS records on a dynamic DNS server. The dhisd-5 software and the dhis-dns module are required. genid is a program that parses the dhis.db file and returns the next available ID number genpass generates a random 15 character password genkeys generates a set of private and public keys to be used with QRC. Requires libgmp to be installed. register-p.sh Adds a password record to the DHIS server. Calls genid and genpass. register-q.sh Adds a QRC record to the DHIS server Calls genid and genkeys. Both register scripts assume DHIS standard locations and execute genid, genpass and genkeys from /etc/dhis/bin Please edit and change as appropriate. Both register scripts have the following syntax: register-?.sh hostname.domain "Contact Name" contact@address These are provided as is without any warranty and should be used as examples and not as solutions.