Commit Graph

263 Commits

Author SHA1 Message Date
Zac Medico
84ed570eae librc: fix EACCES errno false-positive crash
Use errno != EACCES to fix false-positive for non-root users
with grsecurity kernels.

Fixes: 37e2944272 ("librc: Add check for crashed state")
This fixes #237
2018-08-06 17:39:52 -05:00
William Hubbs
3a803b3135 librc-daemon.c: fix memory leaks 2018-06-27 12:06:19 -05:00
William Hubbs
72df51e17b librc-daemon: convert most snprintf calls to xasprintf 2018-06-22 15:41:25 -05:00
William Hubbs
b2f5531194 librc-misc: convert snprintf calls to xasprintf 2018-06-20 17:45:01 -05:00
William Hubbs
37e2944272 librc: Add check for crashed state
In rc_service_state,, call rc_service_daemons_crashed to check for
a crashed daemon if the service is started.
2018-05-22 12:19:41 -05:00
William Hubbs
4e0eace837 librc: Add crashed state 2018-05-22 12:19:22 -05:00
Will Miles
a7c99506d9 Fix repeated dependency cache rebuild if clock skewed
rc_deptree_update_needed would return early as soon as it found
any file newer than the existing dependency cache.  Unfortunately,
the first file found may not be the newest one there; so the
clock skew workaround in rc-misc:_rc_deptree_load would be given
a timestamp that was still too old.

This fix forces a full scan of all relevant files, so as to
ensure that we return a timestamp that will allow the clock skew
fix to operate.   The runtime cost is no worse than the case where
the cache is up to date (ie. we must check every possible file).

This fixes #161.
2017-11-30 13:56:54 -06:00
William Hubbs
971e82784c rc_find_pids: namespace fix
Ignore namespaces if there are errors reading either the pid namespace
for the current process or the process we aare testing.

This fixes https://github.com/openrc/openrc/issues/180.
2017-11-13 16:54:57 -06:00
William Hubbs
cf429ee359 rc_service_value_set: remove the option if NULL is the value
This allows the equivalent of "unsetting" a value for a service.
2017-10-26 12:54:37 -05:00
William Hubbs
f5acc66db7 rc_find_pids: ignore pids that are not in our pid namespace
X-Gentoo-Bug: 634634
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=634634
2017-10-24 10:37:37 -05:00
William Hubbs
13ca79856e add init process
openrc-init.c and openrc-shutdown.c are based on code which was written by
James Hammons <jlhamm@acm.org>, so I would like to publically
thank him for his work.
2017-04-06 17:13:59 -05:00
Benda Xu
c304522131 Clean up warnings that can use the _unused macro
X-Gentoo-Bug: 604666
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604666
2017-01-04 17:18:35 -06:00
Doug Freed
45aa36cc62 librc: detect loops in stacked runlevels and abort
This fixes #109.
X-Gentoo-Bug: 558700
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=558700
2016-12-19 18:24:31 -06:00
William Hubbs
ca8c29ee60 librc: fix Docker auto detection
The original auto detection of Docker containers assumed the presence of
a container environment variable. However, Docker-1.12 does not
implement this, and I'm not sure which versions of docker implemented
it.

The new test is for the presence of a file named .dockerenv in the
root directory.
2016-07-31 12:24:56 -05:00
William Hubbs
3a1262703f Remove the DEBUG_MEMORY macro
This fixes #43.
2016-07-14 16:52:57 -05:00
William Hubbs
69f052b611 librc: Complain when a real and virtual service have the same name 2016-01-21 15:58:03 -06:00
Doug Freed
4c814a0a28 librc: handle rc_sys="prefix" even if we weren't built with a prefix
This probably isn't needed, but it mimics old behavior.
2016-01-19 00:09:20 -06:00
Doug Freed
36dde4e7f2 librc: fix handling the nothing special case for rc_sys 2016-01-19 00:09:20 -06:00
Doug Freed
649f63d882 librc: move system detection code into rc_sys and use it
This fixes an issue where librc code was calling code that only existed
in the rc binary.

This reverts commits 8addd79 and 9f6e056

This fixes #75.
2016-01-19 00:09:20 -06:00
William Hubbs
6c09421375 Revert "librc: fix librc-depend functions to call rc_sys"
This reverts commit 73482cf13a.
2016-01-18 23:40:03 -06:00
William Hubbs
73482cf13a librc: fix librc-depend functions to call rc_sys 2016-01-18 15:09:31 -06:00
William Hubbs
000503fad7 Convert OpenRC to a centralized copyright/license structure
In the past, OpenRC was a hybrid of a centralized and file-scope
license/copyright structure.

I followed the instructions from the Software Freedom Law Center [1] to
convert to a Centralized structure where possible, for easier future
maintenance.

[1] https://softwarefreedom.org/resources/2012/ManagingCopyrightInformation.html
2015-12-21 12:16:06 -06:00
William Hubbs
f9bdb072e8 rc.map: remove references to rc_sys_v{1,2} 2015-12-08 12:50:47 -06:00
William Hubbs
9f6e05671d Convert rc_sys() calls to detect_container() and detect_vm() 2015-12-08 12:09:33 -06:00
William Hubbs
a0cf8f9124 Add detection for rkt containers 2015-12-02 10:20:39 -06:00
William Hubbs
9fedb3b40b Add detection for docker containers 2015-12-02 10:20:15 -06:00
William Hubbs
635e33cdc8 librc: comsolidate rc_sys_v1 and rc_sys_v2 into rc_sys
These functions were never meant to be used outside of OpenRC, and they
were added when we thought we were going to do away with the automatic
detection of subsystems. Since the autodetection is not going away, we
can combine these functions into rc_sys.
2015-12-01 17:39:04 -06:00
Ian Stakenvicius
33d3f33b3c Implement "want" dependency
The want dependency is similar to the use dependency. If a service
script, for example called service1, adds "want service2" to its depend
function, OpenRC will attempt to start service2, if it exists on the
system,  when service1 is started.

