Re: [systemd-devel] [PATCHv2] tty: Set correct tty name in 'active' sysfs attribute

2014-02-07 Thread Kay Sievers
On Thu, Feb 6, 2014 at 5:29 PM, Greg Kroah-Hartman
gre...@linuxfoundation.org wrote:
 On Thu, Feb 06, 2014 at 04:44:20PM +0100, Hannes Reinecke wrote:
 On 02/06/2014 04:29 PM, Greg Kroah-Hartman wrote:
  On Thu, Feb 06, 2014 at 03:27:43PM +0100, Hannes Reinecke wrote:
  The 'active' sysfs attribute should refer to the currently
  active tty devices the console is running on, not the currently
  active console.
 
  That's not what Documentation/ABI/sysfs-tty says:
   Shows the list of currently configured
   console devices, like 'tty1 ttyS0'.
   The last entry in the file is the active
   device connected to /dev/console.
   The file supports poll() to detect virtual
   console switches.
 
 The problem is indeed with 'console devices'. There is no such
 thing; you only have tty devices where the console is running on.

  The console structure doesn't refer to any device in sysfs,
  only the tty the console is running on has.
 
  That sentance doesn't make sense.
 
  So we need to print out the tty names in 'active', not
  the console names.
 
  But that doesn't match the documentation.
 
  What exactly are you trying to fix here?  What is the problem that the
  current file has that is broken?  And as you are changing what this file
  means, what will break if the information in the file changes?
 
 systemd is using the 'active' sysfs attribute to figure out on which
 _tty_ device to start a getty on.
 As soon as the console name and the tty name are different
 you have no means of figuring out which _device_ to open.
 AFAICS the console 'device' (ie the current entry in 'active')
 doesn't have _any_ equivalent in sysfs; it just so happens that for
 most console drivers the tty driver name is identical.
 But this is not a requirement, and fails for drivers which have a
 different device for the console and the tty.

 EG on S/390 the 3270 tty has the devices

 /dev/3270/tty1

 but the console driver announces the name 'tty3270'.
 So as per current rules the 'active' attribute contains

 tty32700

 which correct as per documentation, but doesn't have _any_
 equivalent in sysfs.

 Martin has the grubby details here.

 But of course, the documentation should be updated to match the new
 behavior.

 Ok, care to send an updated version, that fixes the Documentation as
 well?  If Kay agrees that this is the correct solution, I'll be glad to
 take it.

Sounds good to me. The intention clearly was to point to the device in use,
which we can find then.

I would not expect problems with this change. For common uses it is the
same name already and nothing visibly should change, and for the ones
where it isn't the same, I expect it is not too useful to find the driver
name.

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


[systemd-devel] [PATCHv3] tty: Set correct tty name in 'active' sysfs attribute

2014-02-07 Thread Hannes Reinecke
The 'active' sysfs attribute should refer to the currently
active tty devices the console is running on, not the currently
active console.
The console structure doesn't refer to any device in sysfs,
only the tty the console is running on has.
So we need to print out the tty names in 'active', not
the console names.

Cc: Lennart Poettering lenn...@poettering.net
Cc: Kay Sievers k...@vrfy.org
Cc: Greg Kroah-Hartmann gre...@linuxfoundation.org
Cc: Jiri Slaby jsl...@suse.cz
Cc: David Herrmann dh.herrm...@gmail.com
Signed-off-by: Werner Fink wer...@suse.de
Signed-off-by: Hannes Reinecke h...@suse.de
---
 Documentation/ABI/testing/sysfs-tty |  3 ++-
 drivers/tty/tty_io.c| 25 ++---
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-tty 
b/Documentation/ABI/testing/sysfs-tty
index ad22fb0..a2ccec3 100644
--- a/Documentation/ABI/testing/sysfs-tty
+++ b/Documentation/ABI/testing/sysfs-tty
@@ -3,7 +3,8 @@ Date:   Nov 2010
 Contact:   Kay Sievers kay.siev...@vrfy.org
 Description:
 Shows the list of currently configured
-console devices, like 'tty1 ttyS0'.
+tty devices used for the console,
+like 'tty1 ttyS0'.
 The last entry in the file is the active
 device connected to /dev/console.
 The file supports poll() to detect virtual
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index c74a00a..bd2715a 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1267,16 +1267,17 @@ static void pty_line_name(struct tty_driver *driver, 
int index, char *p)
  * @p: output buffer of at least 7 bytes
  *
  * Generate a name from a driver reference and write it to the output
- * buffer.
+ * buffer. Return the number of bytes written.
  *
  * Locking: None
  */
-static void tty_line_name(struct tty_driver *driver, int index, char *p)
+static ssize_t tty_line_name(struct tty_driver *driver, int index, char *p)
 {
if (driver-flags  TTY_DRIVER_UNNUMBERED_NODE)
-   strcpy(p, driver-name);
+   return sprintf(p, %s, driver-name);
else
-   sprintf(p, %s%d, driver-name, index + driver-name_base);
+   return sprintf(p, %s%d, driver-name,
+  index + driver-name_base);
 }
 
 /**
@@ -3545,9 +3546,19 @@ static ssize_t show_cons_active(struct device *dev,
if (i = ARRAY_SIZE(cs))
break;
}
-   while (i--)
-   count += sprintf(buf + count, %s%d%c,
-cs[i]-name, cs[i]-index, i ? ' ':'\n');
+   while (i--) {
+   struct tty_driver *driver;
+   const char *name = cs[i]-name;
+   int index = cs[i]-index;
+
+   driver = cs[i]-device(cs[i], index);
+   if (driver) {
+   count += tty_line_name(driver, index, buf + count);
+   count += sprintf(buf + count, %c, i ? ' ':'\n');
+   } else
+   count += sprintf(buf + count, %s%d%c,
+name, index, i ? ' ':'\n');
+   }
console_unlock();
 
return count;
-- 
1.7.12.4

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


[systemd-devel] [PATCH] man: cryptsetup-1.6.3 now allows partition device file in system mode

2014-02-07 Thread Jan Janssen
---
 man/crypttab.xml | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/man/crypttab.xml b/man/crypttab.xml
index 5f386e5..c563851 100644
--- a/man/crypttab.xml
+++ b/man/crypttab.xml
@@ -305,14 +305,7 @@
 
 listitemparaUse TrueCrypt in system
 encryption mode. This implies
-varnametcrypt/varname./para
-
-paraPlease note that when using this mode, 
the
-whole device needs to be given in the second
-field instead of the partition. For example: if
-literal/dev/sda2/literal is the system
-encrypted TrueCrypt patition, 
literal/dev/sda/literal
-has to be given./para/listitem
+   varnametcrypt/varname./para/listitem
 /varlistentry
 
 varlistentry
-- 
1.8.5.4

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


Re: [systemd-devel] [PATCH 1/3] Add SELinuxContext configuration item

2014-02-07 Thread Michael Scherer
Le jeudi 06 février 2014 à 12:21 -0800, David Timothy Strauss a écrit :
 In order to maximize consistency with newly committed options in
 systemd-nspawn, would it make sense to allow independent configuration
 of the process and file labels instead?


The file label are decided by selinux policy based on the path and/or
process domain, from what I seen.

In the case of systemd-nspawn, it is done by using a specific option of
mount, and only for tmpfs/devpts. 

So I am not sure if this can be done, and i fail to see a usecase for
that ( except having container described in .service, which could be
nice but maybe too much )

-- 
Michael Scherer

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


Re: [systemd-devel] [PATCH] man: cryptsetup-1.6.3 now allows partition device file in system mode

2014-02-07 Thread Tom Gundersen
On Fri, Feb 7, 2014 at 12:47 PM, Jan Janssen medhe...@web.de wrote:
 ---
  man/crypttab.xml | 9 +
  1 file changed, 1 insertion(+), 8 deletions(-)

 diff --git a/man/crypttab.xml b/man/crypttab.xml
 index 5f386e5..c563851 100644
 --- a/man/crypttab.xml
 +++ b/man/crypttab.xml
 @@ -305,14 +305,7 @@

  listitemparaUse TrueCrypt in system
  encryption mode. This implies
 -varnametcrypt/varname./para
 -
 -paraPlease note that when using this mode, 
 the
 -whole device needs to be given in the second
 -field instead of the partition. For example: 
 if
 -literal/dev/sda2/literal is the system
 -encrypted TrueCrypt patition, 
 literal/dev/sda/literal
 -has to be given./para/listitem
 +   varnametcrypt/varname./para/listitem
  /varlistentry

  varlistentry
 --
 1.8.5.4

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


Applied. Thanks!

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


Re: [systemd-devel] [PATCH 1/7] logind: add function session_jobs_reply() to unify the create reply

2014-02-07 Thread Lennart Poettering
On Thu, 06.02.14 21:37, Djalal Harouni (tix...@opendz.org) wrote:

Applied this one! Thanks!

 The session_send_create_reply() function which notifies clients about
 session creation is used for both session and user units. Unify the
 shared code in a new function session_jobs_reply().
 
 The session_save() will be called unconditionally on sessions since it
 does not make sense to only call it if '!session-started', this will
 also allow to update the session state as soon as possible.
 ---
  src/login/logind-dbus.c | 46 --
  1 file changed, 24 insertions(+), 22 deletions(-)
 
 diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
 index 4745961..7b050fb 100644
 --- a/src/login/logind-dbus.c
 +++ b/src/login/logind-dbus.c
 @@ -1919,6 +1919,27 @@ const sd_bus_vtable manager_vtable[] = {
  SD_BUS_VTABLE_END
  };
  
 +static int session_jobs_reply(Session *s, const char *unit, const char 
 *result) {
 +int r = 0;
 +
 +assert(s);
 +assert(unit);
 +
 +if (!s-started)
 +return r;
 +
 +if (streq(result, done))
 +r = session_send_create_reply(s, NULL);
 +else {
 +_cleanup_bus_error_free_ sd_bus_error e = SD_BUS_ERROR_NULL;
 +
 +sd_bus_error_setf(e, BUS_ERROR_JOB_FAILED, Start job for 
 unit %s failed with '%s', unit, result);
 +r = session_send_create_reply(s, e);
 +}
 +
 +return r;
 +}
 +
  int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, 
 sd_bus_error *error) {
  const char *path, *result, *unit;
  Manager *m = userdata;
 @@ -1958,18 +1979,9 @@ int match_job_removed(sd_bus *bus, sd_bus_message 
 *message, void *userdata, sd_b
  session-scope_job = NULL;
  }
  
 -if (session-started) {
 -if (streq(result, done))
 -session_send_create_reply(session, NULL);
 -else {
 -_cleanup_bus_error_free_ sd_bus_error e = 
 SD_BUS_ERROR_NULL;
 -
 -sd_bus_error_setf(e, BUS_ERROR_JOB_FAILED, 
 Start job for unit %s failed with '%s', unit, result);
 -session_send_create_reply(session, e);
 -}
 -} else
 -session_save(session);
 +session_jobs_reply(session, unit, result);
  
 +session_save(session);
  session_add_to_gc_queue(session);
  }
  
 @@ -1987,17 +1999,7 @@ int match_job_removed(sd_bus *bus, sd_bus_message 
 *message, void *userdata, sd_b
  }
  
  LIST_FOREACH(sessions_by_user, session, user-sessions) {
 -if (!session-started)
 -continue;
 -
 -if (streq(result, done))
 -session_send_create_reply(session, NULL);
 -else {
 -_cleanup_bus_error_free_ sd_bus_error e = 
 SD_BUS_ERROR_NULL;
 -
 -sd_bus_error_setf(e, BUS_ERROR_JOB_FAILED, 
 Start job for unit %s failed with '%s', unit, result);
 -session_send_create_reply(session, e);
 -}
 +session_jobs_reply(session, unit, result);
  }
  
  user_save(user);


Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] STACK (http://css.csail.mit.edu/stack/) found issues for unstable optimized code again.

2014-02-07 Thread Stefan Beller
The first problem arises in src/gudev/gudevdevice.c
In lines 688 and 882 we call the function split_at_whitespace,
which is just a wrapper around g_strsplit_set, but removes also
the empty strings.

Now in this wrapper function we have a 'gchar **result;' on
which we'll operate. In line 638 we start on removing
the empty strings by checking them one by one.
Before the for loop we could mentally add an
assert(result);
because if this assertion doesn't hold, the access
of result[n] would segfault.

Now compilers, which optimize heavily such as gcc 4.8,
will take notes and remember this implicit assertion in
case it can optimize something later on based on
this assumption.

And indeed it can do so, when returning from the function
split_at_whitespace in lines 688 and 882. There are checks
for this assertion being violated:
  if (result == NULL)
goto out;
But the assertion must hold, or we'd have been segfaulting
earlier. That means either, we can remove the two lines
  if (result == NULL)
goto out;
or we forgot to check the results of g_strsplit_set properly.

Now it's time to read the documentation on that
https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strsplit-set
And as far as I understand that, g_strsplit_set will never return a plain
NULL, but at least a pointer to a NULL. So the implementation of the
wrapper seems alright and we can remove the superfluous lines checking
for NULL.
---
 src/gudev/gudevdevice.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/src/gudev/gudevdevice.c b/src/gudev/gudevdevice.c
index 6c9e0f5..57a47d9 100644
--- a/src/gudev/gudevdevice.c
+++ b/src/gudev/gudevdevice.c
@@ -685,8 +685,6 @@ g_udev_device_get_property_as_strv (GUdevDevice  *device,
 goto out;
 
   result = split_at_whitespace (s);
-  if (result == NULL)
-goto out;
 
   if (device-priv-prop_strvs == NULL)
 device-priv-prop_strvs = g_hash_table_new_full (g_str_hash, g_str_equal, 
g_free, (GDestroyNotify) g_strfreev);
@@ -879,8 +877,6 @@ g_udev_device_get_sysfs_attr_as_strv (GUdevDevice  *device,
 goto out;
 
   result = split_at_whitespace (s);
-  if (result == NULL)
-goto out;
 
   if (device-priv-sysfs_attr_strvs == NULL)
 device-priv-sysfs_attr_strvs = g_hash_table_new_full (g_str_hash, 
g_str_equal, g_free, (GDestroyNotify) g_strfreev);
-- 
1.9.rc2

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


Re: [systemd-devel] [PATCH v2 0/7] logind: close races on user and session states

2014-02-07 Thread Lennart Poettering
On Thu, 06.02.14 21:37, Djalal Harouni (tix...@opendz.org) wrote:

Heya!

So, I was working on fixes for this in parallel which I have pushed
earlier today, which change a couple of things around in more complex
ways. Some of them conflict with yours changes. I'll commit the
ones of yours that still appear necessary. If you think I am missing
some, please let me know.

The new logic I commited changes around how scopes are used by
logind. Previously the KillUserProcesses= option in logind.conf would
influence KillMode= of the scope. However that was a bad idea since we
actually want to provide people a way to terminate sessions and we
actually need them to order things properly on shutdown so that scopes
go away before the network is removed, and suchlike. Hence I changed the
logic so we are OK with leavig scopes around from the logind side, we
just mark the session entries as closing. KillUserProcesses= hence
simply controls whether we leave them around and hence the session in
closing or whether we actively shut them down.

Sorry for commiting into the middle of your work!

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 2/7] logind: close races on user and session states during login

2014-02-07 Thread Lennart Poettering
On Thu, 06.02.14 21:37, Djalal Harouni (tix...@opendz.org) wrote:

I think this one I fixed by adding a new stopping variable. Could you check?

 Currently the user and session states are not stable, they are affected
 by several races during login:
 
 1) session state:
To get the session state the function session_get_state() is used.
 
 Opening state:
 At login the D-Bus CreateSession() method will call session_start() which
 calls user_start() and session_start_scope() to queue the scope job and
 set the session-scope_job
 
=  session_get_state() == SESSION_OPENING   (correct)
 
 Then execution will continue from session_send_create() which is called
 by the D-Bus match_job_removed() signal. math_job_removed() will check if
 this is the session scope and if this is the previously queued scope job.
 If so it will clear the session-scope_job
 
=  session_get_state() == SESSION_CLOSING   (incorrect)
   (session closing since fifo_fd == -1)
 
 So scope job has finished and scope was created successfully, later the
 session_send_create_reply() will wait for the session scope *and* the
 user service to be successfully created.
 
   /* user service is still pending */
   if (s-scope_job || s-user-service_job))
  return 0
 
