Compare commits

..

22 Commits

Author SHA1 Message Date
Daniel Robbins
7cd9ea5eff merging latest gentoo stuff 2011-07-02 20:31:33 -06:00
Daniel Robbins
7146e99855 Revert "Unprivileged users (such as services for example) should not be able view who is logged into system."
This reverts commit 62bd337494.

It's a bit too restrictive for a default install, as it also prevents "who" from working on user accounts.
2011-06-20 22:14:53 -06:00
Daniel Robbins
e65ce9e301 Merge remote-tracking branch 'gentoo/master' 2011-06-04 17:04:04 -06:00
Daniel Robbins
6a5e6f1ee0 openrc-0.7.0 upstream merge 2011-01-20 14:00:29 -07:00
Piotr Karbowski
d8ce5dccb2 openrc-0.6.8 2010-12-16 11:17:34 +01:00
Piotr Karbowski
62bd337494 Unprivileged users (such as services for example) should not be able view who is logged into system. 2010-12-16 10:04:46 +01:00
Jory A. Pratt
06c8bd0156 Fix for make-3.82 breakage. 2010-12-03 20:06:34 -07:00
Daniel Robbins
33803219d4 openrc-0.6.5 2010-11-26 17:02:16 -07:00
Jory A. Pratt
18c08a9d4d remove 'use hostname' bug 340991, Thanks Diego 2010-11-26 16:59:28 -07:00
William Hubbs
2406dc4f3e allow net_fs_list to be extended but not replaced
This fixes bug #342825.
2010-11-26 16:59:18 -07:00
Diego Elio Pettenò
8e6d461a7f Allow cleaning up of pam_mktemp-based temporary directories.
This was blacklisted before, so the .private directories never had their
content cleaned up, even if WIPE_TMP was set to yes.
2010-11-26 16:57:37 -07:00
William Hubbs
472a3bb99c remove support for local.start and local.stop for bug #343709
The openrc ebuild now migrates these files to /etc/conf.d/local, so we
do not need to support them.
2010-11-26 16:53:54 -07:00
William Hubbs
c9a2085699 add warnings about local.start and local.stop for bug #343709
We need to warn users that they should be using /etc/conf.d/local
instead of /etc/conf.d/local.start and /etc/conf.d/local.stop. This adds
those warnings.
2010-11-26 16:53:50 -07:00
William Hubbs
69169b7e95 update documentation for rc_interactive
rc_interactive is automatically disabled if rc_parallel is set to YES.
Update the documentation in rc.conf to reflect this.
This fixes bug #327305.
2010-11-26 16:53:37 -07:00
William Hubbs
3a11f8af34 remove "use hostname" from sysctl for bsd systems 2010-11-26 16:51:42 -07:00
William Hubbs
e2e5b27d85 do not mount local file systems with the _netdev option in fstab
This fixes #344947.
2010-11-26 16:51:20 -07:00
Daniel Robbins
f343360741 0.6.4 release 2010-10-27 23:43:30 -06:00
Brant Gurganus
694fd2027f correction for unmounting volumes with weird characters 2010-10-24 13:08:38 -04:00
Daniel Robbins
ca76764743 Merge branch 'master' of github.com:funtoo/openrc 2010-10-20 19:21:48 -06:00
Jory A. Pratt
19bd9923d7 surpress output of loadkeys, fix setfont path check 2010-10-20 19:21:02 -06:00
Brant Gurganus
2a844e1122 corrected a typo 2010-10-20 16:26:01 -04:00
Daniel Robbins
5135412978 fixing history, one step at a time 2010-08-16 19:09:26 -06:00
30 changed files with 220 additions and 292 deletions

View File

@@ -1,3 +1,3 @@
NAME= openrc
VERSION= 0.9.2
VERSION= 0.8.3
PKG= ${NAME}-${VERSION}

74
README
View File

