From owner-p4-projects@FreeBSD.ORG Fri Jul 29 16:25:43 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6312616A421; Fri, 29 Jul 2005 16:25:43 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 25F1616A41F for ; Fri, 29 Jul 2005 16:25:43 +0000 (GMT) (envelope-from soc-tyler@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id B81E243D46 for ; Fri, 29 Jul 2005 16:25:42 +0000 (GMT) (envelope-from soc-tyler@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j6TGPg4o071753 for ; Fri, 29 Jul 2005 16:25:42 GMT (envelope-from soc-tyler@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j6TGPg1M071750 for perforce@freebsd.org; Fri, 29 Jul 2005 16:25:42 GMT (envelope-from soc-tyler@freebsd.org) Date: Fri, 29 Jul 2005 16:25:42 GMT Message-Id: <200507291625.j6TGPg1M071750@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to soc-tyler@freebsd.org using -f From: soc-tyler To: Perforce Change Reviews Cc: Subject: PERFORCE change 81166 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jul 2005 16:25:44 -0000 http://perforce.freebsd.org/chv.cgi?CH=81166 Change 81166 by soc-tyler@soc-tyler_launchd on 2005/07/29 16:24:55 Syncing this up before I forget or leave town, whichever comes first. Affected files ... .. //depot/projects/soc2005/launchd/Makefile#9 edit .. //depot/projects/soc2005/launchd/includes/launch.h#7 edit .. //depot/projects/soc2005/launchd/includes/launchd.h#6 edit .. //depot/projects/soc2005/launchd/launchd.c#8 edit Differences ... ==== //depot/projects/soc2005/launchd/Makefile#9 (text+ko) ==== @@ -2,10 +2,10 @@ # $FreeBSD$ PROG= launchd -SRCS= launchd.c liblaunch.c ##init.c +SRCS= launchd.c liblaunch.c init.c #launchdebugd.c launchproxy.c -MAN= launchd.conf.5 launchd.plist.5 init.8 launchd.8 \ - launchd_debug.8 launchproxy.8 rc.8 service.8 +MAN= launchd.conf.5 init.8 launchd.8 launchd_debugd.8 \ + launchproxy.8 service.8 BINMODE=500 INSTALLFLAGS=-b -B.bak @@ -14,7 +14,8 @@ CFLAGS+= -g -Wall -W -Wshadow -Wpadded -Iincludes -D_LAUNCHD_ # init.c related CFLAGS (from src/sbin/init/Makefile) -CFLAGS+= -DDEBUGSHELL -DSECURE -DLOGIN_CAP -DCOMPAT_SYSV_INIT +# -DSECURE to make secure single-user logins (enter root passwd, etc) +CFLAGS+= -DDEBUGSHELL -DLOGIN_CAP -DCOMPAT_SYSV_INIT # Do not let launchd(8) have init(8) functionality (or I haven't implemented it yet.. ;)) CFLAGS+= -D_NO_INIT_ ==== //depot/projects/soc2005/launchd/includes/launch.h#7 (text+ko) ==== @@ -58,11 +58,6 @@ #define _BUILD_DARWIN_ #endif -#ifndef _BUILD_DARWIN_ -// on Darwin-based systems, LOG_LAUNCHD is defined for syslog() -#define LOG_LAUNCHD LOG_DAEMON -#endif - #define LAUNCH_KEY_SUBMITJOB "SubmitJob" #define LAUNCH_KEY_REMOVEJOB "RemoveJob" #define LAUNCH_KEY_STARTJOB "StartJob" ==== //depot/projects/soc2005/launchd/includes/launchd.h#6 (text+ko) ==== @@ -42,7 +42,7 @@ void init_pre_kevent(void); bool init_check_pid(pid_t); -void update_ttys(void); +void clean_ttys(void); void catatonia(void); void death(void); @@ -51,20 +51,26 @@ void launchd_SessionCreate(const char *who); #endif + #ifndef _BUILD_DARWIN_ +// on Darwin-based systems, LOG_LAUNCHD is defined for syslog() +#define LOG_LAUNCHD LOG_DAEMON + /* on Darwin-based systems, O_EVTONLY helps us track changes to a certain file descriptor * as outlined here: * http://developer.apple.com/documentation/Performance/Conceptual/FileSystem/Articles/TrackingChanges.html#//apple_ref/doc/uid/20001993-118158 * - * on FreeBSD, specifically, EVFILT_VNODE is the closest thing to what we want to do + * in FreeBSDland, EVFILT_VNODE is the closest thing to what we want to do + * see: job_watch():launchd.c and load_job():launchd.c for it's usage. */ #define O_EVTONLY EVFILT_VNODE -/* these are defined in sys/event.h in the Darwin source tree, for now we'll +/* + * these are defined in sys/event.h in the Darwin source tree, for now we'll * define them here (disgusting, but we'll see how it works out. * - * XXX: this may break something ;) + * XXX: this _will_ (most likely) break something ;) */ #define NOTE_SECONDS 0x00000001 /* data is seconds */ #define NOTE_USECONDS 0x00000002 /* data is microseconds */ @@ -72,5 +78,4 @@ #define NOTE_ABSOLUTE 0x00000008 /* absolute timeout */ #endif - #endif ==== //depot/projects/soc2005/launchd/launchd.c#8 (text+ko) ==== @@ -331,9 +331,17 @@ #ifdef _BUILD_DARWIN_ launchd_bootstrap_port = bootstrap_port; #endif + /* + * launchd_server_init() is called now if we're not assuming PID 1, + * i.e. all filesystems are mounted and marked rw; otherwise, we call + * launchd_server_init() from fs_callback() + */ launchd_server_init(argv[0] ? true : false); } + /* this registers for the kqfs_callback (fs_callback()) function to be + * called when the mount table is updated, so we can call some PID 1 stuff */ + /* do this after pid1_magic_init() to not catch ourselves mounting stuff */ if (kevent_mod(0, EVFILT_FS, EV_ADD, 0, 0, &kqfs_callback) == -1) syslog(LOG_ERR, "kevent_mod(EVFILT_FS, &kqfs_callback): %m"); @@ -352,8 +360,10 @@ struct timespec *timeoutp = NULL; if (getpid() == 1) { +#ifndef _NO_INIT_ if (readcfg_pid == 0) init_pre_kevent(); +#endif } else { if (TAILQ_EMPTY(&jobs)) { /* launched on demand */ @@ -457,7 +467,6 @@ init_boot(sflag, vflag, xflag); } - #ifdef PID1_REAP_ADOPTED_CHILDREN static bool launchd_check_pid(pid_t p) { @@ -1041,7 +1050,7 @@ resp = launch_data_new_errno(EACCES); } } else if (!strcmp(cmd, LAUNCH_KEY_RELOADTTYS)) { - update_ttys(); + clean_ttys(); resp = launch_data_new_errno(0); } else if (!strcmp(cmd, LAUNCH_KEY_SHUTDOWN)) { do_shutdown(); @@ -1921,7 +1930,7 @@ { switch (kev->ident) { case SIGHUP: - update_ttys(); + clean_ttys(); reload_launchd_config(); break; case SIGTERM: