home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / samba-1.9.18p7.tar.gz / samba-1.9.18p7.tar / samba-1.9.18p7 / source / testparm.c < prev    next >
C/C++ Source or Header  |  1998-05-12  |  3KB  |  120 lines

  1. /* 
  2.    Unix SMB/Netbios implementation.
  3.    Version 1.9.
  4.    Test validity of smb.conf
  5.    Copyright (C) Karl Auer 1993, 1994-1998
  6.  
  7.    Extensively modified by Andrew Tridgell, 1995
  8.    
  9.    This program is free software; you can redistribute it and/or modify
  10.    it under the terms of the GNU General Public License as published by
  11.    the Free Software Foundation; either version 2 of the License, or
  12.    (at your option) any later version.
  13.    
  14.    This program is distributed in the hope that it will be useful,
  15.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.    GNU General Public License for more details.
  18.    
  19.    You should have received a copy of the GNU General Public License
  20.    along with this program; if not, write to the Free Software
  21.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. */
  23.  
  24. /*
  25.  * Testbed for loadparm.c/params.c
  26.  *
  27.  * This module simply loads a specified configuration file and
  28.  * if successful, dumps it's contents to stdout. Note that the
  29.  * operation is performed with DEBUGLEVEL at 3.
  30.  *
  31.  * Useful for a quick 'syntax check' of a configuration file.
  32.  *
  33.  */
  34.  
  35. #include "includes.h"
  36. #include "smb.h"
  37.  
  38. /* these live in util.c */
  39. extern FILE *dbf;
  40. extern int DEBUGLEVEL;
  41. extern pstring myhostname;
  42.  
  43.  int main(int argc, char *argv[])
  44. {
  45.   pstring configfile;
  46.   int s;
  47.  
  48.   TimeInit();
  49.  
  50.   setup_logging(argv[0],True);
  51.   
  52.   charset_initialise();
  53.  
  54.   if (argc < 2)
  55.     pstrcpy(configfile,CONFIGFILE);
  56.   else
  57.     pstrcpy(configfile,argv[1]);
  58.  
  59.   dbf = stdout;
  60.   DEBUGLEVEL = 2;
  61.  
  62.   printf("Load smb config files from %s\n",configfile);
  63.  
  64.   if(!get_myname(myhostname,NULL))
  65.   {
  66.     printf("Failed to get my hostname.\n");
  67.     return(1);
  68.   }
  69.  
  70.   if (!lp_load(configfile,False))
  71.     {
  72.       printf("Error loading services.\n");
  73.       return(1);
  74.     }
  75.  
  76.  
  77.   printf("Loaded services file OK.\n");
  78.  
  79.   for (s=0;s<1000;s++)
  80.     if (VALID_SNUM(s))
  81.       if (strlen(lp_servicename(s)) > 8) {
  82.     printf("WARNING: You have some share names that are longer than 8 chars\n");
  83.     printf("These may give errors while browsing or may not be accessible\nto some older clients\n");
  84.     break;
  85.       }
  86.  
  87.   if (argc < 4)
  88.     {
  89.       printf("Press enter to see a dump of your service definitions\n");
  90.       fflush(stdout);
  91.       getc(stdin);
  92.       lp_dump(stdout);      
  93.     }
  94.   
  95.   if (argc == 4)
  96.     {
  97.       char *cname = argv[2];
  98.       char *caddr = argv[3];
  99.       
  100.       /* this is totally ugly, a real `quick' hack */
  101.       for (s=0;s<1000;s++)
  102.     if (VALID_SNUM(s))
  103.       {         
  104.         if (allow_access(lp_hostsdeny(s),lp_hostsallow(s),cname,caddr))
  105.           {
  106.         printf("Allow connection from %s (%s) to %s\n",
  107.                cname,caddr,lp_servicename(s));
  108.           }
  109.         else
  110.           {
  111.         printf("Deny connection from %s (%s) to %s\n",
  112.                cname,caddr,lp_servicename(s));
  113.           }
  114.       }
  115.     }
  116.   return(0);
  117. }
  118.  
  119.  
  120.