#include "cf.defs.h"#include "cf.extern.h"Go to the source code of this file.
Defines | |
| #define | FileVerbose if (VERBOSE || DEBUG || D2) fprintf |
Enumerations | |
| enum | fileoutputlevels { fopl_normal, fopl_error, fopl_inform } |
Functions | |
| void CheckOptsAndInit | ARGLIST ((int argc, char **argv)) |
| int | main (int argc, char **argv) |
| void | CheckOptsAndInit (int argc, char **argv) |
| int | PollServer (char *host, char *options, int StoreInFile) |
| void | ReadCfrunConf () |
| int | ParseHostname (char *hostname, char *new_hostname) |
| void | SendClassData (int sd, char *sendbuffer) |
| void | CheckAccess (char *users) |
| void | FileOutput (FILE *fp, enum fileoutputlevels level, char *message) |
| void | cfrunSyntax () |
| cfagent_connection * | NewAgentConn () |
| void | DeleteAgentConn (struct cfagent_connection *ap) |
| void | FatalError (char *s) |
| int | RecursiveTidySpecialArea (char *name, struct Tidy *tp, int maxrecurse, struct stat *sb) |
| int | CompareMD5Net (char *file1, char *file2, struct Image *ip) |
| void | yyerror (char *s) |
Variables | |
| int | MAXCHILD = 1 |
| int | FileFlag = 0 |
| int | TRUSTALL = false |
| enum fileoutputlevels | OUTPUTLEVEL = fopl_normal |
| char | OUTPUTDIR [bufsize] |
| Item * | VCFRUNCLASSES = NULL |
| Item * | VCFRUNOPTIONHOSTS = NULL |
| Item * | VCFRUNHOSTLIST = NULL |
| char | VCFRUNHOSTS [bufsize] = "cfrun.hosts" |
| char | CFRUNOPTIONS [bufsize] |
| char | CFLOCK [bufsize] = "dummy" |
|
|
Definition at line 38 of file cfrun.c. Referenced by PollServer(). |
|
|
Definition at line 43 of file cfrun.c. 00044 { 00045 fopl_normal, 00046 fopl_error, 00047 fopl_inform 00048 };
|
|
|
|
|
|
Definition at line 869 of file cfrun.c. Referenced by CheckOptsAndInit(). 00871 { 00872 printf("Usage: cfrun [-f cfrun.hosts|-h|-d|-S|-T|-v] [-- OPTIONS [-- CLASSES]]\n\n"); 00873 printf("-f cfrun.hosts\tcfrun file to read in list of hosts (see below for syntax.)\n"); 00874 printf("-h\t\tGet this help message.\n"); 00875 printf("-d\t\tDebug mode, turns on verbose as well.\n"); 00876 printf("-S\t\tSilent mode.\n"); 00877 printf("-T\t\tTrust all incoming public keys.\n"); 00878 printf("-v\t\tVerbose mode.\n"); 00879 printf("-- OPTIONS\tArguments to be passed to host application.\n"); 00880 printf("-- CLASSES\tClasses to be defined for the hosts.\n\n"); 00881 printf("e.g. cfrun -- -- linux Run on all linux machines\n"); 00882 printf(" cfrun -- -p Ping and parse on all hosts\n"); 00883 printf(" cfrun host1 host2 -- -p Ping and parse on named hosts\n"); 00884 printf(" cfrun -v -- -p Ping all, local verbose\n"); 00885 printf(" cfrun -v -- -k -- solaris Local verbose, all solaris, but no copy\n\n"); 00886 printf("cfrun.hosts file syntax:\n"); 00887 printf("# starts a comment\n"); 00888 printf("domain = [domain]\t# Domain to use for connection(s).\n"); 00889 printf("maxchild = [num]\t# Maximum number of children to spawn during run.\n"); 00890 printf("outputdir = [dir]\t# Directory where to put host output files.\n"); 00891 printf("access = [user]\t\t# User allowed to do cfrun?\n"); 00892 printf("[host]\t\t\t# One host per line list to cycle through.\n"); 00893 printf("\t\t\t# Only the hosts are required for cfrun to operate.\n"); 00894 00895 exit(0); 00896 }
|
|
|
Definition at line 789 of file cfrun.c. References maxvarsize, NULL, and sp. Referenced by ReadCfrunConf(). 00793 { char id[maxvarsize], *sp; 00794 struct passwd *pw; 00795 int uid,myuid; 00796 00797 myuid = getuid(); 00798 00799 if (myuid == 0) 00800 { 00801 return; 00802 } 00803 00804 for (sp = users; *sp != '\0'; sp++) 00805 { 00806 id[0] = '\0'; 00807 00808 sscanf(sp,"%295[^,:]",id); 00809 00810 sp += strlen(id); 00811 00812 if (isalpha((int)id[0])) 00813 { 00814 if ((pw = getpwnam(id)) == NULL) 00815 { 00816 printf("cfrun: No such user (%s) in password database\n",id); 00817 continue; 00818 } 00819 00820 if (pw->pw_uid == myuid) 00821 { 00822 return; 00823 } 00824 } 00825 else 00826 { 00827 uid = atoi(id); 00828 if (uid == myuid) 00829 { 00830 return; 00831 } 00832 } 00833 } 00834 00835 printf("cfrun: you have not been granted permission to run cfrun\n"); 00836 exit(0); 00837 }
|
|
||||||||||||
|
Definition at line 147 of file cfrun.c. References AppendItem(), bufsize, bzero, CFRUNOPTIONS, cfrunSyntax(), CheckWorkDirectories(), DEBUG, Debug, GetNameInfo(), i, LoadSecretKeys(), Item::name, Item::next, NULL, RandomSeed(), ReadCfrunConf(), SILENT, TRUSTALL, VCFRUNHOSTS, VERBOSE, VFQNAME, VLOCKDIR, VLOGDIR, and VPREFIX. 00152 { int optgroup = 0, i; 00153 struct Item *ip; 00154 00155 /* Separate command args into options and classes */ 00156 bzero(CFRUNOPTIONS,bufsize); 00157 00158 for (i = 1; i < argc; i++) 00159 { 00160 if (optgroup == 0) 00161 { 00162 if (strncmp(argv[i],"-h",2) == 0) 00163 { 00164 cfrunSyntax(); 00165 } 00166 else if (strncmp(argv[i],"-f",2) == 0) 00167 { 00168 i++; 00169 00170 if ((i >= argc) || (strncmp(argv[i],"-",1) == 0)) 00171 { 00172 printf("Error: No filename listed after -f option.\n"); 00173 cfrunSyntax(); 00174 exit(0); 00175 } 00176 bzero(VCFRUNHOSTS,bufsize); 00177 strcat(VCFRUNHOSTS,argv[i]); 00178 Debug("cfrun: cfrun file = %s\n",VCFRUNHOSTS); 00179 } 00180 else if (strncmp(argv[i],"-d",2) == 0) 00181 { 00182 DEBUG = true; 00183 VERBOSE = true; 00184 } 00185 else if (strncmp(argv[i],"-v",2) == 0) 00186 { 00187 VERBOSE=true; 00188 } 00189 else if (strncmp(argv[i],"-T",2) == 0) 00190 { 00191 TRUSTALL = true; 00192 } 00193 else if (strncmp(argv[i],"-S",2) == 0) 00194 { 00195 SILENT = true; 00196 } 00197 else if (strncmp(argv[i],"--",2) == 0) 00198 { 00199 optgroup++; 00200 } 00201 else if (argv[i][0] == '-') 00202 { 00203 printf("Error: Unknown option.\n"); 00204 cfrunSyntax(); 00205 exit(0); 00206 } 00207 else 00208 { 00209 AppendItem(&VCFRUNOPTIONHOSTS,argv[i],NULL); /* Restrict run hosts */ 00210 } 00211 } 00212 else if (optgroup == 1) 00213 { 00214 if (strncmp(argv[i],"--",2) == 0) 00215 { 00216 optgroup++; 00217 } 00218 else 00219 { 00220 strcat(CFRUNOPTIONS,argv[i]); 00221 strcat(CFRUNOPTIONS," "); 00222 } 00223 } 00224 else 00225 { 00226 AppendItem(&VCFRUNCLASSES,argv[i],""); 00227 } 00228 } 00229 00230 Debug("CFRUNOPTIONS string: %s\n",CFRUNOPTIONS); 00231 00232 for (ip = VCFRUNCLASSES; ip != NULL; ip=ip->next) 00233 { 00234 Debug("Class item: %s\n",ip->name); 00235 } 00236 00237 ReadCfrunConf(); 00238 00239 GetNameInfo(); 00240 00241 /* 00242 if (uname(&VSYSNAME) == -1) 00243 { 00244 perror("uname "); 00245 printf("cfrun: uname couldn't get kernel name info!!\n"); 00246 exit(1); 00247 } 00248 00249 if ((strlen(VDOMAIN) > 0) && !strchr(VSYSNAME.nodename,'.')) 00250 { 00251 sprintf(VFQNAME,"%s.%s",VSYSNAME.nodename,VDOMAIN); 00252 } 00253 else 00254 { 00255 sprintf(VFQNAME,"%s",VSYSNAME.nodename); 00256 } 00257 */ 00258 00259 Debug("FQNAME = %s\n",VFQNAME); 00260 00261 sprintf(VPREFIX,"cfrun:%s",VFQNAME); 00262 00263 /* Read hosts file */ 00264 00265 umask(077); 00266 strcpy(VLOCKDIR,WORKDIR); 00267 strcpy(VLOGDIR,WORKDIR); 00268 00269 OpenSSL_add_all_algorithms(); 00270 ERR_load_crypto_strings(); 00271 CheckWorkDirectories(); 00272 LoadSecretKeys(); 00273 RandomSeed(); 00274 00275 }
|
|
||||||||||||||||
|
Definition at line 952 of file cfrun.c. Referenced by CompareBinarySums(), and CompareCheckSums().
|
|
|
Definition at line 915 of file cfrun.c. References NULL. Referenced by MakeImages(). 00919 { 00920 if (ap->session_key != NULL) 00921 { 00922 free(ap->session_key); 00923 } 00924 00925 free(ap); 00926 ap = NULL; 00927 }
|
|
|
Definition at line 933 of file cfrun.c.
|
|
||||||||||||||||
|
Definition at line 841 of file cfrun.c. References fopl_error, fopl_inform, and OUTPUTLEVEL. Referenced by PollServer(). 00847 { 00848 switch (level) 00849 { 00850 case fopl_inform: 00851 if (OUTPUTLEVEL >= fopl_inform) 00852 { 00853 fprintf(fp, "cfrun: INFORM: %s", message); 00854 } 00855 break; 00856 case fopl_error: 00857 if (OUTPUTLEVEL >= fopl_error) 00858 { 00859 fprintf(fp, "cfrun: ERROR: %s", message); 00860 } 00861 break; 00862 /* Default is to do nothing. That's right for "normal"! */ 00863 } 00864 return; 00865 }
|
|
||||||||||||
|
Definition at line 81 of file cfrun.c. References CheckOptsAndInit(), Item::classes, Debug, FileFlag, i, MAXCHILD, Item::name, Item::next, NULL, PollServer(), and Verbose. 00086 { struct Item *ip; 00087 int i=0; 00088 int status; 00089 int pid; 00090 00091 CheckOptsAndInit(argc,argv); 00092 00093 ip = VCFRUNHOSTLIST; 00094 00095 while (ip != NULL) 00096 { 00097 if (i < MAXCHILD) 00098 { 00099 if (fork() == 0) /* child */ 00100 { 00101 printf("cfrun(%d): .......... [ Hailing %s ] ..........\n",i,ip->name); 00102 Debug("pid = %d i = %d\n", getpid(), i); 00103 00104 if (PollServer(ip->name,ip->classes, FileFlag)) 00105 { 00106 Verbose("Connection with %s completed\n\n",ip->name); 00107 } 00108 else 00109 { 00110 Verbose("Connection refused...\n\n"); 00111 } 00112 exit(0); 00113 } 00114 else 00115 { 00116 /* parent */ 00117 i++; 00118 } 00119 } 00120 else 00121 { 00122 pid = wait(&status); 00123 Debug("wait result pid = %d number %d\n", pid, i); 00124 i--; 00125 } 00126 if ( i < MAXCHILD ) 00127 { 00128 ip = ip->next; 00129 } 00130 } 00131 00132 while (i > 0) 00133 { 00134 pid = wait(&status); 00135 Debug("Child pid = %d ended\n", pid); 00136 i--; 00137 } 00138 00139 exit(0); 00140 return 0; 00141 }
|
|
|
Definition at line 900 of file cfrun.c. References cf_not_connected, cfagent_connection::family, cfagent_connection::localip, malloc(), NULL, cfagent_connection::remoteip, cfagent_connection::sd, cfagent_connection::session_key, and cfagent_connection::trust. Referenced by MakeImages(), and PollServer(). 00902 { struct cfagent_connection *ap = (struct cfagent_connection *)malloc(sizeof(struct cfagent_connection)); 00903 00904 ap->sd = cf_not_connected; 00905 ap->family = AF_INET; 00906 ap->trust = false; 00907 ap->localip[0] = '\0'; 00908 ap->remoteip[0] = '\0'; 00909 ap->session_key = NULL; 00910 return ap; 00911 };
|
|
||||||||||||
|
Definition at line 715 of file cfrun.c. Referenced by PollServer(). 00720 { int port=0; 00721 00722 sscanf(hostname,"%[^:]:%d", new_hostname, &port); 00723 00724 return(port); 00725 }
|
|
||||||||||||||||
|
Definition at line 280 of file cfrun.c. References bufsize, bzero, CF_DONE, cf_not_connected, CFD_TERMINATOR, CFENGINE_SERVICE, cferror, CfLog(), cfmaxiplen, CFRUNOPTIONS, Chop(), CONN, Debug, Image::encrypt, errno, cfagent_connection::family, FileOutput(), FileVerbose, fopl_error, fopl_inform, fp, HavePublicKey(), hp, IdentifyForVerification(), KeyAuthentication(), cfagent_connection::localip, NewAgentConn(), NULL, OUTPUT, OUTPUTDIR, ParseHostname(), ReceiveTransaction(), RemoteConnect(), cfagent_connection::remoteip, cfagent_connection::sd, SendClassData(), SendTransaction(), Image::server, snprintf(), sockaddr_ntop(), sp, strdup(), strstr(), TRUSTALL, Image::trustkey, and VFQNAME. Referenced by main(). 00285 { struct hostent *hp; 00286 struct sockaddr_in raddr; 00287 char sendbuffer[bufsize],recvbuffer[bufsize]; 00288 char filebuffer[bufsize],parsed_host[bufsize]; 00289 char reply[8]; 00290 struct servent *server; 00291 int err,n_read,first,port; 00292 char *sp,forceipv4='n'; 00293 FILE *fp; 00294 struct Image addresses; 00295 #ifdef HAVE_GETADDRINFO 00296 struct addrinfo query, *response=NULL, *ap; 00297 #endif 00298 00299 CONN = NewAgentConn(); 00300 00301 if (StoreInFile) 00302 { 00303 sprintf(filebuffer, "%s/%s", OUTPUTDIR, host); 00304 if ((fp = fopen(filebuffer, "w")) == NULL) 00305 { 00306 return false; 00307 } 00308 } 00309 else 00310 { 00311 fp = stdout; 00312 } 00313 00314 port = ParseHostname(host,parsed_host); 00315 00316 FileVerbose(fp, "Connecting to server %s to port %d with options %s %s\n",parsed_host,port,options,CFRUNOPTIONS); 00317 00318 #ifdef HAVE_GETADDRINFO 00319 00320 Debug("Using v6 compatible lookup...\n"); 00321 00322 bzero(&query,sizeof(struct addrinfo)); 00323 query.ai_family = AF_UNSPEC; 00324 query.ai_socktype = SOCK_STREAM; 00325 query.ai_flags = AI_PASSIVE; 00326 00327 if ((err=getaddrinfo(parsed_host,NULL,&query,&response)) != 0) 00328 { 00329 snprintf(OUTPUT,bufsize,"Unable to lookup %s (%s)",parsed_host,gai_strerror(err)); 00330 CfLog(cferror,OUTPUT,""); 00331 } 00332 00333 for (ap = response; ap != NULL; ap = ap->ai_next) 00334 { 00335 snprintf(CONN->remoteip,cfmaxiplen,"%s",sockaddr_ntop(ap->ai_addr)); 00336 break; 00337 } 00338 00339 if (response != NULL) 00340 { 00341 freeaddrinfo(response); 00342 } 00343 00344 #else 00345 00346 if ((hp = gethostbyname(parsed_host)) == NULL) 00347 { 00348 printf("Unknown host: %s\n", parsed_host); 00349 printf("Make sure that fully qualified names can be looked up at your site!\n"); 00350 printf("i.e. www.gnu.org, not just www. If you use NIS or /etc/hosts\n"); 00351 printf("make sure that the full form is registered too as an alias!\n"); 00352 FileOutput(fp, fopl_error, "Unknown host\n"); 00353 exit(1); 00354 } 00355 00356 bzero(&raddr,sizeof(raddr)); 00357 00358 if (port) 00359 { 00360 raddr.sin_port = htons(port); 00361 } 00362 else 00363 { 00364 if ((server = getservbyname(CFENGINE_SERVICE,"tcp")) == NULL) 00365 { 00366 CfLog(cferror,"Unable to find cfengine port","getservbyname"); 00367 FileOutput(fp, fopl_error, "Unable to find cfengine port\n"); 00368 exit (1); 00369 } 00370 else 00371 { 00372 raddr.sin_port = (unsigned int) server->s_port; 00373 } 00374 } 00375 00376 raddr.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr; 00377 raddr.sin_family = AF_INET; 00378 00379 snprintf(CONN->remoteip,cfmaxiplen,"%s",inet_ntoa(raddr.sin_addr)); 00380 00381 #endif 00382 00383 addresses.trustkey = 'n'; 00384 addresses.encrypt = 'n'; 00385 addresses.server = strdup(parsed_host); 00386 00387 snprintf(sendbuffer,bufsize,"root-%s",CONN->remoteip); 00388 00389 00390 if (HavePublicKey(sendbuffer) == NULL) 00391 { 00392 if (TRUSTALL) 00393 { 00394 printf("Accepting public key from %s\n",parsed_host); 00395 FileOutput(fp, fopl_inform, "Accepting public key from host\n"); 00396 addresses.trustkey = 'y'; 00397 } 00398 else 00399 { 00400 printf("WARNING - You do not have a public key from host %s = %s\n",host,CONN->remoteip); 00401 printf(" Do you want to accept one on trust? (yes/no)\n\n--> "); 00402 00403 while (true) 00404 { 00405 fgets(reply,8,stdin); 00406 Chop(reply); 00407 00408 if (strcmp(reply,"yes")==0) 00409 { 00410 addresses.trustkey = 'y'; 00411 break; 00412 } 00413 else if (strcmp(reply,"no")==0) 00414 { 00415 break; 00416 } 00417 else 00418 { 00419 printf("Please reply yes or no...(%s)\n",reply); 00420 } 00421 } 00422 } 00423 } 00424 00425 if (!RemoteConnect(parsed_host,forceipv4)) 00426 { 00427 CfLog(cferror,"Couldn't open a socket","socket"); 00428 FileOutput(fp, fopl_error, "Couldn't open a socket\n"); 00429 if (CONN->sd != cf_not_connected) 00430 { 00431 close(CONN->sd); 00432 CONN->sd = cf_not_connected; 00433 } 00434 free(addresses.server); 00435 return false; 00436 } 00437 00438 if (!IdentifyForVerification(CONN->sd,CONN->localip,CONN->family)) 00439 { 00440 printf("Unable to open a channel\n"); 00441 FileOutput(fp, fopl_error, "Unable to open a channel\n"); 00442 close(CONN->sd); 00443 errno = EPERM; 00444 free(addresses.server); 00445 return false; 00446 } 00447 00448 if (!KeyAuthentication(&addresses)) 00449 { 00450 snprintf(OUTPUT,bufsize,"Key-authentication for %s failed\n",VFQNAME); 00451 CfLog(cferror,OUTPUT,""); 00452 FileOutput(fp, fopl_error, "Key-authentication failed\n"); 00453 errno = EPERM; 00454 close(CONN->sd); 00455 free(addresses.server); 00456 return false; 00457 } 00458 00459 snprintf(sendbuffer,bufsize,"EXEC %s %s",options,CFRUNOPTIONS); 00460 00461 if (SendTransaction(CONN->sd,sendbuffer,0,CF_DONE) == -1) 00462 { 00463 printf("Transmission rejected"); 00464 FileOutput(fp, fopl_error, "Transmission rejected\n"); 00465 close(CONN->sd); 00466 free(addresses.server); 00467 return false; 00468 } 00469 00470 SendClassData(CONN->sd,sendbuffer); 00471 00472 FileVerbose(fp, "%s replies..\n\n",parsed_host); 00473 00474 first = true; 00475 00476 while (true) 00477 { 00478 bzero(recvbuffer,bufsize); 00479 00480 if ((n_read = ReceiveTransaction(CONN->sd,recvbuffer,NULL)) == -1) 00481 { 00482 if (errno == EINTR) 00483 { 00484 continue; 00485 } 00486 00487 close(CONN->sd); 00488 free(addresses.server); 00489 return true;; 00490 } 00491 00492 if ((sp = strstr(recvbuffer,CFD_TERMINATOR)) != NULL) 00493 { 00494 *sp = '\0'; 00495 fprintf(fp,"%s",recvbuffer); 00496 break; 00497 } 00498 00499 if ((sp = strstr(recvbuffer,"BAD:")) != NULL) 00500 { 00501 *sp = '\0'; 00502 fprintf(fp,"%s",recvbuffer+4); 00503 } 00504 00505 if (n_read == 0) 00506 { 00507 if (!first) 00508 { 00509 fprintf(fp,"\n"); 00510 } 00511 break; 00512 } 00513 00514 if (strlen(recvbuffer) == 0) 00515 { 00516 continue; 00517 } 00518 00519 if (strstr(recvbuffer,"too soon")) 00520 { 00521 FileVerbose(fp,"%s",recvbuffer); 00522 } 00523 00524 if (strstr(recvbuffer,"cfXen")) 00525 { 00526 fprintf(fp,"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"); 00527 continue; 00528 } 00529 00530 if (first) 00531 { 00532 fprintf(fp,"\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n"); 00533 } 00534 00535 first = false; 00536 00537 fprintf(fp,"%s",recvbuffer); 00538 } 00539 00540 if (!first) 00541 { 00542 fprintf(fp,"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n"); 00543 } 00544 00545 close(CONN->sd); 00546 free(addresses.server); 00547 return true; 00548 }
|
|
|
Definition at line 555 of file cfrun.c. References AppendItem(), bufsize, bzero, CFINPUTSVAR, CheckAccess(), Item::classes, Debug, FileFlag, fopl_error, fopl_inform, fopl_normal, fp, getenv(), IsItemIn(), MAXCHILD, maxvarsize, Item::name, Item::next, NULL, OUTPUTDIR, OUTPUTLEVEL, ReadLine(), snprintf(), sp, strstr(), VCFRUNHOSTS, VDOMAIN, and Verbose. Referenced by CheckOptsAndInit(). 00557 { char filename[bufsize], *sp; 00558 char buffer[maxvarsize], options[bufsize], line[bufsize]; 00559 FILE *fp; 00560 struct Item *ip; 00561 00562 bzero(filename,bufsize); 00563 00564 if (!strchr(VCFRUNHOSTS, '/')) 00565 { 00566 if ((sp=getenv(CFINPUTSVAR)) != NULL) 00567 { 00568 strcpy(filename,sp); 00569 if (filename[strlen(filename)-1] != '/') 00570 { 00571 strcat(filename,"/"); 00572 } 00573 } 00574 else 00575 { 00576 snprintf(filename, bufsize, "%s/inputs/", WORKDIR); 00577 } 00578 } 00579 00580 strcat(filename,VCFRUNHOSTS); 00581 00582 if ((fp = fopen(filename,"r")) == NULL) /* Open root file */ 00583 { 00584 printf("Unable to open %s\n",filename); 00585 return; 00586 } 00587 00588 while (!feof(fp)) 00589 { 00590 bzero(buffer,maxvarsize); 00591 bzero(options,bufsize); 00592 bzero(line,bufsize); 00593 00594 ReadLine(line,bufsize,fp); 00595 00596 if (strncmp(line,"domain",6) == 0) 00597 { 00598 sscanf(line,"domain = %295[^# \n]",VDOMAIN); 00599 Verbose("Domain name = %s\n",VDOMAIN); 00600 continue; 00601 } 00602 00603 if (strncmp(line,"maxchild", strlen("maxchild")) == 0) 00604 { 00605 sscanf(line,"maxchild = %295[^# \n]", buffer); 00606 00607 if ( (MAXCHILD = atoi(buffer)) == 0 ) 00608 { 00609 MAXCHILD = 1; 00610 } 00611 00612 Verbose("cfrun: maxchild = %d\n", MAXCHILD); 00613 continue; 00614 } 00615 00616 if (strncmp(line,"outputdir", strlen("outputdir")) == 0) 00617 { 00618 sscanf(line,"outputdir = %295[^# \n]", OUTPUTDIR); 00619 Verbose("cfrun: outputdir = %s\n", OUTPUTDIR); 00620 if ( opendir(OUTPUTDIR) == NULL) 00621 { 00622 printf("Directory %s does not exists\n", OUTPUTDIR); 00623 exit(1); 00624 } 00625 00626 FileFlag=1; 00627 continue; 00628 } 00629 00630 if (strncmp(line,"outputlevel", strlen("outputlevel")) == 0) 00631 { 00632 sscanf(line,"outputlevel = %295[^# \n]", buffer); 00633 00634 if (strncmp(buffer,"inform", strlen("inform")) == 0) 00635 { 00636 OUTPUTLEVEL = fopl_inform; 00637 Verbose("cfrun: outputlevel = inform"); 00638 } 00639 else if (strncmp(buffer,"error", strlen("error")) == 0) 00640 { 00641 OUTPUTLEVEL = fopl_error; 00642 Verbose("cfrun: outputlevel = error"); 00643 } 00644 else if (strncmp(buffer,"normal", strlen("normal")) == 0) 00645 { 00646 OUTPUTLEVEL = fopl_normal; 00647 Verbose("cfrun: outputlevel = normal"); 00648 } 00649 else 00650 { 00651 printf("Invalid outputlevel: %s\n", OUTPUTDIR); 00652 } 00653 00654 continue; 00655 } 00656 00657 if (strncmp(line,"access",6) == 0) 00658 { 00659 for (sp = line; (*sp != '=') && (*sp != '\0'); sp++) 00660 { 00661 } 00662 00663 if (*sp == '\0' || *(++sp) == '\0') 00664 { 00665 continue; 00666 } 00667 00668 CheckAccess(sp); 00669 continue; 00670 } 00671 00672 sscanf(line,"%295s %[^#\n]",buffer,options); 00673 00674 if (buffer[0] == '#') 00675 { 00676 continue; 00677 } 00678 00679 if (strlen(buffer) == 0) 00680 { 00681 continue; 00682 } 00683 00684 00685 if (VCFRUNOPTIONHOSTS != NULL && !IsItemIn(VCFRUNOPTIONHOSTS,buffer)) 00686 { 00687 Verbose("Skipping host %s\n",buffer); 00688 continue; 00689 } 00690 00691 if ((!strstr(buffer,".")) && (strlen(VDOMAIN) > 0)) 00692 { 00693 strcat(buffer,"."); 00694 strcat(buffer,VDOMAIN); 00695 } 00696 00697 if (!IsItemIn(VCFRUNHOSTLIST,buffer)) 00698 { 00699 AppendItem(&VCFRUNHOSTLIST,buffer,options); 00700 } 00701 } 00702 00703 for (ip = VCFRUNHOSTLIST; ip != NULL; ip=ip->next) 00704 { 00705 Debug("host item: %s (%s)\n",ip->name,ip->classes); 00706 } 00707 00708 fclose(fp); 00709 00710 }
|
|
||||||||||||||||||||
|
Definition at line 942 of file cfrun.c.
|
|
||||||||||||
|
Definition at line 730 of file cfrun.c. References bufsize, bzero, CF_DONE, CFD_TERMINATOR, Item::name, Item::next, NULL, SendTransaction(), and sp. Referenced by PollServer(). 00735 { struct Item *ip; 00736 int used; 00737 char *sp; 00738 00739 sp = sendbuffer; 00740 used = 0; 00741 bzero(sendbuffer,bufsize); 00742 00743 for (ip = VCFRUNCLASSES; ip != NULL; ip = ip->next) 00744 { 00745 if (used + strlen(ip->name) +2 > bufsize) 00746 { 00747 if (SendTransaction(sd,sendbuffer,0,CF_DONE) == -1) 00748 { 00749 perror("send"); 00750 return; 00751 } 00752 00753 used = 0; 00754 sp = sendbuffer; 00755 bzero(sendbuffer,bufsize); 00756 } 00757 00758 strcat(sendbuffer,ip->name); 00759 strcat(sendbuffer," "); 00760 00761 sp += strlen(ip->name)+1; 00762 used += strlen(ip->name)+1; 00763 } 00764 00765 if (used + strlen(CFD_TERMINATOR) +2 > bufsize) 00766 { 00767 if (SendTransaction(sd,sendbuffer,0,CF_DONE) == -1) 00768 { 00769 perror("send"); 00770 return; 00771 } 00772 00773 used = 0; 00774 sp = sendbuffer; 00775 bzero(sendbuffer,bufsize); 00776 } 00777 00778 sprintf(sp,CFD_TERMINATOR); 00779 00780 if (SendTransaction(sd,sendbuffer,0,CF_DONE) == -1) 00781 { 00782 perror("send"); 00783 return; 00784 } 00785 }
|
|
|
Definition at line 962 of file cfrun.c.
|
|
|
|
|
|
Definition at line 61 of file cfrun.c. Referenced by CheckOptsAndInit(), and PollServer(). |
|
|
Definition at line 51 of file cfrun.c. Referenced by main(), and ReadCfrunConf(). |
|
|
Definition at line 50 of file cfrun.c. Referenced by main(), and ReadCfrunConf(). |
|
|
Definition at line 54 of file cfrun.c. Referenced by PollServer(), and ReadCfrunConf(). |
|
|
Definition at line 53 of file cfrun.c. Referenced by FileOutput(), and ReadCfrunConf(). |
|
|
Definition at line 52 of file cfrun.c. Referenced by CheckOptsAndInit(), and PollServer(). |
|
|
|
|
|
|
|
|
Definition at line 60 of file cfrun.c. Referenced by CheckOptsAndInit(), and ReadCfrunConf(). |
|
|
|