Skip to content

Commit

Permalink
Merge branch 'v239-stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamakuzure committed Oct 16, 2018
2 parents 5319c95 + 7f1e80b commit ca59daa
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 17 deletions.
5 changes: 5 additions & 0 deletions cb/elogind.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,11 @@
<Option target="all" />
<Option target="clean" />
</Unit>
<Unit filename="../tools/meson-build.sh" />
<Unit filename="../tools/meson-check-compilation.sh" />
<Unit filename="../tools/meson-link-test.c">
<Option compilerVar="CC" />
</Unit>
<Extensions>
<envvars />
<code_completion />
Expand Down
16 changes: 16 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,22 @@ else
conf.set10('HAVE_GETRANDOM', have)
endif

#if 1 /// elogind shall be usable with non-glibc libc variations
#####################################################################
# Find out whether program_invocation[_short]_name is supported
have_pisn = cc.links('''
#define _GNU_SOURCE 1
#include <errno.h>
int main(void) {
if (program_invocation_name && program_invocation_short_name)
return 0;
return 1;
}
''', name : 'program_invocation[_short]_name test')
conf.set10('HAVE_PROGRAM_INVOCATION_NAME', have_pisn,
description : 'program_invocation[_short]_name is provided by libc')

#endif // 1
#####################################################################

sed = find_program('sed')
Expand Down
12 changes: 9 additions & 3 deletions src/core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ libcore_la_sources = files('''
'''.split())
#endif // 0

#if 0 /// The rest is not needed by elogind, we use the sources directly in login
#if 0 /// Almost the rest is not needed by elogind, we use the sources directly in login
# load_fragment_gperf_gperf = custom_target(
# 'load-fragment-gperf.gperf',
# input : 'load-fragment-gperf.gperf.m4',
Expand Down Expand Up @@ -218,8 +218,14 @@ libcore_la_sources = files('''
# install_data('user.conf',
# install_dir : pkgsysconfdir)
#
# meson.add_install_script('sh', '-c', mkdir_p.format(systemshutdowndir))
# meson.add_install_script('sh', '-c', mkdir_p.format(systemsleepdir))
#endif // 0
meson.add_install_script('sh', '-c', mkdir_p.format(systemshutdowndir))
meson.add_install_script('sh', '-c', mkdir_p.format(systemsleepdir))
#if 1 /// some package sytems like portage might strip empty directories created for elogind
meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@/.keep_dir'.format(systemshutdowndir))
meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@/.keep_dir'.format(systemsleepdir))
#endif // 1
#if 0 /// UNNEEDED by elogind
# meson.add_install_script('sh', '-c', mkdir_p.format(systemgeneratordir))
# meson.add_install_script('sh', '-c', mkdir_p.format(usergeneratordir))
#
Expand Down
18 changes: 13 additions & 5 deletions src/login/elogind-dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


#include "elogind-dbus.h"
#include "exec-util.h"
#include "process-util.h"
#include "sd-messages.h"
#include "sleep.h"
Expand Down Expand Up @@ -74,9 +75,16 @@ static int bus_manager_log_shutdown(
}

/* elogind specific helper to make HALT and REBOOT possible. */
static int run_helper(const char *helper) {
static int run_helper(const char *helper, const char *arg_verb) {
char *arguments[3];
static const char* const dirs[] = { SYSTEM_SHUTDOWN_PATH, NULL };
int r = 0;

arguments[0] = NULL;
arguments[1] = (char*)arg_verb;
arguments[2] = NULL;
execute_directories(dirs, DEFAULT_TIMEOUT_USEC, NULL, NULL, arguments);

r = safe_fork_full(helper, NULL, 0, FORK_RESET_SIGNALS|FORK_REOPEN_LOG, NULL);

if (r < 0)
Expand All @@ -99,13 +107,13 @@ static int shutdown_or_sleep(Manager *m, HandleAction action) {

switch (action) {
case HANDLE_POWEROFF:
return run_helper(POWEROFF);
return run_helper(POWEROFF, "poweroff");
case HANDLE_REBOOT:
return run_helper(REBOOT);
return run_helper(REBOOT, "reboot");
case HANDLE_HALT:
return run_helper(HALT);
return run_helper(HALT, "halt");
case HANDLE_KEXEC:
return run_helper(KEXEC);
return run_helper(KEXEC, "kexec");
case HANDLE_SUSPEND:
return do_sleep(m, "suspend");
case HANDLE_HIBERNATE:
Expand Down
2 changes: 2 additions & 0 deletions src/login/logind-dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -2440,7 +2440,9 @@ static int method_can_shutdown_or_sleep(
action, result);
}

#if 0 /// UNNEEDED by elogind
finish:
#endif // 0
return sd_bus_reply_method_return(message, "s", result);
}

Expand Down
8 changes: 4 additions & 4 deletions src/shared/musl_missing.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

#include "alloc-util.h"

#ifndef __GLIBC__
#if HAVE_PROGRAM_INVOCATION_NAME == 0
char *program_invocation_name = NULL;
char *program_invocation_short_name = NULL;
#endif // __GLIBC__
#endif // libc does not provide these variables

const char *program_arg_name = NULL;

Expand Down Expand Up @@ -55,8 +55,8 @@ void elogind_set_program_name(const char* pcall) {
program_invocation_name = strdup(program_arg_name);
if (NULL == program_invocation_short_name)
program_invocation_short_name = strdup(basename(program_arg_name));
#ifndef __GLIBC__
#if HAVE_PROGRAM_INVOCATION_NAME == 0
atexit(elogind_free_program_name);
#endif // __GLIBC__
#endif // libc does not provide these variables
}

5 changes: 0 additions & 5 deletions src/shared/musl_missing.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ void elogind_set_program_name(const char* pcall);

#define strerror_r(e, m, k) (strerror_r(e, m, k) < 0 ? strdup("strerror_r() failed") : m);

#ifndef _ERRNO_H
extern char *program_invocation_name;
extern char *program_invocation_short_name;
#endif // errno.h included beforehand

/*
* Possibly TODO according to http://man7.org/linux/man-pages/man3/getenv.3.html
* + test if the process's effective user ID does not match its real user ID or
Expand Down

0 comments on commit ca59daa

Please sign in to comment.