=  session_get_state() == SESSION_CLOSING   (incorrect)
 
   else
  session_create_fifo()/* fifo_fd finally created */
 
=  session_get_state() == SESSION_ACTIVE   (correct)
 
 To sum it up, current state during login:
 SESSION_OPENING=SESSION_CLOSINGx2=SESSION_ACTIVE
 
 To fix the session state and remove the two incorrect SESSION_CLOSING,
 we do not clear up the session-scope_job when we detect that this is
 the session scope, we setup a temporary variable scope_job that will
 get the current value of session-scope_job and update it if
 necessary.
 
 Add a new active variable to check if the session scope and user
 service jobs are still being created.
 
 Update session_jobs_replay() and session_send_create_reply() function to
 receive the opening variable as an argument, so it will still wait for
 the scope and service jobs to finish before creating the session fifo.
 
 The session-scope_job will be cleared when session_jobs_reply()
 finishes. This ensures that the state will just go from:
 SESSION_OPENING = SESSION_ACTIVE
 
 2) user state:
To get the user state the function user_get_state() is used.
 
 I'll add that the user_get_state() and session_get_state() do not have
 the same logic when it comes to sessions, this will just add ambiguity.
 user_get_state() calls session_is_active() before checking
 session_get_state(), and session_is_active() will return true right from
 the start since the logic is set during D-Bus CreateSession(). This will
 we be fixed in the followup patches.
 
 Opening state:
 At login we have session_start() which calls user_start()
 
 here we already:
 