@@ -1,8 +1,9 @@
OpenRC README
=============
Installation
------------
make install
Yup, that simple. Works with GNU make.
@@ -67,33 +68,54 @@ init.d.misc is not installed by default as the scripts will need
tweaking on a per distro basis. They are also non essential to the operation
of the system.
Reporting Bugs
--------------
Since Gentoo Linux is hosting OpenRC development, Bugs should go to
the Gentoo Bugzilla:
http://bugs.gentoo.org/
They should be filed under the "Gentoo Hosted Projects" product and
the "openrc" component.
If you installed OpenRC from your chosen distribution, you should report
bugs directly to them. For example, if you use Gentoo and emerged OpenRC
then you should reports bugs to http://bugs.gentoo.org.
History - by Roy Marples
------------------------
I became a Gentoo/Linux developer in 2004 and wrote the modular network
scripts for the Gentoo baselayout package. baselayout is a collection of
bash scripts to bring up your computer and its services.
Then towards the end of 2005 I found myself as the primary maintainer
for baselayout.
History - by Daniel Robbins
---------------------------
At the start of 2007, baselayout-2 is announced to the world, re-writing the
core of baselayout in C and allowing POSIX sh init scripts instead of
forcing the use of bash. By Mid 2007 I have re-written everything, including
init scripts, and alpha and pre baselayout-2 snapshots where put into Gentoo.
Towards the end of 2007 I retired as a Gentoo developer for reasons I won't
go into here. baselayout-2 was still in the pre stage, and aside from the
fbsd users, it was masked everywhere. However, I also desired to keep the
baselayout-2 project alive, but outside of Gentoo and into other projects
such as FreeBSD.
The Gentoo modular network scripts were created by Daniel Robbins for
Gentoo Linux 1.0_rc6, in development during most of 2001 and released
in September 2001. After their development, the dependency-based initscript
system was maintained by a number of senior developers, primarily Martin
Schlemmer (azarah).
As such, the Gentoo Council have allowed the creation of OpenRC under the
2 clause BSD license, managed by me as an external project.
excerpt from http://www.gentoo.org/news/en/gwn/20040426-newsletter.xml
by Grant Goodyear:
"My recollection is that one of woodchip's more impressive early feats was the
complete replacement of all of the init scripts in Portage for Gentoo Linux
1.0_rc6. Through 1.0_rc5 Gentoo had used fairly standard rc scripts modified
from Stampede Linux, but for 1.0_rc6 Daniel Robbins (drobbins) and Martin
Schlemmer (azarah) had created a new dependency-based init script system that
is still used today. Within a span of days Donny rewrote every single init
script in the Portage tree and committed new masked packages to await the
release of 1.0_rc6. Thanks to woodchip (and drobbins and azarah, of course) the
transition to the new init scripts was nearly painless."
Roy Marples became a Gentoo/Linux developer in 2004 and maintained the modular
network scripts for the Gentoo baselayout package. Then towards the end of
2005, he became the the primary maintainer for baselayout.
At the start of 2007, Roy Marples announced the ongoing development of
baselayout-2, containing a rewritten initscript code in C and allowing POSIX sh
init scripts instead of forcing the use of bash. By Mid 2007 Roy Marples had
re-implemented the Gentoo initscript design created by Daniel Robbins, using an
entirely new code base. Alpha and pre-release baselayout-2 snapshots were
added to Gentoo's Portage tree as an optional component.
Towards the end of 2007, Roy Marples retired as a Gentoo developer Baselayout-2
was still in the pre stage, and aside from the fbsd users, it was masked
everywhere. However, Roy Marples desired to keep the baselayout-2 project
alive, but outside of Gentoo and into other projects such as FreeBSD.
As such, the Gentoo Council permitted Roy Marples to release OpenRC under the 2
clause BSD license, managed by him as an external project. Around mid-2010, Roy
Marples decided to no longer maintain OpenRC. At this point, he transferred
development back to Gentoo, which continues to maintain the scripts. In
addition, Daniel Robbins continues to maintain an independent version OpenRC
for Funtoo Linux, which includes a Funtoo-specific network configuration
system.

51
STYLE
View File

