aboutsummaryrefslogtreecommitdiff
path: root/src/librc
AgeCommit message (Collapse)Author
2021-08-13librc: fix rc_runlevel_exists return for empty stringWilliam Hubbs
This function should return false if the runlevel is an empty string. X-Gentoo-Bug: 803536 X-Gentoo-Bug-URL: https://bugs.gentoo.org/803536 Closes: https://github.com/OpenRC/openrc/pull/431
2021-03-22stop namespaced services with specified pidsWilliam Hubbs
The previous fix excludes PIDs of processes running in a different namespace regardless of whether the PID has been explicitly stored in a PID file mentioned in the --pidfile parameter. The correct behavior is to only exclude the pid if it is not stored in a pidfile. X-Gentoo-Bug: 776010 X-Gentoo-Bug-URL: https://bugs.gentoo.org/776010
2019-07-24Fix build with ClangMartin Wilke
This fixes #313.
2019-02-26remove hidden-visibility.hWilliam Hubbs
I am removing this on the advice of a member of the Gentoo toolchain team. It was explained to me that this doesn't offer any significant benefits to OpenRC. If anyone ffeels differently, please open a pull request reverting this and adding an explanation of what it does and how to know which functions to mark hidden in the future. This fixes #301.
2019-02-23librc: fix potential buffer overflow in pid_is_argvWilliam Hubbs
This fixes #299.
2019-02-23Revert "src/librc/librc-daemon.c: fix buffer overrun in pid_is_argv"William Hubbs
This reverts commit 084877eb52971faf8f52c780ddd08ed9af140eb6. The mentioned commit caused some systems to have some services reported as crashed. This fixes #297. This fixes #298.
2019-02-21librc/librc-depend.c: fix NULL pointer dereferenceGeorgy Yakovlev
In some cases deptree or depinfo can be NULL, check before dereferencing. Fixes https://github.com/OpenRC/openrc/issues/293 Fixes https://github.com/OpenRC/openrc/pulls/294 X-Gentoo-Bug: 659906 X-Gentoo-Bug-URL: https://bugs.gentoo.org/659906
2019-02-12librc: fix realpath() return value checkEdan Bedrik
This fixes #226.
2018-12-27fix leading whitespacephilhofer
Clean up code indented with mixed tabs and spaces. No actual code changes. This fixes #280.
2018-12-27fix potential out-of-bounds readsphilhofer
readlink(3) does not nul-terminate the result it sticks into the supplied buffer. Consequently, the code rc = readlink(path, buf, sizeof(buf)); does not necessarily produce a C string. The code in rc_find_pid() produces some C strings this way and passes them to strlen() and strcmp(), which can lead to an out-of-bounds read. In this case, since the code already takes care to zero-initialize the buffers before passing them to readlink(3), only allow sizeof(buf)-1 bytes to be returned. (While fixing this issue, I fixed two other locations that used the same problematic pattern.) This fixes #270.
2018-12-24src/librc/librc-daemon.c: fix buffer overrun in pid_is_argvphilhofer
The contents of /proc/<pid>/cmdline are read into a stack buffer using bytes = read(fd, buffer, sizeof(buffer)); followed by appending a null terminator to the buffer with buffer[bytes] = '\0'; If bytes == sizeof(buffer), then this write is out-of-bounds. Refactor the code to use rc_getfile instead, since PATH_MAX is not the maximum size of /proc/<pid>/cmdline. (I hit this issue in practice while compiling Linux; it tripped the stack-smashing protector.) This is roughly the same buffer overflow condition that was fixed by commit 0ddee9b7d2b8dea810e252ca6a95c457876df120 This fixes #269.
2018-12-21fix compiler warningsWilliam Hubbs
2018-08-06librc: fix EACCES errno false-positive crashZac Medico
Use errno != EACCES to fix false-positive for non-root users with grsecurity kernels. Fixes: 37e29442721a ("librc: Add check for crashed state") This fixes #237
2018-06-27librc-daemon.c: fix memory leaksWilliam Hubbs
2018-06-22librc-daemon: convert most snprintf calls to xasprintfWilliam Hubbs
2018-06-20librc-misc: convert snprintf calls to xasprintfWilliam Hubbs
2018-05-22librc: Add check for crashed stateWilliam Hubbs
In rc_service_state,, call rc_service_daemons_crashed to check for a crashed daemon if the service is started.
2018-05-22librc: Add crashed stateWilliam Hubbs
2017-11-30Fix repeated dependency cache rebuild if clock skewedWill Miles
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-13rc_find_pids: namespace fixWilliam Hubbs
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-10-26rc_service_value_set: remove the option if NULL is the valueWilliam Hubbs
This allows the equivalent of "unsetting" a value for a service.
2017-10-24rc_find_pids: ignore pids that are not in our pid namespaceWilliam Hubbs
X-Gentoo-Bug: 634634 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=634634
2017-04-06add init processWilliam Hubbs
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-01-04Clean up warnings that can use the _unused macroBenda Xu
X-Gentoo-Bug: 604666 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604666
2016-12-19librc: detect loops in stacked runlevels and abortDoug Freed
This fixes #109. X-Gentoo-Bug: 558700 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=558700
2016-07-31librc: fix Docker auto detectionWilliam Hubbs
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-14Remove the DEBUG_MEMORY macroWilliam Hubbs
This fixes #43.
2016-01-21librc: Complain when a real and virtual service have the same nameWilliam Hubbs
2016-01-19librc: handle rc_sys="prefix" even if we weren't built with a prefixDoug Freed
This probably isn't needed, but it mimics old behavior.
2016-01-19librc: fix handling the nothing special case for rc_sysDoug Freed
2016-01-19librc: move system detection code into rc_sys and use itDoug Freed
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-18Revert "librc: fix librc-depend functions to call rc_sys"William Hubbs
This reverts commit 73482cf13a338051606788957cbd0031ac850c70.
2016-01-18librc: fix librc-depend functions to call rc_sysWilliam Hubbs
2015-12-21Convert OpenRC to a centralized copyright/license structureWilliam Hubbs
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-08rc.map: remove references to rc_sys_v{1,2}William Hubbs
2015-12-08Convert rc_sys() calls to detect_container() and detect_vm()William Hubbs
2015-12-02Add detection for rkt containersWilliam Hubbs
2015-12-02Add detection for docker containersWilliam Hubbs
2015-12-01librc: comsolidate rc_sys_v1 and rc_sys_v2 into rc_sysWilliam Hubbs
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-11-12Implement "want" dependencyIan Stakenvicius
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-11Standardize macro tests for gnu hurdBenda Xu
This also fixes breakage of GNU/hurd builds introduced by commit 3f82edbeb92.
2015-11-05librc: rework overriding rc.conf options from the kclWilliam Hubbs
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-05librc: Remove redundant code from rc_config_loadWilliam Hubbs
2015-11-05Add rc.conf.d supportWilliam Hubbs
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-05-04librc: Fix crash if the service name is the same as the including runlevelJakob Drexel
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-01Add support for systemd-nspawn containersWilliam Hubbs
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-04-27convert all references from runscript to openrc-runWilliam Hubbs
2015-03-24Fix some compiler warningsDoug Freed
librc: Fix C90 warning (mixed declaration and code) rc: Fix warning about discarding const qualifier Fixes #45.
2015-01-24Prioritize local includes and librariesWill Miles
This fixes #35.
2015-01-12fix double free of pidfileDoug Freed
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