[systemd-devel] [206] Using `systemd --user` to manage user's session -- is it still possible?

2013-08-28 Thread Ivan Shapovalov
Hello!

With systemd v204 and earlier, I used `systemd --user` to manage my complete 
session, including X server (via xorg-launch-helper) and all related things.

I used a slightly modified user-session@.service unit to start the
`systemd --user` instance in its own session to get PolicyKit working:

[Service]
PAMName=login
TTYPath=/dev/tty7 # Xorg has been configured to start on vt7

That is pretty hackish (especially the hardcoded tty) but it worked: I was 
getting an active tty session in an autologin style; the session leader was 
systemd.

With v206, that stopped working. It seems that `systemd --user` now must be 
launched
1) with PAMName=systemd-shared
2) by logind on a per-user basis
   (IOW, `systemctl start user@1000.service` does not work)

...to have it started (otherwise, `systemd --user` does not start), and

3) with /etc/pam.d/systemd-shared symlinked to system-login or whatever
   (see https://bugs.freedesktop.org/show_bug.cgi?id=68164)

...to have XDG_RUNTIME_DIR=/run/user/%U instead of /run.

With that done, systemd starts successfully, but does not get linked to any 
session (so PolicyKit does not work, audio does not work, etc).

Is it somehow possible with v206 to continue using `systemd --user` as a 
session manager?

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


Re: [systemd-devel] implies MemoryAccounting=true

2013-08-28 Thread Zbigniew Jędrzejewski-Szmek
On Mon, Aug 26, 2013 at 11:19:54AM +0800, Gao feng wrote:
 Hi
 
 The SYSTEMD.CGROUP(5) said if MemoryLimit=bytes is set for unit, it
 implies MemeoryAccounting=true for this unit.
 
 But seems systemd didn't implement this hint. CPUShares  BlockIO have
 the same problem, this is a shortage? patch needed?
Hm, without looking at code actually, I thought that this
is basically a limitation/requirement of the cgroup controller:
if a memory share is assigned, memory accounting will be performed
by the kernelfor it to work.

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


Re: [systemd-devel] [PATCH] blcokio bandwidth: add missing set of CGroupBlockIODeviceBandwidth's read

2013-08-28 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Aug 28, 2013 at 12:10:16PM +0800, Gao feng wrote:
 BlockIOReadBandwidth and BlockIOWriteBandwidth both use
 config_parse_blockio_bandwidth to set up CGroupBlockIODeviceBandwidth,
 We should set the read value based on the left values
 in config files.
Applied.

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


Re: [systemd-devel] [PATCH v2] device cgroup: don't create a new CGroupDeviceAllow when it already in the list

2013-08-28 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Aug 28, 2013 at 09:49:11AM +0800, Gao feng wrote:
 If a device node is already in the device_allow list of
 CGroupContext, we should replace it instead of create a
 new one and append this new one to the end of device_allow
 list.
 
 change from v1: use streq to replace !strcmp
Applied.

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


Re: [systemd-devel] [PATCH] cgroup: only check once when mode is UNIT_CHECK

2013-08-28 Thread Zbigniew Jędrzejewski-Szmek
On Mon, Aug 26, 2013 at 10:36:45AM +0800, Gao feng wrote:
 If the mode is UNIT_CHECK,it means we only want to check if
 the paramaters are valid. the first round of cycle already
 did this check, no need to check again.
Applied.

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


Re: [systemd-devel] [206] Using `systemd --user` to manage user's session -- is it still possible?

2013-08-28 Thread Mantas Mikulėnas
Partial reply:

On Wed, Aug 28, 2013 at 10:15 AM, Ivan Shapovalov intelfx...@gmail.com wrote:
 With v206, that stopped working. It seems that `systemd --user` now must be
 launched
 1) with PAMName=systemd-shared
 […]
 3) with /etc/pam.d/systemd-shared symlinked to system-login or whatever
(see https://bugs.freedesktop.org/show_bug.cgi?id=68164)

 ...to have XDG_RUNTIME_DIR=/run/user/%U instead of /run.

The only requirement here is that PAM must call pam_systemd.so to set
up cgroups and XDG_RUNTIME_DIR. It's nothing new to v205/v206.

 2) by logind on a per-user basis
(IOW, `systemctl start user@1000.service` does not work)

It /should/ work, because that's exactly how logind starts it.

-- 
Mantas Mikulėnas graw...@gmail.com
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Fedora 19 hangs on startup: A start job is running for Monitoring of LVM2 mirror...rogress polling

2013-08-28 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Aug 22, 2013 at 09:07:09AM -0700, Ben Greear wrote:
 I have a E5 processor system with 128GB SSD freshly installed and updated
 with Fedora 19.  After the initial boot, I added MATE, put system at runlevel 
 3,
 removed 'initial-setup' package, and so forth.  System is
 configured for serial console.  I'm not sure how much of this matters, 
 however.
 
 On bootup, the system hung with the error:
 
 A start job is running for Monitoring of LVM2 mirror...rogress polling
 
 The little red stars move back and forth, so not a total cpu lock,
 but it made no progress in this state overnight.
Seems like an outright systemd bug, if you're not thrown into a rescue
session at some point. Can you pull the logs from this boot? (From the
options in http://freedesktop.org/wiki/Software/systemd/Debugging/,
systemd.log_level=debug and debug-shell.service are probably most
useful).

Zbyszek

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


[systemd-devel] [PATCH resend] getty-generator: Enable getty on all active serial consoles.

2013-08-28 Thread Michael Marineau
This enables a getty on active kernel consoles even when they are not
the last one specified on the kernel command line and mapped to
/dev/console. Now the order console=ttyS0 console=tty0 works in
addition to console=tty0 console=ttyS0.
---
 src/getty-generator/getty-generator.c | 37 ++-
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/src/getty-generator/getty-generator.c 
b/src/getty-generator/getty-generator.c
index 4b7a60a..6c93806 100644
--- a/src/getty-generator/getty-generator.c
+++ b/src/getty-generator/getty-generator.c
@@ -122,33 +122,42 @@ int main(int argc, char *argv[]) {
 }
 
 if (read_one_line_file(/sys/class/tty/console/active, active) = 0) 
{
-const char *tty;
-
-tty = strrchr(active, ' ');
-if (tty)
-tty ++;
-else
-tty = active;
-
-/* Automatically add in a serial getty on the kernel
- * console */
-if (isempty(tty) || tty_is_vc(tty))
-free(active);
-else {
+char *w, *state;
+size_t l;
+
+/* Automatically add in a serial getty on all active
+ * kernel consoles */
+FOREACH_WORD(w, l, active, state) {
+char *tty;
 int k;
 
+tty = strndup(w, l);
+if (!tty) {
+log_oom();
+free(active);
+r = EXIT_FAILURE;
+goto finish;
+}
+
+if (isempty(tty) || tty_is_vc(tty)) {
+free(tty);
+continue;
+}
+
 /* We assume that gettys on virtual terminals are
  * started via manual configuration and do this magic
  * only for non-VC terminals. */
 
 k = add_serial_getty(tty);
-free(active);
 
 if (k  0) {
+free(tty);
+free(active);
 r = EXIT_FAILURE;
 goto finish;
 }
 }
+free(active);
 }
 
 /* Automatically add in a serial getty on the first
-- 
1.8.1.5

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


[systemd-devel] [PATCH] util, utf8: recognize wide characters in wellipsize_mem()

2013-08-28 Thread Shawn Landden
---
 src/shared/utf8.c | 64 +++
 src/shared/utf8.h |  4 +++-
 src/shared/util.c | 19 ++---
 src/shared/util.h |  1 +
 4 files changed, 84 insertions(+), 4 deletions(-)

diff --git a/src/shared/utf8.c b/src/shared/utf8.c
index 8a37c3a..607f0c1 100644
--- a/src/shared/utf8.c
+++ b/src/shared/utf8.c
@@ -372,4 +372,68 @@ utf8_get_char (const char *p)
   UTF8_GET (result, p, i, mask, len);
 
   return result;
+}
+
+struct Interval
+{
+  unichar start, end;
+};
+
+static int
+interval_compare (const void *key, const void *elt)
+{
+  unichar c = (unichar) (long) (key);
+  struct Interval *interval = (struct Interval *)elt;
+
+  if (c  interval-start)
+return -1;
+  if (c  interval-end)
+return +1;
+
+  return 0;
+}
+
+/*
+ * NOTE:
+ *
+ * The tables for g_unichar_iswide() and g_unichar_iswide_cjk() are
+ * generated from the Unicode Character Database's file
+ * extracted/DerivedEastAsianWidth.txt using the gen-iswide-table.py
+ * in this way:
+ *
+ *   ./gen-iswide-table.py  path/to/ucd/extracted/DerivedEastAsianWidth.txt | 
fmt
+ *
+ * Last update for Unicode 6.0.
+ */
+
+/**
+ * g_unichar_iswide:
+ * @c: a Unicode character
+ *
+ * Determines if a character is typically rendered in a double-width
+ * cell.
+ *
+ * Return value: %TRUE if the character is wide
+ **/
+bool
+unichar_iswide (unichar c)
+{
+  /* See NOTE earlier for how to update this table. */
+  static const struct Interval wide[] = {
+{0x1100, 0x115F}, {0x2329, 0x232A}, {0x2E80, 0x2E99}, {0x2E9B, 0x2EF3},
+{0x2F00, 0x2FD5}, {0x2FF0, 0x2FFB}, {0x3000, 0x303E}, {0x3041, 0x3096},
+{0x3099, 0x30FF}, {0x3105, 0x312D}, {0x3131, 0x318E}, {0x3190, 0x31BA},
+{0x31C0, 0x31E3}, {0x31F0, 0x321E}, {0x3220, 0x3247}, {0x3250, 0x32FE},
+{0x3300, 0x4DBF}, {0x4E00, 0xA48C}, {0xA490, 0xA4C6}, {0xA960, 0xA97C},
+{0xAC00, 0xD7A3}, {0xF900, 0xFAFF}, {0xFE10, 0xFE19}, {0xFE30, 0xFE52},
+{0xFE54, 0xFE66}, {0xFE68, 0xFE6B}, {0xFF01, 0xFF60}, {0xFFE0, 0xFFE6},
+{0x1B000, 0x1B001}, {0x1F200, 0x1F202}, {0x1F210, 0x1F23A}, {0x1F240,
+0x1F248}, {0x1F250, 0x1F251}, {0x2, 0x2FFFD}, {0x3, 0x3FFFD}
+  };
+
+  if (bsearch ((long)c, wide, (sizeof (wide) / sizeof ((wide)[0])), sizeof 
wide[0],
+  interval_compare))
+return true;
+
+  return false;
 }
\ No newline at end of file
diff --git a/src/shared/utf8.h b/src/shared/utf8.h
index 020bc27..f1be180 100644
--- a/src/shared/utf8.h
+++ b/src/shared/utf8.h
@@ -131,4 +131,6 @@ static const char utf8_skip_data[256] = {
  * Before using this macro, use g_utf8_validate() to validate strings
  * that may contain invalid UTF-8.
  */
-#define utf8_next_char(p) (char *)((p) + utf8_skip_data[*(const char *)(p)])
\ No newline at end of file
+#define utf8_next_char(p) (char *)((p) + utf8_skip_data[*(const char *)(p)])
+
+bool unichar_iswide (unichar c);
\ No newline at end of file
diff --git a/src/shared/util.c b/src/shared/util.c
index 58a1787..1c73b3e 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -3357,22 +3357,35 @@ char *wellipsize_mem(const char *s, size_t old_length, 
size_t new_length, unsign
 if (x  new_length - 3)
 x = new_length - 3;
 
-for (i = (char *)s;k  x;i = utf8_next_char(i))
+for (i = (char *)s;k  x;i = utf8_next_char(i)) {
+c = utf8_get_char(i);
 k++;
+if (unichar_iswide(c))
+k++;
+}
+
+if (k  x) /* last character was wide and went over quota */
+x++;
 
 j = i - s;
 memcpy(e, s, j);
-e[j] = '.';   /* TODO: use … tri-dot? */
-e[j+1] = '.'; /* 0xe2 0x80 0xa6 */
+e[j]   = '.'; /* TODO: use … tri-dot? */
+e[j+1] = '.'; /* 0xE2 0x80 0xA6 */
 e[j+2] = '.';
 
 k = 0;
 for (i = (char *)s + old_length;
  k  new_length - x - 3;) {
 i = utf8_prev_char(i);
+c = utf8_get_char(i);
 k++;
+if (unichar_iswide(c))
+k++;
 }
 
+if (k  new_length - x - 3) /* last (reverse) character was wide and 
went over quota */
+i = utf8_next_char(i);
+
 strcpy(e + j + 3, i);
 
 return e;
diff --git a/src/shared/util.h b/src/shared/util.h
index 9b17db9..97d8697 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -405,6 +405,7 @@ int running_in_chroot(void);
 char *ellipsize(const char *s, size_t length, unsigned percent);
 char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, 
unsigned percent);
 char *wellipsize(const char *s, size_t length, unsigned percent);
+/* bytes  columns */
 char *wellipsize_mem(const char *s, size_t old_length, size_t new_length, 
unsigned percent);
 
 int touch(const char *path);
-- 
1.8.4.rc3

___
systemd-devel 

Re: [systemd-devel] [PATCH] util, utf8: recognize wide characters in wellipsize_mem()

2013-08-28 Thread Shawn
here is the test runner I am using, doesn't really make sense to add this
to the tree as it has to be visually inspected

diff --git a/Makefile.am b/Makefile.am
index cdbfdea..8813299 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1124,6 +1124,7 @@ tests += \
test-unit-file \
test-util \
test-date \
+   test-wellipsize \
test-sleep \
test-replace-var \
test-sched-prio \
@@ -1302,6 +1303,12 @@ test_date_SOURCES = \
 test_date_LDADD = \
libsystemd-core.la

+test_wellipsize_SOURCES = \
+src/test/test-wellipsize.c
+
+test_wellipsize_LDADD = \
+libsystemd-core.la
+
 test_sleep_SOURCES = \
src/test/test-sleep.c
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/

/***
  This file is part of systemd.

  Copyright 2012 Lennart Poettering

  systemd is free software; you can redistribute it and/or modify it
  under the terms of the GNU Lesser General Public License as published by
  the Free Software Foundation; either version 2.1 of the License, or
  (at your option) any later version.

  systemd is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License
  along with systemd; If not, see http://www.gnu.org/licenses/.
***/

#include stdio.h

#include util.h
#include utf8.h

static void test_one(const char *p) {
puts(wellipsize(p, 80, 70));
}

int main(int argc, char *argv[]) {
test_one(s한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어);
test_one(日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国);
test_one(€€);
test_one(………);
test_one();
test_one(asdfnjaskdfnklasdgnjaskdghnkasdgfklasdfjkasdfjaksdfaskldfnaskldfnaskldfnaklsdfnaklsdfnklnaskjgdknl);

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