@@ -32,54 +32,3 @@ void foo(int c)
return ret;
}
##################
# COMMIT MESSAGES #
##################
The following is an example of a correctly formatted git commit message
for this repository. Most of this information came from this blog post
[1], so I would like to thank the author.
### cut here ###
Capitalized, short (50 chars or less) summary
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.
Write your commit message in the present tense: "Fix bug" and not "Fixed
bug." This convention matches up with commit messages generated by
commands like git merge and git revert.
Further paragraphs come after blank lines.
- Bullet points are okay, too
- Typically a hyphen or asterisk is used for the bullet, preceded by a
single space, with blank lines in between, but conventions vary here
- Use a hanging indent
Reported-by: User Name <email>
X-[Distro]-Bug: BugID
X-[Distro]-Bug-URL: URL for the bug (on the distribution's web site typically)
### cut here ###
If you did not write the code and the patch does not include authorship
information in a format git can use, please use the --author option of the
git commit command to make the authorship correct.
The Reported-by tag is required if the person who reported the bug is
different from the author and committer.
The X-[Distro]-Bug/Bug-URL tags are required if this commit is related
to a bug reported to us by a specific distribution of linux or a
*BSD. Also, [Distro] should be replaced with the name of the
distribution, e.g. X-Gentoo-Bug.
[1] http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html

View File

@@ -1,10 +1,8 @@
# You can define a list modules for a specific kernel version,
# a released kernel version, a main kernel version or just a list.
# The most specific versioned variable will take precedence.
#modules_2_6_23_gentoo_r5="ieee1394 ohci1394"
#modules_2_6_23="tun ieee1394"
#modules_2_6="tun"
#modules_2="ipv6"
#modules="ohci1394"
# You can give modules a different name when they load - the new name
@@ -12,12 +10,10 @@
#modules="dummy:dummy1"
# Give the modules some arguments if needed, per version if necessary.
# Again, the most specific versioned variable will take precedence.
#module_ieee1394_args="debug"
#module_ieee1394_args_2_6_23_gentoo_r5="debug2"
#module_ieee1394_args_2_6_23="debug3"
#module_ieee1394_args_2_6="debug4"
#module_ieee1394_args_2="debug5"
#module_ieee1394_args_2_6_23_gentoo_r5="ieee1394 ohci1394"
#module_ieee1394_args_2_6_23="tun ieee1394"
#module_ieee1394_args_2_6="tun"
# You should consult your kernel documentation and configuration
# for a list of modules and their options.

View File

@@ -47,10 +47,6 @@
# logging can take place and as such cannot log the sysinit runlevel.
#rc_logger="YES"
# Through rc_log_path you can specify a custom log file.
# The default value is: /var/log/rc.log
#rc_log_path="/var/log/rc.log"
# By default we filter the environment for our running scripts. To allow other
# variables through, add them here. Use a * to allow all variables through.
#rc_env_allow="VAR1 VAR2"

View File

@@ -16,7 +16,7 @@ start()
{
# Mount local filesystems in /etc/fstab.
local types="noproc" x= no_netdev=
for x in $net_fs_list $extra_net_fs_list; do
for x in $net_fs_list; do
types="${types},${x}"
done
@@ -37,10 +37,16 @@ stop()
local x= no_umounts_r="/|/dev|/dev/.*|${RC_SVCDIR}"
no_umounts_r="${no_umounts_r}|/bin|/sbin|/lib|/libexec"
# RC_NO_UMOUNTS is an env var that can be set by plugins
local IFS="$IFS:"
local OIFS=$IFS SIFS=${IFS-y}
IFS=$IFS:
for x in $no_umounts $RC_NO_UMOUNTS; do
no_umounts_r="$no_umounts_r|$x"
done
if [ "$SIFS" = y ]; then
IFS=$OIFS
else
unset IFS
fi
if [ "$RC_UNAME" = Linux ]; then
no_umounts_r="$no_umounts_r|/proc|/proc/.*|/run|/sys|/sys/.*"
@@ -64,7 +70,7 @@ stop()
einfo "Unmounting filesystems"
eindent
local fs=
for x in $net_fs_list $extra_net_fs_list; do
for x in $net_fs_list; do
fs="$fs${fs:+|}$x"
done
[ -n "$fs" ] && fs="^($fs)$"

View File

@@ -16,21 +16,18 @@ start()
# support compiled in ...
[ ! -f /proc/modules ] && return 0
local KV x y kv_variant_list
KV=$(uname -r)
# full $KV
kv_variant_list="${KV}"
# remove any KV_EXTRA options to just get the full version
x=${KV%%-*}
# now slowly strip them
while [ -n "$x" ] && [ "$x" != "$y" ]; do
kv_variant_list="${kv_variant_list} $x"
y=$x
x=${x%.*}
done
local KV=$(uname -r)
local KV_MAJOR=${KV%%.*}
local x=${KV#*.}
local KV_MINOR=${x%%.*}
x=${KV#*.*.}
local KV_MICRO=${x%%-*}
local list= x= xx= y= args= mpargs= cnt=0 a=
for x in $kv_variant_list ; do
for x in "$KV" \
$KV_MAJOR.$KV_MINOR.$KV_MICRO \
$KV_MAJOR.$KV_MINOR \
; do
eval list=\$modules_$(shell_var "$x")
[ -n "$list" ] && break
done
@@ -48,7 +45,10 @@ start()
fi
aa=$(shell_var "$a")
xx=$(shell_var "$x")
for y in $kv_variant_list ; do
for y in "$KV" \
$KV_MAJOR.$KV_MINOR.$KV_MICRO \
$KV_MAJOR.$KV_MINOR \
; do
eval args=\$module_${aa}_args_$(shell_var "$y")
[ -n "${args}" ] && break
eval args=\$module_${xx}_args_$(shell_var "$y")

View File

@@ -22,13 +22,19 @@ start()
local m="/dev|/dev/.*|/proc|/proc.*|/sys|/sys/.*|${RC_SVCDIR}" x= fs=
m="$m|/bin|/sbin|/lib|/libexec"
# RC_NO_UMOUNTS is an env var that can be set by plugins
local IFS="$IFS:"
local OIFS=$IFS SIFS=${IFS-y} IFS=$IFS
IFS=$IFS:
for x in $no_umounts $RC_NO_UMOUNTS; do
m="$m|$x"
done
if [ "$SIFS" = y ]; then
IFS=$OIFS
else
unset IFS
fi
m="^($m)$"
fs=
for x in $net_fs_list $extra_net_fs_list; do
for x in $net_fs_list; do
fs="$fs${fs:+|}$x"
done
[ -n "$fs" ] && fs="^($fs)$"

View File

@@ -12,9 +12,9 @@ depend()
start()
{
if [ -L /etc/mtab ]
then
einfo "Skipping mtab update (mtab is a symbolic link)"
# /etc/mtab could be a symlink to /proc/mounts
if [ ! -w /etc/mtab -a -L /etc/mtab ]; then
eeinfo "Skipping mtab update (non writeable symlink)"
return 0
fi

View File

@@ -48,9 +48,6 @@ _get_array()
if [ -n "${BASH}" ]; then
case "$(declare -p "$1" 2>/dev/null)" in
"declare -a "*)
ewarn "You are using a bash array for $1."
ewarn "This feature will be removed in the future."
ewarn "Please see net.example for the correct format for $1."
eval "set -- \"\${$1[@]}\""
for _a; do
printf "%s\n" "${_a}"
@@ -72,9 +69,6 @@ _flatten_array()
if [ -n "${BASH}" ]; then
case "$(declare -p "$1" 2>/dev/null)" in
"declare -a "*)
ewarn "You are using a bash array for $1."
ewarn "This feature will be removed in the future."
ewarn "Please see net.example for the correct format for $1."
eval "set -- \"\${$1[@]}\""
for x; do
printf "'%s' " "$(printf "$x" | sed "s:':'\\\'':g")"
@@ -545,9 +539,7 @@ start()
[ -z "${config}" ] && break
set -- ${config}
if [ "$1" != "null" -a "$1" != "noop" ]; then
ebegin "$1"
fi
ebegin "$1"
eindent
case "$1" in
noop)

View File

@@ -44,7 +44,7 @@ start()
[ -x @SYSCONFDIR@/init.d/rpcbind ] && pmap="rpcbind"
local x= fs= rc=
for x in $net_fs_list $extra_net_fs_list; do
for x in $net_fs_list; do
case "$x" in
nfs|nfs4)
# If the nfsmount script took care of the nfs
@@ -81,7 +81,7 @@ stop()
ebegin "Unmounting network filesystems"
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
for x in $net_fs_list $extra_net_fs_list; do
for x in $net_fs_list; do
fs="$fs${fs:+,}$x"
done
if [ -n "$fs" ]; then
@@ -90,7 +90,7 @@ stop()
eindent
fs=
for x in $net_fs_list $extra_net_fs_list; do
for x in $net_fs_list; do
fs="$fs${fs:+|}$x"
done
[ -n "$fs" ] && fs="^($fs)$"

View File

@@ -16,9 +16,7 @@ depend()
start()
{
ebegin "Setting the local clock based on last shutdown time"
if ! swclock 2> /dev/null; then
swclock --warn @PREFIX@/sbin/runscript
fi
swclock --warn
eend $?
}

View File

@@ -105,7 +105,8 @@ and
respectively, but only work when
.Va EINFO_VERBOSE
is true. You can also make the
.Fn einfo
.Fn einfo ,
.Fn ewarn ,
and
.Fn ebegin
functions silent by setting

View File

@@ -462,6 +462,12 @@ show()
.Ed
.Sh BUGS
Because of the way we load our configuration files and the need to handle
more than one service directory, you can only use symlinks in service
directories to other services in the same directory.
You cannot symlink to a service in a different directory even if it is
another service directory.
.Pp
is_older_than should return 0 on success.
Instead we return 1 to be compliant with Gentoo baselayout.
Users are encouraged to use the is_newer_than function which returns correctly.

View File

@@ -29,7 +29,7 @@ ethtool_pre_start() {
# Skip everything if no arguments
[ -z "${args}" ] && continue
# Split on \n
local IFS="$__IFS"

View File

@@ -111,32 +111,38 @@ _add_address()
return 0
fi
local address netmask broadcast peer anycast label scope
local valid_lft preferred_lft home nodad
address="$1" ; shift
while [ -n "$*" ]; do
case "$1" in
netmask)
netmask="/$(_netmask2cidr "$2")" ; shift ; shift ;;
broadcast|brd)
broadcast="broadcast $2" ; shift ; shift ;;
pointopoint|pointtopoint|peer)
peer="peer $2" ; shift ; shift ;;
anycast|label|scope|valid_lft|preferred_lft)
eval "$1=$2" ; shift ; shift ;;
home|nodad)
eval "$1=$1" ; shift ;;
esac
done
# Convert an ifconfig line to iproute2
if [ "$2" = "netmask" ]; then
local one="$1" three="$3"
shift; shift; shift
set -- "${one}/$(_netmask2cidr "${three}")" "$@"
fi
# tunnel keyword is 'peer' in iproute2, but 'pointopoint' in ifconfig.
if [ "$2" = "pointopoint" ]; then
local one="$1"
shift; shift
set -- "${one}" "peer" "$@"
fi
# Always scope lo addresses as host unless specified otherwise
if [ "${IFACE}" = "lo" ]; then
[ -z "$scope" ] && scope="scope host"
set -- "$@" "scope" "host"
fi
set -- "${address}${netmask}" $peer $broadcast $anycast $label $scope dev "${IFACE}" $valid_lft $preferred_lft $home $nodad
veinfo ip addr add "$@"
ip addr add "$@"
# IPv4 specifics
case "$1" in
*.*.*.*)
case "$@" in
*" brd "*);;
*" broadcast "*);;
*) set -- "$@" brd +;;
esac
;;
esac
veinfo ip addr add "$@" dev "${IFACE}"
ip addr add "$@" dev "${IFACE}"
}
_add_route()

