Remove attempts to quieten compiler static-checking
[exim.git] / src / src / exim.c
index 905ef0a7008bbe12078dac39137f823a11e6ff72..dcfc066232e3c8b833e632f1315bbb06134d29c3 100644 (file)
@@ -279,7 +279,6 @@ Returns:  nothing
 void
 sigalrm_handler(int sig)
 {
-sig = sig;      /* Keep picky compilers happy */
 sigalrm_seen = TRUE;
 os_non_restarting_signal(SIGALRM, sigalrm_handler);
 }
@@ -1618,6 +1617,7 @@ BOOL removed_privilege = FALSE;
 BOOL usage_wanted = FALSE;
 BOOL verify_address_mode = FALSE;
 BOOL verify_as_sender = FALSE;
+BOOL rcpt_verify_quota = FALSE;
 BOOL version_printed = FALSE;
 uschar *alias_arg = NULL;
 uschar *called_as = US"";
@@ -2148,7 +2148,7 @@ on the second character (the one after '-'), to save some effort. */
        concept of *the* alias file, but since Sun's YP make script calls
        sendmail this way, some support must be provided. */
        case 'i':
-         if (!*++argrest) bi_option = TRUE;
+         if (!*argrest) bi_option = TRUE;
          else badarg = TRUE;
          break;
 
@@ -2790,6 +2790,13 @@ on the second character (the one after '-'), to save some effort. */
                  else badarg = TRUE;
                  break;
 
+    /* -MCq: do a quota check on the given recipient for the given size
+    of message.  Separate from -MC. */
+       case 'q': rcpt_verify_quota = TRUE;
+                 if (++i < argc) message_size = Uatoi(argv[i]);
+                 else badarg = TRUE;
+                 break;
+
     /* -MCS: set the smtp_use_size flag; this is useful only when it
     precedes -MC (see above) */
 
@@ -4109,7 +4116,7 @@ script. */
 if (bi_option)
   {
   (void)fclose(config_file);
-  if (bi_command)
+  if (bi_command && *bi_command)
     {
     int i = 0;
     uschar *argv[3];
@@ -4120,11 +4127,11 @@ if (bi_option)
     setgroups(group_count, group_list);
     exim_setugid(real_uid, real_gid, FALSE, US"running bi_command");
 
-    DEBUG(D_exec) debug_printf("exec %.256s %.256s\n", argv[0],
-      argv[1] ? argv[1] : US"");
+    DEBUG(D_exec) debug_printf("exec '%.256s' %s%.256s%s\n", argv[0],
+      argv[1] ? "'" : "", argv[1] ? argv[1] : US"", argv[1] ? "'" : "");
 
     execv(CS argv[0], (char *const *)argv);
-    exim_fail("exim: exec failed: %s\n", strerror(errno));
+    exim_fail("exim: exec '%s' failed: %s\n", argv[0], strerror(errno));
     }
   else
     {
@@ -4296,6 +4303,7 @@ if (  !unprivileged                               /* originally had root AND */
             || msg_action != MSG_DELIVER       /* not delivering          */
            )                                   /*       and               */
          && (!checking || !f.address_test_mode)        /* not address checking    */
+        && !rcpt_verify_quota                  /* and not quota checking  */
    )  )  )
   exim_setugid(exim_uid, exim_gid, TRUE, US"privilege not needed");
 
@@ -4315,8 +4323,10 @@ else
     if (!(unprivileged || removed_privilege))
       exim_fail("exim: changing group failed: %s\n", strerror(errno));
     else
+      {
       DEBUG(D_any) debug_printf("changing group to %ld failed: %s\n",
           (long int)exim_gid, strerror(errno));
+      }
   }
 
 /* Handle a request to scan a file for malware */
@@ -4414,6 +4424,18 @@ needed in transports so we lost the optimisation. */
 #endif
   }
 
+/* Handle a request to check quota */
+if (rcpt_verify_quota)
+  if (real_uid != root_uid && real_uid != exim_uid)
+    exim_fail("exim: Permission denied\n");
+  else if (recipients_arg >= argc)
+    exim_fail("exim: missing recipient for quota check\n");
+  else
+    {
+    verify_quota(argv[recipients_arg]);
+    exim_exit(EXIT_SUCCESS);
+    }
+
 /* Handle the -brt option. This is for checking out retry configurations.
 The next three arguments are a domain name or a complete address, and
 optionally two error numbers. All it does is to call the function that