[systemd-devel] [PATCH] Add SHELL environment variable

2013-09-23 Thread Evan Callicoat
With the advent of systemd --user sessions, it's become very interesting to 
spawn X as a user unit, as well as accompanying processes that may have 
previously been in a .xinitrc/.xsession, or even just to replace a collection 
of XDG/GDM/KDM/etc session files with independent systemd --user units. The 
simplest case here would be to login on a tty, with the traditional 
/usr/sbin/login "login manager".

However, systemd --user (spawned by user@.service) is at the top level of the 
slice for the user, and does not inherit any environment variables from the 
login process. Given the number of common applications which rely on SHELL 
being set in the environment, it seems like the cleanest way to provide this 
variable is to set it to %s in the user@.service.

Ideally in the long-term, applications which rely on SHELL being set should be 
fixed to just grab it from getpwnam() or similar, but until that becomes more 
common, I propose this simple change to make user sessions a little bit nicer 
out of the box.

---
 units/u...@.service.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/units/u...@.service.in b/units/u...@.service.in
index 3f8b59d..3718a57 100644
--- a/units/u...@.service.in
+++ b/units/u...@.service.in
@@ -13,6 +13,7 @@ After=systemd-user-sessions.service
 User=%I
 PAMName=systemd-user
 Type=notify
+Environment=SHELL=%s
 ExecStart=-@rootlibexecdir@/systemd --user
 
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%I/dbus/user_bus_socket
 Slice=user-%i.slice
-- 
1.8.3.1




signature.asc
Description: This is a digitally signed message part
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH v2 1/4] cgroup: add the setting memory.use_hierarchy support for systemd

2013-09-23 Thread Gao feng
On 09/24/2013 08:36 AM, Gao feng wrote:
> On 09/24/2013 05:06 AM, Lennart Poettering wrote:
>> On Mon, 23.09.13 14:30, Gao feng (gaof...@cn.fujitsu.com) wrote:
>>
>>> Some programs need to set the memory.use_hierarchy(such as libvirt),
>>> Add this feature.
>>
>> As mentioned already: this really shouldn't be configurable but simply
>> the unconditional configuration that systemd requires. I have hence now
>> commited a different patch that strictly enables this option at
>> boot-time in the root memory hierarchy and does not turn this into yet
>> another user config switch.
> 
> So administrator has no rights to set use_hierarchy to false?

If so, there is no need for kernel to export this file to user space.