=  user_get_state() == USER_ACTIVE   (incorrect)
(not fixed in this patch)
 
 user_start() calls:
 user_start_slice() queue the slice and set user-slice_job
 user_start_service() queue the service and set user-service_job
 
=  user_get_state() == USER_OPENING   (correct)
 
 Then execution will continue from session_send_create() which is called
 by the D-Bus match_job_removed() signal. math_job_removed() will check if
 these are the user service and slice and if they are the previously queued
 jobs. If so it will clear the: user-service_job and user-slice_job
 
=  user_get_state() == USER_ACTIVE   (incorrect)
  (incorrect since the fifo_fd has not been created,
   here the state should stay USER_OPENING)
 
 Later when the user service is created successfully,
 session_send_create_reply() will also wait for the session scope to be
 created. If so then session_send_create_reply() will continue and call
 session_create_fifo()
 
=  user_get_state() == USER_ACTIVE   (correct)
(fifo_fd was created)
 
 To fix this, we use the same logic as used to fix session states. In
 order to remove the incorrect state when the fifo_fd is not created but
 the state shows USER_ACTIVE, we do not clear the user-service_job and
 user-slice_job right away, we store the state in a temporary variable
 service_job and update it later if we detect that this is the user
 service.
 
 The new active variable will be used to check if the session scope and
 user service are still being created. If so we'll wait for the next
 match_job_removed() signal and continue, otherwise we proceed with
 session_jobs_reply() and session_send_create_reply() in order to notify
 clients.
 ---
  src/login/logind-dbus.c | 44 
 ++---
  src/login/logind-session-dbus.c |  8 +---
  src/login/logind-session.h  |  2 +-
  3 files changed, 39 insertions(+), 15 deletions(-)
 
 diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
 index 

