Skip to content

Commit

Permalink
Merge branch 'master' into rc-status-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
williamh authored Sep 25, 2024
2 parents 6d586dc + cadc1d2 commit 82e41fe
Show file tree
Hide file tree
Showing 23 changed files with 94 additions and 179 deletions.
19 changes: 0 additions & 19 deletions FEATURE-REMOVAL-SCHEDULE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ Why: Obsolete or replaced by other options.

Who:

# runscript and rc symbolic links

When: 1.0

Why: Deprecated in favor of openrc-run and openrc due to naming
conflicts with other software.

Who:

# support for the opts variable in service scripts

When: 1.0
Expand Down Expand Up @@ -67,13 +58,3 @@ Who:
If you have a c program that links to librc and uses functions from
there, this section will list API functions which are deprecated and
will be removed along with the reason they are being removed.

## rc_getline()

When: 1.0

Why: The getline() function was standardized in POSIX.1-2008, so it
should be available on POSIX systems.

Who:

13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ We don't support building a static OpenRC with PAM.
`LOCAL_PREFIX` should be set to where user maintained packages are.
Only set `LOCAL_PREFIX` if different from `PKG_PREFIX`.

`ROOTPREFIX` should be set when the root path is different from '/'.

`rc` and `rc.shutdown` are the hooks from the BSD init into OpenRC.

`devd.conf` is modified from FreeBSD to call `/etc/rc.devd` which is a
Expand All @@ -32,6 +30,17 @@ Obviously, if you're installing this onto a system that does not use
OpenRC by default then you may wish to backup the above listed files,
remove them and then install so that the OS hooks into OpenRC.

If you are installing this onto a system which has separate / and /usr
file systems and expects / to be mounted before /usr, you will need to
make sure the appropriate pieces are installed on / by passing the
appropriate options to "meson setup" as follows:

```
$ meson setup \
--bindir /bin --libdir /lib64 --libexecdir /lib --sbindir /sbin \
build_path
```

## Discussions

We are testing [discussions](https://github.com/OpenRC/openrc/discussions), so
Expand Down
3 changes: 0 additions & 3 deletions man/openrc-run.8
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,6 @@ Default runlevel chosen. Default is default.
.It Va RC_SYS
A special variable to describe the system more.
Possible values are OPENVZ, XENU, XEN0, UML and VSERVER.
.It Va RC_PREFIX
In a Gentoo Prefix installation, this variable contains the prefix
offset. Otherwise it is undefined.
.It Va RC_UNAME
The result of `uname -s`.
.It Va RC_CMD
Expand Down
20 changes: 6 additions & 14 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,15 @@ else
pkg_prefix = option_pkg_prefix
endif

rootprefix = get_option('rootprefix')
if rootprefix == ''
rootprefix = '/'
endif

bindir = rootprefix / get_option('bindir')
libdir = rootprefix / get_option('libdir')
libexecdir = get_option('libexecdir')
if os == 'Linux' and libexecdir == 'libexec'
libexecdir = 'lib'
endif
libexecdir = rootprefix / libexecdir
bindir = get_option('prefix') / get_option('bindir')
libdir = get_option('prefix') / get_option('libdir')
pluginsdir = libdir / 'rc/plugins'
libexecdir = get_option('prefix') / get_option('libexecdir')
rc_libexecdir = libexecdir / 'rc'
rc_bindir = rc_libexecdir / 'bin'
rc_sbindir = rc_libexecdir / 'sbin'
rc_shdir = rc_libexecdir / 'sh'
sbindir = rootprefix / get_option('sbindir')
sbindir = get_option('prefix') / get_option('sbindir')
pamdir = get_option('sysconfdir') / 'pam.d'

crypt_dep = []
Expand Down Expand Up @@ -230,7 +222,7 @@ if get_option('pkgconfig')
libraries : librc,
subdirs : ['openrc'],
variables: {
'rc_path': rc_libexecdir,
'pluginsdir': pluginsdir,
}
)
endif
Expand Down
2 changes: 0 additions & 2 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ option('pkg_prefix', type : 'string',
description : 'default location where packages are installed')
option('pkgconfig', type : 'boolean',
description : 'build PKGConfig files')
option('rootprefix', type : 'string',
description : 'override the root prefix')
option('selinux', type : 'feature', value : 'auto',
description : 'enable SELinux support')
option('shell', type : 'string', value : '/bin/sh',
Expand Down
8 changes: 1 addition & 7 deletions sh/functions.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,10 @@ if [ -n "$ZSH_VERSION" ]; then
fi

# Make a sane PATH
_PREFIX=@PREFIX@
_PKG_PREFIX=@PKG_PREFIX@
_LOCAL_PREFIX=@LOCAL_PREFIX@
_LOCAL_PREFIX=${_LOCAL_PREFIX:-/usr/local}
_PATH=@LIBEXECDIR@/bin
case "$_PREFIX" in
"$_PKG_PREFIX"|"$_LOCAL_PREFIX") ;;
*) _PATH="$_PATH:$_PREFIX/bin:$_PREFIX/sbin";;
esac
_PATH="$_PATH":/bin:/sbin:/usr/bin:/usr/sbin
_PATH="@LIBEXECDIR@/bin:/bin:/sbin:/usr/bin:/usr/sbin"

if [ -n "$_PKG_PREFIX" ]; then
_PATH="$_PATH:$_PKG_PREFIX/bin:$_PKG_PREFIX/sbin"
Expand Down
5 changes: 0 additions & 5 deletions sh/meson.build
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
sh_conf_data = configuration_data()
if rootprefix == '/'
sh_conf_data.set('PREFIX', '')
else
sh_conf_data.set('PREFIX', rootprefix)
endif
sh_conf_data.set('BINDIR', bindir)
sh_conf_data.set('LIBEXECDIR', rc_libexecdir)
sh_conf_data.set('LOCAL_PREFIX', local_prefix)
Expand Down
2 changes: 1 addition & 1 deletion src/kill_all/kill_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static bool is_user_process(pid_t pid)
temp_pid = -1;
while (!feof(fp)) {
buf = NULL;
if (getline(&buf, &size, fp) != -1) {
if (xgetline(&buf, &size, fp) != -1) {
sscanf(buf, "PPid: %d", &temp_pid);
free(buf);
} else {
Expand Down
10 changes: 4 additions & 6 deletions src/librc/librc-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
if (exists("/proc/self/status")) {
fp = fopen("/proc/self/status", "r");
if (fp) {
while (!feof(fp)) {
rc_getline(&line, &len, fp);
while (xgetline(&line, &len, fp) != -1) {
if (strncmp(line, "envID:\t0", 8) == 0) {
openvz_host = true;
break;
Expand Down Expand Up @@ -196,8 +195,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
free(buffer);
if (!fp)
continue;
while (!feof(fp)) {
rc_getline(&line, &len, fp);
while (xgetline(&line, &len, fp) != -1) {
if (strncmp(line, "envID:", 6) == 0) {
container_pid = !(strncmp(line, "envID:\t0", 8) == 0);
break;
Expand Down Expand Up @@ -346,7 +344,7 @@ _match_daemon(const char *path, const char *file, RC_STRINGLIST *match)
if (!fp)
return false;

while ((rc_getline(&line, &len, fp))) {
while (xgetline(&line, &len, fp) != -1) {
TAILQ_FOREACH(m, match, entries)
if (strcmp(line, m->value) == 0) {
TAILQ_REMOVE(match, m, entries);
Expand Down Expand Up @@ -559,7 +557,7 @@ rc_service_daemons_crashed(const char *service)
if (!fp)
break;

while ((rc_getline(&line, &len, fp))) {
while (xgetline(&line, &len, fp) != -1) {
p = line;
if ((token = strsep(&p, "=")) == NULL || !p)
continue;
Expand Down
14 changes: 5 additions & 9 deletions src/librc/librc-depend.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ rc_deptree_load_file(const char *deptree_file)
RC_DEPINFO *depinfo = NULL;
RC_DEPTYPE *deptype = NULL;
char *line = NULL;
size_t len = 0;
ssize_t size;
size_t size;
char *type;
char *p;
char *e;
Expand All @@ -171,8 +170,7 @@ rc_deptree_load_file(const char *deptree_file)
return NULL;

deptree = make_deptree();
while ((size = getline(&line, &len, fp)) != -1) {
line[size - 1] = '\0';
while (xgetline(&line, &size, fp) != -1) {
p = line;
e = strsep(&p, "_");
if (!e || strcmp(e, "depinfo") != 0)
Expand Down Expand Up @@ -788,8 +786,7 @@ rc_deptree_update(void)
RC_STRINGLIST *config, *dupes, *types, *sorted, *visited;
RC_STRING *s, *s2, *s2_np, *s3, *s4;
char *line = NULL;
size_t len = 0;
ssize_t size;
size_t size;
char *depend, *depends, *service, *type;
size_t i, l;
bool retval = true;
Expand All @@ -811,8 +808,7 @@ rc_deptree_update(void)
config = rc_stringlist_new();

deptree = make_deptree();
while ((size = getline(&line, &len, fp)) != -1) {
line[size - 1] = '\0';
while (xgetline(&line, &size, fp) != -1) {
depends = line;
service = strsep(&depends, " ");
if (!service || !*service)
Expand Down Expand Up @@ -894,8 +890,8 @@ rc_deptree_update(void)
* work for them. This doesn't stop them from being run directly. */
if (sys) {
char *nosys, *onosys;
size_t len = strlen(sys);

len = strlen(sys);
nosys = xmalloc(len + 2);
nosys[0] = '-';
for (i = 0; i < len; i++)
Expand Down
30 changes: 2 additions & 28 deletions src/librc/librc-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,38 +102,13 @@ rc_getfile(const char *file, char **buffer, size_t *len)
return ret;
}

ssize_t
rc_getline(char **line, size_t *len, FILE *fp)
{
char *p;
size_t last = 0;

while (!feof(fp)) {
if (*line == NULL || last != 0) {
*len += BUFSIZ;
*line = xrealloc(*line, *len);
}
p = *line + last;
memset(p, 0, BUFSIZ);
if (fgets(p, BUFSIZ, fp) == NULL)
break;
last += strlen(p);
if (last && (*line)[last - 1] == '\n') {
(*line)[last - 1] = '\0';
break;
}
}
return last;
}

char *
rc_proc_getent(const char *ent RC_UNUSED)
{
#ifdef __linux__
FILE *fp;
char *proc = NULL, *p, *value = NULL, *save;
size_t i, len;
ssize_t size;

if (!exists("/proc/cmdline"))
return NULL;
Expand All @@ -142,11 +117,10 @@ rc_proc_getent(const char *ent RC_UNUSED)
return NULL;

i = 0;
if ((size = getline(&proc, &i, fp)) == -1) {
if (xgetline(&proc, &i, fp) == -1) {
free(proc);
return NULL;
}
proc[size - 1] = '\0';
save = proc;

len = strlen(ent);
Expand Down Expand Up @@ -184,7 +158,7 @@ rc_config_list(const char *file)
if (!(fp = fopen(file, "r")))
return list;

while ((rc_getline(&buffer, &len, fp))) {
while (xgetline(&buffer, &len, fp) != -1) {
p = buffer;
/* Strip leading spaces/tabs */
while ((*p == ' ') || (*p == '\t'))
Expand Down
Loading

0 comments on commit 82e41fe

Please sign in to comment.