Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jul 2005 16:25:42 GMT
From:      soc-tyler <soc-tyler@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 81166 for review
Message-ID:  <200507291625.j6TGPg1M071750@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200507291625.j6TGPg1M071750>