[systemd-devel] [PATCH 1/1] RFC: Set the Default OOM Score from configuration file

2013-04-27 Thread Sangjung Woo
If 'OOMScoreAdjust' option is ommited from unit file, this patch makes
the executed process's oom_score_adj as default OOM score in case of
explicitly 'DefaultOOMScore' is declared in configuration file.
(i.e. system.conf and user.conf)

If the unit file has 'OOMScoreAdjust' option, set the its oom_score_adj
as declared value as before.

Signed-off-by: Sangjung Woo 
---
 src/core/main.c  |8 
 src/core/system.conf |1 +
 src/core/user.conf   |1 +
 3 files changed, 10 insertions(+)

diff --git a/src/core/main.c b/src/core/main.c
index 22cec4e..e8bb015 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -90,6 +90,7 @@ static bool arg_confirm_spawn = false;
 static bool arg_show_status = true;
 static bool arg_switched_root = false;
 static char **arg_default_controllers = NULL;
+static char *arg_default_oom_score = NULL;
 static char ***arg_join_controllers = NULL;
 static ExecOutput arg_default_std_output = EXEC_OUTPUT_JOURNAL;
 static ExecOutput arg_default_std_error = EXEC_OUTPUT_INHERIT;
@@ -641,6 +642,7 @@ static int parse_config_file(void) {
 { "Manager", "DefaultStandardOutput", config_parse_output, 
  0, &arg_default_std_output  },
 { "Manager", "DefaultStandardError",  config_parse_output, 
  0, &arg_default_std_error   },
 { "Manager", "JoinControllers",   
config_parse_join_controllers, 0, &arg_join_controllers },
+{ "Manager", "DefaultOOMScore",   config_parse_string, 
  0, &arg_default_oom_score   },
 { "Manager", "RuntimeWatchdogSec",config_parse_sec,
  0, &arg_runtime_watchdog},
 { "Manager", "ShutdownWatchdogSec",   config_parse_sec,
  0, &arg_shutdown_watchdog   },
 { "Manager", "CapabilityBoundingSet", 
config_parse_bounding_set, 0, &arg_capability_bounding_set_drop },
@@ -1414,6 +1416,12 @@ int main(int argc, char *argv[]) {
 if (parse_config_file() < 0)
 goto finish;
 
+if (arg_default_oom_score)
+if (write_string_file("/proc/self/oom_score_adj", 
arg_default_oom_score) < 0){
+log_error("Fail to set default oom_score_adj: %s", 
arg_default_oom_score);
+goto finish;
+}
+
 if (arg_running_as == SYSTEMD_SYSTEM)
 if (parse_proc_cmdline() < 0)
 goto finish;
diff --git a/src/core/system.conf b/src/core/system.conf
index 508e0f5..7c0e12e 100644
--- a/src/core/system.conf
+++ b/src/core/system.conf
@@ -41,3 +41,4 @@
 #DefaultLimitNICE=
 #DefaultLimitRTPRIO=
 #DefaultLimitRTTIME=
+#DefaultOOMScore=
diff --git a/src/core/user.conf b/src/core/user.conf
index 4252451..f101e99 100644
--- a/src/core/user.conf
+++ b/src/core/user.conf
@@ -15,3 +15,4 @@
 #DefaultControllers=cpu
 #DefaultStandardOutput=inherit
 #DefaultStandardError=inherit
+#DefaultOOMScore=
-- 
1.7.10.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] systemctl: bugfix for systemctl reboot command with argument

2015-01-23 Thread Sangjung Woo
According to systemctl man page, 'systemctl reboot [arg]' should work
without any errors. However, it does not work because of 'Invalid number
of arguments' error, except for 'reboot [arg]'. This patch fixes the bug
so that both of commands work in exactly the same way.

Signed-off-by: Sangjung Woo 
---
 src/systemctl/systemctl.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index cdc1a50..0764907 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2955,6 +2955,12 @@ static int start_special(sd_bus *bus, char **args) {
 return -EPERM;
 }
 
+if (a == ACTION_REBOOT) {
+r = update_reboot_param_file(args[1]);
+if (r < 0)
+return r;
+}
+
 if (arg_force >= 2 &&
 (a == ACTION_HALT ||
  a == ACTION_POWEROFF ||
@@ -7071,7 +7077,7 @@ static int systemctl_main(sd_bus *bus, int argc, char 
*argv[], int bus_error) {
 { "import-environment",MORE,  1, import_environment},
 { "halt",  EQUAL, 1, start_special,FORCE },
 { "poweroff",  EQUAL, 1, start_special,FORCE },
-{ "reboot",EQUAL, 1, start_special,FORCE },
+{ "reboot",MORE,  1, start_special,FORCE },
 { "kexec", EQUAL, 1, start_special },
 { "suspend",   EQUAL, 1, start_special },
 { "hibernate", EQUAL, 1, start_special },
-- 
1.7.9.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] sd_daemon: use secure_getenv() instead of getenv()

2015-01-23 Thread Sangjung Woo
According to the glibc manual, secure_getenv() is more trustful than
getenv() since it returns a null pointer if the environment is untrusted
such as setting SUID or SGID bits. Moreover, libraries should use
secure_getenv().
(http://www.gnu.org/software/libc/manual/html_node/Environment-Access.html)

Signed-off-by: Sangjung Woo 
---
 src/libsystemd/sd-daemon/sd-daemon.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/libsystemd/sd-daemon/sd-daemon.c 
b/src/libsystemd/sd-daemon/sd-daemon.c
index 028c2a7..86e6aed 100644
--- a/src/libsystemd/sd-daemon/sd-daemon.c
+++ b/src/libsystemd/sd-daemon/sd-daemon.c
@@ -46,7 +46,7 @@ _public_ int sd_listen_fds(int unset_environment) {
 int r, fd;
 pid_t pid;
 
-e = getenv("LISTEN_PID");
+e = secure_getenv("LISTEN_PID");
 if (!e) {
 r = 0;
 goto finish;
@@ -62,7 +62,7 @@ _public_ int sd_listen_fds(int unset_environment) {
 goto finish;
 }
 
-e = getenv("LISTEN_FDS");
+e = secure_getenv("LISTEN_FDS");
 if (!e) {
 r = 0;
 goto finish;
@@ -374,7 +374,7 @@ _public_ int sd_pid_notify_with_fds(pid_t pid, int 
unset_environment, const char
 goto finish;
 }
 
-e = getenv("NOTIFY_SOCKET");
+e = secure_getenv("NOTIFY_SOCKET");
 if (!e)
 return 0;
 
@@ -525,7 +525,7 @@ _public_ int sd_watchdog_enabled(int unset_environment, 
uint64_t *usec) {
 uint64_t u;
 int r = 0;
 
-s = getenv("WATCHDOG_USEC");
+s = secure_getenv("WATCHDOG_USEC");
 if (!s)
 goto finish;
 
@@ -537,7 +537,7 @@ _public_ int sd_watchdog_enabled(int unset_environment, 
uint64_t *usec) {
 goto finish;
 }
 
-p = getenv("WATCHDOG_PID");
+p = secure_getenv("WATCHDOG_PID");
 if (p) {
 pid_t pid;
 
-- 
1.7.9.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] tmpfiles: Remove unnecessary blank line when configured with "--disable-resolved"

2015-02-02 Thread Sangjung Woo
This patch removes unnecessary blank line in
/usr/lib/tmpfiles.d/etc.conf when configured with "--disable-resolved".
(i.e. ENABLE_RESOLVED is not defined)

Signed-off-by: Sangjung Woo 
---
 tmpfiles.d/etc.conf.m4 |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tmpfiles.d/etc.conf.m4 b/tmpfiles.d/etc.conf.m4
index f567c8d..9b0e080 100644
--- a/tmpfiles.d/etc.conf.m4
+++ b/tmpfiles.d/etc.conf.m4
@@ -12,6 +12,6 @@ L /etc/localtime - - - - ../usr/share/zoneinfo/UTC
 L+ /etc/mtab - - - - ../proc/self/mounts
 m4_ifdef(`ENABLE_RESOLVED',
 L /etc/resolv.conf - - - - ../run/systemd/resolve/resolv.conf
-)
+)m4_dnl
 C /etc/nsswitch.conf - - - -
 C /etc/pam.d - - - -
-- 
1.7.9.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] core: mount only 4 partition in mount_setup_early()

2014-08-06 Thread Sangjung Woo
systemd doesn't mount smackfs if systemd was compiled without Smack
support. However, the number of mount point entry in mount_setup_early()
(i.e. N_EARLY_MOUNT) is 5 since smackfs is included. N_EARLY_MOUNT
should be 4 because currently smackfs is optional.

Signed-off-by: Sangjung Woo 
---
 src/core/mount-setup.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index 206f89a..f15647b 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -64,7 +64,7 @@ typedef struct MountPoint {
 /* The first three entries we might need before SELinux is up. The
  * fourth (securityfs) is needed by IMA to load a custom policy. The
  * other ones we can delay until SELinux and IMA are loaded. */
-#define N_EARLY_MOUNT 5
+#define N_EARLY_MOUNT 4
 
 static const MountPoint mount_table[] = {
 { "sysfs",  "/sys",  "sysfs",  NULL, 
MS_NOSUID|MS_NOEXEC|MS_NODEV,
-- 
1.7.9.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel