PERFORCE change 79811 for review
soc-tyler
soc-tyler at FreeBSD.org
Sat Jul 9 09:18:11 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=79811
Change 79811 by soc-tyler at soc-tyler_launchd on 2005/07/09 09:18:09
replace read_plist_file() and CF2launch_data() with just read_conf_file() which adds the 'properties' linked list as the opaque data type to the launch_data_t pointer and returns
Affected files ...
.. //depot/projects/soc2005/launchd/NOTES#2 edit
.. //depot/projects/soc2005/launchd/includes/launch.h#2 edit
.. //depot/projects/soc2005/launchd/launchctl/launchctl.c#5 edit
.. //depot/projects/soc2005/launchd/launchers/ftp.launch#3 edit
.. //depot/projects/soc2005/launchd/launchers/ssh.launch#3 edit
.. //depot/projects/soc2005/launchd/liblaunch.c#2 edit
Differences ...
==== //depot/projects/soc2005/launchd/NOTES#2 (text+ko) ====
@@ -9,3 +9,11 @@
There are no plans to incorporate this aspect of launchd(8) into FreeBSD until
Zeroconf is stable, and in the base system of FreeBSD (6.xx, 7.xx, X.xx ;))
+
+ o launch_msg() doesn't need to be reimplemented until launchctl(1) is revamped
+ to work fully on FreeBSD (well, except for the controlling of launchd(8) part)
+
+ After launchctl(1) is modified correctly, removal of CoreFoundation and
+ Zeroconf calls from launchd(8) can be made, and finally liblaunch can be
+ fixed to accomodate.
+
==== //depot/projects/soc2005/launchd/includes/launch.h#2 (text+ko) ====
@@ -1,4 +1,31 @@
/*
+ * $FreeBSD$
+ *
+ * Copyright (c) 2005 R. Tyler Ballance <tyler at tamu.edu> All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE *
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
* Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
@@ -112,6 +139,7 @@
LAUNCH_DATA_BOOL,
LAUNCH_DATA_STRING,
LAUNCH_DATA_OPAQUE,
+ LAUNCH_DATA_PROPERTY,
LAUNCH_DATA_ERRNO,
} launch_data_type_t;
==== //depot/projects/soc2005/launchd/launchctl/launchctl.c#5 (text+ko) ====
@@ -72,6 +72,8 @@
#include <unistd.h>
#include <dirent.h>
#include <libgen.h>
+/* include libutil.h for basic property parsing (see: xx.launch) */
+#include <libutil.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -98,6 +100,7 @@
static void distill_config_file(launch_data_t);
static void sock_dict_cb(launch_data_t what, const char *key, void *context);
static void sock_dict_edit_entry(launch_data_t tmp, const char *key, launch_data_t fdarray, launch_data_t thejob);
+static launch_data_t read_conf_file(const char *, bool, bool);
//static launch_data_t CF2launch_data(const void *);
//static launch_data_t read_plist_file(const char *file, bool editondisk, bool load);
//static const void *CreateMyPropertyListFromFile(const char *);
@@ -330,11 +333,30 @@
}
static launch_data_t read_conf_file(const char *file, bool editondisk, bool load) {
- launch_data_t r = NULL;
+ /* fill this with an array of launch_data_t structs */
+ launch_data_t retval = NULL;
+ properties conf_props;
+ int fd;
+
+ fd = open(file, O_RDONLY);
+ if (fd == -1)
+ return NULL; /* calling function must check for a NULL pointer */
+
+ conf_props = properties_read(fd); /* read in config data */
+ retval = launch_data_alloc(LAUNCH_DATA_PROPERTY);
+ launch_data_set_opaque(retval, (const void *)(conf_props), sizeof(properties));
- return r;
+ /* I figure we'll just add the properties(3) linked list to the
+ * opaque launch_data_t datatype (opaque ~= void *)
+ *
+ * this will probably come back to haunt me
+ */
+
+ close(fd);
+ return retval;
}
+
/*
static launch_data_t read_plist_file(const char *file, bool editondisk, bool load)
{
==== //depot/projects/soc2005/launchd/launchers/ftp.launch#3 (text+ko) ====
@@ -3,6 +3,7 @@
# Simple, launchd(8) launcher for the ftp daemon
#
+program = ftpd
progpath = /usr/libexec/ftpd
#firstboot = /usr/libexec/ftpd
progflags = -l
@@ -12,6 +13,6 @@
##################################
## inetd related options
+### start this daemon from the (x)inetd super server
# inetd = false
# inetd_wait = false
-
==== //depot/projects/soc2005/launchd/launchers/ssh.launch#3 (text+ko) ====
@@ -3,6 +3,7 @@
# Simple, launchd(8) launcher for the SSH daemon
#
+program = sshd
progpath = /usr/bin/sshd
#firstboot = /some/script/to/do/keygen
progflags = -i
@@ -12,6 +13,6 @@
##################################
## inetd related options
+### start this daemon from the (x)inetd super server
# inetd = false
# inetd_wait = false
-
==== //depot/projects/soc2005/launchd/liblaunch.c#2 (text+ko) ====
@@ -156,6 +156,7 @@
if (d) {
d->type = t;
switch (t) {
+ case LAUNCH_DATA_PROPERTY:
case LAUNCH_DATA_DICTIONARY:
case LAUNCH_DATA_ARRAY:
d->_array = malloc(0);
@@ -168,10 +169,7 @@
return d;
}
-launch_data_type_t launch_data_get_type(launch_data_t d)
-{
- return d->type;
-}
+launch_data_type_t launch_data_get_type(launch_data_t d) { return d->type; }
void launch_data_free(launch_data_t d)
{
More information about the p4-projects
mailing list