Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unxsBind patch #7

Open
unxs0 opened this issue May 30, 2017 · 1 comment
Open

unxsBind patch #7

unxs0 opened this issue May 30, 2017 · 1 comment
Assignees

Comments

@unxs0
Copy link
Owner

unxs0 commented May 30, 2017

[root@master1 /root/unxsVZ/unxsBind]# svn diff
Index: tzonefunc.h
===================================================================
--- tzonefunc.h	(revision 3002)
+++ tzonefunc.h	(working copy)
@@ -91,6 +91,7 @@
 void tNSSetMembers(unsigned uNSSet);//tnssetfunc.h
 void CloneZone(char *cSourceZone,char *cTargetZone,unsigned uView);
 unsigned uGetZoneSearchGroup(const char *gcUser);
+char *cNSFromWhois(char const *cZone);
 
 //bind.c
 void ProcessRRLine(const char *cLine,char *cZoneName,const unsigned uZone,const unsigned uCustId,
@@ -613,7 +614,7 @@
 			}
 		}
                 else if(!strcmp(gcCommand,"Fold A Records") || !strcmp(gcCommand,"Delete Checked")
-                	|| (!strcmp(gcCommand,"Backup")) || (!strcmp(gcCommand,"Restore")))
+                	|| (!strcmp(gcCommand,"Backup")) || (!strcmp(gcCommand,"Restore")) || (!strcmp(gcCommand,"Whois")))
                 {
 			ProcesstZoneVars(entries,x);
                         guMode=12002;
@@ -1504,6 +1505,8 @@
 			printf("&nbsp;<input title='Restore zone from tZoneBackup and tResourceBackup tables."
 				" Any existing tZone and tResource records will be deleted or replaced!'"
 				" type=submit class=lwarnButton name=gcCommand value='Restore'>\n");
+			printf("&nbsp;<input title='Whois report of name servers'"
+				" type=submit class=largeButton name=gcCommand value='Whois'>\n");
 			CloseFieldSet();
 
 			sprintf(gcQuery,"Search Set Contents");
@@ -1575,6 +1578,12 @@
 					break;
 				}//Delete Checked
 
+				else if(!strcmp(gcCommand,"Whois"))
+				{
+					sprintf(cResult,cNSFromWhois(field[0]));
+					break;
+				}//Delete Checked
+
 				else if(!strcmp(gcCommand,"Restore"))
 				{
 					MYSQL_RES *res2;
@@ -4264,6 +4273,26 @@
 }//void htmlMassCheckZone(void)
 
 
+char *cNSFromWhois(char const *cZone)
+{
+	FILE *fp;
+	char cCommand[256];
+
+	char static cNSList[256]={""};
+	sprintf(cNSList,"whois error");
+	sprintf(cCommand,"/usr/bin/whois %.99s 2> /dev/null | grep -i name | grep -i server"
+			"| cut -f 2 -d ':' | sed -e 's/^[[:space:]]*//' | sort -u | tr '[:space:]' ','",cZone);
+	if((fp=popen(cCommand,"r")))
+	{
+		fgets(cNSList,255,fp);
+		pclose(fp);
+		if(!cNSList[0])
+			sprintf(cNSList,"no info");
+	}
+	return(cNSList);
+}//char *cNSFromWhois(char const *cZone)
+
+
 void tZoneNavList(void)
 {
         MYSQL_RES *res;
Index: tresourcefunc.h
===================================================================
--- tresourcefunc.h	(revision 3000)
+++ tresourcefunc.h	(working copy)
@@ -568,8 +568,16 @@
 		}
 		if(cParam1[0]!='"' && cParam1[strlen(cParam1)-1]!='"')
 		{
-			sprintf(gcQuery,"\"%s\"",cParam1);
-			strcpy(cParam1,gcQuery);
+			if(strlen(cParam1)>250)
+			{
+				sprintf(gcQuery,"\"%.250s\" \"%.260s\"",cParam1,cParam1+250);
+				strcpy(cParam1,gcQuery);
+			}	
+			else
+			{
+				sprintf(gcQuery,"\"%s\"",cParam1);
+				strcpy(cParam1,gcQuery);
+			}
 		}
 
 	}
@unxs0 unxs0 self-assigned this May 30, 2017
@unxs0
Copy link
Owner Author

unxs0 commented Jun 4, 2017

Proper patch:

From:

svn diff --diff-cmd /usr/bin/diff -x "-i -b" > mypatch
...
patch -p0 < mypatch
Index: tzonefunc.h
===================================================================
93a94
> char *cNSFromWhois(char const *cZone);
616c617
<                 	|| (!strcmp(gcCommand,"Backup")) || (!strcmp(gcCommand,"Restore")))
---
>                 	|| (!strcmp(gcCommand,"Backup")) || (!strcmp(gcCommand,"Restore")) || (!strcmp(gcCommand,"Whois")))
1506a1508,1509
> 			printf("&nbsp;<input title='Whois report of name servers'"
> 				" type=submit class=largeButton name=gcCommand value='Whois'>\n");
1577a1581,1586
> 				else if(!strcmp(gcCommand,"Whois"))
> 				{
> 					sprintf(cResult,cNSFromWhois(field[0]));
> 					break;
> 				}//Delete Checked
> 
4266a4276,4295
> char *cNSFromWhois(char const *cZone)
> {
> 	FILE *fp;
> 	char cCommand[256];
> 
> 	char static cNSList[256]={""};
> 	sprintf(cNSList,"whois error");
> 	sprintf(cCommand,"/usr/bin/whois %.99s 2> /dev/null | grep -i name | grep -i server"
> 			"| cut -f 2 -d ':' | sed -e 's/^[[:space:]]*//' | sort -u | tr '[:space:]' ','",cZone);
> 	if((fp=popen(cCommand,"r")))
> 	{
> 		fgets(cNSList,255,fp);
> 		pclose(fp);
> 		if(!cNSList[0])
> 			sprintf(cNSList,"no info");
> 	}
> 	return(cNSList);
> }//char *cNSFromWhois(char const *cZone)
> 
> 
Index: tresourcefunc.h
===================================================================
570a571,577
> 			if(strlen(cParam1)>250)
> 			{
> 				sprintf(gcQuery,"\"%.250s\" \"%.260s\"",cParam1,cParam1+250);
> 				strcpy(cParam1,gcQuery);
> 			}	
> 			else
> 			{
573a581
> 		}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant