chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mkdir: append _label to all mkdir() calls that explicitly set the selinux context
[elogind.git]
/
src
/
rc-local-generator
/
rc-local-generator.c
diff --git
a/src/rc-local-generator/rc-local-generator.c
b/src/rc-local-generator/rc-local-generator.c
index 42d7ae41edd5ad97f2b0ccef898fc9e04e6553ec..f41a6bf265f9f0a5fdcec807baa0aa10f0ccedc2 100644
(file)
--- a/
src/rc-local-generator/rc-local-generator.c
+++ b/
src/rc-local-generator/rc-local-generator.c
@@
-29,21
+29,23
@@
#include "mkdir.h"
#if defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA) || defined(TARGET_MAGEIA)
#include "mkdir.h"
#if defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA) || defined(TARGET_MAGEIA)
-#define SCRIPT_PATH "/etc/rc.d/rc.local"
+#define SCRIPT_PATH
_START
"/etc/rc.d/rc.local"
#elif defined(TARGET_SUSE)
#elif defined(TARGET_SUSE)
-#define SCRIPT_PATH "/etc/init.d/boot.local"
+#define SCRIPT_PATH
_START
"/etc/init.d/boot.local"
#endif
#endif
+#define SCRIPT_PATH_STOP "/sbin/halt.local"
+
const char *arg_dest = "/tmp";
const char *arg_dest = "/tmp";
-static int add_symlink(const char *service) {
+static int add_symlink(const char *service
, const char *where
) {
char *from = NULL, *to = NULL;
int r;
assert(service);
asprintf(&from, SYSTEM_DATA_UNIT_PATH "/%s", service);
char *from = NULL, *to = NULL;
int r;
assert(service);
asprintf(&from, SYSTEM_DATA_UNIT_PATH "/%s", service);
- asprintf(&to, "%s/
multi-user.target.wants/%s", arg_dest
, service);
+ asprintf(&to, "%s/
%s.wants/%s", arg_dest, where
, service);
if (!from || !to) {
log_error("Out of memory");
if (!from || !to) {
log_error("Out of memory");
@@
-51,7
+53,7
@@
static int add_symlink(const char *service) {
goto finish;
}
goto finish;
}
- mkdir_parents(to, 0755);
+ mkdir_parents
_label
(to, 0755);
r = symlink(from, to);
if (r < 0) {
r = symlink(from, to);
if (r < 0) {
@@
-64,7
+66,6
@@
static int add_symlink(const char *service) {
}
finish:
}
finish:
-
free(from);
free(to);
free(from);
free(to);
@@
-81,27
+82,34
@@
static bool file_is_executable(const char *f) {
}
int main(int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
-
int r = EXIT_SUCCESS;
int r = EXIT_SUCCESS;
- if (argc >
2
) {
- log_error("This program takes
on
e or no arguments.");
+ if (argc >
1 && argc != 4
) {
+ log_error("This program takes
thre
e or no arguments.");
return EXIT_FAILURE;
}
return EXIT_FAILURE;
}
- log_set_target(LOG_TARGET_AUTO);
+ if (argc > 1)
+ arg_dest = argv[1];
+
+ log_set_target(LOG_TARGET_SAFE);
log_parse_environment();
log_open();
log_parse_environment();
log_open();
- if (argc > 1)
- arg_dest = argv[1];
+ umask(0022);
- if (file_is_executable(SCRIPT_PATH)) {
+ if (file_is_executable(SCRIPT_PATH
_START
)) {
log_debug("Automatically adding rc-local.service.");
log_debug("Automatically adding rc-local.service.");
- if (add_symlink("rc-local.service") < 0)
+ if (add_symlink("rc-local.service"
, "multi-user.target"
) < 0)
r = EXIT_FAILURE;
r = EXIT_FAILURE;
+ }
+ if (file_is_executable(SCRIPT_PATH_STOP)) {
+ log_debug("Automatically adding halt-local.service.");
+
+ if (add_symlink("halt-local.service", "final.target") < 0)
+ r = EXIT_FAILURE;
}
return r;
}
return r;