4 * Main loop for the CUPS scheduler.
6 * Copyright 2007-2014 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * "LICENSE" which should have been included with this file. If this
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * Include necessary headers...
22 #include <sys/resource.h>
29 # define CUPS_KEEPALIVE CUPS_CACHEDIR "/org.cups.cupsd"
30 /* Name of the launchd KeepAlive file */
31 # ifndef LAUNCH_JOBKEY_KEEPALIVE
32 # define LAUNCH_JOBKEY_KEEPALIVE "KeepAlive"
33 # endif /* !LAUNCH_JOBKEY_KEEPALIVE */
34 # ifndef LAUNCH_JOBKEY_PATHSTATE
35 # define LAUNCH_JOBKEY_PATHSTATE "PathState"
36 # endif /* !LAUNCH_JOBKEY_PATHSTATE */
37 # ifndef LAUNCH_JOBKEY_SERVICEIPC
38 # define LAUNCH_JOBKEY_SERVICEIPC "ServiceIPC"
39 # endif /* !LAUNCH_JOBKEY_SERVICEIPC */
40 #endif /* HAVE_LAUNCH_H */
42 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
44 #endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
48 #endif /* HAVE_NOTIFY_H */
50 #ifdef HAVE_SYS_PARAM_H
51 # include <sys/param.h>
52 #endif /* HAVE_SYS_PARAM_H */
60 static void launchd_checkin(void);
61 static void launchd_checkout(void);
62 #endif /* HAVE_LAUNCHD */
63 static void parent_handler(int sig
);
64 static void process_children(void);
65 static void sigchld_handler(int sig
);
66 static void sighup_handler(int sig
);
67 static void sigterm_handler(int sig
);
68 static long select_timeout(int fds
);
69 static void usage(int status
) __attribute__((noreturn
));
76 static int parent_signal
= 0;
77 /* Set to signal number from child */
78 static int holdcount
= 0; /* Number of times "hold" was called */
79 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
80 static sigset_t holdmask
; /* Old POSIX signal mask */
81 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
82 static int dead_children
= 0;
84 static int stop_scheduler
= 0;
85 /* Should the scheduler stop? */
89 * 'main()' - Main entry for the CUPS scheduler.
92 int /* O - Exit status */
93 main(int argc
, /* I - Number of command-line args */
94 char *argv
[]) /* I - Command-line arguments */
96 int i
; /* Looping var */
97 char *opt
; /* Option character */
98 int fg
; /* Run in the foreground */
99 int fds
; /* Number of ready descriptors */
100 cupsd_client_t
*con
; /* Current client */
101 cupsd_job_t
*job
; /* Current job */
102 cupsd_listener_t
*lis
; /* Current listener */
103 time_t current_time
, /* Current time */
104 activity
, /* Client activity timer */
105 senddoc_time
, /* Send-Document time */
106 expire_time
, /* Subscription expire time */
107 report_time
, /* Malloc/client/job report time */
108 event_time
; /* Last event notification time */
109 long timeout
; /* Timeout for cupsdDoSelect() */
110 struct rlimit limit
; /* Runtime limit */
111 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
112 struct sigaction action
; /* Actions for POSIX signals */
113 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
114 int run_as_child
= 0;
115 /* Needed for background fork/exec */
117 int use_sysman
= !getuid();
118 /* Use system management functions? */
120 time_t netif_time
= 0; /* Time since last network update */
121 #endif /* __APPLE__ */
123 int launchd_idle_exit
;
124 /* Idle exit on select timeout? */
125 #endif /* HAVE_LAUNCHD */
130 * Check for setuid invocation, which we do not support!
133 if (getuid() != geteuid())
135 fputs("cupsd: Cannot run as a setuid program\n", stderr
);
138 #endif /* HAVE_GETEUID */
141 * Check for command-line arguments...
147 if (getenv("CUPSD_LAUNCHD"))
152 #endif /* HAVE_LAUNCHD */
154 for (i
= 1; i
< argc
; i
++)
155 if (argv
[i
][0] == '-')
156 for (opt
= argv
[i
] + 1; *opt
!= '\0'; opt
++)
159 case 'C' : /* Run as child with config file */
163 case 'c' : /* Configuration file */
167 _cupsLangPuts(stderr
, _("cupsd: Expected config filename "
168 "after \"-c\" option."));
172 if (argv
[i
][0] == '/')
175 * Absolute directory...
178 cupsdSetString(&ConfigurationFile
, argv
[i
]);
183 * Relative directory...
186 char *current
; /* Current directory */
189 * Allocate a buffer for the current working directory to
190 * reduce run-time stack usage; this approximates the
191 * behavior of some implementations of getcwd() when they
192 * are passed a NULL pointer.
195 if ((current
= malloc(1024)) == NULL
)
197 _cupsLangPuts(stderr
,
198 _("cupsd: Unable to get current directory."));
202 if (!getcwd(current
, 1024))
204 _cupsLangPuts(stderr
,
205 _("cupsd: Unable to get current directory."));
210 cupsdSetStringf(&ConfigurationFile
, "%s/%s", current
, argv
[i
]);
215 case 'f' : /* Run in foreground... */
219 case 'F' : /* Run in foreground, but disconnect from terminal... */
223 case 'h' : /* Show usage/help */
227 case 'l' : /* Started by launchd... */
232 _cupsLangPuts(stderr
, _("cupsd: launchd(8) support not compiled "
233 "in, running in normal mode."));
235 #endif /* HAVE_LAUNCHD */
238 case 'p' : /* Stop immediately for profiling */
239 fputs("cupsd: -p (startup profiling) is for internal testing "
240 "use only!\n", stderr
);
245 case 'P' : /* Disable security profiles */
246 fputs("cupsd: -P (disable security profiles) is for internal "
247 "testing use only!\n", stderr
);
251 case 's' : /* Set cups-files.conf location */
255 _cupsLangPuts(stderr
, _("cupsd: Expected cups-files.conf "
256 "filename after \"-s\" option."));
260 if (argv
[i
][0] != '/')
263 * Relative filename not allowed...
266 _cupsLangPuts(stderr
, _("cupsd: Relative cups-files.conf "
267 "filename not allowed."));
271 cupsdSetString(&CupsFilesFile
, argv
[i
]);
275 case 'S' : /* Disable system management functions */
276 fputs("cupsd: -S (disable system management) for internal "
277 "testing use only!\n", stderr
);
280 #endif /* __APPLE__ */
282 case 't' : /* Test the cupsd.conf file... */
287 default : /* Unknown option */
288 _cupsLangPrintf(stderr
, _("cupsd: Unknown option \"%c\" - "
295 _cupsLangPrintf(stderr
, _("cupsd: Unknown argument \"%s\" - aborting."),
300 if (!ConfigurationFile
)
301 cupsdSetString(&ConfigurationFile
, CUPS_SERVERROOT
"/cupsd.conf");
305 char *filename
, /* Copy of cupsd.conf filename */
306 *slash
; /* Final slash in cupsd.conf filename */
307 size_t len
; /* Size of buffer */
309 len
= strlen(ConfigurationFile
) + 15;
310 if ((filename
= malloc(len
)) == NULL
)
312 _cupsLangPrintf(stderr
,
313 _("cupsd: Unable to get path to "
314 "cups-files.conf file."));
318 strlcpy(filename
, ConfigurationFile
, len
);
319 if ((slash
= strrchr(filename
, '/')) == NULL
)
321 _cupsLangPrintf(stderr
,
322 _("cupsd: Unable to get path to "
323 "cups-files.conf file."));
327 strlcpy(slash
, "/cups-files.conf", len
- (size_t)(slash
- filename
));
328 cupsdSetString(&CupsFilesFile
, filename
);
333 * If the user hasn't specified "-f", run in the background...
339 * Setup signal handlers for the parent...
342 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
343 sigset(SIGUSR1
, parent_handler
);
344 sigset(SIGCHLD
, parent_handler
);
346 sigset(SIGHUP
, SIG_IGN
);
347 #elif defined(HAVE_SIGACTION)
348 memset(&action
, 0, sizeof(action
));
349 sigemptyset(&action
.sa_mask
);
350 sigaddset(&action
.sa_mask
, SIGUSR1
);
351 action
.sa_handler
= parent_handler
;
352 sigaction(SIGUSR1
, &action
, NULL
);
353 sigaction(SIGCHLD
, &action
, NULL
);
355 sigemptyset(&action
.sa_mask
);
356 action
.sa_handler
= SIG_IGN
;
357 sigaction(SIGHUP
, &action
, NULL
);
359 signal(SIGUSR1
, parent_handler
);
360 signal(SIGCLD
, parent_handler
);
362 signal(SIGHUP
, SIG_IGN
);
363 #endif /* HAVE_SIGSET */
368 * OK, wait for the child to startup and send us SIGUSR1 or to crash
369 * and the OS send us SIGCHLD... We also need to ignore SIGHUP which
370 * might be sent by the init script to restart the scheduler...
373 for (; parent_signal
== 0;)
376 if (parent_signal
== SIGUSR1
)
384 else if (WIFEXITED(i
))
386 fprintf(stderr
, "cupsd: Child exited with status %d\n",
392 fprintf(stderr
, "cupsd: Child exited on signal %d\n", WTERMSIG(i
));
397 #if defined(__OpenBSD__) && OpenBSD < 201211
399 * Call _thread_sys_closefrom() so the child process doesn't reset the
400 * parent's file descriptors to be blocking. This is a workaround for a
401 * limitation of userland libpthread on older versions of OpenBSD.
404 _thread_sys_closefrom(0);
405 #endif /* __OpenBSD__ && OpenBSD < 201211 */
408 * Since CoreFoundation and DBUS both create fork-unsafe data on execution of
409 * a program, and since this kind of really unfriendly behavior seems to be
410 * more common these days in system libraries, we need to re-execute the
411 * background cupsd with the "-C" option to avoid problems. Unfortunately,
412 * we also have to assume that argv[0] contains the name of the cupsd
413 * executable - there is no portable way to get the real pathname...
416 execlp(argv
[0], argv
[0], "-C", ConfigurationFile
, (char *)0);
423 * Make sure we aren't tying up any filesystems...
430 * Disable core dumps...
433 getrlimit(RLIMIT_CORE
, &limit
);
435 setrlimit(RLIMIT_CORE
, &limit
);
438 * Disconnect from the controlling terminal...
444 * Close all open files...
447 getrlimit(RLIMIT_NOFILE
, &limit
);
449 for (i
= 0; i
< limit
.rlim_cur
&& i
< 1024; i
++)
453 * Redirect stdin/out/err to /dev/null...
456 if ((i
= open("/dev/null", O_RDONLY
)) != 0)
462 if ((i
= open("/dev/null", O_WRONLY
)) != 1)
468 if ((i
= open("/dev/null", O_WRONLY
)) != 2)
477 * Set the timezone info...
483 setlocale(LC_TIME
, "");
487 * Set the maximum number of files...
490 getrlimit(RLIMIT_NOFILE
, &limit
);
492 #if !defined(HAVE_POLL) && !defined(HAVE_EPOLL) && !defined(HAVE_KQUEUE)
493 if (limit
.rlim_max
> FD_SETSIZE
)
496 #endif /* !HAVE_POLL && !HAVE_EPOLL && !HAVE_KQUEUE */
498 if (limit
.rlim_max
== RLIM_INFINITY
)
501 #endif /* RLIM_INFINITY */
502 MaxFDs
= limit
.rlim_max
;
504 limit
.rlim_cur
= (rlim_t
)MaxFDs
;
506 setrlimit(RLIMIT_NOFILE
, &limit
);
511 * Read configuration...
514 if (!cupsdReadConfiguration())
516 else if (TestConfigFile
)
518 printf("\"%s\" is OK.\n", CupsFilesFile
);
519 printf("\"%s\" is OK.\n", ConfigurationFile
);
524 * Clean out old temp files and printer cache data.
527 if (!strncmp(TempDir
, RequestRoot
, strlen(RequestRoot
)))
528 cupsdCleanFiles(TempDir
, NULL
);
530 cupsdCleanFiles(CacheDir
, "*.ipp");
536 * If we were started by launchd get the listen sockets file descriptors...
542 #endif /* HAVE_LAUNCHD */
545 * Startup the server...
553 * Catch hangup and child signals and ignore broken pipes...
556 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
557 sigset(SIGCHLD
, sigchld_handler
);
558 sigset(SIGHUP
, sighup_handler
);
559 sigset(SIGPIPE
, SIG_IGN
);
560 sigset(SIGTERM
, sigterm_handler
);
561 #elif defined(HAVE_SIGACTION)
562 memset(&action
, 0, sizeof(action
));
564 sigemptyset(&action
.sa_mask
);
565 sigaddset(&action
.sa_mask
, SIGTERM
);
566 sigaddset(&action
.sa_mask
, SIGCHLD
);
567 action
.sa_handler
= sigchld_handler
;
568 sigaction(SIGCHLD
, &action
, NULL
);
570 sigemptyset(&action
.sa_mask
);
571 sigaddset(&action
.sa_mask
, SIGHUP
);
572 action
.sa_handler
= sighup_handler
;
573 sigaction(SIGHUP
, &action
, NULL
);
575 sigemptyset(&action
.sa_mask
);
576 action
.sa_handler
= SIG_IGN
;
577 sigaction(SIGPIPE
, &action
, NULL
);
579 sigemptyset(&action
.sa_mask
);
580 sigaddset(&action
.sa_mask
, SIGTERM
);
581 sigaddset(&action
.sa_mask
, SIGCHLD
);
582 action
.sa_handler
= sigterm_handler
;
583 sigaction(SIGTERM
, &action
, NULL
);
585 signal(SIGCLD
, sigchld_handler
); /* No, SIGCLD isn't a typo... */
586 signal(SIGHUP
, sighup_handler
);
587 signal(SIGPIPE
, SIG_IGN
);
588 signal(SIGTERM
, sigterm_handler
);
589 #endif /* HAVE_SIGSET */
592 * Initialize authentication certificates...
598 * If we are running in the background, signal the parent process that
599 * we are up and running...
602 if (!fg
|| run_as_child
)
605 * Send a signal to the parent process, but only if the parent is
606 * not PID 1 (init). This avoids accidentally shutting down the
607 * system on OpenBSD if you CTRL-C the server before it is up...
610 i
= getppid(); /* Save parent PID to avoid race condition */
618 * Start power management framework...
622 cupsdStartSystemMonitor();
623 #endif /* __APPLE__ */
626 * Send server-started event...
631 cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED
, NULL
, NULL
,
632 "Scheduler started via launchd.");
634 #endif /* HAVE_LAUNCHD */
636 cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED
, NULL
, NULL
,
637 "Scheduler started in foreground.");
639 cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED
, NULL
, NULL
,
640 "Scheduler started in background.");
643 * Start any pending print jobs...
652 current_time
= time(NULL
);
653 event_time
= current_time
;
654 expire_time
= current_time
;
657 senddoc_time
= current_time
;
659 while (!stop_scheduler
)
662 * Check if there are dead children to handle...
669 * Check if we need to load the server configuration file...
675 * Close any idle clients...
678 if (cupsArrayCount(Clients
) > 0)
680 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
682 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
683 if (httpGetState(con
->http
) == HTTP_WAITING
)
684 cupsdCloseClient(con
);
686 con
->http
->keep_alive
= HTTP_KEEPALIVE_OFF
;
688 cupsdPauseListening();
692 * Restart if all clients are closed and all jobs finished, or
693 * if the reload timeout has elapsed...
696 if ((cupsArrayCount(Clients
) == 0 &&
697 (cupsArrayCount(PrintingJobs
) == 0 || NeedReload
!= RELOAD_ALL
)) ||
698 (time(NULL
) - ReloadTime
) >= ReloadTimeout
)
701 * Shutdown the server...
709 * Read configuration...
712 if (!cupsdReadConfiguration())
714 syslog(LOG_LPR
, "Unable to read configuration file \'%s\' - exiting!",
723 * If we were started by launchd, get the listen socket file
730 #endif /* HAVE_LAUNCHD */
733 * Startup the server...
741 * Send a server-restarted event...
744 cupsdAddEvent(CUPSD_EVENT_SERVER_RESTARTED
, NULL
, NULL
,
745 "Scheduler restarted.");
750 * Check for available input or ready output. If cupsdDoSelect()
751 * returns 0 or -1, something bad happened and we should exit
754 * Note that we at least have one listening socket open at all
758 if ((timeout
= select_timeout(fds
)) > 1 && LastEvent
)
763 * If no other work is scheduled and we're being controlled by
764 * launchd then timeout after 'LaunchdTimeout' seconds of
768 if (timeout
== 86400 && Launchd
&& LaunchdTimeout
&&
769 !cupsArrayCount(ActiveJobs
) &&
770 (!Browsing
|| !BrowseLocalProtocols
|| !cupsArrayCount(Printers
)))
772 timeout
= LaunchdTimeout
;
773 launchd_idle_exit
= 1;
776 launchd_idle_exit
= 0;
777 #endif /* HAVE_LAUNCHD */
779 if ((fds
= cupsdDoSelect(timeout
)) < 0)
782 * Got an error from select!
785 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
786 cupsd_printer_t
*p
; /* Current printer */
787 #endif /* HAVE_DNSSD || HAVE_AVAHI */
790 if (errno
== EINTR
) /* Just interrupted by a signal */
794 * Log all sorts of debug info to help track down the problem.
797 cupsdLogMessage(CUPSD_LOG_EMERG
, "cupsdDoSelect() failed - %s!",
800 for (i
= 0, con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
802 i
++, con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
803 cupsdLogMessage(CUPSD_LOG_EMERG
,
804 "Clients[%d] = %d, file = %d, state = %d",
805 i
, con
->number
, con
->file
, httpGetState(con
->http
));
807 for (i
= 0, lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
809 i
++, lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
810 cupsdLogMessage(CUPSD_LOG_EMERG
, "Listeners[%d] = %d", i
, lis
->fd
);
812 cupsdLogMessage(CUPSD_LOG_EMERG
, "CGIPipes[0] = %d", CGIPipes
[0]);
815 cupsdLogMessage(CUPSD_LOG_EMERG
, "SysEventPipes[0] = %d",
817 #endif /* __APPLE__ */
819 for (job
= (cupsd_job_t
*)cupsArrayFirst(ActiveJobs
);
821 job
= (cupsd_job_t
*)cupsArrayNext(ActiveJobs
))
822 cupsdLogMessage(CUPSD_LOG_EMERG
, "Jobs[%d] = %d < [%d %d] > [%d %d]",
824 job
->status_buffer
? job
->status_buffer
->fd
: -1,
825 job
->print_pipes
[0], job
->print_pipes
[1],
826 job
->back_pipes
[0], job
->back_pipes
[1]);
828 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
829 for (p
= (cupsd_printer_t
*)cupsArrayFirst(Printers
);
831 p
= (cupsd_printer_t
*)cupsArrayNext(Printers
))
832 cupsdLogMessage(CUPSD_LOG_EMERG
, "printer[%s] reg_name=\"%s\"", p
->name
,
833 p
->reg_name
? p
->reg_name
: "(null)");
834 #endif /* HAVE_DNSSD || HAVE_AVAHI */
839 current_time
= time(NULL
);
842 * Write dirty config/state files...
845 if (DirtyCleanTime
&& current_time
>= DirtyCleanTime
)
850 * If we are going to sleep and still have pending jobs, stop them after
851 * a period of time...
854 if (SleepJobs
> 0 && current_time
>= SleepJobs
&&
855 cupsArrayCount(PrintingJobs
) > 0)
858 cupsdStopAllJobs(CUPSD_JOB_DEFAULT
, 5);
860 #endif /* __APPLE__ */
864 * Update the network interfaces once a minute...
867 if ((current_time
- netif_time
) >= 60)
869 netif_time
= current_time
;
872 #endif /* !__APPLE__ */
876 * If no other work was scheduled and we're being controlled by launchd
877 * then timeout after 'LaunchdTimeout' seconds of inactivity...
880 if (!fds
&& launchd_idle_exit
)
882 cupsdLogMessage(CUPSD_LOG_INFO
,
883 "Printer sharing is off and there are no jobs pending, "
884 "will restart on demand.");
888 #endif /* HAVE_LAUNCHD */
891 * Resume listening for new connections as needed...
894 if (ListeningPaused
&& ListeningPaused
<= current_time
&&
895 cupsArrayCount(Clients
) < MaxClients
)
896 cupsdResumeListening();
899 * Expire subscriptions and unload completed jobs as needed...
902 if (current_time
> expire_time
)
904 if (cupsArrayCount(Subscriptions
) > 0)
905 cupsdExpireSubscriptions(NULL
, NULL
);
907 cupsdUnloadCompletedJobs();
909 expire_time
= current_time
;
912 #ifndef HAVE_AUTHORIZATION_H
914 * Update the root certificate once every 5 minutes if we have client
918 if ((current_time
- RootCertTime
) >= RootCertDuration
&& RootCertDuration
&&
919 !RunUser
&& cupsArrayCount(Clients
))
922 * Update the root certificate...
926 cupsdAddCert(0, "root", cupsdDefaultAuthType());
928 #endif /* !HAVE_AUTHORIZATION_H */
931 * Check for new data on the client sockets...
934 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
936 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
939 * Process pending data in the input buffer...
942 // TODO: Use httpGetReady()
945 cupsdReadClient(con
);
950 * Check the activity and close old clients...
953 // TODO: Use httpGetActivity()
954 activity
= current_time
- Timeout
;
955 if (con
->http
->activity
< activity
&& !con
->pipe_pid
)
957 cupsdLogMessage(CUPSD_LOG_DEBUG
,
958 "Closing client %d after %d seconds of inactivity...",
959 con
->number
, Timeout
);
961 cupsdCloseClient(con
);
967 * Update any pending multi-file documents...
970 if ((current_time
- senddoc_time
) >= 10)
973 senddoc_time
= current_time
;
977 * Clean job history...
980 if (JobHistoryUpdate
&& current_time
>= JobHistoryUpdate
)
984 * Log statistics at most once a minute when in debug mode...
987 if ((current_time
- report_time
) >= 60 && LogLevel
>= CUPSD_LOG_DEBUG
)
989 size_t string_count
, /* String count */
990 alloc_bytes
, /* Allocated string bytes */
991 total_bytes
; /* Total string bytes */
993 struct mallinfo mem
; /* Malloc information */
997 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: malloc-arena=%lu", mem
.arena
);
998 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: malloc-used=%lu",
999 mem
.usmblks
+ mem
.uordblks
);
1000 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: malloc-free=%lu",
1001 mem
.fsmblks
+ mem
.fordblks
);
1002 #endif /* HAVE_MALLINFO */
1004 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: clients=%d",
1005 cupsArrayCount(Clients
));
1006 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: jobs=%d",
1007 cupsArrayCount(Jobs
));
1008 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: jobs-active=%d",
1009 cupsArrayCount(ActiveJobs
));
1010 cupsdLogMessage(CUPSD_LOG_DEBUG
, "Report: printers=%d",
1011 cupsArrayCount(Printers
));
1013 string_count
= _cupsStrStatistics(&alloc_bytes
, &total_bytes
);
1014 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1015 "Report: stringpool-string-count=" CUPS_LLFMT
,
1016 CUPS_LLCAST string_count
);
1017 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1018 "Report: stringpool-alloc-bytes=" CUPS_LLFMT
,
1019 CUPS_LLCAST alloc_bytes
);
1020 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1021 "Report: stringpool-total-bytes=" CUPS_LLFMT
,
1022 CUPS_LLCAST total_bytes
);
1024 report_time
= current_time
;
1028 * Handle OS-specific event notification for any events that have
1029 * accumulated. Don't send these more than once a second...
1032 if (LastEvent
&& (current_time
- event_time
) >= 1)
1034 #ifdef HAVE_NOTIFY_POST
1035 if (LastEvent
& (CUPSD_EVENT_PRINTER_ADDED
|
1036 CUPSD_EVENT_PRINTER_DELETED
|
1037 CUPSD_EVENT_PRINTER_MODIFIED
))
1039 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1040 "notify_post(\"com.apple.printerListChange\")");
1041 notify_post("com.apple.printerListChange");
1044 if (LastEvent
& CUPSD_EVENT_PRINTER_STATE_CHANGED
)
1046 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1047 "notify_post(\"com.apple.printerHistoryChange\")");
1048 notify_post("com.apple.printerHistoryChange");
1051 if (LastEvent
& (CUPSD_EVENT_JOB_STATE_CHANGED
|
1052 CUPSD_EVENT_JOB_CONFIG_CHANGED
|
1053 CUPSD_EVENT_JOB_PROGRESS
))
1055 cupsdLogMessage(CUPSD_LOG_DEBUG2
,
1056 "notify_post(\"com.apple.jobChange\")");
1057 notify_post("com.apple.jobChange");
1059 #endif /* HAVE_NOTIFY_POST */
1062 * Reset the accumulated events...
1065 LastEvent
= CUPSD_EVENT_NONE
;
1066 event_time
= current_time
;
1071 * Log a message based on what happened...
1076 cupsdLogMessage(CUPSD_LOG_INFO
, "Scheduler shutting down normally.");
1077 cupsdAddEvent(CUPSD_EVENT_SERVER_STOPPED
, NULL
, NULL
,
1078 "Scheduler shutting down normally.");
1082 cupsdLogMessage(CUPSD_LOG_ERROR
,
1083 "Scheduler shutting down due to program error.");
1084 cupsdAddEvent(CUPSD_EVENT_SERVER_STOPPED
, NULL
, NULL
,
1085 "Scheduler shutting down due to program error.");
1089 * Close all network clients...
1098 * Update the launchd KeepAlive file as needed...
1103 #endif /* HAVE_LAUNCHD */
1113 * Stop monitoring system event monitoring...
1117 cupsdStopSystemMonitor();
1118 #endif /* __APPLE__ */
1122 return (!stop_scheduler
);
1127 * 'cupsdAddString()' - Copy and add a string to an array.
1130 int /* O - 1 on success, 0 on failure */
1131 cupsdAddString(cups_array_t
**a
, /* IO - String array */
1132 const char *s
) /* I - String to copy and add */
1135 *a
= cupsArrayNew3((cups_array_func_t
)strcmp
, NULL
,
1136 (cups_ahash_func_t
)NULL
, 0,
1137 (cups_acopy_func_t
)_cupsStrAlloc
,
1138 (cups_afree_func_t
)_cupsStrFree
);
1140 return (cupsArrayAdd(*a
, (char *)s
));
1145 * 'cupsdCheckProcess()' - Tell the main loop to check for dead children.
1149 cupsdCheckProcess(void)
1152 * Flag that we have dead children...
1160 * 'cupsdClearString()' - Clear a string.
1164 cupsdClearString(char **s
) /* O - String value */
1175 * 'cupsdFreeStrings()' - Free an array of strings.
1179 cupsdFreeStrings(cups_array_t
**a
) /* IO - String array */
1183 cupsArrayDelete(*a
);
1190 * 'cupsdHoldSignals()' - Hold child and termination signals.
1194 cupsdHoldSignals(void)
1196 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
1197 sigset_t newmask
; /* New POSIX signal mask */
1198 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
1208 #elif defined(HAVE_SIGACTION)
1209 sigemptyset(&newmask
);
1210 sigaddset(&newmask
, SIGTERM
);
1211 sigaddset(&newmask
, SIGCHLD
);
1212 sigprocmask(SIG_BLOCK
, &newmask
, &holdmask
);
1213 #endif /* HAVE_SIGSET */
1218 * 'cupsdReleaseSignals()' - Release signals for delivery.
1222 cupsdReleaseSignals(void)
1231 #elif defined(HAVE_SIGACTION)
1232 sigprocmask(SIG_SETMASK
, &holdmask
, NULL
);
1233 #endif /* HAVE_SIGSET */
1238 * 'cupsdSetString()' - Set a string value.
1242 cupsdSetString(char **s
, /* O - New string */
1243 const char *v
) /* I - String value */
1252 *s
= _cupsStrAlloc(v
);
1259 * 'cupsdSetStringf()' - Set a formatted string value.
1263 cupsdSetStringf(char **s
, /* O - New string */
1264 const char *f
, /* I - Printf-style format string */
1265 ...) /* I - Additional args as needed */
1267 char v
[65536 + 64]; /* Formatting string value */
1268 va_list ap
; /* Argument pointer */
1269 char *olds
; /* Old string */
1280 vsnprintf(v
, sizeof(v
), f
, ap
);
1283 *s
= _cupsStrAlloc(v
);
1295 * 'launchd_checkin()' - Check-in with launchd and collect the listening fds.
1299 launchd_checkin(void)
1301 size_t i
, /* Looping var */
1302 count
; /* Number of listeners */
1303 launch_data_t ld_msg
, /* Launch data message */
1304 ld_resp
, /* Launch data response */
1305 ld_array
, /* Launch data array */
1306 ld_sockets
, /* Launch data sockets dictionary */
1307 tmp
; /* Launch data */
1308 cupsd_listener_t
*lis
; /* Listeners array */
1309 http_addr_t addr
; /* Address variable */
1310 socklen_t addrlen
; /* Length of address */
1311 int fd
; /* File descriptor */
1312 char s
[256]; /* String addresss */
1315 cupsdLogMessage(CUPSD_LOG_DEBUG
, "launchd_checkin: pid=%d", (int)getpid());
1318 * Check-in with launchd...
1321 ld_msg
= launch_data_new_string(LAUNCH_KEY_CHECKIN
);
1322 if ((ld_resp
= launch_msg(ld_msg
)) == NULL
)
1324 cupsdLogMessage(CUPSD_LOG_ERROR
,
1325 "launchd_checkin: launch_msg(\"" LAUNCH_KEY_CHECKIN
1328 return; /* anti-compiler-warning */
1331 if (launch_data_get_type(ld_resp
) == LAUNCH_DATA_ERRNO
)
1333 errno
= launch_data_get_errno(ld_resp
);
1334 cupsdLogMessage(CUPSD_LOG_ERROR
, "launchd_checkin: Check-in failed: %s",
1337 return; /* anti-compiler-warning */
1341 * Get the sockets dictionary...
1344 if ((ld_sockets
= launch_data_dict_lookup(ld_resp
, LAUNCH_JOBKEY_SOCKETS
))
1347 cupsdLogMessage(CUPSD_LOG_ERROR
,
1348 "launchd_checkin: No sockets found to answer requests on!");
1350 return; /* anti-compiler-warning */
1354 * Get the array of listener sockets...
1357 if ((ld_array
= launch_data_dict_lookup(ld_sockets
, "Listeners")) == NULL
)
1359 cupsdLogMessage(CUPSD_LOG_ERROR
,
1360 "launchd_checkin: No sockets found to answer requests on!");
1362 return; /* anti-compiler-warning */
1366 * Add listening fd(s) to the Listener array...
1369 if (launch_data_get_type(ld_array
) == LAUNCH_DATA_ARRAY
)
1371 count
= launch_data_array_get_count(ld_array
);
1373 for (i
= 0; i
< count
; i
++)
1376 * Get the launchd file descriptor and address...
1379 if ((tmp
= launch_data_array_get_index(ld_array
, i
)) != NULL
)
1381 fd
= launch_data_get_fd(tmp
);
1382 addrlen
= sizeof(addr
);
1384 if (getsockname(fd
, (struct sockaddr
*)&addr
, &addrlen
))
1386 cupsdLogMessage(CUPSD_LOG_ERROR
,
1387 "launchd_checkin: Unable to get local address - %s",
1393 * Try to match the launchd socket address to one of the listeners...
1396 for (lis
= (cupsd_listener_t
*)cupsArrayFirst(Listeners
);
1398 lis
= (cupsd_listener_t
*)cupsArrayNext(Listeners
))
1399 if (httpAddrEqual(&lis
->address
, &addr
))
1403 * Add a new listener If there's no match...
1408 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1409 "launchd_checkin: Matched existing listener %s with fd %d...",
1410 httpAddrString(&(lis
->address
), s
, sizeof(s
)), fd
);
1414 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1415 "launchd_checkin: Adding new listener %s with fd %d...",
1416 httpAddrString(&addr
, s
, sizeof(s
)), fd
);
1418 if ((lis
= calloc(1, sizeof(cupsd_listener_t
))) == NULL
)
1420 cupsdLogMessage(CUPSD_LOG_ERROR
,
1421 "launchd_checkin: Unable to allocate listener - "
1422 "%s.", strerror(errno
));
1426 cupsArrayAdd(Listeners
, lis
);
1428 memcpy(&lis
->address
, &addr
, sizeof(lis
->address
));
1434 if (httpAddrPort(&(lis
->address
)) == 443)
1435 lis
->encryption
= HTTP_ENCRYPT_ALWAYS
;
1436 # endif /* HAVE_SSL */
1441 launch_data_free(ld_msg
);
1442 launch_data_free(ld_resp
);
1447 * 'launchd_checkout()' - Update the launchd KeepAlive file as needed.
1451 launchd_checkout(void)
1453 int fd
; /* File descriptor */
1457 * Create or remove the launchd KeepAlive file based on whether
1458 * there are active jobs, polling, browsing for remote printers or
1459 * shared printers to advertise...
1462 if (cupsArrayCount(ActiveJobs
) ||
1463 (Browsing
&& BrowseLocalProtocols
&& cupsArrayCount(Printers
)))
1465 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1466 "Creating launchd keepalive file \"" CUPS_KEEPALIVE
1469 if ((fd
= open(CUPS_KEEPALIVE
, O_RDONLY
| O_CREAT
| O_EXCL
, S_IRUSR
)) >= 0)
1474 cupsdLogMessage(CUPSD_LOG_DEBUG
,
1475 "Removing launchd keepalive file \"" CUPS_KEEPALIVE
1478 unlink(CUPS_KEEPALIVE
);
1481 #endif /* HAVE_LAUNCHD */
1485 * 'parent_handler()' - Catch USR1/CHLD signals...
1489 parent_handler(int sig
) /* I - Signal */
1492 * Store the signal we got from the OS and return...
1495 parent_signal
= sig
;
1500 * 'process_children()' - Process all dead children...
1504 process_children(void)
1506 int status
; /* Exit status of child */
1507 int pid
, /* Process ID of child */
1508 job_id
; /* Job ID of child */
1509 cupsd_job_t
*job
; /* Current job */
1510 int i
; /* Looping var */
1511 char name
[1024]; /* Process name */
1512 const char *type
; /* Type of program */
1515 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "process_children()");
1518 * Reset the dead_children flag...
1524 * Collect the exit status of some children...
1528 while ((pid
= waitpid(-1, &status
, WNOHANG
)) > 0)
1529 #elif defined(HAVE_WAIT3)
1530 while ((pid
= wait3(&status
, WNOHANG
, NULL
)) > 0)
1532 if ((pid
= wait(&status
)) > 0)
1533 #endif /* HAVE_WAITPID */
1536 * Collect the name of the process that finished...
1539 cupsdFinishProcess(pid
, name
, sizeof(name
), &job_id
);
1542 * Delete certificates for CGI processes...
1546 cupsdDeleteCert(pid
);
1549 * Handle completed job filters...
1553 job
= cupsdFindJob(job_id
);
1559 for (i
= 0; job
->filters
[i
]; i
++)
1560 if (job
->filters
[i
] == pid
)
1563 if (job
->filters
[i
] || job
->backend
== pid
)
1566 * OK, this process has gone away; what's left?
1569 if (job
->filters
[i
])
1571 job
->filters
[i
] = -pid
;
1576 job
->backend
= -pid
;
1580 if (status
&& status
!= SIGTERM
&& status
!= SIGKILL
&&
1584 * An error occurred; save the exit status so we know to stop
1585 * the printer or cancel the job when all of the filters finish...
1587 * A negative status indicates that the backend failed and the
1588 * printer needs to be stopped.
1590 * In order to preserve the most serious status, we always log
1591 * when a process dies due to a signal (e.g. SIGABRT, SIGSEGV,
1592 * and SIGBUS) and prefer to log the backend exit status over a
1596 int old_status
= abs(job
->status
);
1598 if (WIFSIGNALED(status
) || /* This process crashed, or */
1599 !job
->status
|| /* No process had a status, or */
1600 (!job
->filters
[i
] && WIFEXITED(old_status
)))
1601 { /* Backend and filter didn't crash */
1602 if (job
->filters
[i
])
1603 job
->status
= status
; /* Filter failed */
1605 job
->status
= -status
; /* Backend failed */
1608 if (job
->state_value
== IPP_JOB_PROCESSING
&&
1609 job
->status_level
> CUPSD_LOG_ERROR
&&
1610 (job
->filters
[i
] || !WIFEXITED(status
)))
1612 char message
[1024]; /* New printer-state-message */
1615 job
->status_level
= CUPSD_LOG_ERROR
;
1617 snprintf(message
, sizeof(message
), "%s failed", type
);
1621 strlcpy(job
->printer
->state_message
, message
,
1622 sizeof(job
->printer
->state_message
));
1628 if (!job
->printer_message
&& job
->attrs
)
1630 if ((job
->printer_message
=
1631 ippFindAttribute(job
->attrs
, "job-printer-state-message",
1632 IPP_TAG_TEXT
)) == NULL
)
1633 job
->printer_message
= ippAddString(job
->attrs
, IPP_TAG_JOB
,
1635 "job-printer-state-message",
1639 if (job
->printer_message
)
1640 cupsdSetString(&(job
->printer_message
->values
[0].string
.text
),
1646 * If this is not the last file in a job, see if all of the
1647 * filters are done, and if so move to the next file.
1650 if (job
->current_file
< job
->num_files
&& job
->printer
)
1652 for (i
= 0; job
->filters
[i
] < 0; i
++);
1654 if (!job
->filters
[i
] &&
1655 (!job
->printer
->pc
|| !job
->printer
->pc
->single_file
||
1659 * Process the next file...
1662 cupsdContinueJob(job
);
1665 else if (job
->state_value
>= IPP_JOB_CANCELED
)
1668 * Remove the job from the active list if there are no processes still
1672 for (i
= 0; job
->filters
[i
] < 0; i
++);
1674 if (!job
->filters
[i
] && job
->backend
<= 0)
1675 cupsArrayRemove(ActiveJobs
, job
);
1681 * Show the exit status as needed, ignoring SIGTERM and SIGKILL errors
1682 * since they come when we kill/end a process...
1685 if (status
== SIGTERM
|| status
== SIGKILL
)
1687 cupsdLogJob(job
, CUPSD_LOG_DEBUG
,
1688 "PID %d (%s) was terminated normally with signal %d.", pid
,
1691 else if (status
== SIGPIPE
)
1693 cupsdLogJob(job
, CUPSD_LOG_DEBUG
,
1694 "PID %d (%s) did not catch or ignore signal %d.", pid
, name
,
1699 if (WIFEXITED(status
))
1701 int code
= WEXITSTATUS(status
); /* Exit code */
1704 cupsdLogJob(job
, CUPSD_LOG_DEBUG
,
1705 "PID %d (%s) stopped with status %d (%s)", pid
, name
,
1706 code
, strerror(code
- 100));
1708 cupsdLogJob(job
, CUPSD_LOG_DEBUG
,
1709 "PID %d (%s) stopped with status %d.", pid
, name
, code
);
1712 cupsdLogJob(job
, CUPSD_LOG_DEBUG
, "PID %d (%s) crashed on signal %d.",
1713 pid
, name
, WTERMSIG(status
));
1715 if (LogLevel
< CUPSD_LOG_DEBUG
)
1716 cupsdLogJob(job
, CUPSD_LOG_INFO
,
1717 "Hint: Try setting the LogLevel to \"debug\" to find out "
1721 cupsdLogJob(job
, CUPSD_LOG_DEBUG
, "PID %d (%s) exited with no errors.",
1726 * If wait*() is interrupted by a signal, tell main() to call us again...
1729 if (pid
< 0 && errno
== EINTR
)
1735 * 'select_timeout()' - Calculate the select timeout value.
1739 static long /* O - Number of seconds */
1740 select_timeout(int fds
) /* I - Number of descriptors returned */
1742 long timeout
; /* Timeout for select */
1743 time_t now
; /* Current time */
1744 cupsd_client_t
*con
; /* Client information */
1745 cupsd_job_t
*job
; /* Job information */
1746 cupsd_subscription_t
*sub
; /* Subscription information */
1747 const char *why
; /* Debugging aid */
1750 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "select_timeout: JobHistoryUpdate=%ld",
1751 (long)JobHistoryUpdate
);
1754 * Check to see if any of the clients have pending data to be
1755 * processed; if so, the timeout should be 0...
1758 // TODO: Use httpGetReady()
1759 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
1761 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
1762 if (con
->http
->used
> 0)
1766 * If select has been active in the last second (fds > 0) or we have
1767 * many resources in use then don't bother trying to optimize the
1768 * timeout, just make it 1 second.
1771 if (fds
> 0 || cupsArrayCount(Clients
) > 50)
1775 * Otherwise, check all of the possible events that we need to wake for...
1779 timeout
= now
+ 86400; /* 86400 == 1 day */
1784 * When going to sleep, wake up to cancel jobs that don't complete in time.
1787 if (SleepJobs
> 0 && SleepJobs
< timeout
)
1789 timeout
= SleepJobs
;
1790 why
= "cancel jobs before sleeping";
1792 #endif /* __APPLE__ */
1795 * Check whether we are accepting new connections...
1798 if (ListeningPaused
> 0 && cupsArrayCount(Clients
) < MaxClients
&&
1799 ListeningPaused
< timeout
)
1801 if (ListeningPaused
<= now
)
1804 timeout
= ListeningPaused
;
1806 why
= "resume listening";
1810 * Check the activity and close old clients...
1813 // TODO: Use httpGetActivity()
1814 for (con
= (cupsd_client_t
*)cupsArrayFirst(Clients
);
1816 con
= (cupsd_client_t
*)cupsArrayNext(Clients
))
1817 if ((con
->http
->activity
+ Timeout
) < timeout
)
1819 timeout
= con
->http
->activity
+ Timeout
;
1820 why
= "timeout a client connection";
1824 * Write out changes to configuration and state files...
1827 if (DirtyCleanTime
&& timeout
> DirtyCleanTime
)
1829 timeout
= DirtyCleanTime
;
1830 why
= "write dirty config/state files";
1834 * Check for any job activity...
1837 if (JobHistoryUpdate
&& timeout
> JobHistoryUpdate
)
1839 timeout
= JobHistoryUpdate
;
1840 why
= "update job history";
1843 for (job
= (cupsd_job_t
*)cupsArrayFirst(ActiveJobs
);
1845 job
= (cupsd_job_t
*)cupsArrayNext(ActiveJobs
))
1847 if (job
->cancel_time
&& job
->cancel_time
< timeout
)
1849 timeout
= job
->cancel_time
;
1850 why
= "cancel stuck jobs";
1853 if (job
->kill_time
&& job
->kill_time
< timeout
)
1855 timeout
= job
->kill_time
;
1856 why
= "kill unresponsive jobs";
1859 if (job
->state_value
== IPP_JOB_HELD
&& job
->hold_until
< timeout
)
1861 timeout
= job
->hold_until
;
1862 why
= "release held jobs";
1865 if (job
->state_value
== IPP_JOB_PENDING
&& timeout
> (now
+ 10))
1868 why
= "start pending jobs";
1873 #ifdef HAVE_MALLINFO
1875 * Log memory usage every minute...
1878 if (LogLevel
>= CUPSD_LOG_DEBUG
&& (mallinfo_time
+ 60) < timeout
)
1880 timeout
= mallinfo_time
+ 60;
1881 why
= "display memory usage";
1883 #endif /* HAVE_MALLINFO */
1886 * Expire subscriptions as needed...
1889 for (sub
= (cupsd_subscription_t
*)cupsArrayFirst(Subscriptions
);
1891 sub
= (cupsd_subscription_t
*)cupsArrayNext(Subscriptions
))
1892 if (!sub
->job
&& sub
->expire
&& sub
->expire
< timeout
)
1894 timeout
= sub
->expire
;
1895 why
= "expire subscription";
1899 * Adjust from absolute to relative time. We add 1 second to the timeout since
1900 * events occur after the timeout expires, and limit the timeout to 86400
1901 * seconds (1 day) to avoid select() timeout limits present on some operating
1905 timeout
= timeout
- now
+ 1;
1909 else if (timeout
> 86400)
1913 * Log and return the timeout value...
1916 cupsdLogMessage(CUPSD_LOG_DEBUG2
, "select_timeout(%d): %ld seconds to %s",
1924 * 'sigchld_handler()' - Handle 'child' signals from old processes.
1928 sigchld_handler(int sig
) /* I - Signal number */
1933 * Flag that we have dead children...
1939 * Reset the signal handler as needed...
1942 #if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION)
1943 signal(SIGCLD
, sigchld_handler
);
1944 #endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
1949 * 'sighup_handler()' - Handle 'hangup' signals to reconfigure the scheduler.
1953 sighup_handler(int sig
) /* I - Signal number */
1957 NeedReload
= RELOAD_ALL
;
1958 ReloadTime
= time(NULL
);
1960 #if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION)
1961 signal(SIGHUP
, sighup_handler
);
1962 #endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
1967 * 'sigterm_handler()' - Handle 'terminate' signals that stop the scheduler.
1971 sigterm_handler(int sig
) /* I - Signal number */
1973 (void)sig
; /* remove compiler warnings... */
1976 * Flag that we should stop and return...
1984 * 'usage()' - Show scheduler usage.
1988 usage(int status
) /* O - Exit status */
1990 FILE *fp
= status
? stderr
: stdout
; /* Output file */
1993 _cupsLangPuts(fp
, _("Usage: cupsd [options]"));
1994 _cupsLangPuts(fp
, _("Options:"));
1995 _cupsLangPuts(fp
, _(" -c cupsd.conf Set cupsd.conf file to use."));
1996 _cupsLangPuts(fp
, _(" -f Run in the foreground."));
1997 _cupsLangPuts(fp
, _(" -F Run in the foreground but "
1998 "detach from console."));
1999 _cupsLangPuts(fp
, _(" -h Show this usage message."));
2000 _cupsLangPuts(fp
, _(" -l Run cupsd from launchd(8)."));
2001 _cupsLangPuts(fp
, _(" -t Test the configuration "