Re: [systemd-devel] [PATCH 7/7] logind: do not call session_jobs_reply() on CLOSING

2014-02-07 Thread Lennart Poettering
On Thu, 06.02.14 21:37, Djalal Harouni (tix...@opendz.org) wrote:

Hmm, isn't this issue already caught by the if (!s-create_message)
check in session_send_reply()?

Thanks!

 match_job_removed() signal is triggered when queued jobs finish during
 session opening or closing.
 
 Calling session_jobs_reply() during opening is valid, but during
 session closing does not make sense.
 
 The session_send_create_reply() function which is called by
 session_jobs_reply() is able to detect if it was not called during
 open time by checking the 'session-create_message'. However, making
 session_jobs_reply() check session_is_opening() and user_is_opening()
 is more comprehensive.
 ---
  src/login/logind-dbus.c | 5 +
  1 file changed, 5 insertions(+)
 
 diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
 index 24482fd..4b71d9e 100644
 --- a/src/login/logind-dbus.c
 +++ b/src/login/logind-dbus.c
 @@ -1930,6 +1930,10 @@ static int session_jobs_reply(Session *s, const char 
 *unit, const char *result,
  if (!s-started)
  return r;
  
 +/* Don't call me if this is not opening state */
 +if (!session_is_opening(s)  !user_is_opening(s-user))
 +return r;
 +
  if (streq(result, done))
  r = session_send_create_reply(s, NULL, opening);
  else {
 @@ -2010,6 +2014,7 @@ int match_job_removed(sd_bus *bus, sd_bus_message 
 *message, void *userdata, sd_b
   * still being created this will be set to true,
   * otherwise it will be false */
  active = service_job || !!session-scope_job;
 +
  session_jobs_reply(session, unit, result, active);
  }
  


Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 5/7] logind: just call session_get_state() to get the session state

2014-02-07 Thread Lennart Poettering
On Thu, 06.02.14 21:37, Djalal Harouni (tix...@opendz.org) wrote:

This one looks good, but could you rebase it please?

Thanks!

 In function user_get_state() remove the session_is_active() check, just
 count on the session_get_state() function to get the correct session
 state.
 
 session_is_active() may return true before starting the session scope and
 user service, this means it will return true even before the creation of
 the session fifo_fd which will produce incorrect states.
 
 Another point is that session_get_state() will check if the fifo_fd was
 created before checking if the session is active, this is the correct
 behaviour since the session fifo_fd should be considered the point of
 session states synchronization.
 
 So be consistent and follow the session_get_state() logic.
 ---
  src/login/logind-user.c | 8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)
 
 diff --git a/src/login/logind-user.c b/src/login/logind-user.c
 index 8183721..9ed216d 100644
 --- a/src/login/logind-user.c
 +++ b/src/login/logind-user.c
 @@ -637,6 +637,7 @@ void user_add_to_gc_queue(User *u) {
  
  UserState user_get_state(User *u) {
  Session *i;
 +SessionState session_state;
  bool all_closing = true;
  
  assert(u);
 @@ -645,9 +646,12 @@ UserState user_get_state(User *u) {
  return USER_OPENING;
  
  LIST_FOREACH(sessions_by_user, i, u-sessions) {
 -if (session_is_active(i))
 +/* session_get_state() will check for fifo_fd */
 +session_state = session_get_state(i);
 +
 +if (session_state == SESSION_ACTIVE)
  return USER_ACTIVE;
 -if (session_get_state(i) != SESSION_CLOSING)
 +else if (session_state != SESSION_CLOSING)
  all_closing = false;
  }
  


Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 0/3] SELinuxContext configuration, v2

2014-02-07 Thread Lennart Poettering
On Thu, 06.02.14 10:05, Michael Scherer (m...@zarb.org) wrote:

 This series of patch implement a SELinuxContext configuration item,
 whose usage is explained in the first mail. This patch series take in 
 account the feedback received on
 http://lists.freedesktop.org/archives/systemd-devel/2013-December/015875.html

Applied with some whitespace fixes.

Thanks!

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH v2 0/7] logind: close races on user and session states

2014-02-07 Thread Djalal Harouni
On Fri, Feb 07, 2014 at 04:29:48PM +0100, Lennart Poettering wrote:
 On Thu, 06.02.14 21:37, Djalal Harouni (tix...@opendz.org) wrote:
 
 Heya!
 
 So, I was working on fixes for this in parallel which I have pushed
 earlier today, which change a couple of things around in more complex
 ways. Some of them conflict with yours changes. I'll commit the
 ones of yours that still appear necessary. If you think I am missing
 some, please let me know.
Ok, I'll do.

 The new logic I commited changes around how scopes are used by
 logind. Previously the KillUserProcesses= option in logind.conf would
 influence KillMode= of the scope. However that was a bad idea since we
 actually want to provide people a way to terminate sessions and we
 actually need them to order things properly on shutdown so that scopes
 go away before the network is removed, and suchlike. Hence I changed the
Yes, I was going to ask about why scopes are influenced by
KillUserProcesses? anyway I'll read your changes.

 logic so we are OK with leavig scopes around from the logind side, we
 just mark the session entries as closing. KillUserProcesses= hence
 simply controls whether we leave them around and hence the session in
 closing or whether we actively shut them down.
Ok.

 Sorry for commiting into the middle of your work!
No worries, I did a dive into the internals and the picture is still not
clear :-)

 Lennart