View File

@@ -38,8 +38,7 @@ yesno()
esac
}
rc_runlevel()
{
rc_runlevel() {
rc-status --runlevel
}

View File

@@ -39,7 +39,7 @@ stop_addon()
}
net_fs_list="afs cifs coda davfs fuse fuse.sshfs gfs glusterfs lustre
ncpfs nfs nfs4 ocfs2 shfs smbfs"
ncpfs nfs nfs4 ocfs2 shfs smbfs $extra_net_fs_list"
is_net_fs()
{
[ -z "$1" ] && return 1
@@ -50,7 +50,7 @@ is_net_fs()
# Fall back on fs types
local t=$(mountinfo --fstype "$1")
for x in $net_fs_list $extra_net_fs_list; do
for x in $net_fs_list; do
[ "$x" = "$t" ] && return 0
done
return 1

View File

@@ -16,23 +16,6 @@ sourcex()
fi
}
loadconfig()
{
# If we're net.eth0 or openvpn.work then load net or openvpn config
_c=${RC_SVCNAME%%.*}
if [ -n "$_c" -a "$_c" != "$RC_SVCNAME" ]; then
if ! sourcex -e "$1/$_c.$RC_RUNLEVEL"; then
sourcex -e "$1/$_c"
fi
fi
unset _c
# Overlay with our specific config
if ! sourcex -e "$1/$RC_SVCNAME.$RC_RUNLEVEL"; then
sourcex -e "$1/$RC_SVCNAME"
fi
}
if [ ! -e ${RC_SVCDIR}/softlevel ]; then
eerror "You are attempting to run an openrc service on a"
eerror "system which openrc did not boot."
@@ -182,9 +165,21 @@ status()
yesno $RC_DEBUG && set -x
if ! loadconfig "${RC_SERVICE%/*}/../conf.d"; then
loadconfig "@SYSCONFDIR@/conf.d"
_conf_d=${RC_SERVICE%/*}/../conf.d
# If we're net.eth0 or openvpn.work then load net or openvpn config
_c=${RC_SVCNAME%%.*}
if [ -n "$_c" -a "$_c" != "$RC_SVCNAME" ]; then
if ! sourcex -e "$_conf_d/$_c.$RC_RUNLEVEL"; then
sourcex -e "$_conf_d/$_c"
fi
fi
unset _c
# Overlay with our specific config
if ! sourcex -e "$_conf_d/$RC_SVCNAME.$RC_RUNLEVEL"; then
sourcex -e "$_conf_d/$RC_SVCNAME"
fi
unset _conf_d
# Load any system overrides
sourcex -e "@SYSCONFDIR@/rc.conf"
@@ -211,12 +206,6 @@ for _f in $required_files; do
done
unset _f
if [ -n "$opts" ]; then
ewarn "Use of the opts variable is deprecated and will be"
ewarn "removed in the future."
ewarn "Please use extra_commands or extra_started_commands."
fi
while [ -n "$1" ]; do
# Sepcial case depend
if [ "$1" = depend ]; then

View File

@@ -30,7 +30,7 @@ update_ntp()
{
peer_var "${PEER_NTP}" && return
[ -z "${ntpsrv}" ] && return
conf="# Generated by udhcpc for interface ${interface}\n"
conf="${conf}restrict default noquery notrust nomodify\n"
conf="${conf}restrict 127.0.0.1\n"
@@ -64,7 +64,7 @@ update_interface()
update_routes()
{
peer_var "${PEER_ROUTERS}" && return
if [ -n "${router}" ] ; then
metric=
[ -n "${IF_METRIC}" ] && metric="metric ${IF_METRIC}"

View File

@@ -725,7 +725,7 @@ ewarn(const char *EINFO_RESTRICT fmt, ...)
int retval;
va_list ap;
if (!fmt)
if (!fmt || is_quiet())
return 0;
va_start(ap, fmt);
elogv(LOG_WARNING, fmt, ap);

View File

@@ -54,54 +54,6 @@ rc_yesno(const char *value)
}
librc_hidden_def(rc_yesno)
/**
* Read the entire @file into the buffer and set @len to the
* size of the buffer when finished. For C strings, this will
* be strlen(buffer) + 1.
* Don't forget to free the buffer afterwards!
*/
bool
rc_getfile(const char *file, char **buffer, size_t *len)
{
bool ret = false;
FILE *fp;
int fd;
struct stat st;
size_t done, left;
fp = fopen(file, "re");
if (!fp)
return false;
/* assume fileno() never fails */
fd = fileno(fp);
if (fstat(fd, &st))
goto finished;
left = st.st_size;
*len = left + 1; /* NUL terminator */
*buffer = xrealloc(*buffer, *len);
while (left) {
done = fread(*buffer, sizeof(*buffer[0]), left, fp);
if (done == 0 && ferror(fp))
goto finished;
left -= done;
}
ret = true;
finished:
if (!ret) {
free(*buffer);
*len = 0;
} else
(*buffer)[*len - 1] = '\0';
fclose(fp);
return ret;
}
librc_hidden_def(rc_getfile)
ssize_t
rc_getline(char **line, size_t *len, FILE *fp)
{
@@ -221,8 +173,10 @@ rc_config_load(const char *file)
/* In shells the last item takes precedence, so we need to remove
any prior values we may already have */
TAILQ_FOREACH(cline, config, entries) {
i = strlen(entry);
if (strncmp(entry, cline->value, i) == 0 && cline->value[i] == '=') {
p = strchr(cline->value, '=');
if (p && strncmp(entry, cline->value,
(size_t)(p - cline->value)) == 0)
{
/* We have a match now - to save time we directly replace it */
free(cline->value);
cline->value = newline;
@@ -248,13 +202,15 @@ rc_config_value(RC_STRINGLIST *list, const char *entry)
{
RC_STRING *line;
char *p;
size_t len;
size_t len, dif;
len = strlen(entry);
TAILQ_FOREACH(line, list, entries) {
p = strchr(line->value, '=');
if (p != NULL) {
if (strncmp(entry, line->value, len) == 0 && line->value[len] == '=')
dif = (p - line->value);
if (dif == len &&
strncmp(entry, line->value, dif) == 0)
return ++p;
}
}

View File

@@ -767,15 +767,19 @@ librc_hidden_def(rc_service_state)
char *
rc_service_value_get(const char *service, const char *option)
{
char *buffer = NULL;
FILE *fp;
char *line = NULL;
size_t len = 0;
char file[PATH_MAX];
snprintf(file, sizeof(file), RC_SVCDIR "/options/%s/%s",
service, option);
rc_getfile(file, &buffer, &len);
if ((fp = fopen(file, "r"))) {
rc_getline(&line, &len, fp);
fclose(fp);
}
return buffer;
return line;
}
librc_hidden_def(rc_service_value_get)

View File

@@ -84,7 +84,6 @@ librc_hidden_proto(rc_deptree_order)
librc_hidden_proto(rc_deptree_update)
librc_hidden_proto(rc_deptree_update_needed)
librc_hidden_proto(rc_find_pids)
librc_hidden_proto(rc_getfile)
librc_hidden_proto(rc_getline)
librc_hidden_proto(rc_newer_than)
librc_hidden_proto(rc_older_than)

View File

@@ -544,9 +544,6 @@ typedef LIST_HEAD(rc_pidlist, rc_pid) RC_PIDLIST;
* @return NULL terminated list of pids */
RC_PIDLIST *rc_find_pids(const char *, const char *const *, uid_t, pid_t);
/* Basically the same as rc_getline() below, it just returns multiple lines */
bool rc_getfile(const char *, char **, size_t *);
/* getline is a handy glibc function that not all libcs have, so
* we have our own */
ssize_t rc_getline(char **, size_t *, FILE *);

View File

@@ -14,7 +14,6 @@ global:
rc_deptree_update_needed;
rc_environ_fd;
rc_find_pids;
rc_getfile;
rc_getline;
rc_newer_than;
rc_older_than;

View File

@@ -57,8 +57,10 @@
#include "rc.h"
#include "rc-misc.h"
#define TMPLOG RC_SVCDIR "/rc.log"
#define DEFAULTLOG "/var/log/rc.log"
#define LOGFILE RC_SVCDIR "/rc.log"
#define PERMLOG "/var/log/rc.log"
#define MOVELOG "cat " LOGFILE " 2>/dev/null >>" PERMLOG " && " \
"rm -f " LOGFILE
static int signal_pipe[2] = { -1, -1 };
static int fd_stdout = -1;
@@ -147,15 +149,12 @@ rc_logger_open(const char *level)
int slave_tty;
struct termios tt;
struct winsize ws;
char buffer[BUFSIZ];
char *buffer;
struct pollfd fd[2];
int s = 0;
size_t bytes;
int i;
FILE *log = NULL;
FILE *plog = NULL;
const char *logfile;
int log_error = 0;
if (!rc_conf_yesno("rc_logger"))
return;
@@ -193,7 +192,7 @@ rc_logger_open(const char *level)
signal_pipe[1] = -1;
runlevel = level;
if ((log = fopen(TMPLOG, "ae")))
if ((log = fopen(LOGFILE, "a")))
write_time(log, "started");
else {
free(logbuf);
@@ -202,6 +201,7 @@ rc_logger_open(const char *level)
logbuf_len = 0;
}
buffer = xmalloc(sizeof (char) * BUFSIZ);
fd[0].fd = signal_pipe[0];
fd[0].events = fd[1].events = POLLIN;
fd[0].revents = fd[1].revents = 0;
@@ -242,8 +242,9 @@ rc_logger_open(const char *level)
if (fd[0].revents & (POLLIN | POLLHUP))
break;
}
free(buffer);
if (logbuf) {
if ((log = fopen(TMPLOG, "ae"))) {
if ((log = fopen(LOGFILE, "a"))) {
write_time(log, "started");
write_log(fileno(log), logbuf, logbuf_len);
}
@@ -254,39 +255,10 @@ rc_logger_open(const char *level)
fclose(log);
}
/* Append the temporary log to the real log */
logfile = rc_conf_value("rc_log_path");
if (logfile == NULL)
logfile = DEFAULTLOG;
if ((plog = fopen(logfile, "ae"))) {
if ((log = fopen(TMPLOG, "re"))) {
while ((bytes = fread(buffer, sizeof(*buffer), BUFSIZ, log)) > 0) {
if (fwrite(buffer, sizeof(*buffer), bytes, plog) < bytes) {
log_error = 1;
eerror("Error: write(%s) failed: %s", logfile, strerror(errno));
break;
}
}
} else {
log_error = 1;
eerror("Error: fopen(%s) failed: %s", TMPLOG, strerror(errno));
}
fclose(log);
fclose(plog);
} else {
log_error = 1;
eerror("Error: fopen(%s) failed: %s", logfile, strerror(errno));
}
/* Try to keep the temporary log in case of errors */
if (!log_error) {
if (unlink(TMPLOG) == -1)
eerror("Error: unlink(%s) failed: %s", TMPLOG, strerror(errno));
} else if (exists(TMPLOG))
eerrorx("Warning: temporary logfile left behind: %s", TMPLOG);
/* Try and cat our new logfile to a more permament location
and then punt it */
if (system(MOVELOG) == -1)
eerror("system: %s: %s", MOVELOG, strerror(errno));
exit(0);
/* NOTREACHED */

View File

@@ -1100,7 +1100,7 @@ runscript(int argc, char **argv)
bool doneone = false;
int retval, opt, depoptions = RC_DEP_TRACE;
RC_STRING *svc;
char *save = NULL;
char path[PATH_MAX], lnk[PATH_MAX], *dir, *save = NULL, *save2 = NULL;
char pidstr[10];
size_t l = 0, ll;
const char *file;
@@ -1120,7 +1120,40 @@ runscript(int argc, char **argv)
atexit(cleanup);
service = xstrdup(argv[1]);
/* We need to work out the real full path to our service.
* This works fine, provided that we ONLY allow multiplexed services
* to exist in the same directory as the master link.
* Also, the master link as to be a real file in the init dir. */
if (!realpath(argv[1], path)) {
fprintf(stderr, "realpath: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
memset(lnk, 0, sizeof(lnk));
if (readlink(argv[1], lnk, sizeof(lnk)-1)) {
dir = dirname(path);
if (strchr(lnk, '/')) {
save = xstrdup(dir);
save2 = xstrdup(lnk);
dir = dirname(save2);
if (strcmp(dir, save) == 0)
file = basename_c(argv[1]);
else
file = basename_c(lnk);
dir = save;
} else
file = basename_c(argv[1]);
ll = strlen(dir) + strlen(file) + 2;
service = xmalloc(ll);
snprintf(service, ll, "%s/%s", dir, file);
if (stat(service, &stbuf) != 0) {
free(service);
service = xstrdup(lnk);
}
free(save);
free(save2);
}
if (!service)
service = xstrdup(path);
applet = basename_c(service);
if (argc < 3)
@@ -1300,6 +1333,12 @@ runscript(int argc, char **argv)
prefix = NULL;
retval = svc_exec("status", NULL);
} else {
if (strcmp(optarg, "pause") == 0) {
ewarn("WARNING: 'pause' is deprecated; please use '--nodeps stop'");
deps = false;
optarg = "stop";
}
if (strcmp(optarg, "conditionalrestart") == 0 ||
strcmp(optarg, "condrestart") == 0)
{
@@ -1310,11 +1349,7 @@ runscript(int argc, char **argv)
svc_restart();
} else if (strcmp(optarg, "start") == 0) {
svc_start();
} else if (strcmp(optarg, "stop") == 0 || strcmp(optarg, "pause") == 0) {
if (strcmp(optarg, "pause") == 0) {
ewarn("WARNING: 'pause' is deprecated; please use '--nodeps stop'");
deps = false;
}
} else if (strcmp(optarg, "stop") == 0) {
if (deps && in_background)
get_started_services();
svc_stop();
@@ -1346,7 +1381,7 @@ runscript(int argc, char **argv)
strerror(errno));
unhotplug();
} else
retval = svc_exec(optarg, NULL);
svc_exec(optarg, NULL);
/* We should ensure this list is empty after
* an action is done */

View File

@@ -1183,6 +1183,8 @@ start_stop_daemon(int argc, char **argv)
pamr = pam_start("start-stop-daemon",
"nobody", &conv, &pamh);
if (pamr == PAM_SUCCESS)
pamr = pam_authenticate(pamh, PAM_SILENT);
if (pamr == PAM_SUCCESS)
pamr = pam_acct_mgmt(pamh, PAM_SILENT);
if (pamr == PAM_SUCCESS)

View File

@@ -24,8 +24,6 @@ rc_deptree_update_needed
rc_deptree_update_needed@@RC_1.0
rc_find_pids
rc_find_pids@@RC_1.0
rc_getfile
rc_getfile@@RC_1.0
rc_getline
rc_getline@@RC_1.0
rc_newer_than