However, service1 will start regardless of the status of
service2.

X-Gentoo-Bug: 406021
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=406021
2015-11-12 12:32:45 -06:00
Benda Xu
085d77f17e Standardize macro tests for gnu hurd
This also fixes breakage of GNU/hurd builds introduced by commit 3f82edbeb9.
2015-11-11 13:37:41 -06:00
William Hubbs
c831f1f994 librc: rework overriding rc.conf options from the kcl
Rename the rc_conf_override function to describe its purpose better,
drop one conditional compile by making it available everywhere, and move
the call to it after the optional rc.conf.d directory is processed.
2015-11-05 11:20:57 -06:00
William Hubbs
591aea2821 librc: Remove redundant code from rc_config_load 2015-11-05 11:20:57 -06:00
William Hubbs
c09eeca491 Add rc.conf.d support
This makes it possible to override settings in rc.conf by adding a
directory @SYSCONFDIR@/rc.conf.d and putting files in this directory.
The files will be processed in lexical order, and the last setting in
these files will be used.
2015-11-05 10:40:24 -06:00
Jakob Drexel
0b435ddd83 librc: Fix crash if the service name is the same as the including runlevel
If a service has the same name as the runlevel it is in, openrc will
crash on changing to such runlevel. It goes in a recursive madness and
eventually gets a SEGV while in snprintf (don't know why).

This fixes two errors:
1. ls_dir stats files not with full path -> stat always returns != 0
2. ls_dir adds files to list if stat failed

This fixes #53.

X-Gentoo-Bug: 537304
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=537304
2015-05-04 09:54:51 -05:00
William Hubbs
c709e6077c Add support for systemd-nspawn containers
This adds support for running OpenRC in a container created by
the systemd-nspawn utility.

This fixes #52.

X-Gentoo-Bug: 548058
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=548058
2015-05-01 09:04:07 -05:00
William Hubbs
8b93492086 convert all references from runscript to openrc-run 2015-04-27 11:21:29 -05:00
Doug Freed
f085ae400c Fix some compiler warnings
librc: Fix C90 warning (mixed declaration and code)
rc: Fix warning about discarding const qualifier

Fixes #45.
2015-03-24 19:08:29 -05:00
Will Miles
3f80f22e22 Prioritize local includes and libraries
This fixes #35.
2015-01-24 13:48:53 -06:00
Doug Freed
74478830a8 fix double free of pidfile
This fixes a double free of the pidfile variable. For discussion of this
issue, see the bug.

X-Gentoo-Bug: 531600
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=531600
2015-01-12 10:30:36 -06:00
Alexander Vershilov
be952bebb3 Fix incorrect handling of chroot option.
Fixes #28.

X-Gentoo-Bug: #527370
X-Gentoo-Bug-Url: https://bugs.gentoo.org/show_bug.cgi?id=527370
2014-11-01 16:44:30 -05:00
William Hubbs
7700e6fe79 Fix compile errors created by bundling queue.h 2014-10-24 10:44:14 -05:00
Anthony G. Basile
1e0a4bebde Bundle <sys/queue.h> from NetBSD
We are bundling this to allow building on musl-based systems since musl
does not include <sys/queue.h>.
2014-10-23 19:14:06 -05:00
William Hubbs
ca6b86be44 Fix all tests for GNU/kFreeBSD
It is necessary to check for both the kernel and c library because
__FreeBSD_kernel is also defined on native FreeBSD [1].

[1] http://sourceforge.net/p/predef/wiki/OperatingSystems/
2014-10-23 18:47:24 -05:00
Gabriele Giacone
4ac289b539 Fix rc_svcdir for GNU/Hurd 2014-10-23 13:05:08 -05:00
Svante Signell
875f03e27c fix defines for GNU/Hurd 2014-10-23 13:00:24 -05:00
Gabriele Giacone
89c8a62a10 Fix rc_svcdir for GNU/kFreeBSD 2014-10-22 13:27:37 -05:00
Svante Signell
3f82edbeb9 Fix GNU/kFreeBSD port
Check for __FreeBSD_kernel instead of __GLIBC__ in source files.

note from William Hubbs:
I was told this is a better check for GNU/kFreeBSD than checking the
C  library the source is being compiled against.
GNU/kFreeBSD than checking which library we are using.
2014-10-22 11:05:07 -05:00
Anthony G. Basile
86e9aa0d36 einfo.h, rc.h.in: simplify __BEGIN_DECLS logic
There is no need to redefine __BEGIN_DECLS and __END_DECLS.
We simplify the logic here and avoid undefining these macros.
2014-10-22 07:46:49 -04:00
Anthony G. Basile
4a08517cac einfo.h, rc.h.in: ensure __BEGIN_DECLS is defined
Some Standard C Libraries, like musl, don't define __BEGIN_DECLS
or __END_DECLS.  We add some ifdef magic to ensure these are
available.
2014-10-21 09:39:34 -04:00
Alexander Vershilov
f9acd65497 librc:look for the pid file in a chroot if defined
X-Gentoo-Bug: 524388
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=524388
2014-10-20 15:44:19 -05:00
William Hubbs
1f7582c78b src/librc/librc-daemon.c: style fix 2014-07-19 13:03:00 -05:00