Thanks

 -- 
 Lennart Poettering, Red Hat

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


[systemd-devel] systemd-networkd + VLANs problems

2014-02-07 Thread Oleksii Shevchuk
Hello, list.

So, I try to use VLANs feature introduced to systemd-networkd/git two
weeks ago (54abf461d6b10dc270c4bb2aeac65f240ff1c5cd).

I want to have next layout:

Links:

1. Eth
1.1 Vlan1 
1.2 Vlan2 (Ring1)
2. Bridge (Ring0)
2.1 Vlan2

Networks:

1. Vlan1
2. Bridge

So, I try next configs:

 cat Ring0.netdev
[NetDev]
Name=br0
Kind=bridge

 cat Ring1.netdev
[NetDev]
Name=vlan2
Kind=vlan

[VLAN]
Id=2

 cat LocalLink.network
[Match]
Name=vlan2

[Network]
Bridge=br0

.. and some other .network configs with IP configuration.

At this point, nothing works -- no vlan links were created. So, I grep
sources, and find out the Network.VLAN option (note - missing in man
page). So I add some more configs:

 cat Switch1.network
[Match]
Name=net1

[Network]
VLAN=vlan1

 cat Switch2.network
[Match]
Name=net1

[Network]
VLAN=vlan2

At this point I have successfully running/configured vlan1, but not
vlan2.

Then I manually create and up vlan2 with iproute2. At this point device
were up, but systemd-networkd didn't put it to bridge.

So, the question is: how should I configure this layout with two vlans
on one ethernet, where one of vlans is bridged?

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