> This patchset enables use_hierarchy for unit by default. but give
> users the rights to disable this.
> 
>>
>> THis is what Tejun suggested to do and is also what makes the most sense
>> to me. cgroups after all are organized logically in a tree and it is
>> simply contradictory ignore this all and pretend everything was flat...
>>
>>> ---
>>>  src/core/cgroup.c |  6 ++
>>>  src/core/cgroup.h |  1 +
>>>  src/core/dbus-cgroup.c| 16 
>>>  src/core/load-fragment-gperf.gperf.m4 |  1 +
>>>  4 files changed, 24 insertions(+)
>>>
>>> diff --git a/src/core/cgroup.c b/src/core/cgroup.c
>>> index d10f205..68615c3 100644
>>> --- a/src/core/cgroup.c
>>> +++ b/src/core/cgroup.c
>>> @@ -32,6 +32,7 @@ void cgroup_context_init(CGroupContext *c) {
>>>  /* Initialize everything to the kernel defaults, assuming the
>>>   * structure is preinitialized to 0 */
>>>  
>>> +c->memory_hierarchy = true;
>>>  c->cpu_shares = 1024;
>>>  c->memory_limit = (uint64_t) -1;
>>>  c->blockio_weight = 1000;
>>> @@ -263,6 +264,11 @@ void cgroup_context_apply(CGroupContext *c, 
>>> CGroupControllerMask mask, const cha
>>>  
>>>  if (r < 0)
>>>  log_error("Failed to set memory.limit_in_bytes on 
>>> %s: %s", path, strerror(-r));
>>> +
>>> +r = cg_set_attribute("memory", path, 
>>> "memory.use_hierarchy", c->memory_hierarchy ? "1" : "0");
>>> +
>>> +if (r < 0)
>>> +log_error("Failed to set memory.use_hierarchy on 
>>> %s: %s", path, strerror(-r));
>>>  }
>>>  
>>>  if (mask & CGROUP_DEVICE) {
>>> diff --git a/src/core/cgroup.h b/src/core/cgroup.h
>>> index 0a079e9..f87c16a 100644
>>> --- a/src/core/cgroup.h
>>> +++ b/src/core/cgroup.h
>>> @@ -69,6 +69,7 @@ struct CGroupContext {
>>>  bool cpu_accounting;
>>>  bool blockio_accounting;
>>>  bool memory_accounting;
>>> +bool memory_hierarchy;
>>>  
>>>  unsigned long cpu_shares;
>>>  
>>> diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
>>> index 9ebcad9..a8a5f81 100644
>>> --- a/src/core/dbus-cgroup.c
>>> +++ b/src/core/dbus-cgroup.c
>>> @@ -132,6 +132,7 @@ const BusProperty bus_cgroup_context_properties[] = {
>>>  { "BlockIOReadBandwidth",bus_cgroup_append_device_bandwidths, 
>>> "a(st)", 0   },
>>>  { "BlockIOWriteBandwidth",   bus_cgroup_append_device_bandwidths, 
>>> "a(st)", 0   },
>>>  { "MemoryAccounting",bus_property_append_bool,
>>> "b", offsetof(CGroupContext, memory_accounting)  },
>>> +{ "MemoryHierarchy", bus_property_append_bool,
>>> "b", offsetof(CGroupContext, memory_hierarchy)   },
>>>  { "MemoryLimit", bus_property_append_uint64,  
>>> "t", offsetof(CGroupContext, memory_limit)   },
>>>  { "DevicePolicy",bus_cgroup_append_device_policy, 
>>> "s", offsetof(CGroupContext, device_policy)  },
>>>  { "DeviceAllow", bus_cgroup_append_device_allow,  
>>> "a(ss)", 0   },
>>> @@ -417,6 +418,21 @@ int bus_cgroup_set_property(
>>>  
>>>  return 1;
>>>  
>>> +} else if (streq(name, "MemoryHierarchy")) {
>>> +
>>> +if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN)
>>> +return -EINVAL;
>>> +
>>> +if (mode != UNIT_CHECK) {
>>> +dbus_bool_t b;
>>> +dbus_message_iter_get_basic(i, &b);
>>> +
>>> +c->memory_hierarchy = b;
>>> +unit_write_drop_in_private(u, mode, name, b ? 
>>> "MemoryHierarchy=yes" : "MemoryHierarchy=no");
>>> +}
>>> +
>>> +return 1;
>>> +
>>>  } else if (streq(name, "MemoryLimit")) {
>>>  
>>>  if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_UINT64)
>>> diff --git a/src/core/load-fragment-gperf.gperf.m4 
>>> b/src/core/load-fragment-gperf.gperf.m4
>>> index 2

Re: [systemd-devel] [PATCH v2 1/4] cgroup: add the setting memory.use_hierarchy support for systemd

2013-09-23 Thread Gao feng
On 09/24/2013 05:06 AM, Lennart Poettering wrote:
> On Mon, 23.09.13 14:30, Gao feng (gaof...@cn.fujitsu.com) wrote:
> 
>> Some programs need to set the memory.use_hierarchy(such as libvirt),
>> Add this feature.
> 
> As mentioned already: this really shouldn't be configurable but simply
> the unconditional configuration that systemd requires. I have hence now
> commited a different patch that strictly enables this option at
> boot-time in the root memory hierarchy and does not turn this into yet
> another user config switch.

So administrator has no rights to set use_hierarchy to false?
This patchset enables use_hierarchy for unit by default. but give
users the rights to disable this.

> 
> THis is what Tejun suggested to do and is also what makes the most sense
> to me. cgroups after all are organized logically in a tree and it is
> simply contradictory ignore this all and pretend everything was flat...
> 
>> ---
>>  src/core/cgroup.c |  6 ++
>>  src/core/cgroup.h |  1 +
>>  src/core/dbus-cgroup.c| 16 
>>  src/core/load-fragment-gperf.gperf.m4 |  1 +
>>  4 files changed, 24 insertions(+)
>>
>> diff --git a/src/core/cgroup.c b/src/core/cgroup.c
>> index d10f205..68615c3 100644
>> --- a/src/core/cgroup.c
>> +++ b/src/core/cgroup.c
>> @@ -32,6 +32,7 @@ void cgroup_context_init(CGroupContext *c) {
>>  /* Initialize everything to the kernel defaults, assuming the
>>   * structure is preinitialized to 0 */
>>  
>> +c->memory_hierarchy = true;
>>  c->cpu_shares = 1024;
>>  c->memory_limit = (uint64_t) -1;
>>  c->blockio_weight = 1000;
>> @@ -263,6 +264,11 @@ void cgroup_context_apply(CGroupContext *c, 
>> CGroupControllerMask mask, const cha
>>  
>>  if (r < 0)
>>  log_error("Failed to set memory.limit_in_bytes on 
>> %s: %s", path, strerror(-r));
>> +
>> +r = cg_set_attribute("memory", path, 
>> "memory.use_hierarchy", c->memory_hierarchy ? "1" : "0");
>> +
>> +if (r < 0)
>> +log_error("Failed to set memory.use_hierarchy on 
>> %s: %s", path, strerror(-r));
>>  }
>>  
>>  if (mask & CGROUP_DEVICE) {
>> diff --git a/src/core/cgroup.h b/src/core/cgroup.h
>> index 0a079e9..f87c16a 100644
>> --- a/src/core/cgroup.h
>> +++ b/src/core/cgroup.h
>> @@ -69,6 +69,7 @@ struct CGroupContext {
>>  bool cpu_accounting;
>>  bool blockio_accounting;
>>  bool memory_accounting;
>> +bool memory_hierarchy;
>>  
>>  unsigned long cpu_shares;
>>  
>> diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
>> index 9ebcad9..a8a5f81 100644
>> --- a/src/core/dbus-cgroup.c
>> +++ b/src/core/dbus-cgroup.c
>> @@ -132,6 +132,7 @@ const BusProperty bus_cgroup_context_properties[] = {
>>  { "BlockIOReadBandwidth",bus_cgroup_append_device_bandwidths, 
>> "a(st)", 0   },
>>  { "BlockIOWriteBandwidth",   bus_cgroup_append_device_bandwidths, 
>> "a(st)", 0   },
>>  { "MemoryAccounting",bus_property_append_bool,
>> "b", offsetof(CGroupContext, memory_accounting)  },
>> +{ "MemoryHierarchy", bus_property_append_bool,
>> "b", offsetof(CGroupContext, memory_hierarchy)   },
>>  { "MemoryLimit", bus_property_append_uint64,  
>> "t", offsetof(CGroupContext, memory_limit)   },
>>  { "DevicePolicy",bus_cgroup_append_device_policy, 
>> "s", offsetof(CGroupContext, device_policy)  },
>>  { "DeviceAllow", bus_cgroup_append_device_allow,  
>> "a(ss)", 0   },
>> @@ -417,6 +418,21 @@ int bus_cgroup_set_property(
>>  
>>  return 1;
>>  
>> +} else if (streq(name, "MemoryHierarchy")) {
>> +
>> +if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN)
>> +return -EINVAL;
>> +
>> +if (mode != UNIT_CHECK) {
>> +dbus_bool_t b;
>> +dbus_message_iter_get_basic(i, &b);
>> +
>> +c->memory_hierarchy = b;
>> +unit_write_drop_in_private(u, mode, name, b ? 
>> "MemoryHierarchy=yes" : "MemoryHierarchy=no");
>> +}
>> +
>> +return 1;
>> +
>>  } else if (streq(name, "MemoryLimit")) {
>>  
>>  if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_UINT64)
>> diff --git a/src/core/load-fragment-gperf.gperf.m4 
>> b/src/core/load-fragment-gperf.gperf.m4
>> index 25bd3aa..b43ca05 100644
>> --- a/src/core/load-fragment-gperf.gperf.m4
>> +++ b/src/core/load-fragment-gperf.gperf.m4
>> @@ -88,6 +88,7 @@ m4_define(`CGROUP_CONTEXT_CONFIG_ITEMS',
>>  $1.CPUAccounting,config_pars

Re: [systemd-devel] [PATCH v2 1/4] cgroup: add the setting memory.use_hierarchy support for systemd

2013-09-23 Thread Lennart Poettering
On Mon, 23.09.13 14:30, Gao feng (gaof...@cn.fujitsu.com) wrote:

> Some programs need to set the memory.use_hierarchy(such as libvirt),
> Add this feature.

As mentioned already: this really shouldn't be configurable but simply
the unconditional configuration that systemd requires. I have hence now
commited a different patch that strictly enables this option at
boot-time in the root memory hierarchy and does not turn this into yet
another user config switch.

THis is what Tejun suggested to do and is also what makes the most sense
to me. cgroups after all are organized logically in a tree and it is
simply contradictory ignore this all and pretend everything was flat...

> ---
>  src/core/cgroup.c |  6 ++
>  src/core/cgroup.h |  1 +
>  src/core/dbus-cgroup.c| 16 
>  src/core/load-fragment-gperf.gperf.m4 |  1 +
>  4 files changed, 24 insertions(+)
> 
> diff --git a/src/core/cgroup.c b/src/core/cgroup.c
> index d10f205..68615c3 100644
> --- a/src/core/cgroup.c
> +++ b/src/core/cgroup.c
> @@ -32,6 +32,7 @@ void cgroup_context_init(CGroupContext *c) {
>  /* Initialize everything to the kernel defaults, assuming the
>   * structure is preinitialized to 0 */
>  
> +c->memory_hierarchy = true;
>  c->cpu_shares = 1024;
>  c->memory_limit = (uint64_t) -1;
>  c->blockio_weight = 1000;
> @@ -263,6 +264,11 @@ void cgroup_context_apply(CGroupContext *c, 
> CGroupControllerMask mask, const cha
>  
>  if (r < 0)
>  log_error("Failed to set memory.limit_in_bytes on 
> %s: %s", path, strerror(-r));
> +
> +r = cg_set_attribute("memory", path, "memory.use_hierarchy", 
> c->memory_hierarchy ? "1" : "0");
> +
> +if (r < 0)
> +log_error("Failed to set memory.use_hierarchy on %s: 
> %s", path, strerror(-r));
>  }
>  
>  if (mask & CGROUP_DEVICE) {
> diff --git a/src/core/cgroup.h b/src/core/cgroup.h
> index 0a079e9..f87c16a 100644
> --- a/src/core/cgroup.h
> +++ b/src/core/cgroup.h
> @@ -69,6 +69,7 @@ struct CGroupContext {
>  bool cpu_accounting;
>  bool blockio_accounting;
>  bool memory_accounting;
> +bool memory_hierarchy;
>  
>  unsigned long cpu_shares;
>  
> diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
> index 9ebcad9..a8a5f81 100644
> --- a/src/core/dbus-cgroup.c
> +++ b/src/core/dbus-cgroup.c
> @@ -132,6 +132,7 @@ const BusProperty bus_cgroup_context_properties[] = {
>  { "BlockIOReadBandwidth",bus_cgroup_append_device_bandwidths, 
> "a(st)", 0   },
>  { "BlockIOWriteBandwidth",   bus_cgroup_append_device_bandwidths, 
> "a(st)", 0   },
>  { "MemoryAccounting",bus_property_append_bool,
> "b", offsetof(CGroupContext, memory_accounting)  },
> +{ "MemoryHierarchy", bus_property_append_bool,
> "b", offsetof(CGroupContext, memory_hierarchy)   },
>  { "MemoryLimit", bus_property_append_uint64,  
> "t", offsetof(CGroupContext, memory_limit)   },
>  { "DevicePolicy",bus_cgroup_append_device_policy, 
> "s", offsetof(CGroupContext, device_policy)  },
>  { "DeviceAllow", bus_cgroup_append_device_allow,  
> "a(ss)", 0   },
> @@ -417,6 +418,21 @@ int bus_cgroup_set_property(
>  
>  return 1;
>  
> +} else if (streq(name, "MemoryHierarchy")) {
> +
> +if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN)
> +return -EINVAL;
> +
> +if (mode != UNIT_CHECK) {
> +dbus_bool_t b;
> +dbus_message_iter_get_basic(i, &b);
> +
> +c->memory_hierarchy = b;
> +unit_write_drop_in_private(u, mode, name, b ? 
> "MemoryHierarchy=yes" : "MemoryHierarchy=no");
> +}
> +
> +return 1;
> +
>  } else if (streq(name, "MemoryLimit")) {
>  
>  if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_UINT64)
> diff --git a/src/core/load-fragment-gperf.gperf.m4 
> b/src/core/load-fragment-gperf.gperf.m4
> index 25bd3aa..b43ca05 100644
> --- a/src/core/load-fragment-gperf.gperf.m4
> +++ b/src/core/load-fragment-gperf.gperf.m4
> @@ -88,6 +88,7 @@ m4_define(`CGROUP_CONTEXT_CONFIG_ITEMS',
>  $1.CPUAccounting,config_parse_bool,  0,  
>offsetof($1, cgroup_context.cpu_accounting)
>  $1.CPUShares,config_parse_cpu_shares,0,  
>offsetof($1, cgroup_context)
>  $1.MemoryAccounting, config_parse_bool,  0,  
> 

Re: [systemd-devel] [PATCH] Fix obsolete references to systemd-random-seed-load.service

2013-09-23 Thread Zbigniew Jędrzejewski-Szmek
On Sun, Sep 22, 2013 at 08:38:24PM +0200, Eelco Dolstra wrote:
> This service was merged with systemd-random-seed-save.service in
> c35b956d34bbb8bb208e49e45de2c103ca11911c.
Applied.

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