Proposed improvements to service_ok()

David Collier-Brown davecb at canada.sun.com
Thu Jan 27 00:21:21 GMT 2000


  I've been unhappy for some time with the weak checking
of service self-consistency in .../source/param/loadparm.c's
"service_ok" function.
  Here's my initial draft of a better one, in diff format.
Suggestions and criticism welcome!

--dave  
-- 
David Collier-Brown,  | Always do right. This will gratify
185 Ellerslie Ave.,   | some people and astonish the rest.
Willowdale, Ontario,  |                      -- Mark Twain
CANADA. 416-223-8968  | davecb at canada.sun.com
-------------- next part --------------
1770c1770,1772
< incomplete or faulty, else True.
---
> incomplete or faulty, else True.  The messages use WARNING for something
> that indicates a failure occuring, NOTICE for something arguably wrong,
> and ERROR for something having failed.
1774c1776,1778
<    BOOL bRetval;
---
>    BOOL bRetval = True;
>    static int globalCheck = True;
>    struct stat buf;
1776c1780,1830
<    bRetval = True;
---
>    /* Look for inconstancies in roughly decreasing order of severity, */
>    /* starting with globals. */
> 
>    if (globalCheck == True) 
>    {
>       globalCheck = False; /* Only check once. */
> 
>       /* Check for both wins server and wins support, make sure server wins. */
>       if (Globals.szWINSserver != '\0' && Globals.bWINSsupport == True)
>       {
>          DEBUG(0,( "ERROR: both wins server and wins support turned on, "
> 		  "using wins server \"%s\".\n", Globals.szWINSserver));
> 	 Globals.bWINSsupport = False;
>       }
> 
>       /* Check for announcing as something other than NT, which can */
>       /* interefere with serving browse lists. */
>       if (Globals.announce_as == ANNOUNCE_AS_NT_SERVER)
>          DEBUG(0,( "WARNING: announce as not set to \"NT\", this may "
> 		  "interfere with browsing.\n"));
> 
> 
>       /* Cross-check PDC vs BDC vs Unix logon server for win9x */
>       /*	security	domain	domain	encrypt
>        *			logons	master	passwds
>        * PDC	domain		yes	yes	yes
>        * BDC	domain		yes	no	yes
>        * Unix	user/server	yes	no	yes
>        * The last one works for win9x, but won't work with NT clients,
>        * which require NT domains  to do domain logons to.
>        */
>       if (Globals.bDomainLogons == True)
> 	{
> 	if (Globals.bEncryptPasswords == False)
> 	   DEBUG(0,( "WARNING: encrypt passwords must be true if "
> 	      "domain logons is true.\n"));
> 
> 	if (Globals.security == SEC_SHARE)
> 	   DEBUG(0,( "WARNING: security should be domain if "
> 	      "domain logons is true.\n"));
> 	else if (Globals.security == SEC_USER 
> 	   || Globals.security == SEC_SERVER)
> 	   DEBUG(0,( "NOTICE: security = user or server will only "
> 	      "support domain logons from Windows 95 and 98, not NT.\n"));
>       }
> 
>    } /* End of globals. */
> 
> 
>    /* Now do per-service options, starting with ERRORs. */
>    /* Test for a missing service name. */
1780c1834
<       DEBUG(0,( "No service name in service entry.\n"));
---
>       DEBUG(0,( "ERROR: No service name in service entry.\n"));
1783a1838,1849
>    /* Test for path not pointing to a dir (other tests follow). */
>    if (iSERVICE(iService).szPath[0] != '\0') 
>    {
>       if (stat(iSERVICE(iService).szPath,&buf) == -1)
>          DEBUG(0,("ERROR: can't stat path %s in service %s.\n",
> 		iSERVICE(iService).szPath, iSERVICE(iService).szService));
>       else if (buf.st_mode != S_IFDIR && buf.st_mode != S_IFLNK)
>          DEBUG(0,("ERROR: Path %s in service %s isn't a directory.\n",
> 		iSERVICE(iService).szPath, iSERVICE(iService).szService));
>    }
> 
>    /* Contradictions in terms: */
1789c1855
<          DEBUG(0,( "WARNING: [%s] service MUST be printable!\n",
---
>          DEBUG(0,( "ERROR: printer service [%s] MUST be printable!\n",
1793a1860,1899
>    /* Things that are inherently dangerous: WARNINGs. */
>    /* Check for announcing as something other than NT, which can */
>    
>    /* Look for map archive forced to fail by bad create mask. */
>    /* Ditto map system, map hidden. */
>    if (iSERVICE(iService).bMap_archive == True
>        && (iSERVICE(iService).iCreate_mask & 0100) == 0)
> 	DEBUG(0,( "WARNING: map archive set in share %s, but create "
> 		 "mask doesn't allow setting archive bit (100 octal).\n",
> 		 iSERVICE(iService).szService));
> 
>     if (iSERVICE(iService).bMap_system == True
>       && (iSERVICE(iService).iCreate_mask & 0010) == 0)
> 	DEBUG(0,( "WARNING: map system set in share %s, but create "
> 		 "mask doesn't allow setting system bit (010 octal).\n",
> 		 iSERVICE(iService).szService));
> 
>    if (iSERVICE(iService).bMap_hidden == True
>        && (iSERVICE(iService).iCreate_mask & 0001) == 0)
> 	DEBUG(0,( "WARNING: map hidden set in share %s, but create "
> 		 "mask doesn't allow setting hidden bit (001 octal).\n",
> 		 iSERVICE(iService).szService));
> 
>    /* And see if force create mode sets any of the same three bits */
>    if ((iSERVICE(iService).iCreate_force_mode & 0100) != 0)
> 	DEBUG(0,( "WARNING: force create mode forces archive bit on "
> 		 "on all files in share %s.\n", 
> 		 iSERVICE(iService).szService));
>    if ((iSERVICE(iService).iCreate_force_mode & 0010) != 0)
> 	DEBUG(0,( "WARNING: force create mode forces system bit on "
> 		 "on all files in share %s.\n", 
> 		 iSERVICE(iService).szService));
>    if ((iSERVICE(iService).iCreate_force_mode & 0001) != 0)
> 	DEBUG(0,( "WARNING: force create mode forces hidden bit on "
> 		 "on all file in share %s.\n",
> 	    	 iSERVICE(iService).szService));
> 
> 
>    /* Depending on defaults for proper execution: NOTICEs.*/
>    /* Test for missing path, substitute the default if unset. */
1797c1903,1904
<       DEBUG(0,("No path in service %s - using %s\n",iSERVICE(iService).szService,tmpdir()));
---
>       DEBUG(0,("NOTICE: No path in service %s - using %s\n",
> 	       iSERVICE(iService).szService,tmpdir()));
1800a1908
>    /* Implausible overrides: WARNINGs. */
1803c1911
<       DEBUG(1,( "NOTE: Service %s is flagged unavailable.\n",
---
>       DEBUG(1,( "NOTICE: Service %s is flagged unavailable.\n",
1804a1913,1917
> 
>    /* If it's unbrowsable but we're serving browse lists, log that too. */
>    if (iSERVICE(iService).bBrowseable == False && Globals.bBrowseList == True)
>       DEBUG(0,( "NOTICE: Service %s is flagged unbrowsable, but browse "
> 	    "lists are being served.\n", iSERVICE(iService).szService));


More information about the samba mailing list