chiark / gitweb /
use "Out of memory." consistantly (or with "\n")
[elogind.git] / src / rc-local-generator / rc-local-generator.c
index a5987f977e0527a4dcdd54f29468129d1f06fceb..9fafa29f2212919a8385f6abda195e146df78867 100644 (file)
@@ -48,12 +48,12 @@ static int add_symlink(const char *service, const char *where) {
         asprintf(&to, "%s/%s.wants/%s", arg_dest, where, service);
 
         if (!from || !to) {
-                log_error("Out of memory");
+                log_error("Out of memory.");
                 r = -ENOMEM;
                 goto finish;
         }
 
-        mkdir_parents(to, 0755);
+        mkdir_parents_label(to, 0755);
 
         r = symlink(from, to);
         if (r < 0) {
@@ -66,7 +66,6 @@ static int add_symlink(const char *service, const char *where) {
         }
 
 finish:
-
         free(from);
         free(to);
 
@@ -83,20 +82,21 @@ static bool file_is_executable(const char *f) {
 }
 
 int main(int argc, char *argv[]) {
-
         int r = EXIT_SUCCESS;
 
-        if (argc > 2) {
-                log_error("This program takes one or no arguments.");
+        if (argc > 1 && argc != 4) {
+                log_error("This program takes three or no arguments.");
                 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();
 
-        if (argc > 1)
-                arg_dest = argv[1];
+        umask(0022);
 
         if (file_is_executable(SCRIPT_PATH_START)) {
                 log_debug("Automatically adding rc-local.service.");