update testparm with -s option so it doesn't require a carriage return
[samba.git] / source / utils / testparm.c
index c7cbab91b87ee9e8ea714f5af73ac71c73c14c99..9bf741e24f14ae3df926ef7da22d69bf7814c9ae 100644 (file)
@@ -44,15 +44,18 @@ extern pstring myhostname;
  Here we do a set of 'hard coded' checks for bad
  configuration settings.
 ************************************************/
-
-void do_global_checks(void)
+static void do_global_checks(void)
 {
-       struct stat st;
+       SMB_STRUCT_STAT st;
        if (lp_security() > SEC_SHARE && lp_revalidate(-1)) {
                printf("WARNING: the 'revalidate' parameter is ignored in all but \
 'security=share' mode.\n");
        }
 
+    if (lp_security() == SEC_DOMAIN && !lp_encrypted_passwords()) {
+               printf("ERROR: in 'security=domain' mode the 'encrypt passwords' parameter must also be set to 'true'.\n");
+       }
+
        if (lp_wins_support() && *lp_wins_server()) {
                printf("ERROR: both 'wins support = true' and 'wins server = <server>' \
 cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
@@ -61,16 +64,20 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
        if (!directory_exist(lp_lockdir(), &st)) {
                printf("ERROR: lock directory %s does not exist\n",
                       lp_lockdir());
-       } else if ((st.st_mode & 0666) != 0644) {
-               printf("WARNING: lock directory %s should have permissions 0644 for browsing to work\n",
+       } else if ((st.st_mode & 0777) != 0755) {
+               printf("WARNING: lock directory %s should have permissions 0755 for browsing to work\n",
                       lp_lockdir());
        }
 }   
 
  int main(int argc, char *argv[])
 {
+  extern char *optarg;
+  extern int optind;
   pstring configfile;
+  int opt;
   int s;
+  BOOL silent_mode = False;
 
   TimeInit();
 
@@ -78,10 +85,20 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
   
   charset_initialise();
 
-  if (argc < 2)
+  while ((opt = getopt(argc, argv,"s")) != EOF) {
+  switch (opt) {
+    case 's':
+      silent_mode = True;
+      break;
+    }
+  }
+
+  argc += (1 - optind);
+
+  if ((argc == 1) || (argc == 3))
     pstrcpy(configfile,CONFIGFILE);
-  else
-    pstrcpy(configfile,argv[1]);
+  else if ((argc == 2) || (argc == 4))
+    pstrcpy(configfile,argv[optind]);
 
   dbf = stdout;
   DEBUGLEVEL = 2;
@@ -113,19 +130,29 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
        break;
       }
 
-  if (argc < 4)
+  if (argc < 3)
     {
-      printf("Press enter to see a dump of your service definitions\n");
-      fflush(stdout);
-      getc(stdin);
+      if (!silent_mode) {
+       printf("Press enter to see a dump of your service definitions\n");
+       fflush(stdout);
+       getc(stdin);
+      }
       lp_dump(stdout,True);
     }
   
-  if (argc == 4)
+  if (argc >= 3)
     {
-      char *cname = argv[2];
-      char *caddr = argv[3];
+      char *cname;
+      char *caddr;
       
+      if (argc == 3) {
+       cname = argv[optind];
+       caddr = argv[optind+1];
+      } else if (argc == 4) {
+       cname = argv[optind+1];
+       caddr = argv[optind+2];
+      }
+
       /* this is totally ugly, a real `quick' hack */
       for (s=0;s<1000;s++)
        if (VALID_SNUM(s))